Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
8de2ac4
Update mongodbatlas library & corresponding specs
vasilevp Jan 29, 2021
625446c
Add more test cases
vasilevp Jan 29, 2021
47b7b41
Reorganize tests
vasilevp Jan 29, 2021
210db05
Merge remote-tracking branch 'origin/main' into CLOUDP-81076
vasilevp Feb 1, 2021
0918c4a
Fix disk size condition
vasilevp Feb 1, 2021
657ab6f
Remove disk size increase test (takes too long)
vasilevp Feb 1, 2021
1cb4f91
Merge remote-tracking branch 'origin/main' into CLOUDP-81076
vasilevp Feb 1, 2021
e868edc
PR comments
vasilevp Feb 3, 2021
5b15641
Merge branch 'CLOUDP-81076' of github.com:mongodb/mongodb-atlas-kuber…
vasilevp Feb 3, 2021
45894cf
Merge remote-tracking branch 'origin/main' into CLOUDP-81076
vasilevp Feb 3, 2021
e416aaa
Fixes after merge
vasilevp Feb 3, 2021
ba5f2ba
Small fixes
vasilevp Feb 3, 2021
4cdeb41
Small fixes
vasilevp Feb 3, 2021
94234a4
Merge branch 'CLOUDP-81076' of github.com:mongodb/mongodb-atlas-kuber…
vasilevp Feb 3, 2021
a6ba48f
Make atlas tests generic & reusable
vasilevp Feb 3, 2021
9438080
Merge remote-tracking branch 'origin/main' into CLOUDP-81143-cluster-…
vasilevp Feb 4, 2021
42df9c4
Initial test impl
vasilevp Feb 5, 2021
78cb6db
Add special case for Paused
vasilevp Feb 5, 2021
f432351
Run make generate manifests
vasilevp Feb 5, 2021
286f2f0
Fix matched condition in Pause
vasilevp Feb 5, 2021
a097a09
Fix matched condition for unpause
vasilevp Feb 5, 2021
51d2ec9
Fix typo
vasilevp Feb 5, 2021
6755c28
Add int tests for cluster (un)pause
vasilevp Feb 8, 2021
3b00aab
Support "REPAIRING" state (for pause)
vasilevp Feb 8, 2021
3cd01f8
Add tests between pause/unpause
vasilevp Feb 9, 2021
5686ceb
Fix lastGeneration in tests
vasilevp Feb 9, 2021
ba12fab
Reduce project remove timeout
vasilevp Feb 9, 2021
8f88f60
Merge remote-tracking branch 'origin/main' into CLOUDP-80765-cluster-…
vasilevp Feb 9, 2021
6f60768
Add common checks to post-pause
vasilevp Feb 9, 2021
0c1d6d2
Fix atlas cluster unit test
vasilevp Feb 9, 2021
6146120
Rework tests
vasilevp Feb 9, 2021
f3bf39c
Starting lastGeneration should be 0
vasilevp Feb 10, 2021
fa78e81
Merge remote-tracking branch 'origin/main' into CLOUDP-80765-cluster-…
vasilevp Feb 10, 2021
493d645
Merge remote-tracking branch 'origin/main' into CLOUDP-81143-cluster-…
vasilevp Feb 10, 2021
3c7052f
Merge branch 'CLOUDP-80765-cluster-pause' into CLOUDP-81143-cluster-t…
vasilevp Feb 10, 2021
d0a6cdf
Add more fail tests
vasilevp Feb 10, 2021
110483f
More lastGeneration stuff
vasilevp Feb 10, 2021
643c0c3
Merge branch 'CLOUDP-80765-cluster-pause' into CLOUDP-81143-cluster-t…
vasilevp Feb 10, 2021
745e31f
Remove unused func
vasilevp Feb 10, 2021
f09e5b9
Merge remote-tracking branch 'origin/main' into CLOUDP-81143-cluster-…
vasilevp Feb 10, 2021
aaea167
Add ClusterNotUpdatedInAtlas; stub WithMessageRegexp
vasilevp Feb 10, 2021
bb998f0
Fix
vasilevp Feb 10, 2021
5f06c4c
Add a test for create failure
vasilevp Feb 10, 2021
39bcdc0
Remove rename test
vasilevp Feb 10, 2021
ebb2e76
Fix WithMessageRegexp
vasilevp Feb 10, 2021
c7da935
Change message regexp
vasilevp Feb 11, 2021
ff2744e
Rework create failure case
vasilevp Feb 11, 2021
da59546
Merge remote-tracking branch 'origin/main' into CLOUDP-81143-cluster-…
vasilevp Feb 11, 2021
43bd6bd
Revert timeout
vasilevp Feb 11, 2021
dc84a40
Fix reason for invalid name
vasilevp Feb 11, 2021
e09e1c2
Fix invalid cluster used for update
vasilevp Feb 11, 2021
f10e557
Fix conditions
vasilevp Feb 11, 2021
421479b
Try to fix generation?
vasilevp Feb 11, 2021
7d98c08
Unfocus tests
vasilevp Feb 11, 2021
63c1603
Add comment for create failed test
vasilevp Feb 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions config/crd/bases/atlas.mongodb.com_atlasprojects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ spec:
this field is updated by the Atlas Operator only after specification
changes
items:
description: TODO solve circular dependency (move ProjectIPAccessList
to subpackage?) Copy of mdbv1.ProjectIPAccessList
description: ProjectIPAccessList is a copy of mdbv1.ProjectIPAccessList
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

