diff --git a/test/batch_restart_pods_test.go b/test/batch_restart_pods_test.go index 312086a97..118127941 100644 --- a/test/batch_restart_pods_test.go +++ b/test/batch_restart_pods_test.go @@ -20,9 +20,9 @@ import ( const batchClusterName = "batch-restart" var ( - unavailableImage = fmt.Sprintf("%s:%s", baseImage, "6.0.0.99") - availableImage1 = fmt.Sprintf("%s:%s", baseImage, "6.0.0.1") - availableImage2 = fmt.Sprintf("%s:%s", baseImage, "6.0.0.2") + unavailableImage = fmt.Sprintf("%s:%s", baseImage, "7.0.0.99") + availableImage1 = fmt.Sprintf("%s:%s", baseImage, "7.0.0.0_1") + availableImage2 = fmt.Sprintf("%s:%s", baseImage, "7.0.0.0_2") ) func percent(val string) *intstr.IntOrString { @@ -244,8 +244,8 @@ func BatchRollingRestart(ctx goctx.Context, clusterNamespacedName types.Namespac // Test steps // 1: update cluster to demand huge resources. It will unschedule batch of pods - // 2: verify if more than 1 pods are in unscheduled state. - // In default mode, there can not be more than 1 unscheduled pods + // 2: verify if more than 1 pod are in unscheduled state. + // In default mode, there cannot be more than 1 unscheduled pods // 3: update cluster to demand limited resources. It will schedule old unscheduled pods // Restart full rack at a time @@ -331,7 +331,8 @@ func BatchUpgrade(ctx goctx.Context, clusterNamespacedName types.NamespacedName) aeroCluster, err := getCluster(k8sClient, ctx, clusterNamespacedName) Expect(err).ToNot(HaveOccurred()) - _ = deleteCluster(k8sClient, ctx, aeroCluster) + err = deleteCluster(k8sClient, ctx, aeroCluster) + Expect(err).ToNot(HaveOccurred()) }, ) // Restart 1 node at a time @@ -350,8 +351,8 @@ func BatchUpgrade(ctx goctx.Context, clusterNamespacedName types.NamespacedName) // Test steps // 1: update cluster with unavailable image. It will unschedule batch of pods - // 2: verify if more than 1 pods are in unscheduled state. - // In default mode, there can not be more than 1 unscheduled pods + // 2: verify if more than 1 pod are in unscheduled state. + // In default mode, there cannot be more than 1 unscheduled pods // 3: update cluster to demand limited resources. It will schedule old unscheduled pods // Restart full rack at a time diff --git a/test/cluster_helper.go b/test/cluster_helper.go index ac5a133ae..662d11f27 100644 --- a/test/cluster_helper.go +++ b/test/cluster_helper.go @@ -29,7 +29,7 @@ import ( const ( baseImage = "aerospike/aerospike-server-enterprise" - prevServerVersion = "6.3.0.0" + prevServerVersion = "6.4.0.0" pre6Version = "5.7.0.17" version6 = "6.0.0.5" latestServerVersion = "7.0.0.0" @@ -781,7 +781,7 @@ func createAerospikeClusterPost460( }, "network": getNetworkTLSConfig(), "namespaces": []interface{}{ - getNonSCNamespaceConfig("test", "/test/dev/xvdf"), + getNonSCNamespaceConfigPre700("test", "/test/dev/xvdf"), }, }, }, @@ -842,7 +842,7 @@ func createAerospikeClusterPost560( "security": map[string]interface{}{}, "network": getNetworkTLSConfig(), "namespaces": []interface{}{ - getNonSCNamespaceConfig("test", "/test/dev/xvdf"), + getNonSCNamespaceConfigPre700("test", "/test/dev/xvdf"), }, }, }, @@ -855,6 +855,17 @@ func createAerospikeClusterPost560( return aeroCluster } +func createAerospikeClusterPost640( + clusterNamespacedName types.NamespacedName, size int32, image string, +) *asdbv1.AerospikeCluster { + // create Aerospike custom resource + aeroCluster := createAerospikeClusterPost560(clusterNamespacedName, size, image) + aeroCluster.Spec.AerospikeConfig.Value["namespaces"] = []interface{}{ + getNonSCNamespaceConfig("test", "/test/dev/xvdf"), + } + + return aeroCluster +} func createDummyRackAwareWithStorageAerospikeCluster( clusterNamespacedName types.NamespacedName, size int32, ) *asdbv1.AerospikeCluster { @@ -1039,12 +1050,61 @@ func UpdateClusterImage( return err } - ov, err := asconfig.CompareVersions(outgoingVersion, "5.7.0") + ov, err := asconfig.CompareVersions(outgoingVersion, "7.0.0") if err != nil { return err } - nv, err := asconfig.CompareVersions(incomingVersion, "5.7.0") + nv, err := asconfig.CompareVersions(incomingVersion, "7.0.0") + if err != nil { + return err + } + + switch { + case nv >= 0 && ov >= 0, nv < 0 && ov < 0: + aerocluster.Spec.Image = image + + case nv >= 0 && ov < 0: + aerocluster.Spec.Image = image + + namespaces := aerocluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{}) + for idx := range namespaces { + ns := namespaces[idx].(map[string]interface{}) + delete(ns, "memory-size") + + storageEngine := ns["storage-engine"].(map[string]interface{}) + if storageEngine["type"] == "memory" { + storageEngine["data-size"] = 1073741824 + ns["storage-engine"] = storageEngine + } + + namespaces[idx] = ns + } + + default: + aerocluster.Spec.Image = image + + namespaces := aerocluster.Spec.AerospikeConfig.Value["namespaces"].([]interface{}) + for idx := range namespaces { + ns := namespaces[idx].(map[string]interface{}) + ns["memory-size"] = 1073741824 + + storageEngine := ns["storage-engine"].(map[string]interface{}) + if storageEngine["type"] == "memory" { + delete(storageEngine, "data-size") + ns["storage-engine"] = storageEngine + } + + namespaces[idx] = ns + } + } + + ov, err = asconfig.CompareVersions(outgoingVersion, "5.7.0") + if err != nil { + return err + } + + nv, err = asconfig.CompareVersions(incomingVersion, "5.7.0") if err != nil { return err } @@ -1411,6 +1471,14 @@ func getNonSCNamespaceConfig(name, path string) map[string]interface{} { return getNonSCNamespaceConfigWithRF(name, path, 2) } +// getNonSCNamespaceConfigPre700 returns a namespace config for Aerospike version < 7.0.0 +func getNonSCNamespaceConfigPre700(name, path string) map[string]interface{} { + config := getNonSCNamespaceConfigWithRF(name, path, 2) + config["memory-size"] = 2000955200 + + return config +} + func getNonSCNamespaceConfigWithRF(name, path string, rf int) map[string]interface{} { return map[string]interface{}{ "name": name, diff --git a/test/cluster_test.go b/test/cluster_test.go index f48dd90da..d5af68e05 100644 --- a/test/cluster_test.go +++ b/test/cluster_test.go @@ -958,7 +958,7 @@ func negativeDeployClusterValidationTest( It( "MultipleCertSource: should fail if both SecretCertSource and CertPathInOperator is set", func() { - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 1, latestImage, ) aeroCluster.Spec.OperatorClientCertSpec.CertPathInOperator = &asdbv1.AerospikeCertPathInOperatorSource{} @@ -972,7 +972,7 @@ func negativeDeployClusterValidationTest( It( "MissingClientKeyFilename: should fail if ClientKeyFilename is missing", func() { - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 1, latestImage, ) aeroCluster.Spec.OperatorClientCertSpec.SecretCertSource.ClientKeyFilename = "" @@ -987,7 +987,7 @@ func negativeDeployClusterValidationTest( It( "Should fail if both CaCertsFilename and CaCertsSource is set", func() { - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 1, latestImage, ) aeroCluster.Spec.OperatorClientCertSpec.SecretCertSource.CaCertsSource = &asdbv1.CaCertsSource{} @@ -1002,7 +1002,7 @@ func negativeDeployClusterValidationTest( It( "MissingClientCertPath: should fail if clientCertPath is missing", func() { - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 1, latestImage, ) aeroCluster.Spec.OperatorClientCertSpec.SecretCertSource = nil @@ -1366,7 +1366,7 @@ func negativeDeployClusterValidationTest( It( "WhenFeatureKeyExist: should fail for no feature-key-file path in storage volume", func() { - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 1, latestImage, ) aeroCluster.Spec.AerospikeConfig.Value["service"] = map[string]interface{}{ @@ -1380,7 +1380,7 @@ func negativeDeployClusterValidationTest( It( "WhenTLSExist: should fail for no tls path in storage volume", func() { - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 1, latestImage, ) aeroCluster.Spec.AerospikeConfig.Value["network"] = map[string]interface{}{ @@ -1399,7 +1399,7 @@ func negativeDeployClusterValidationTest( It( "WhenTLSExist: should fail for both ca-file and ca-path in tls", func() { - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 1, latestImage, ) aeroCluster.Spec.AerospikeConfig.Value["network"] = map[string]interface{}{ @@ -1421,7 +1421,7 @@ func negativeDeployClusterValidationTest( It( "WhenTLSExist: should fail for ca-file path pointing to Secret Manager", func() { - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 1, latestImage, ) aeroCluster.Spec.AerospikeConfig.Value["network"] = map[string]interface{}{ @@ -1442,7 +1442,7 @@ func negativeDeployClusterValidationTest( It( "WhenTLSExist: should fail for ca-path pointing to Secret Manager", func() { - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 1, latestImage, ) aeroCluster.Spec.AerospikeConfig.Value["network"] = map[string]interface{}{ @@ -1917,7 +1917,7 @@ func negativeUpdateClusterValidationTest( "InvalidAerospikeConfigSecret", func() { BeforeEach( func() { - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 2, latestImage, ) diff --git a/test/host_network_test.go b/test/host_network_test.go index fc21332c3..5c1b5315d 100644 --- a/test/host_network_test.go +++ b/test/host_network_test.go @@ -22,7 +22,7 @@ var _ = Describe( clusterNamespacedName := getNamespacedName( clusterName, namespace, ) - aeroCluster := createAerospikeClusterPost560( + aeroCluster := createAerospikeClusterPost640( clusterNamespacedName, 2, latestImage, ) aeroCluster.Spec.PodSpec.HostNetwork = true diff --git a/test/utils.go b/test/utils.go index 8d747973b..6046917f2 100644 --- a/test/utils.go +++ b/test/utils.go @@ -469,7 +469,8 @@ func NewAerospikeConfSpec(image string) (*AerospikeConfSpec, error) { "name": "test", "replication-factor": 1, "storage-engine": map[string]interface{}{ - "type": "memory", + "type": "memory", + "data-size": 1073741824, }, }, } @@ -563,20 +564,35 @@ func getAeroClusterConfig( return nil, err } - cmpVal, err := asconfig.CompareVersions(version, "5.7.0") + cmpVal1, err := asconfig.CompareVersions(version, "5.7.0") if err != nil { return nil, err } - if cmpVal >= 0 { + cmpVal2, err := asconfig.CompareVersions(version, "7.0.0") + if err != nil { + return nil, err + } + + switch { + case cmpVal2 >= 0: + return createAerospikeClusterPost640( + namespace, 2, image, + ), nil + + case cmpVal1 >= 0: return createAerospikeClusterPost560( namespace, 2, image, ), nil - } - return createAerospikeClusterPost460( - namespace, 2, image, - ), nil + case cmpVal1 < 0: + return createAerospikeClusterPost460( + namespace, 2, image, + ), nil + + default: + return nil, fmt.Errorf("invalid image version %s", version) + } } func getAerospikeStorageConfig( diff --git a/test/warm_restart_test.go b/test/warm_restart_test.go index 6322e314a..6f91a8268 100644 --- a/test/warm_restart_test.go +++ b/test/warm_restart_test.go @@ -54,9 +54,11 @@ func rollCluster(ctx goCtx.Context, image string, expectWarmStart bool) { clusterName := "warm-restart-cluster" clusterNamespacedName := getNamespacedName(clusterName, namespace) - aeroCluster := createAerospikeClusterPost560( - clusterNamespacedName, 2, image, + aeroCluster, err := getAeroClusterConfig( + clusterNamespacedName, image, ) + Expect(err).ToNot(HaveOccurred()) + // Add a volume of type empty dir to figure if pod restarted. aeroCluster.Spec.Storage.Volumes = append( aeroCluster.Spec.Storage.Volumes, asdbv1.VolumeSpec{ @@ -67,7 +69,7 @@ func rollCluster(ctx goCtx.Context, image string, expectWarmStart bool) { Aerospike: &asdbv1.AerospikeServerVolumeAttachment{Path: tempTestDir}, }, ) - err := deployCluster(k8sClient, ctx, aeroCluster) + err = deployCluster(k8sClient, ctx, aeroCluster) Expect(err).ToNot(HaveOccurred()) defer func(