diff --git a/.github/workflows/kindIntegTest.yml b/.github/workflows/kindIntegTest.yml index ca238c450..6f6eb376f 100644 --- a/.github/workflows/kindIntegTest.yml +++ b/.github/workflows/kindIntegTest.yml @@ -14,6 +14,7 @@ jobs: integration_test: - smoke_test_dse - smoke_test_oss + - smoke_test_4x # let other tests continue to run # even if one fails fail-fast: false diff --git a/charts/cass-operator-chart/templates/customresourcedefinition.yaml b/charts/cass-operator-chart/templates/customresourcedefinition.yaml index 270344dd1..b977a6f2a 100644 --- a/charts/cass-operator-chart/templates/customresourcedefinition.yaml +++ b/charts/cass-operator-chart/templates/customresourcedefinition.yaml @@ -6035,7 +6035,7 @@ spec: serverVersion: description: Version string for config builder, used to generate Cassandra server configuration - pattern: (6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+) + pattern: (6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+)|(4\.0-beta\d+) type: string serviceAccount: description: The k8s service account to use for the server pods diff --git a/operator/deploy/crds/cassandra.datastax.com_cassandradatacenters_crd.yaml b/operator/deploy/crds/cassandra.datastax.com_cassandradatacenters_crd.yaml index b5515fdf1..2c456e04d 100644 --- a/operator/deploy/crds/cassandra.datastax.com_cassandradatacenters_crd.yaml +++ b/operator/deploy/crds/cassandra.datastax.com_cassandradatacenters_crd.yaml @@ -6047,7 +6047,7 @@ spec: serverVersion: description: Version string for config builder, used to generate Cassandra server configuration - pattern: (6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+) + pattern: (6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+)|(4\.0-beta\d+) type: string serviceAccount: description: The k8s service account to use for the server pods diff --git a/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types.go b/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types.go index 1951a5b37..3bc91407d 100644 --- a/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types.go +++ b/operator/pkg/apis/cassandra/v1beta1/cassandradatacenter_types.go @@ -70,7 +70,7 @@ type CassandraDatacenterSpec struct { // Version string for config builder, // used to generate Cassandra server configuration - // +kubebuilder:validation:Pattern=(6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+) + // +kubebuilder:validation:Pattern=(6\.8\.\d+)|(3\.11\.\d+)|(4\.0\.\d+)|(4\.0-beta\d+) ServerVersion string `json:"serverVersion"` // Cassandra server image name. diff --git a/operator/pkg/apis/cassandra/v1beta1/webhook_test.go b/operator/pkg/apis/cassandra/v1beta1/webhook_test.go index f588edb0a..6901a449c 100644 --- a/operator/pkg/apis/cassandra/v1beta1/webhook_test.go +++ b/operator/pkg/apis/cassandra/v1beta1/webhook_test.go @@ -85,6 +85,32 @@ func Test_ValidateSingleDatacenter(t *testing.T) { }, errString: "", }, + { + name: "Cassandra invalid", + dc: &CassandraDatacenter{ + ObjectMeta: metav1.ObjectMeta{ + Name: "exampleDC", + }, + Spec: CassandraDatacenterSpec{ + ServerType: "cassandra", + ServerVersion: "4.0-beta", + }, + }, + errString: "use unsupported Cassandra version '4.0-beta'", + }, + { + name: "Cassandra valid", + dc: &CassandraDatacenter{ + ObjectMeta: metav1.ObjectMeta{ + Name: "exampleDC", + }, + Spec: CassandraDatacenterSpec{ + ServerType: "cassandra", + ServerVersion: "4.0-beta4", + }, + }, + errString: "", + }, { name: "Cassandra Invalid", dc: &CassandraDatacenter{ diff --git a/operator/pkg/images/images.go b/operator/pkg/images/images.go index 0e7fb1b2c..606f3a522 100644 --- a/operator/pkg/images/images.go +++ b/operator/pkg/images/images.go @@ -21,7 +21,7 @@ const ( envDefaultRegistryOverridePullSecrets = "DEFAULT_CONTAINER_REGISTRY_OVERRIDE_PULL_SECRETS" EnvBaseImageOS = "BASE_IMAGE_OS" ValidDseVersionRegexp = "6\\.8\\.\\d+" - ValidOssVersionRegexp = "(3\\.11\\.\\d+)|(4\\.0\\.\\d+)" + ValidOssVersionRegexp = "(3\\.11\\.\\d+)|(4\\.0\\.\\d+)|(4\\.0-beta\\d+)" UbiImageSuffix = "-ubi7" ) diff --git a/operator/pkg/images/images_test.go b/operator/pkg/images/images_test.go index 58cf27f50..a900c5756 100644 --- a/operator/pkg/images/images_test.go +++ b/operator/pkg/images/images_test.go @@ -85,3 +85,44 @@ func Test_CalculateDockerImageRunsAsCassandra(t *testing.T) { assert.Equal(t, got, tt.want, fmt.Sprintf("Version: %s should not have returned %v", tt.version, got)) } } + +func Test_IsOssVersionSupported(t *testing.T) { + tests := []struct { + version string + expected bool + }{ + { + version: "3.11.6", + expected: true, + }, + { + version: "3.11.10", + expected: true, + }, + { + version: "3.0.23", + expected: false, + }, + { + version: "4.0.0", + expected: true, + }, + { + version: "4.0.1", + expected: true, + }, + { + version: "4.0-beta4", + expected: true, + }, + { + version: "4.1.0", + expected: false, + }, + } + for _, tt := range tests { + supported := IsOssVersionSupported(tt.version) + + assert.Equal(t, supported, tt.expected, fmt.Sprintf("Version: %s should not have returned supported=%v", tt.version, supported)) + } +} diff --git a/tests/smoke_test_4x/smoke_test_4x_suite_test.go b/tests/smoke_test_4x/smoke_test_4x_suite_test.go new file mode 100644 index 000000000..de7a1c04c --- /dev/null +++ b/tests/smoke_test_4x/smoke_test_4x_suite_test.go @@ -0,0 +1,97 @@ +// Copyright DataStax, Inc. +// Please see the included license file for details. + +package smoke_test_4x + +import ( + "fmt" + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + ginkgo_util "github.com/datastax/cass-operator/mage/ginkgo" + "github.com/datastax/cass-operator/mage/kubectl" +) + +var ( + testName = "Smoke test of basic functionality for one-node OSS Cassandra 4.x cluster." + namespace = "test-smoke-test-4x" + dcName = "dc2" + dcYaml = "../testdata/smoke-test-4x.yaml" + operatorYaml = "../testdata/operator.yaml" + dcResource = fmt.Sprintf("CassandraDatacenter/%s", dcName) + dcLabel = fmt.Sprintf("cassandra.datastax.com/datacenter=%s", dcName) + ns = ginkgo_util.NewWrapper(testName, namespace) +) + +func TestLifecycle(t *testing.T) { + AfterSuite(func() { + logPath := fmt.Sprintf("%s/aftersuite", ns.LogDir) + kubectl.DumpAllLogs(logPath).ExecV() + fmt.Printf("\n\tPost-run logs dumped at: %s\n\n", logPath) + ns.Terminate() + }) + + RegisterFailHandler(Fail) + RunSpecs(t, testName) +} + +var _ = Describe(testName, func() { + Context("when in a new cluster", func() { + Specify("the operator can stand up a one node cluster", func() { + By("creating a namespace") + err := kubectl.CreateNamespace(namespace).ExecV() + Expect(err).ToNot(HaveOccurred()) + + step := "setting up cass-operator resources via helm chart" + ns.HelmInstall("../../charts/cass-operator-chart") + + step = "waiting for the operator to become ready" + json := "jsonpath={.items[0].status.containerStatuses[0].ready}" + k := kubectl.Get("pods"). + WithLabel("name=cass-operator"). + WithFlag("field-selector", "status.phase=Running"). + FormatOutput(json) + ns.WaitForOutputAndLog(step, k, "true", 360) + + step = "creating a datacenter resource with 1 rack/1 node" + k = kubectl.ApplyFiles(dcYaml) + ns.ExecAndLog(step, k) + + ns.WaitForDatacenterReady(dcName) + + step = "deleting the dc" + k = kubectl.DeleteFromFiles(dcYaml) + ns.ExecAndLog(step, k) + + step = "checking that the dc no longer exists" + json = "jsonpath={.items}" + k = kubectl.Get("CassandraDatacenter"). + WithLabel(dcLabel). + FormatOutput(json) + ns.WaitForOutputAndLog(step, k, "[]", 600) + + step = "checking that no dc pods remain" + json = "jsonpath={.items}" + k = kubectl.Get("pods"). + WithLabel(dcLabel). + FormatOutput(json) + ns.WaitForOutputAndLog(step, k, "[]", 600) + + step = "checking that no dc services remain" + json = "jsonpath={.items}" + k = kubectl.Get("services"). + WithLabel(dcLabel). + FormatOutput(json) + ns.WaitForOutputAndLog(step, k, "[]", 600) + + step = "checking that no dc stateful sets remain" + json = "jsonpath={.items}" + k = kubectl.Get("statefulsets"). + WithLabel(dcLabel). + FormatOutput(json) + ns.WaitForOutputAndLog(step, k, "[]", 600) + }) + }) +}) diff --git a/tests/testdata/smoke-test-4x.yaml b/tests/testdata/smoke-test-4x.yaml new file mode 100644 index 000000000..b7362a5c5 --- /dev/null +++ b/tests/testdata/smoke-test-4x.yaml @@ -0,0 +1,26 @@ +apiVersion: cassandra.datastax.com/v1beta1 +kind: CassandraDatacenter +metadata: + name: dc2 +spec: + clusterName: cluster2 + serverType: cassandra + serverVersion: "4.0-beta4" + serverImage: "datastax/cassandra-mgmtapi-4_0_0:v0.1.20" + managementApiAuth: + insecure: {} + size: 1 + storageConfig: + cassandraDataVolumeClaimSpec: + storageClassName: server-storage + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 250Mi + racks: + - name: r1 + config: + jvm-server-options: + initial_heap_size: "800m" + max_heap_size: "800m"