Skip to content

Commit

Permalink
Updating tests
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Nov 1, 2024
1 parent a41b03c commit edbd553
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 0 deletions.
15 changes: 15 additions & 0 deletions exp/internal/controllers/machinepool_controller_phases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ func TestReconcileMachinePoolPhases(t *testing.T) {
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.TestBootstrapConfigKind,
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
},
InfrastructureRef: corev1.ObjectReference{
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachineTemplateKind,
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
},
},
Expand Down Expand Up @@ -795,6 +797,7 @@ func TestReconcileMachinePoolBootstrap(t *testing.T) {
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.TestBootstrapConfigKind,
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
},
},
Expand Down Expand Up @@ -936,6 +939,7 @@ func TestReconcileMachinePoolBootstrap(t *testing.T) {
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.TestBootstrapConfigKind,
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
DataSecretName: ptr.To("data"),
},
Expand Down Expand Up @@ -1019,6 +1023,7 @@ func TestReconcileMachinePoolBootstrap(t *testing.T) {
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.TestBootstrapConfigKind,
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
DataSecretName: ptr.To("data"),
},
Expand Down Expand Up @@ -1093,12 +1098,14 @@ func TestReconcileMachinePoolInfrastructure(t *testing.T) {
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.TestBootstrapConfigKind,
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
},
InfrastructureRef: corev1.ObjectReference{
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachineTemplateKind,
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
},
},
Expand Down Expand Up @@ -1172,12 +1179,14 @@ func TestReconcileMachinePoolInfrastructure(t *testing.T) {
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.TestBootstrapConfigKind,
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
},
InfrastructureRef: corev1.ObjectReference{
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachineTemplateKind,
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
},
},
Expand Down Expand Up @@ -1268,12 +1277,14 @@ func TestReconcileMachinePoolInfrastructure(t *testing.T) {
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.TestBootstrapConfigKind,
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
},
InfrastructureRef: corev1.ObjectReference{
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachineTemplateKind,
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
},
},
Expand Down Expand Up @@ -1775,12 +1786,14 @@ func TestReconcileMachinePoolScaleToFromZero(t *testing.T) {
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.TestBootstrapConfigKind,
Name: "bootstrap-config1",
Namespace: ns.Name,
},
},
InfrastructureRef: corev1.ObjectReference{
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachineTemplateKind,
Name: "infra-config1",
Namespace: ns.Name,
},
},
},
Expand Down Expand Up @@ -2196,12 +2209,14 @@ func getMachinePool(replicas int, mpName, clusterName, nsName string) expv1.Mach
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.GenericBootstrapConfigKind,
Name: "bootstrap-config1",
Namespace: nsName,
},
},
InfrastructureRef: corev1.ObjectReference{
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.GenericInfrastructureMachineKind,
Name: "infra-config1",
Namespace: nsName,
},
},
},
Expand Down
9 changes: 9 additions & 0 deletions exp/internal/controllers/machinepool_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ func TestReconcileMachinePoolRequest(t *testing.T) {
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachinePoolKind,
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
Bootstrap: clusterv1.Bootstrap{DataSecretName: ptr.To("data")},
},
Expand Down Expand Up @@ -404,6 +405,7 @@ func TestReconcileMachinePoolRequest(t *testing.T) {
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachinePoolKind,
Name: "infra-config1-already-deleted", // Use an InfrastructureMachinePool that doesn't exist, so reconcileDelete doesn't get stuck on deletion
Namespace: metav1.NamespaceDefault,
},
Bootstrap: clusterv1.Bootstrap{DataSecretName: ptr.To("data")},
NodeDeletionTimeout: &metav1.Duration{Duration: 10 * time.Minute},
Expand Down Expand Up @@ -466,6 +468,7 @@ func TestReconcileMachinePoolRequest(t *testing.T) {
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachinePoolKind,
Name: "infra-config1-already-deleted", // Use an InfrastructureMachinePool that doesn't exist, so reconcileDelete doesn't get stuck on deletion
Namespace: metav1.NamespaceDefault,
},
Bootstrap: clusterv1.Bootstrap{DataSecretName: ptr.To("data")},
NodeDeletionTimeout: &metav1.Duration{Duration: 10 * time.Minute},
Expand Down Expand Up @@ -528,6 +531,7 @@ func TestReconcileMachinePoolRequest(t *testing.T) {
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachinePoolKind,
Name: "infra-config1-already-deleted", // Use an InfrastructureMachinePool that doesn't exist, so reconcileDelete doesn't get stuck on deletion
Namespace: metav1.NamespaceDefault,
},
Bootstrap: clusterv1.Bootstrap{DataSecretName: ptr.To("data")},
NodeDeletionTimeout: &metav1.Duration{Duration: 10 * time.Second}, // timeout passed
Expand Down Expand Up @@ -761,12 +765,14 @@ func TestReconcileMachinePoolDeleteExternal(t *testing.T) {
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachineTemplateKind,
Name: "delete-infra",
Namespace: metav1.NamespaceDefault,
},
Bootstrap: clusterv1.Bootstrap{
ConfigRef: &corev1.ObjectReference{
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.TestBootstrapConfigKind,
Name: "delete-bootstrap",
Namespace: metav1.NamespaceDefault,
},
},
},
Expand Down Expand Up @@ -864,6 +870,7 @@ func TestRemoveMachinePoolFinalizerAfterDeleteReconcile(t *testing.T) {
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachineTemplateKind,
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
Bootstrap: clusterv1.Bootstrap{DataSecretName: ptr.To("data")},
},
Expand Down Expand Up @@ -957,12 +964,14 @@ func TestMachinePoolConditions(t *testing.T) {
APIVersion: builder.InfrastructureGroupVersion.String(),
Kind: builder.TestInfrastructureMachineTemplateKind,
Name: "infra1",
Namespace: metav1.NamespaceDefault,
},
Bootstrap: clusterv1.Bootstrap{
ConfigRef: &corev1.ObjectReference{
APIVersion: builder.BootstrapGroupVersion.String(),
Kind: builder.TestBootstrapConfigKind,
Name: "bootstrap1",
Namespace: metav1.NamespaceDefault,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestClusterReconcilePhases(t *testing.T) {
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureMachine",
Name: "test",
Namespace: "test-namespace",
},
},
}
Expand All @@ -73,6 +74,7 @@ func TestClusterReconcilePhases(t *testing.T) {
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureMachine",
Name: "test",
Namespace: "test-namespace",
},
},
}
Expand Down Expand Up @@ -248,6 +250,7 @@ func TestClusterReconcilePhases(t *testing.T) {
APIVersion: "controlplane.cluster.x-k8s.io/v1beta1",
Kind: "GenericControlPlane",
Name: "test",
Namespace: "test-namespace",
},
},
}
Expand All @@ -264,6 +267,7 @@ func TestClusterReconcilePhases(t *testing.T) {
APIVersion: "controlplane.cluster.x-k8s.io/v1beta1",
Kind: "GenericControlPlane",
Name: "test",
Namespace: "test-namespace",
},
},
}
Expand Down Expand Up @@ -689,6 +693,7 @@ func TestClusterReconcilePhases_reconcileFailureDomains(t *testing.T) {
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureCluster",
Name: "test",
Namespace: "test-namespace",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,14 @@ func TestNodeLabelSync(t *testing.T) {
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
Kind: "GenericBootstrapConfig",
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
},
InfrastructureRef: corev1.ObjectReference{
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureMachine",
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
},
}
Expand Down Expand Up @@ -450,6 +452,8 @@ func TestNodeLabelSync(t *testing.T) {

machine := defaultMachine.DeepCopy()
machine.Namespace = ns.Name
machine.Spec.Bootstrap.ConfigRef.Namespace = ns.Name
machine.Spec.InfrastructureRef.Namespace = ns.Name
machine.Spec.ProviderID = ptr.To(nodeProviderID)

// Set Machine labels.
Expand Down
10 changes: 10 additions & 0 deletions internal/controllers/machine/machine_controller_phases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func TestReconcileBootstrap(t *testing.T) {
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
Kind: "GenericBootstrapConfig",
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
},
},
Expand Down Expand Up @@ -217,6 +218,7 @@ func TestReconcileBootstrap(t *testing.T) {
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
Kind: "GenericBootstrapConfig",
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
DataSecretName: ptr.To("secret-data"),
},
Expand Down Expand Up @@ -261,6 +263,7 @@ func TestReconcileBootstrap(t *testing.T) {
APIVersion: "bootstrap.cluster.x-k8s.io/v1beta1",
Kind: "GenericBootstrapConfig",
Name: "bootstrap-config1",
Namespace: metav1.NamespaceDefault,
},
DataSecretName: ptr.To("secret-data"),
},
Expand Down Expand Up @@ -339,6 +342,7 @@ func TestReconcileInfrastructure(t *testing.T) {
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureMachine",
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
},
}
Expand Down Expand Up @@ -619,6 +623,7 @@ func TestReconcileInfrastructure(t *testing.T) {
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureMachine",
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
ProviderID: ptr.To("test://something"),
FailureDomain: ptr.To("something"),
Expand Down Expand Up @@ -680,6 +685,7 @@ func TestReconcileInfrastructure(t *testing.T) {
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureMachine",
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
ProviderID: ptr.To("test://something"),
FailureDomain: ptr.To("something"),
Expand Down Expand Up @@ -741,6 +747,7 @@ func TestReconcileInfrastructure(t *testing.T) {
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureMachine",
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
},
Status: clusterv1.MachineStatus{
Expand Down Expand Up @@ -769,6 +776,7 @@ func TestReconcileInfrastructure(t *testing.T) {
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureMachine",
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
},
Status: clusterv1.MachineStatus{
Expand Down Expand Up @@ -799,6 +807,7 @@ func TestReconcileInfrastructure(t *testing.T) {
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureMachine",
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
},
Status: clusterv1.MachineStatus{
Expand All @@ -825,6 +834,7 @@ func TestReconcileInfrastructure(t *testing.T) {
APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1",
Kind: "GenericInfrastructureMachine",
Name: "infra-config1",
Namespace: metav1.NamespaceDefault,
},
},
Status: clusterv1.MachineStatus{
Expand Down
Loading

0 comments on commit edbd553

Please sign in to comment.