properties:
awsSecurityGroup:
description: Unique identifier of AWS security group in this
Expand Down
7 changes: 3 additions & 4 deletions pkg/controller/atlascluster/atlascluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ import (
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/source"

"github.com/mongodb/mongodb-atlas-kubernetes/pkg/controller/watch"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/controller/workflow"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/util/kube"

mdbv1 "github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/v1"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/api/v1/status"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/controller/atlas"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/controller/customresource"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/controller/statushandler"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/controller/watch"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/controller/workflow"
"github.com/mongodb/mongodb-atlas-kubernetes/pkg/util/kube"
)

// AtlasClusterReconciler reconciles an AtlasCluster object
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/atlascluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (r *AtlasClusterReconciler) ensureClusterState(log *zap.SugaredLogger, conn

c, _, err = client.Clusters.Update(ctx, project.Status.ID, cluster.Spec.Name, spec)
if err != nil {
return c, workflow.Terminate(workflow.ClusterNotCreatedInAtlas, err.Error())
return c, workflow.Terminate(workflow.ClusterNotUpdatedInAtlas, err.Error())
}

return c, workflow.InProgress(workflow.ClusterUpdating, "cluster is updating")
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/workflow/reason.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
// Atlas Cluster reasons
const (
ClusterNotCreatedInAtlas ConditionReason = "ClusterNotCreatedInAtlas"
ClusterNotUpdatedInAtlas ConditionReason = "ClusterNotUpdatedInAtlas"
ClusterCreating ConditionReason = "ClusterCreating"
ClusterUpdating ConditionReason = "ClusterUpdating"
)
1 change: 0 additions & 1 deletion pkg/util/testutil/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func (m *conditionMatcher) Match(actual interface{}) (success bool, err error) {
if m.ExpectedCondition.Type != "" && c.Type != m.ExpectedCondition.Type {
return false, nil
}
// Add regexp when necessary
if m.ExpectedCondition.Message != "" {
gomega.Expect(c.Message).To(gomega.MatchRegexp(m.ExpectedCondition.Message))
}
Expand Down
105 changes: 104 additions & 1 deletion test/int/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,43 @@ var _ = Describe("AtlasCluster", func() {
}

Describe("Create/Update the cluster", func() {
It("Should fail, then be fixed", func() {
expectedCluster := testAtlasCluster(namespace.Name, "test-cluster", createdProject.Name)
expectedCluster.Spec.Name = ""

By(fmt.Sprintf("Creating the Cluster %s with invalid parameters", kube.ObjectKeyFromObject(expectedCluster)), func() {
createdCluster.ObjectMeta = expectedCluster.ObjectMeta
Expect(k8sClient.Create(context.Background(), expectedCluster)).ToNot(HaveOccurred())

Eventually(
testutil.WaitFor(
k8sClient,
createdCluster,
status.
FalseCondition(status.ClusterReadyType).
WithReason(string(workflow.Internal)). // Internal due to reconciliation failing on the initial GET request
WithMessageRegexp("name is invalid because must be set"),
),
60,
interval,
).Should(BeTrue())

lastGeneration++
})

By("Fixing the cluster", func() {
createdCluster.Spec.Name = "fixed-cluster"

Expect(k8sClient.Update(context.Background(), createdCluster)).To(Succeed())

Eventually(testutil.WaitFor(k8sClient, createdCluster, status.TrueCondition(status.ReadyType), validateClusterCreatingFunc()),
1200, interval).Should(BeTrue())

doCommonChecks()
checkAtlasState()
})
})

It("Should Succeed", func() {
expectedCluster := testAtlasCluster(namespace.Name, "test-cluster", createdProject.Name)

Expand Down Expand Up @@ -180,7 +217,14 @@ var _ = Describe("AtlasCluster", func() {

Expect(k8sClient.Update(context.Background(), createdCluster)).To(Succeed())
Eventually(
testutil.WaitFor(k8sClient, createdCluster, status.FalseCondition(status.ClusterReadyType).WithReason(string(workflow.ClusterNotCreatedInAtlas))),
testutil.WaitFor(
k8sClient,
createdCluster,
status.
FalseCondition(status.ClusterReadyType).
WithReason(string(workflow.ClusterNotUpdatedInAtlas)).
WithMessageRegexp("CANNOT_UPDATE_PAUSED_CLUSTER"),
),
60,
interval,
).Should(BeTrue())
Expand All @@ -203,6 +247,65 @@ var _ = Describe("AtlasCluster", func() {
Expect(c.ProviderBackupEnabled).To(Equal(createdCluster.Spec.ProviderBackupEnabled))
})
})

By("Setting AutoScaling.Compute.Enabled to false (should fail)", func() {
createdCluster.Spec.ProviderSettings.AutoScaling = &mdbv1.AutoScalingSpec{
Compute: &mdbv1.ComputeSpec{
Enabled: boolptr(false),
},
}

Expect(k8sClient.Update(context.Background(), createdCluster)).To(Succeed())
Eventually(
testutil.WaitFor(
k8sClient,
createdCluster,
status.
FalseCondition(status.ClusterReadyType).
WithReason(string(workflow.ClusterNotUpdatedInAtlas)).
WithMessageRegexp("INVALID_ATTRIBUTE"),
),
60,
interval,
).Should(BeTrue())

lastGeneration++

By("Fixing the Cluster", func() {
createdCluster.Spec.ProviderSettings.AutoScaling = nil
performUpdate()
doCommonChecks()
checkAtlasState()
})
})

By("Setting incorrect instance size (should fail)", func() {
oldSizeName := createdCluster.Spec.ProviderSettings.InstanceSizeName
createdCluster.Spec.ProviderSettings.InstanceSizeName = "M42"

Expect(k8sClient.Update(context.Background(), createdCluster)).To(Succeed())
Eventually(
testutil.WaitFor(
k8sClient,
createdCluster,
status.
FalseCondition(status.ClusterReadyType).
WithReason(string(workflow.ClusterNotUpdatedInAtlas)).
WithMessageRegexp("INVALID_ENUM_VALUE"),
),
60,
interval,
).Should(BeTrue())

lastGeneration++

By("Fixing the Cluster", func() {
createdCluster.Spec.ProviderSettings.InstanceSizeName = oldSizeName
performUpdate()
doCommonChecks()
checkAtlasState()
})
})
})
})
})
Expand Down