Skip to content

Commit

Permalink
initial e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
jsanda committed Jan 12, 2022
1 parent 3e76429 commit 1074535
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/kind_multicluster_e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
matrix:
e2e_test:
- CreateMultiDatacenterCluster
- AddDcToCluster
- CheckStargateApisWithMultiDcCluster
- CreateMultiStargateAndDatacenter
- CreateMultiReaper
Expand Down
49 changes: 49 additions & 0 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func TestOperator(t *testing.T) {
testFunc: createMultiDatacenterCluster,
fixture: "multi-dc",
}))
t.Run("AddDcToCluster", e2eTest(ctx, &e2eTestOpts{
testFunc: addDcToCluster,
fixture: "add-dc",
}))
t.Run("CreateMultiStargateAndDatacenter", e2eTest(ctx, &e2eTestOpts{
testFunc: createStargateAndDatacenter,
fixture: "multi-stargate",
Expand Down Expand Up @@ -617,6 +621,51 @@ func createMultiDatacenterCluster(t *testing.T, ctx context.Context, namespace s
assert.NoError(t, err, "timed out waiting for nodetool status check against "+pod)
}

func addDcToCluster(t *testing.T, ctx context.Context, namespace string, f *framework.E2eFramework) {
require := require.New(t)

t.Log("check that the K8ssandraCluster was created")
kcKey := client.ObjectKey{Namespace: namespace, Name: "test"}
kc := &api.K8ssandraCluster{}
err := f.Client.Get(ctx, kcKey, kc)
require.NoError(err, "failed to get K8ssandraCluster in namespace %s", namespace)

dc1Key := framework.ClusterKey{K8sContext: "kind-k8ssandra-0", NamespacedName: types.NamespacedName{Namespace: namespace, Name: "dc1"}}
checkDatacenterReady(t, ctx, dc1Key, f)

t.Log("add dc2 to cluster")
err = f.Client.Get(ctx, kcKey, kc)
require.NoError(err, "failed to get K8ssandraCluster %s", kcKey)

kc.Spec.Cassandra.Datacenters = append(kc.Spec.Cassandra.Datacenters, api.CassandraDatacenterTemplate{
Meta: api.EmbeddedObjectMeta{
Name: "dc2",
},
K8sContext: "kind-k8ssandra-1",
Size: 1,
})

dc2Key := framework.ClusterKey{K8sContext: "kind-k8ssandra-1", NamespacedName: types.NamespacedName{Namespace: namespace, Name: "dc2"}}
checkDatacenterReady(t, ctx, dc2Key, f)

t.Log("retrieve database credentials")
username, password, err := f.RetrieveDatabaseCredentials(ctx, namespace, kc.Spec.Cassandra.Cluster)
require.NoError(err, "failed to retrieve database credentials")

t.Log("check that nodes in dc1 see nodes in dc2")
pod := "test-dc1-default-sts-0"
count := 6
checkNodeToolStatusUN(t, f, "kind-k8ssandra-0", namespace, pod, count, "-u", username, "-pw", password)

assert.NoError(t, err, "timed out waiting for nodetool status check against "+pod)

t.Log("check nodes in dc2 see nodes in dc1")
pod = "test-dc2-default-sts-0"
checkNodeToolStatusUN(t, f, "kind-k8ssandra-1", namespace, pod, count, "-u", username, "-pw", password)

assert.NoError(t, err, "timed out waiting for nodetool status check against "+pod)
}

func checkStargateApisWithMultiDcCluster(t *testing.T, ctx context.Context, namespace string, f *framework.E2eFramework) {
require := require.New(t)

Expand Down
46 changes: 46 additions & 0 deletions test/testdata/fixtures/add-dc/k8ssandra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: k8ssandra.io/v1alpha1
kind: K8ssandraCluster
metadata:
name: test
spec:
cassandra:
cluster: test
serverVersion: "4.0.1"
storageConfig:
cassandraDataVolumeClaimSpec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
config:
cassandraYaml:
auto_snapshot: false
memtable_flush_writers: 1
commitlog_segment_size_in_mb: 2
concurrent_compactors: 1
compaction_throughput_mb_per_sec: 0
sstable_preemptive_open_interval_in_mb: 0
key_cache_size_in_mb: 0
thrift_prepared_statements_cache_size_mb: 1
prepared_statements_cache_size_mb: 1
start_rpc: false
slow_query_log_timeout_in_ms: 0
counter_cache_size_in_mb: 0
concurrent_reads: 2
concurrent_writes: 2
concurrent_counter_writes: 2
jvmOptions:
heapSize: 384Mi
networking:
hostNetwork: true
resources:
limits:
memory: 512Mi
datacenters:
- metadata:
name: dc1
k8sContext: kind-k8ssandra-0
size: 1

0 comments on commit 1074535

Please sign in to comment.