forked from k8ssandra/cass-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b2245d
commit 40dc8e6
Showing
4 changed files
with
195 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/cdc_successful/cdc_successful_test.go → ...cdc_successful_c/cdc_successful_test_c.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Copyright DataStax, Inc. | ||
// Please see the included license file for details. | ||
|
||
package cdc_successful_dse | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/k8ssandra/cass-operator/tests/kustomize" | ||
ginkgo_util "github.com/k8ssandra/cass-operator/tests/util/ginkgo" | ||
"github.com/k8ssandra/cass-operator/tests/util/kubectl" | ||
shutil "github.com/k8ssandra/cass-operator/tests/util/sh" | ||
) | ||
|
||
var ( | ||
testName = "DSE CDC flows work" | ||
namespace = "test-cdc" | ||
dcName = "dc1" | ||
dcYaml = "../testdata/test-cdc/dse-datacenter.yaml" | ||
pulsarValues = "../testdata/test-cdc/dev-values.yaml" | ||
testUtilsDeployment = "../testdata/test-cdc/testutils-deployment.yaml" | ||
ns = ginkgo_util.NewWrapper(testName, namespace) | ||
) | ||
|
||
func TestLifecycle(t *testing.T) { | ||
AfterSuite(func() { | ||
logPath := fmt.Sprintf("%s/aftersuite", ns.LogDir) | ||
err := kubectl.DumpAllLogs(logPath).ExecV() | ||
if err != nil { | ||
t.Logf("Failed to dump all the logs: %v", err) | ||
} | ||
|
||
fmt.Printf("\n\tPost-run logs dumped at: %s\n\n", logPath) | ||
ns.Terminate() | ||
err = kustomize.Undeploy(namespace) | ||
if err != nil { | ||
t.Logf("Failed to undeploy cass-operator: %v", err) | ||
} | ||
kubectl.Delete("ns", "pulsar").OutputPanic() | ||
}) | ||
|
||
RegisterFailHandler(Fail) | ||
RunSpecs(t, testName) | ||
} | ||
|
||
var _ = Describe(testName, func() { | ||
Context("when in a new cluster with CDC enabled", func() { | ||
Specify("CDC feeds will become available for read", func() { | ||
|
||
By("creating a namespace for the cass-operator") | ||
err := kubectl.CreateNamespace(namespace).ExecV() | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
By("deploy cass-operator with kustomize") | ||
err = kustomize.Deploy(namespace) | ||
Expect(err).ToNot(HaveOccurred()) | ||
ns.WaitForOperatorReady() | ||
|
||
step := "creating a DC" | ||
testFile, err := ginkgo_util.CreateTestFile(dcYaml) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
k := kubectl.ApplyFiles(testFile) | ||
ns.ExecAndLog(step, k) | ||
|
||
By("Deploying Pulsar") | ||
err = shutil.RunV("helm", "repo", "add", "datastax-pulsar", "https://datastax.github.io/pulsar-helm-chart") | ||
Expect(err).ShouldNot(HaveOccurred()) | ||
|
||
err = shutil.RunV("helm", "repo", "update") | ||
Expect(err).ShouldNot(HaveOccurred()) | ||
|
||
err = shutil.RunV("helm", "install", "--create-namespace", "-n", "pulsar", "-f", pulsarValues, "pulsar", "datastax-pulsar/pulsar") | ||
Expect(err).ShouldNot(HaveOccurred()) | ||
|
||
By("Waiting for all components to be ready") | ||
readyGetter := kubectl.Get("pods"). | ||
WithFlag("selector", "app=cdc-testutil"). | ||
WithFlag("selector", "component=proxy"). | ||
WithFlag("namespace", "pulsar"). | ||
FormatOutput("jsonpath={.items[0].status.conditions[?(@.type=='Ready')].status}") | ||
err = kubectl.WaitForOutputContains(readyGetter, "True", 1800) | ||
Expect(err).ShouldNot(HaveOccurred()) | ||
|
||
ns.WaitForDatacenterReadyWithTimeouts(dcName, 1200, 1200) | ||
|
||
step = "Creating a testutils deployment" | ||
k = kubectl.ApplyFiles(testUtilsDeployment) | ||
ns.ExecAndLog(step, k) | ||
|
||
step = "Confirming testutils ready" | ||
readyGetter = kubectl.Get("pods"). | ||
WithFlag("selector", "app=cdc-testutil"). | ||
FormatOutput("jsonpath={.items[0].status.conditions[?(@.type=='Ready')].status}") | ||
ns.WaitForOutputContainsAndLog(step, readyGetter, "True", 1800) | ||
|
||
step = "Running testutils applications" | ||
podGetter := kubectl.Get("pods"). | ||
WithFlag("selector", "app=cdc-testutil"). | ||
WithFlag("namespace", namespace). | ||
FormatOutput("jsonpath='{.items[0].metadata.name}'") | ||
testUtilsPod := podGetter.OutputPanic() | ||
testCommand := kubectl. | ||
ExecOnPod( | ||
strings.ReplaceAll(testUtilsPod, "'", ""), | ||
"--", | ||
"bash", "-c", | ||
"/opt/bin/pulsar-cdc-testutil --cass-contact-points test-cluster-dc1-all-pods-service.test-cdc.svc.cluster.local:9042 --pulsar-url pulsar://pulsar-proxy.pulsar.svc.cluster.local:6650 --pulsar-admin-url http://pulsar-proxy.pulsar.svc.cluster.local:8080 --pulsar-cass-contact-point test-cluster-dc1-all-pods-service.test-cdc.svc.cluster.local"). | ||
InNamespace(namespace) | ||
ns.WaitForOutputContainsAndLog(step, testCommand, "SUCCESS", 1200) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: cassandra.datastax.com/v1beta1 | ||
kind: CassandraDatacenter | ||
metadata: | ||
name: dc1 | ||
spec: | ||
clusterName: test-cluster | ||
# The number of server nodes. | ||
size: 1 | ||
cdc: | ||
pulsarServiceUrl: pulsar://pulsar-proxy.pulsar.svc.cluster.local:6650 | ||
topicPrefix: persistent://public/default/events- | ||
cdcWorkingDir: /var/lib/cassandra/cdc | ||
storageConfig: | ||
cassandraDataVolumeClaimSpec: | ||
storageClassName: standard | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 1Gi | ||
# Which server version to use. Required. | ||
serverVersion: "6.8.26" | ||
serverType: "dse" |