Skip to content

Commit

Permalink
In tests, don't expect reaper's keyspace if its a STS + allow getting…
Browse files Browse the repository at this point in the history
… pod specs if reaper not set
  • Loading branch information
rzvoncek committed Jul 22, 2024
1 parent 29cb6f2 commit a2f0c50
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
3 changes: 2 additions & 1 deletion test/e2e/reaper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ func createSingleReaper(t *testing.T, ctx context.Context, namespace string, f *
f.DeployReaperIngresses(t, f.DataPlaneContexts[0], namespace, dcPrefix+"-reaper-service", reaperRestHostAndPort)
defer f.UndeployAllIngresses(t, f.DataPlaneContexts[0], namespace)
checkReaperApiReachable(t, ctx, reaperRestHostAndPort)
makeDummyKeyspace(t, f, ctx, f.DataPlaneContexts[0], namespace, kc.SanitizedName(), dcPrefix+"-default-sts-0", "dummy_keyspace")

t.Run("TestReaperApi[0]", func(t *testing.T) {
t.Log("test Reaper API in context", f.DataPlaneContexts[0])
reaperUiSecretKey := framework.ClusterKey{K8sContext: f.DataPlaneContexts[0], NamespacedName: types.NamespacedName{Namespace: namespace, Name: "mycluster-reaper-ui"}}
username, password := retrieveCredentials(t, f, ctx, reaperUiSecretKey)
testReaperApi(t, ctx, f.DataPlaneContexts[0], DcClusterName(t, f, dcKey), "reaper_db", username, password)
testReaperApi(t, ctx, f.DataPlaneContexts[0], DcClusterName(t, f, dcKey), "dummy_keyspace", username, password)
})
}

Expand Down
26 changes: 23 additions & 3 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,22 @@ func checkKeyspaceReplication(
}, 1*time.Minute, 3*time.Second)
}

func makeDummyKeyspace(t *testing.T,
f *framework.E2eFramework,
ctx context.Context,
k8sContext, namespace, clusterName, pod, keyspace string,
) {
assert.Eventually(t, func() bool {
dcKey := framework.ClusterKey{K8sContext: f.DataPlaneContexts[0], NamespacedName: types.NamespacedName{Namespace: namespace, Name: "dc1"}}
_, err := f.ExecuteCql(ctx, k8sContext, namespace, clusterName, pod, "CREATE KEYSPACE reaper_db WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', '"+DcName(t, f, dcKey)+"' : 3} ")
if err != nil {
t.Logf("failed to create keyspace %s: %v", keyspace, err)
return false
}
return true
}, 1*time.Minute, 3*time.Second)
}

// assertCassandraDatacenterK8cStatusReady polls the K8ssandraCluster object, checking its status to
// verify the CassandraDatacenter specified by dcName is ready.
func assertCassandraDatacenterK8cStatusReady(
Expand Down Expand Up @@ -2221,11 +2237,15 @@ func checkVectorConfigMapDeleted(t *testing.T, ctx context.Context, f *framework

}

func getPodTemplateSpec(t *testing.T, ctx context.Context, f *framework.E2eFramework, dcKey framework.ClusterKey, kc *api.K8ssandraCluster) *corev1.PodTemplateSpec {
func getPodTemplateSpec(t *testing.T, ctx context.Context, f *framework.E2eFramework, appKey framework.ClusterKey, kc *api.K8ssandraCluster) *corev1.PodTemplateSpec {
// this gets called for other pods than reapers (eg stargate). before reaper gained the option of being a STS, everything was a deployment
if kc.Spec.Reaper == nil {
return getPodTemplateSpecForDeployment(t, ctx, f, appKey)
}
if kc.Spec.Reaper.StorageType == reaperapi.StorageTypeCassandra {
return getPodTemplateSpecForDeployment(t, ctx, f, dcKey)
return getPodTemplateSpecForDeployment(t, ctx, f, appKey)
} else {
return getPodTemplateSpecForStatefulSet(t, ctx, f, dcKey)
return getPodTemplateSpecForStatefulSet(t, ctx, f, appKey)
}
}

Expand Down

0 comments on commit a2f0c50

Please sign in to comment.