Skip to content

Conversation

@antonlisovenko
Copy link
Contributor

@antonlisovenko antonlisovenko commented Mar 25, 2021

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.

  • fixed the situation when the user specifies the providerSettings.regionName together with replicationSpecs. In this case Atlas accepts the update request but erazes the former field so the infinite reconciliation happens as ClustersEqual method constantly returns false.
  • added more checks to the integration test to check all the fields
  • more unit tests to make sure the MergedCluster and ClustersEqual work correctly
  • increased the timeout for project create/update as 20 seconds is not enough often

@antonlisovenko antonlisovenko changed the title CLOUDP-83733: more tests on clusters CLOUDP-83733: more tests on clusters (create only) Mar 26, 2021
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)
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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)
Copy link
Contributor Author

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

@antonlisovenko antonlisovenko marked this pull request as ready for review March 26, 2021 19:07
@antonlisovenko antonlisovenko merged commit 1389eb8 into main Mar 29, 2021
@antonlisovenko antonlisovenko deleted the CLOUDP-83733_more-tests-cluster branch March 29, 2021 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants