Skip to content

Conversation

@leo-ri
Copy link
Contributor

@leo-ri leo-ri commented Feb 3, 2021

part 1: base test
flaky parts:
a) project creating (probably fixed)
b) sometimes 35min is not enough for updating cluster (at least in qa environment, increased to 50 min(?))

what is not ready:
configurations table

Copy link
Contributor

@antonlisovenko antonlisovenko left a comment

Choose a reason for hiding this comment

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

Great work! 🥇 The main suggestion is around the test logic (check for the resource status.Ready) field.

We can discuss the cluster configuration part with the team later!


prepare-e2e:
name: Prepare E2E configuration and image
needs: [unit-test, int-test]
Copy link
Contributor

Choose a reason for hiding this comment

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

can we please remove these and just run the test in parallel with the others?

Copy link
Contributor

Choose a reason for hiding this comment

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

agree with int-test as they take 20 min. I think it makes sense to wait for unit-test as it take a min, but will avoid an unnecessary run of e2e in case of error.

id: prepare
uses: ./.github/actions/set-tag

- name: Push Atlas Operator to Registry
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems, that if we push the dev image here - there's no need in the "Publish image to Registry" workflow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed push trigger from build image workflow, but I would like to leave this workflow for a while until I am sure that e2e are stable

# run if platform = kind #TODO
- name: Create k8s Kind Cluster
if: ${{ steps.properties.outputs.k8s_platform == 'kind' && !env.ACT }}
uses: helm/kind-action@v1.1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

good to know there is an action for Kind already!

RunSpecs(t, "E2e Suite")
}

var _ = SynchronizedBeforeSuite(func() []byte {
Copy link
Contributor

Choose a reason for hiding this comment

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

[q] why do we need the SynchronizedBeforeSuite instead of the BeforeSuite?

Copy link
Contributor Author

@leo-ri leo-ri Feb 5, 2021

Choose a reason for hiding this comment

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

this check run once instead of each time
UPD. move checks to beforeSuite


By("Wait creating and check that it was created")
Eventually(cli.GetGeneration(namespaceUserResources)).Should(Equal("1"))
Eventually(
Copy link
Contributor

Choose a reason for hiding this comment

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

after the Project is ready - then the Atlas is expected to have (not eventually) the project created

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use exec command inside , eventually here means : this command eventually finish with exit 0 (there is a wait() inside) . probably need to discuss

"7m", "10s",
).Should(BeTrue())

projectID := cli.GetProjectID(userProjectConfig.Spec.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend to get the project id from the AtlasProject.status.id instead of the mongocli. This will make sure that the Operator writes the correct id to the status

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm... it probably could fix this:
a) project creating

GinkgoWriter.Write([]byte("projectID = " + projectID))

Eventually(
cli.IsClusterExist(projectID, userClusterConfig.Spec.Name),
Copy link
Contributor

Choose a reason for hiding this comment

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

the same as above: I'd recommend to check for the "status.conditions.Ready=true" instead of checking Atlas. This will make sure the status is updated correctly.

Basically the logic should be: wait for the AtlasCluster to get Ready:true, then make the request to Atlas to check if the cluster created there matches the one that we have just created

}

// GetPodStatus TODO move
func GetPodStatus(ns string) func() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about splitting the helper functions for mongocli and kubectl to separate packages? Then we'd import them with the appropriate names and it would be clear from the calling code what is happening under the hood

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that s why I added "TODO move" )


By("Wait creation")
userClusterConfig = cli.LoadUserClusterConfig("data/updated_atlascluster_basic.yaml")
Eventually(cli.GetGeneration(namespaceUserResources)).Should(Equal("2"))
Copy link
Contributor

Choose a reason for hiding this comment

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

The same as for the create logic the update the code should wait for two things:

  1. the observed generation is equal to the generation field (it's ok to check for "2" directly as well)
  2. the "status.conditions.Ready : true"

Copy link
Contributor

@antonlisovenko antonlisovenko left a comment

Choose a reason for hiding this comment

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

Reviewed p2p

Eventually(
cli.IsProjectExist(userProjectConfig.Spec.Name),
"7m", "10s",
).Should(BeTrue())
Copy link
Contributor

Choose a reason for hiding this comment

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

as discussed p2p: eventually is not necessary - also we don't need to find by name - try using the 'status.ID` from from the AtlasProject

and cosmetic changes to GetStatus

"7m", "10s",
).Should(BeTrue())

projectID := cli.GetProjectID(userProjectConfig.Spec.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

not necessary - use status.ID

}
}

func GetClusterStatus(projectID string, clusterName string) func() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] rename to StateName?


projectID := cli.GetProjectID(userProjectConfig.Spec.Name)
GinkgoWriter.Write([]byte("projectID = " + projectID))
Eventually(
Copy link
Contributor

Choose a reason for hiding this comment

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

add the wait for AtlasCluster k8s resource ready

"5m", "1s",
).Should(BeTrue())

Eventually(
Copy link
Contributor

Choose a reason for hiding this comment

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

the same as for the project: after the AtlasCluster is ready in K8s - there is no need in eventually - we can just read the Cluster from Atlas directly and use Expect.. equal

session = cli.Execute("kubectl", "apply", "-f", ClusterSampleFile, "-n", namespaceUserResources) // TODO param
Eventually(session.Wait()).Should(Say("atlascluster-sample configured"))

By("Wait creation")
Copy link
Contributor

Choose a reason for hiding this comment

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

the same as for create

@leo-ri leo-ri requested a review from antonlisovenko February 9, 2021 09:22
Copy link
Contributor

@antonlisovenko antonlisovenko left a comment

Choose a reason for hiding this comment

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

Just a couple of nits - mostly around namings and code formatting. I believe after committing there will be no need in waiting for the tests.

Great work! 🥇

MCLI_PRIVATE_API_KEY: ${{ secrets.ATLAS_PRIVATE_KEY }}
MCLI_ORG_ID: ${{ secrets.ATLAS_ORG_ID}}
MCLI_OPS_MANAGER_URL: "https://cloud-qa.mongodb.com/"
K8s_PLATFORM: "${{ steps.properties.outputs.k8s_platform }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] K8S_PLATFORM and K8S_VERSION (uppercase)

})

It("Release sample all-in-one.yaml should work", func() {
By("Prepare namespaces and project configuration") // TODO clusters/keys will be a bit later
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] still think that considering the size of the test having By with callbacks (By("", func() {..})) will make the code more readable, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the thing is idk which steps will be final, this test - is the initial version, steps will be reformatted later for all tests need

Eventually(session.Wait()).Should(Say("created"))

By("Wait project creation")
Eventually(cli.GetStatus(namespaceUserResources, "atlasproject.atlas.mongodb.com/"+k8sProjectName)).Should(Equal("True"))
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] rename to GetStatusCondition

@leo-ri leo-ri merged commit 33c0748 into main Feb 10, 2021
@leo-ri leo-ri deleted the CLOUDP-80268-e2e branch February 10, 2021 13:53
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.

4 participants