-
Notifications
You must be signed in to change notification settings - Fork 106
Cloudp-80268 e2e initial #84
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
antonlisovenko
left a comment
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.
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!
.github/workflows/test.yml
Outdated
|
|
||
| prepare-e2e: | ||
| name: Prepare E2E configuration and image | ||
| needs: [unit-test, int-test] |
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.
can we please remove these and just run the test in parallel with the others?
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.
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 |
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.
It seems, that if we push the dev image here - there's no need in the "Publish image to Registry" workflow?
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.
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 |
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.
good to know there is an action for Kind already!
test/e2e/e2e_suite_test.go
Outdated
| RunSpecs(t, "E2e Suite") | ||
| } | ||
|
|
||
| var _ = SynchronizedBeforeSuite(func() []byte { |
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.
[q] why do we need the SynchronizedBeforeSuite instead of the BeforeSuite?
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.
this check run once instead of each time
UPD. move checks to beforeSuite
test/e2e/deploy_test.go
Outdated
|
|
||
| By("Wait creating and check that it was created") | ||
| Eventually(cli.GetGeneration(namespaceUserResources)).Should(Equal("1")) | ||
| Eventually( |
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.
after the Project is ready - then the Atlas is expected to have (not eventually) the project created
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.
I use exec command inside , eventually here means : this command eventually finish with exit 0 (there is a wait() inside) . probably need to discuss
test/e2e/deploy_test.go
Outdated
| "7m", "10s", | ||
| ).Should(BeTrue()) | ||
|
|
||
| projectID := cli.GetProjectID(userProjectConfig.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.
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
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.
hm... it probably could fix this:
a) project creating
test/e2e/deploy_test.go
Outdated
| GinkgoWriter.Write([]byte("projectID = " + projectID)) | ||
|
|
||
| Eventually( | ||
| cli.IsClusterExist(projectID, userClusterConfig.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.
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
test/e2e/utils/cli.go
Outdated
| } | ||
|
|
||
| // GetPodStatus TODO move | ||
| func GetPodStatus(ns string) func() string { |
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.
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
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.
that s why I added "TODO move" )
test/e2e/deploy_test.go
Outdated
|
|
||
| By("Wait creation") | ||
| userClusterConfig = cli.LoadUserClusterConfig("data/updated_atlascluster_basic.yaml") | ||
| Eventually(cli.GetGeneration(namespaceUserResources)).Should(Equal("2")) |
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.
The same as for the create logic the update the code should wait for two things:
- the observed generation is equal to the generation field (it's ok to check for "2" directly as well)
- the "status.conditions.Ready : true"
antonlisovenko
left a comment
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.
Reviewed p2p
| Eventually( | ||
| cli.IsProjectExist(userProjectConfig.Spec.Name), | ||
| "7m", "10s", | ||
| ).Should(BeTrue()) |
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.
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
test/e2e/configuration_test.go
Outdated
| "7m", "10s", | ||
| ).Should(BeTrue()) | ||
|
|
||
| projectID := cli.GetProjectID(userProjectConfig.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.
not necessary - use status.ID
test/e2e/utils/mongocli.go
Outdated
| } | ||
| } | ||
|
|
||
| func GetClusterStatus(projectID string, clusterName string) func() string { |
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.
[nit] rename to StateName?
test/e2e/configuration_test.go
Outdated
|
|
||
| projectID := cli.GetProjectID(userProjectConfig.Spec.Name) | ||
| GinkgoWriter.Write([]byte("projectID = " + projectID)) | ||
| Eventually( |
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.
add the wait for AtlasCluster k8s resource ready
test/e2e/configuration_test.go
Outdated
| "5m", "1s", | ||
| ).Should(BeTrue()) | ||
|
|
||
| Eventually( |
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.
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") |
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.
the same as for create
antonlisovenko
left a comment
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.
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! 🥇
.github/workflows/test.yml
Outdated
| 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 }}" |
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.
[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 |
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.
[nit] still think that considering the size of the test having By with callbacks (By("", func() {..})) will make the code more readable, WDYT?
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.
the thing is idk which steps will be final, this test - is the initial version, steps will be reformatted later for all tests need
test/e2e/configuration_test.go
Outdated
| Eventually(session.Wait()).Should(Say("created")) | ||
|
|
||
| By("Wait project creation") | ||
| Eventually(cli.GetStatus(namespaceUserResources, "atlasproject.atlas.mongodb.com/"+k8sProjectName)).Should(Equal("True")) |
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.
[nit] rename to GetStatusCondition
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