Skip to content

Commit

Permalink
Create dummy keypsaces to repair
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvoncek committed Jul 29, 2024
1 parent a556acb commit d77feae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 3 additions & 2 deletions test/e2e/reaper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ 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")

createEmptyKeyspaceTable(t, f, ctx, f.DataPlaneContexts[0], namespace, kc.SanitizedName(), dcPrefix+"-default-sts-0", "test_ks", "test_table")

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), "dummy_keyspace", username, password)
testReaperApi(t, ctx, f.DataPlaneContexts[0], DcClusterName(t, f, dcKey), "test_ks", username, password)
})
}

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

func makeDummyKeyspace(t *testing.T,
func createEmptyKeyspaceTable(t *testing.T,
f *framework.E2eFramework,
ctx context.Context,
k8sContext, namespace, clusterName, pod, keyspace string,
k8sContext, namespace, clusterName, pod, keyspace, table 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} ")
dcName := DcName(t, f, dcKey)
createKeyspaceStatement := fmt.Sprintf("CREATE KEYSPACE %s WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', '%s' : 3};", keyspace, dcName)
createTableStatement := fmt.Sprintf("CREATE TABLE %s.%s (id int PRIMARY KEY);", keyspace, table)

_, err := f.ExecuteCql(ctx, k8sContext, namespace, clusterName, pod, createKeyspaceStatement)
if err != nil {
t.Logf("failed to create keyspace %s: %v", keyspace, err)
return false
}

_, err = f.ExecuteCql(ctx, k8sContext, namespace, clusterName, pod, createTableStatement)
if err != nil {
t.Logf("failed to create table %s.%s: %v", keyspace, table, err)
return false
}

return true
}, 1*time.Minute, 3*time.Second)
}
Expand Down

0 comments on commit d77feae

Please sign in to comment.