diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index b088ba5ed7..998fb22b9f 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -187,7 +187,6 @@ jobs: "teams", "backup-config", "datafederation", - "deletion-protection", "atlas-search-nodes", "atlas-search-index", "cache-watch", diff --git a/scripts/int_local.sh b/scripts/int_local.sh index 1ba96acb6f..0511383b80 100755 --- a/scripts/int_local.sh +++ b/scripts/int_local.sh @@ -6,7 +6,12 @@ if [ -z "${label+x}" ]; then label="" fi +cluster_wide_labels=("ClusterWide") +int_test_folder=int +if [[ ${cluster_wide_labels[*]} =~ ${label} ]]; then + int_test_folder=int/clusterwide +fi public_key=$(grep "ATLAS_PUBLIC_KEY" .actrc | cut -d "=" -f 2) private_key=$(grep "ATLAS_PRIVATE_KEY" .actrc | cut -d "=" -f 2) org_id=$(grep "ATLAS_ORG_ID" .actrc | cut -d "=" -f 2) @@ -16,4 +21,4 @@ export MCLI_PUBLIC_API_KEY="${MCLI_PUBLIC_API_KEY:-$public_key}" export MCLI_PRIVATE_API_KEY="${MCLI_PRIVATE_API_KEY:-$private_key}" export MCLI_ORG_ID="${MCLI_ORG_ID:-$org_id}" -AKO_INT_TEST=1 ginkgo run --race --label-filter="${label}" --timeout 80m -v ./test/int ./test/int/clusterwide -coverprofile cover.out +AKO_INT_TEST=1 ginkgo run --race --label-filter="${label}" --timeout 80m -v ./test/${int_test_folder} -coverprofile cover.out diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index 75c875b314..6120403faa 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -47,6 +47,10 @@ var _ = BeforeSuite(func() { GinkgoWriter.Write([]byte("========================End of Before==============================\n")) }) +var _ = ReportAfterSuite("Ensure test suite was not empty", func(r Report) { + Expect(r.PreRunStats.SpecsThatWillRun > 0).To(BeTrue(), "Suite must run at least 1 test") +}) + // checkUpEnvironment initial check setup func checkUpEnvironment() { Expect(os.Getenv("MCLI_ORG_ID")).ShouldNot(BeEmpty(), "Please, setup MCLI_ORG_ID environment variable") diff --git a/test/e2e/helm_chart_test.go b/test/e2e/helm_chart_test.go index f06d154b3f..c9b960d05d 100644 --- a/test/e2e/helm_chart_test.go +++ b/test/e2e/helm_chart_test.go @@ -47,7 +47,7 @@ var _ = Describe("HELM charts", Ordered, func() { GinkgoWriter.Write([]byte("Operator namespace: " + data.Resources.Namespace + "\n")) GinkgoWriter.Write([]byte("===============================================\n")) if CurrentSpecReport().Failed() { - GinkgoWriter.Write([]byte("Resources wasn't clean")) + GinkgoWriter.Write([]byte("Resources wasn't clean\n")) namespaceDeployment, err := k8s.GetDeployment("mongodb-atlas-operator", data.Resources.Namespace) Expect(err).Should(BeNil()) namespaceDeploymentJSON, err := json.MarshalIndent(namespaceDeployment, "", " ") @@ -62,7 +62,7 @@ var _ = Describe("HELM charts", Ordered, func() { bytes, err := k8s.GetPodLogsByDeployment("mongodb-atlas-operator", config.DefaultOperatorNS, corev1.PodLogOptions{}) if err != nil { - GinkgoWriter.Write([]byte(err.Error())) + GinkgoWriter.Write([]byte(fmt.Sprintf("%v\n", err))) } utils.SaveToFile( fmt.Sprintf("output/%s/operator-logs-default.txt", data.Resources.Namespace), @@ -70,7 +70,7 @@ var _ = Describe("HELM charts", Ordered, func() { ) bytes, err = k8s.GetPodLogsByDeployment("mongodb-atlas-operator", data.Resources.Namespace, corev1.PodLogOptions{}) if err != nil { - GinkgoWriter.Write([]byte(err.Error())) + GinkgoWriter.Write([]byte(fmt.Sprintf("%v\n", err))) } utils.SaveToFile( fmt.Sprintf("output/%s/operator-logs.txt", data.Resources.Namespace), @@ -236,7 +236,7 @@ var _ = Describe("HELM charts", Ordered, func() { releaseMajorVersion := strings.Split(releasedVersion, ".")[0] if releaseMajorVersion != devMajorVersion { skipped = true - Skip(fmt.Sprintf("cannot test upgrade from incompatible major release version %s to version %s", + Skip(fmt.Sprintf("cannot test upgrade from incompatible major release version %q to version %q", releaseMajorVersion, devMajorVersion)) } }) diff --git a/test/helper/e2e/actions/steps.go b/test/helper/e2e/actions/steps.go index 703e5dd7fb..da2416eaa1 100644 --- a/test/helper/e2e/actions/steps.go +++ b/test/helper/e2e/actions/steps.go @@ -340,22 +340,40 @@ func CheckUsersCanUseApp(data *model.TestDataProvider) { func CheckUsersCanUseOldApp(data *model.TestDataProvider) { input := data.Resources for i, user := range data.Resources.Users { - // data - port := strconv.Itoa(i + data.PortGroup) - key := port - expectedData := fmt.Sprintf("{\"key\":\"%s\",\"shipmodel\":\"heavy\",\"hp\":150}", key) - - cli.Execute("kubectl", "delete", "pod", "-l", "app=test-app-"+user.Spec.Username, "-n", input.Namespace).Wait("2m") - WaitTestApplication(data, input.Namespace, "app", "test-app-"+user.Spec.Username) + By(fmt.Sprintf("Checking user %s (%d) can use old App", user.Spec.Username, i), func() { + // data + port := strconv.Itoa(i + data.PortGroup) + key := port + expectedData := fmt.Sprintf("{\"key\":\"%s\",\"shipmodel\":\"heavy\",\"hp\":150}", key) + + By("Deleting pod to force an app restart and wait for it", func() { + cli.Execute( + "kubectl", "delete", "pod", "-l", "app=test-app-"+user.Spec.Username, "-n", input.Namespace, + ).Wait("2m") + WaitTestApplication(data, input.Namespace, "app", "test-app-"+user.Spec.Username) + }) - app := appclient.NewTestAppClient(port) - ExpectWithOffset(1, app.Get("")).Should(Equal("It is working")) - ExpectWithOffset(1, app.Get("/mongo/"+key)).Should(Equal(expectedData)) + app := appclient.NewTestAppClient(port) + By("Test restarted App access", func() { + getRoot := app.Get("") + GinkgoWriter.Write([]byte(fmt.Sprintf("Test App GET: %q\n", getRoot))) + ExpectWithOffset(1, getRoot).Should(Equal("It is working")) + getKey := app.Get("/mongo/" + key) + GinkgoWriter.Write([]byte(fmt.Sprintf("Test App GET /mongo/%s: %q\n", key, getKey))) + ExpectWithOffset(1, getKey).Should(Equal(expectedData)) + }) - key = port + "up" - dataUpdated := fmt.Sprintf("{\"key\":\"%s\",\"shipmodel\":\"heavy\",\"hp\":150}", key) - ExpectWithOffset(1, app.Post(dataUpdated)).ShouldNot(HaveOccurred()) - ExpectWithOffset(1, app.Get("/mongo/"+key)).Should(Equal(dataUpdated)) + By("Test restarted App update", func() { + key = port + "up" + dataUpdated := fmt.Sprintf("{\"key\":\"%s\",\"shipmodel\":\"heavy\",\"hp\":150}", key) + err := app.Post(dataUpdated) + GinkgoWriter.Write([]byte(fmt.Sprintf("Test App POST %v: %v\n", dataUpdated, err))) + ExpectWithOffset(1, err).ShouldNot(HaveOccurred()) + getKey := app.Get("/mongo/" + key) + GinkgoWriter.Write([]byte(fmt.Sprintf("Test App GET /mongo/%s: %q\n", key, getKey))) + ExpectWithOffset(1, getKey).Should(Equal(dataUpdated)) + }) + }) } } diff --git a/test/helper/e2e/appclient/test_app_client.go b/test/helper/e2e/appclient/test_app_client.go index 617fb5f40a..93506dc6e6 100644 --- a/test/helper/e2e/appclient/test_app_client.go +++ b/test/helper/e2e/appclient/test_app_client.go @@ -34,7 +34,7 @@ func (app *App) Get(endpoint string) string { res, err := http.Get(app.uri + endpoint) if err != nil { fmt.Print(err) - return "" + return err.Error() } defer res.Body.Close() data, _ := io.ReadAll(res.Body) diff --git a/test/helper/e2e/cli/helm/helm.go b/test/helper/e2e/cli/helm/helm.go index 18516fc0df..5bc4fc7891 100644 --- a/test/helper/e2e/cli/helm/helm.go +++ b/test/helper/e2e/cli/helm/helm.go @@ -168,10 +168,18 @@ func InstallOperatorNamespacedSubmodule(input model.UserInputs) { func addPullSecret(installArgs []string, pullSecretPassword, namespace string) []string { registry := os.Getenv("IMAGE_PULL_SECRET_REGISTRY") pullSecretUsername := os.Getenv("IMAGE_PULL_SECRET_USERNAME") - secretName := fmt.Sprintf("ako-pull-secret-%s", registry) + secretName := pullSecretName(registry) createPullSecret(secretName, namespace, registry, pullSecretUsername, pullSecretPassword) + return appendPullSecretArg(installArgs, secretName) +} + +func pullSecretName(registry string) string { + return fmt.Sprintf("ako-pull-secret-%s", registry) +} + +func appendPullSecretArg(installArgs []string, pullSecretName string) []string { return append(installArgs, - "--set-string", fmt.Sprintf("imagePullSecrets[0].name=%s", secretName)) + "--set-string", fmt.Sprintf("imagePullSecrets[0].name=%s", pullSecretName)) } func createNamespace(namespace string) { @@ -234,17 +242,21 @@ func InstallDeploymentRelease(input model.UserInputs) { func UpgradeOperatorChart(input model.UserInputs) { repo, tag := splitDockerImage() packageChart(config.AtlasOperatorCRDHelmChartPath, filepath.Join(config.AtlasOperatorHelmChartPath, "charts")) - Upgrade( - "atlas-operator-"+input.Project.GetProjectName(), + upgradeArgs := []string{ + "atlas-operator-" + input.Project.GetProjectName(), config.AtlasOperatorHelmChartPath, "--set-string", fmt.Sprintf("atlasURI=%s", config.AtlasHost), "--set-string", fmt.Sprintf("image.repository=%s", repo), "--set-string", fmt.Sprintf("image.tag=%s", tag), "--set", "objectDeletionProtection=false", "--set", "subobjectDeletionProtection=false", + "--atomic", "-n", input.Namespace, // "--wait", "--timeout", "5m", // TODO helm upgrade do not exit - ) + } + registry := os.Getenv("IMAGE_PULL_SECRET_REGISTRY") + upgradeArgs = appendPullSecretArg(upgradeArgs, pullSecretName(registry)) + Upgrade(upgradeArgs...) } func UpgradeAtlasDeploymentChartDev(input model.UserInputs) { @@ -276,7 +288,7 @@ func GetDevelopmentMayorVersion() (string, error) { if err != nil { return "", err } - return string(majorVersion), nil + return strings.TrimSpace(string(majorVersion)), nil } func packageChart(sPath, dPath string) { diff --git a/test/int/clusterwide/integration_suite_test.go b/test/int/clusterwide/integration_suite_test.go index cf29217954..b3177ccee2 100644 --- a/test/int/clusterwide/integration_suite_test.go +++ b/test/int/clusterwide/integration_suite_test.go @@ -139,3 +139,7 @@ var _ = AfterSuite(func() { Expect(err).ToNot(HaveOccurred()) }) }) + +var _ = ReportAfterSuite("Ensure test suite was not empty", func(r Report) { + Expect(r.PreRunStats.SpecsThatWillRun > 0).To(BeTrue(), "Suite must run at least 1 test") +}) diff --git a/test/int/integration_suite_test.go b/test/int/integration_suite_test.go index fd8934e75b..2a09216cab 100644 --- a/test/int/integration_suite_test.go +++ b/test/int/integration_suite_test.go @@ -155,6 +155,10 @@ var _ = SynchronizedAfterSuite(func() {}, func() { }) }) +var _ = ReportAfterSuite("Ensure test suite was not empty", func(r Report) { + Expect(r.PreRunStats.SpecsThatWillRun > 0).To(BeTrue(), "Suite must run at least 1 test") +}) + func defaultTimeouts() { SetDefaultEventuallyTimeout(EventuallyTimeout) SetDefaultEventuallyPollingInterval(PollingInterval)