From 6d5a4b7609287b3e2d262eaefe74ac4f1ff5b860 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Mon, 23 Jun 2025 17:37:58 +0200 Subject: [PATCH 1/2] add all-in-one e2e test --- test/e2e2/all_in_one_test.go | 50 +++++++++++++++++++++++++++++++++++ test/helper/e2e2/kube/kube.go | 2 ++ 2 files changed, 52 insertions(+) create mode 100644 test/e2e2/all_in_one_test.go diff --git a/test/e2e2/all_in_one_test.go b/test/e2e2/all_in_one_test.go new file mode 100644 index 0000000000..3119b230f9 --- /dev/null +++ b/test/e2e2/all_in_one_test.go @@ -0,0 +1,50 @@ +package e2e2_test + +import ( + "context" + "time" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper/e2e/cli" + "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper/e2e2/kube" +) + +var _ = Describe("all-in-one.yaml", Ordered, Label("all-in-one"), func() { + var kubeClient client.Client + + _ = BeforeAll(func() { + ctx := context.Background() + c, err := kube.NewK8sTest(ctx) + kubeClient = c + Expect(err).To(Succeed()) + }) + + It("applies all-in-one.yaml", func() { + Expect(cli.Execute("kubectl", "apply", "-f", "../../deploy/all-in-one.yaml").Wait().ExitCode()).Should(Equal(0)) + }) + + It("waits for mongodb-atlas-operator deployment to be Ready", func() { + Eventually(func(g Gomega, ctx context.Context) { + var deployment appsv1.Deployment + err := kubeClient.Get(ctx, client.ObjectKey{ + Namespace: "mongodb-atlas-system", + Name: "mongodb-atlas-operator", + }, &deployment) + g.Expect(err).ToNot(HaveOccurred()) + + var ready bool + for _, cond := range deployment.Status.Conditions { + if cond.Type == appsv1.DeploymentAvailable && cond.Status == corev1.ConditionTrue { + ready = true + break + } + } + g.Expect(ready).To(BeTrue(), "deployment is not Ready") + }).WithContext(context.Background()).WithPolling(time.Second).WithTimeout(time.Minute).Should(Succeed()) + }) +}) diff --git a/test/helper/e2e2/kube/kube.go b/test/helper/e2e2/kube/kube.go index f944a719cf..454eaf86d9 100644 --- a/test/helper/e2e2/kube/kube.go +++ b/test/helper/e2e2/kube/kube.go @@ -19,6 +19,7 @@ import ( "fmt" "time" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -65,6 +66,7 @@ func TestKubeClient() (client.Client, error) { utilruntime.Must(corev1.AddToScheme(testScheme)) utilruntime.Must(apiextensionsv1.AddToScheme(testScheme)) utilruntime.Must(akov2.AddToScheme(testScheme)) + utilruntime.Must(appsv1.AddToScheme(testScheme)) return getKubeClient(testScheme) } From 784c2e589b43e3b4ece69754b91ed9d8544a1797 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Mon, 23 Jun 2025 17:44:41 +0200 Subject: [PATCH 2/2] add header --- test/e2e2/all_in_one_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/e2e2/all_in_one_test.go b/test/e2e2/all_in_one_test.go index 3119b230f9..69374ad740 100644 --- a/test/e2e2/all_in_one_test.go +++ b/test/e2e2/all_in_one_test.go @@ -1,3 +1,17 @@ +// Copyright 2025 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package e2e2_test import ( @@ -45,6 +59,6 @@ var _ = Describe("all-in-one.yaml", Ordered, Label("all-in-one"), func() { } } g.Expect(ready).To(BeTrue(), "deployment is not Ready") - }).WithContext(context.Background()).WithPolling(time.Second).WithTimeout(time.Minute).Should(Succeed()) + }).WithContext(context.Background()).WithPolling(time.Second).WithTimeout(5 * time.Minute).Should(Succeed()) }) })