-
Notifications
You must be signed in to change notification settings - Fork 106
CLOUDP-83733: more tests on clusters (create only) #185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| func (r *AtlasClusterReconciler) ensureClusterState(ctx *workflow.Context, project *mdbv1.AtlasProject, cluster *mdbv1.AtlasCluster) (c *mongodbatlas.Cluster, _ workflow.Result) { | ||
| c, resp, err := ctx.Client.Clusters.Get(context.Background(), project.Status.ID, cluster.Spec.Name) | ||
| func (r *AtlasClusterReconciler) ensureClusterState(ctx *workflow.Context, project *mdbv1.AtlasProject, cluster *mdbv1.AtlasCluster) (atlasCluster *mongodbatlas.Cluster, _ workflow.Result) { | ||
| atlasCluster, resp, err := ctx.Client.Clusters.Get(context.Background(), project.Status.ID, cluster.Spec.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did some renamings of variables as it was a bit hard to follow which cluster is from Atlas and which - from the Operator later when we did merging magic
| func mergedCluster(cluster mongodbatlas.Cluster, spec mdbv1.AtlasClusterSpec) (result mongodbatlas.Cluster, err error) { | ||
| if err = compat.JSONCopy(&result, cluster); err != nil { | ||
| // MergedCluster will return the result of merging AtlasClusterSpec with Atlas Cluster | ||
| func MergedCluster(atlasCluster mongodbatlas.Cluster, spec mdbv1.AtlasClusterSpec) (result mongodbatlas.Cluster, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made public to use inside integration tests
| Expect(err).ToNot(HaveOccurred()) | ||
|
|
||
| createdAtlasCluster, err := createdCluster.Spec.Cluster() | ||
| mergedCluster, err := atlascluster.MergedCluster(*atlasCluster, createdCluster.Spec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the MergedCluster to compare clusters in total.
This could be error-prone in case if MergedCluster has bugs in it - that's why the unit tests above were extended
This PR focuses on more complicated testing of the clusters. Due to the size only the creation is happening - the update will be addressed in the next PR (found some issues there).
The changes were reviewed and agreed on with Pavel p2p.
providerSettings.regionNametogether withreplicationSpecs. In this case Atlas accepts the update request but erazes the former field so the infinite reconciliation happens asClustersEqualmethod constantly returns false.MergedClusterandClustersEqualwork correctly