Skip to content

Commit

Permalink
CLOUDP-286483: Fixed helm-update test (#1945)
Browse files Browse the repository at this point in the history
* Fixed helm-update test

* Fix for AtlasDeployment int test

Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>

* Fix contract tests check

---------

Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
Co-authored-by: jose.vazquez <jose.vazquez@mongodb.com>
  • Loading branch information
igor-karpukhin and josvazg authored Nov 26, 2024
1 parent 7b11f53 commit 2424c47
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
4 changes: 2 additions & 2 deletions test/contract/networkpeering/networkpeering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestPeerContainerServiceCRUD(t *testing.T) {
containers, err := cs.ListContainers(ctx, testProjectID, tc.container.Provider)
require.NoError(t, err)
assert.NotEmpty(t, containers)
assert.Len(t, containers, 1)
assert.GreaterOrEqual(t, len(containers), 1)
})

t.Run(fmt.Sprintf("get %s container", tc.provider), func(t *testing.T) {
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestPeerServiceCRUD(t *testing.T) {
containers, err := ps.ListPeers(ctx, testProjectID)
require.NoError(t, err)
assert.NotEmpty(t, containers)
assert.Len(t, containers, 1)
assert.GreaterOrEqual(t, len(containers), 1)
})

t.Run(fmt.Sprintf("delete %s peer connection", tc.provider), func(t *testing.T) {
Expand Down
17 changes: 17 additions & 0 deletions test/helper/e2e/actions/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,23 @@ func CheckUsersCanUseOldApp(data *model.TestDataProvider) {
WaitTestApplication(data, input.Namespace, "app", "test-app-"+user.Spec.Username)
})

By(fmt.Sprintf("Verifying if a user (%s) is READY", user.Spec.Username), func() {
Eventually(func(g Gomega) {
dbu := &akov2.AtlasDatabaseUser{}
g.Expect(data.K8SClient.Get(data.Context, client.ObjectKey{
Name: fmt.Sprintf("%s-%s", data.Resources.Deployments[0].Spec.GetDeploymentName(), user.Spec.Username),
Namespace: data.Resources.Namespace},
dbu,
)).To(Succeed())
g.Expect(dbu.Status.Conditions).ShouldNot(BeEmpty())
for _, condition := range dbu.Status.Conditions {
if condition.Type == api.ReadyType {
g.Expect(condition.Status).Should(Equal(corev1.ConditionTrue), "User should be ready")
}
}
}).WithTimeout(5 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
})

app := appclient.NewTestAppClient(port)
By("Test restarted App access", func() {
getRoot := app.Get("")
Expand Down
21 changes: 11 additions & 10 deletions test/int/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ var _ = Describe("AtlasDeployment", Label("int", "AtlasDeployment", "deployment-
Describe("Deployment with Termination Protection should remain in Atlas after the CR is deleted", Label("dedicated-termination-protection", "slow"), func() {
It("Should succeed", func() {
createdDeployment = akov2.DefaultAWSDeployment(namespace.Name, createdProject.Name)
deploymentName := createdDeployment.GetDeploymentName()

By(fmt.Sprintf("Creating the Deployment %s", kube.ObjectKeyFromObject(createdDeployment)), func() {
createdDeployment.Spec.DeploymentSpec.TerminationProtectionEnabled = true
Expand All @@ -215,21 +216,21 @@ var _ = Describe("AtlasDeployment", Label("int", "AtlasDeployment", "deployment-
ctx, cancelF := context.WithTimeout(context.Background(), 20*time.Second)
defer cancelF()
aCluster, _, err := atlasClient.ClustersApi.GetCluster(ctx, createdProject.ID(),
createdDeployment.GetDeploymentName()).Execute()
deploymentName).Execute()
g.Expect(err).NotTo(HaveOccurred())
Expect(aCluster.GetName()).Should(BeEquivalentTo(createdDeployment.GetDeploymentName()))
Expect(aCluster.GetName()).Should(BeEquivalentTo(deploymentName))
}).WithTimeout(30 * time.Second).WithPolling(5 * time.Second)
})

By("Disabling Termination protection", func() {
ctx, cancelF := context.WithTimeout(context.Background(), 20*time.Second)
defer cancelF()
aCluster, _, err := atlasClient.ClustersApi.GetCluster(ctx, createdProject.ID(),
createdDeployment.GetDeploymentName()).Execute()
deploymentName).Execute()
Expect(err).NotTo(HaveOccurred())
aCluster.TerminationProtectionEnabled = pointer.MakePtr(false)
aCluster.ConnectionStrings = nil
_, _, err = atlasClient.ClustersApi.UpdateCluster(ctx, createdProject.ID(), createdDeployment.GetDeploymentName(), aCluster).Execute()
_, _, err = atlasClient.ClustersApi.UpdateCluster(ctx, createdProject.ID(), deploymentName, aCluster).Execute()
Expect(err).NotTo(HaveOccurred())
})

Expand All @@ -238,18 +239,18 @@ var _ = Describe("AtlasDeployment", Label("int", "AtlasDeployment", "deployment-
ctx, cancelF := context.WithTimeout(context.Background(), 20*time.Second)
defer cancelF()
aCluster, _, err := atlasClient.ClustersApi.GetCluster(ctx, createdProject.ID(),
createdDeployment.GetDeploymentName()).Execute()
deploymentName).Execute()
g.Expect(err).NotTo(HaveOccurred())
g.Expect(aCluster.TerminationProtectionEnabled).NotTo(BeNil())
g.Expect(*aCluster.TerminationProtectionEnabled).To(BeFalse())
}).WithTimeout(2 * time.Minute).WithPolling(10 * time.Second)
}).WithTimeout(2 * time.Minute).WithPolling(10 * time.Second).Should(Succeed())
})

By("Manually deleting the cluster", func() {
ctx, cancelF := context.WithTimeout(context.Background(), 20*time.Second)
defer cancelF()
_, err := atlasClient.ClustersApi.DeleteCluster(ctx, createdProject.ID(),
createdDeployment.GetDeploymentName()).Execute()
deploymentName).Execute()
Expect(err).NotTo(HaveOccurred())
createdDeployment = nil
})
Expand All @@ -259,9 +260,9 @@ var _ = Describe("AtlasDeployment", Label("int", "AtlasDeployment", "deployment-
ctx, cancelF := context.WithTimeout(context.Background(), 20*time.Second)
defer cancelF()
_, resp, _ := atlasClient.ClustersApi.GetCluster(ctx, createdProject.ID(),
createdDeployment.GetDeploymentName()).Execute()
g.Expect(resp.Status).To(Equal(http.StatusNotFound))
}).WithTimeout(10 * time.Minute).WithPolling(20 * time.Second)
deploymentName).Execute()
g.Expect(resp.StatusCode).To(Equal(http.StatusNotFound))
}).WithTimeout(10 * time.Minute).WithPolling(20 * time.Second).Should(Succeed())
})
})
})
Expand Down

0 comments on commit 2424c47

Please sign in to comment.