Skip to content

Commit

Permalink
Fix container check in e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
olim7t committed Dec 3, 2024
1 parent cfd7174 commit 5838166
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ func createSingleDatacenterCluster(t *testing.T, ctx context.Context, namespace
require.NoError(err, "failed to patch K8ssandraCluster in namespace %s", namespace)
checkStargateReady(t, f, ctx, stargateKey)
checkStargateK8cStatusReady(t, f, ctx, kcKey, dcKey)
checkContainerPresence(t, ctx, f, stargateDeploymentKey, k8ssandra, getPodTemplateSpec, stargate.VectorContainerName)
checkContainerPresenceEventually(t, ctx, f, stargateDeploymentKey, k8ssandra, getPodTemplateSpec, stargate.VectorContainerName)
checkVectorAgentConfigMapPresence(t, ctx, f, dcKey, stargate.VectorAgentConfigMapName)

t.Log("check that if Stargate is deleted directly it gets re-created")
Expand All @@ -853,7 +853,7 @@ func createSingleDatacenterCluster(t *testing.T, ctx context.Context, namespace
require.NoError(err, "failed to delete Stargate in namespace %s", namespace)
checkStargateReady(t, f, ctx, stargateKey)

checkContainerPresence(t, ctx, f, stargateDeploymentKey, k8ssandra, getPodTemplateSpec, stargate.VectorContainerName)
checkContainerPresenceEventually(t, ctx, f, stargateDeploymentKey, k8ssandra, getPodTemplateSpec, stargate.VectorContainerName)
checkVectorAgentConfigMapPresence(t, ctx, f, dcKey, stargate.VectorAgentConfigMapName)

t.Log("delete Stargate in k8ssandracluster resource")
Expand Down Expand Up @@ -2324,6 +2324,15 @@ func checkContainerPresence(t *testing.T, ctx context.Context, f *framework.E2eF
require.True(t, containerFound, "cannot find Container in pod template spec")
}

func checkContainerPresenceEventually(t *testing.T, ctx context.Context, f *framework.E2eFramework, podKey framework.ClusterKey, kc *api.K8ssandraCluster, specFunction func(t *testing.T, ctx context.Context, f *framework.E2eFramework, dcKey framework.ClusterKey, kc *api.K8ssandraCluster) *corev1.PodTemplateSpec, containerName string) {
t.Logf("check that %s contains Container named %s", podKey.Name, containerName)
require.Eventually(t, func() bool {
podTempSpec := specFunction(t, ctx, f, podKey, kc)
_, containerFound := cassandra.FindContainer(podTempSpec, containerName)
return containerFound
}, polling.stargateReady.timeout, polling.stargateReady.interval, "cannot find Container in pod template spec")
}

func checkContainerDeleted(t *testing.T, ctx context.Context, f *framework.E2eFramework, podKey framework.ClusterKey, kc *api.K8ssandraCluster, specFunction func(t *testing.T, ctx context.Context, f *framework.E2eFramework, dcKey framework.ClusterKey, kc *api.K8ssandraCluster) *corev1.PodTemplateSpec, containerName string) {
t.Logf("check that %s does not have a Container named %s", podKey.Name, containerName)
podTempSpec := specFunction(t, ctx, f, podKey, kc)
Expand Down

0 comments on commit 5838166

Please sign in to comment.