Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix ControlPlane update in integration test #696

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 24 additions & 22 deletions test/integration/test_controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ func TestControlPlaneWhenNoDataPlane(t *testing.T) {
}), testutils.ControlPlaneCondDeadline, testutils.ControlPlaneCondTick)

t.Log("attaching dataplane to controlplane")
controlplane, err = controlplaneClient.Get(GetCtx(), controlplane.Name, metav1.GetOptions{})
require.NoError(t, err)
controlplane.Spec.DataPlane = &dataplane.Name
controlplane, err = controlplaneClient.Update(GetCtx(), controlplane, metav1.UpdateOptions{})
require.NoError(t, err)
require.Eventually(t,
testutils.ControlPlaneUpdateEventually(t, GetCtx(), controlplaneName, clients, func(cp *operatorv1beta1.ControlPlane) {
cp.Spec.DataPlane = &dataplane.Name
}),
testutils.ControlPlaneCondDeadline, testutils.ControlPlaneCondTick,
)

t.Log("verifying controlplane is now provisioned")
require.Eventually(t, testutils.ControlPlaneIsProvisioned(t, GetCtx(), controlplaneName, clients), testutils.ControlPlaneCondDeadline, testutils.ControlPlaneCondTick)
Expand All @@ -136,11 +137,12 @@ func TestControlPlaneWhenNoDataPlane(t *testing.T) {
require.Eventually(t, testutils.ControlPlaneHasActiveDeployment(t, GetCtx(), controlplaneName, clients), testutils.ControlPlaneCondDeadline, testutils.ControlPlaneCondTick)

t.Log("removing dataplane from controlplane")
controlplane, err = controlplaneClient.Get(GetCtx(), controlplane.Name, metav1.GetOptions{})
require.NoError(t, err)
controlplane.Spec.DataPlane = nil
_, err = controlplaneClient.Update(GetCtx(), controlplane, metav1.UpdateOptions{})
require.NoError(t, err)
require.Eventually(t,
testutils.ControlPlaneUpdateEventually(t, GetCtx(), controlplaneName, clients, func(cp *operatorv1beta1.ControlPlane) {
cp.Spec.DataPlane = nil
}),
testutils.ControlPlaneCondDeadline, testutils.ControlPlaneCondTick,
)

t.Log("verifying controlplane deployment has no active replicas")
require.Eventually(t, testutils.Not(testutils.ControlPlaneHasActiveDeployment(t, GetCtx(), controlplaneName, clients)), testutils.ControlPlaneCondDeadline, testutils.ControlPlaneCondTick)
Expand Down Expand Up @@ -605,18 +607,18 @@ func TestControlPlaneUpdate(t *testing.T) {
testEnv := GetEnvValueByName(container.Env, "TEST_ENV")
require.Equal(t, "before_update", testEnv)

t.Logf("updating controlplane resource")
controlplane, err = controlplaneClient.Get(GetCtx(), controlplaneName.Name, metav1.GetOptions{})
require.NoError(t, err)
container = k8sutils.GetPodContainerByName(&controlplane.Spec.Deployment.PodTemplateSpec.Spec, consts.ControlPlaneControllerContainerName)
require.NotNil(t, container)
container.Env = []corev1.EnvVar{
{
Name: "TEST_ENV", Value: "after_update",
},
}
_, err = controlplaneClient.Update(GetCtx(), controlplane, metav1.UpdateOptions{})
require.NoError(t, err)
t.Logf("updating controlplane resource with new ControlPlane environment variable value")

require.Eventually(t,
testutils.ControlPlaneUpdateEventually(t, GetCtx(), controlplaneName, clients, func(cp *operatorv1beta1.ControlPlane) {
cp.Spec.Deployment.PodTemplateSpec.Spec.Containers[0].Env = []corev1.EnvVar{
{
Name: "TEST_ENV", Value: "after_update",
},
}
}),
testutils.ControlPlaneCondDeadline, testutils.ControlPlaneCondTick,
)

t.Logf("verifying environment variable TEST_ENV in deployment after update")
require.Eventually(t, func() bool {
Expand Down
Loading