Skip to content
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

Start migrating e2e tests to Go. #3079

Merged
merged 15 commits into from
Jun 13, 2022
Merged

Start migrating e2e tests to Go. #3079

merged 15 commits into from
Jun 13, 2022

Conversation

v-shenoy
Copy link
Contributor

@v-shenoy v-shenoy commented May 30, 2022

Signed-off-by: Vighnesh Shenoy vshenoy@microsoft.com

Provide a description of what has been changed

Start migrating e2e tests to Go for code parity.

Sample Logs

Checklist

  • Commits are signed with Developer Certificate of Origin (DCO - learn more)
  • Tests have been added
  • A PR is opened to update our Helm chart (repo) (if applicable, ie. when deployment manifests are modified)
  • A PR is opened to update the documentation on (repo) (if applicable)
  • Changelog has been updated and is aligned with our changelog requirements

Relates to #2737

@v-shenoy v-shenoy requested a review from a team as a code owner May 30, 2022 06:28
@v-shenoy v-shenoy marked this pull request as draft May 30, 2022 06:30
@v-shenoy
Copy link
Contributor Author

Sorry for the delay here, but here's a sample PR with E2E tests in Go.

I have also added sample logs from a test run to see how they look. I feel that the logs are a lot cleaner as well compared to the ones from ava.

@tomkerkhove @JorTurFer @zroubalik

@JorTurFer
Copy link
Member

Sorry for the delay here, but here's a sample PR with E2E tests in Go.

I have also added sample logs from a test run to see how they look. I feel that the logs are a lot cleaner as well compared to the ones from ava.

@tomkerkhove @JorTurFer @zroubalik

I'm a bit busy atm, but I'll review it ASAP, huge kudos for this improvement! ❤️ ❤️ ❤️ ❤️

@v-shenoy
Copy link
Contributor Author

I'm a bit busy atm, but I'll review

That would be great. If the sample looks okay, I will start working on migrating all the other Azure scalers as a part of this PR as well. After that the community can start working on others, and help with the migration.

Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

Looking good! Great job :)

We should find a way how to run these in parallel until the full migration is done.

e2e/helper.go Outdated Show resolved Hide resolved
e2e/helper.go Outdated Show resolved Hide resolved
@zroubalik
Copy link
Member

Could you please also update the https://github.com/kedacore/keda/blob/main/tests/README.md in this PR as well?

@v-shenoy
Copy link
Contributor Author

Looking good! Great job :)

We should find a way how to run these in parallel until the full migration is done.

Could you explain what you mean by this? The run-all.sh file does run the tests in parallel, right?

Or do you mean running the go and ts files in parallel until the full migration is done?

@zroubalik
Copy link
Member

Looking good! Great job :)
We should find a way how to run these in parallel until the full migration is done.

Could you explain what you mean by this? The run-all.sh file does run the tests in parallel, right?

Or do you mean running the go and ts files in parallel until the full migration is done?

yeah, but it's more a matter of modifying GH Workflows. @JorTurFer might have better idea. Let's solve this once this PR is ready.

@v-shenoy
Copy link
Contributor Author

v-shenoy commented May 31, 2022

Could you please also update the https://github.com/kedacore/keda/blob/main/tests/README.md in this PR as well?

Currently, I kept these tests under a folder e2e in the root.
I am thinking of moving these to tests/e2e_go until the complete migration.

After the complete migration, we can remove the contents of tests and rename tests/e2e_go -> tests.

And yes, I will add a readme to tests/e2e_go/README.md explaining the testing.

@zroubalik
Copy link
Member

zroubalik commented May 31, 2022

Could you please also update the https://github.com/kedacore/keda/blob/main/tests/README.md in this PR as well?

Currently, I kept these tests under a folder e2e in the root. I am thinking of moving these to tests/e2e_go until the complete migration.

After the complete migration, we can remove the contents of tests and rename them tests/e2e_go -> tests.

And yes, I will add a readme to tests/e2e_go/README.md explaining the testing.

sounds like a good plan!

@v-shenoy
Copy link
Contributor Author

Looking good! Great job :)
We should find a way how to run these in parallel until the full migration is done.

Could you explain what you mean by this? The run-all.sh file does run the tests in parallel, right?
Or do you mean running the go and ts files in parallel until the full migration is done?

yeah, but it's more a matter of modifying GH Workflows. @JorTurFer might have better idea. Let's solve this once this PR is ready.

The only concern I have is running both the workflows will increase time required. I think what might be a good approach is, letting the main build that gets run on a PR merge not be changed until complete migration is done.

And, for PRs have a temporary separate command such as /run-e2e-go in parallel to /run-e2e. Once the migration is done we can replace the /run-e2e workflow with the other one.

@zroubalik zroubalik mentioned this pull request May 31, 2022
5 tasks
@JorTurFer
Copy link
Member

The only concern I have is running both the workflows will increase time required. I think what might be a good approach is, letting the main build that gets run on a PR merge not be changed until complete migration is done.

And, for PRs have a temporary separate command such as /run-e2e-go in parallel to /run-e2e. Once the migration is done we can replace the /run-e2e workflow with the other one.

uff... Adding a second command could be a pain TBH. The command is a super custom workload that I did, and duplicate it could be horrible. Maybe we can just run both all the time due to we are going to move the tests from one to another, so once we have moved the test to Golang, it shouldn't exist for a long time in typescript.
Other option could be just combining both e2e test files in same folder. Thay have different extensions so we can know which one is each one based on the extension, and having all together can simplify the moving process.
When we add a new e2e test in go, we can just delete the ts file.
WDYT?

@JorTurFer
Copy link
Member

One more thing, the command make test is also executing the new e2e tests. Maybe we have to add build tags

@zroubalik
Copy link
Member

I would go the simplest way - execute both test suites and always delete overlapping tests.

@JorTurFer
Copy link
Member

I would go the simplest way - execute both test suites and always delete overlapping tests.

Agree. The best part of this is that make e2e-test will continue being the way to trigger them, so main-build and nightly build still work without any other change

@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 3, 2022

I am keeping the go tests in scalers_go and the ts tests in scalers. I have modified the run-all.sh file to run both go and ts files until the migration is complete.

Replaced the setup.test.ts and cleanup.test.ts with setup_test.go and cleanup_test.go. And I everytime some adds a test for a scaler which already has a ts test, they should delete the ts file and only keep the go file.

I have also added a section in the README with some instructions and a small example. It isn't the best, but I will try to improve it in the future.

@JorTurFer @zroubalik

@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 3, 2022

I will be adding these tests as a part of this PR (hopefully by Monday/Tuesday).

  • App Insights
  • Blob
  • Data Explorer
  • Key Vault Queue
  • Log Analytics
  • Pipelines
  • Queue Idle Replicas
  • Queue Pause At N
  • Queue Pause
  • Queue Restore Original Replicas
  • Queue Trigger Auth
  • Queue
  • Service Bus Queue Workload Identity
  • Service Bus Queue
  • Service Bus Topic

And hopefully once this PR is merged, the community steps up in helping with the migration and takes up the other scalers.

@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 3, 2022

The tests folder will have to be skipped during pr and main workflows, else the go files for the e2e tests will also be run.

@zroubalik
Copy link
Member

I will be adding these tests as a part of this PR (hopefully by Monday/Tuesday).

* App Insights

* Blob

* Data Explorer

* Key Vault Queue

* Log Analytics

* Pipelines

* Queue Idle Replicas

* Queue Pause At N

* Queue Pause

* Queue Restore Original Replicas

* Queue Trigger Auth

* Queue

* Service Bus Queue Workload Identity

* Service Bus Queue

* Service Bus Topic

And hopefully once this PR is merged, the community steps up in helping with the migration and takes up the other scalers.

@v-shenoy do you think that you can add only a subset of these tests in this PR? There are some new scalers that could already use the golang version. You can add the rest of the Azure related tests in a subsequent PR. WDYT?

@zroubalik
Copy link
Member

The tests folder will have to be skipped during pr and main workflows, else the go files for the e2e tests will also be run.

Please do that in this PR (also include nightly).

@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 6, 2022

I will be adding these tests as a part of this PR (hopefully by Monday/Tuesday).

* App Insights

* Blob

* Data Explorer

* Key Vault Queue

* Log Analytics

* Pipelines

* Queue Idle Replicas

* Queue Pause At N

* Queue Pause

* Queue Restore Original Replicas

* Queue Trigger Auth

* Queue

* Service Bus Queue Workload Identity

* Service Bus Queue

* Service Bus Topic

And hopefully once this PR is merged, the community steps up in helping with the migration and takes up the other scalers.

@v-shenoy do you think that you can add only a subset of these tests in this PR? There are some new scalers that could already use the golang version. You can add the rest of the Azure related tests in a subsequent PR. WDYT?

Alright, I can add the Service Bus (Queue + Topic + Workload) and Key Vault tests. And then add the rest later. Does that seem good?

@zroubalik
Copy link
Member

@v-shenoy yeah, thanks 🙏

@zroubalik zroubalik mentioned this pull request Jun 6, 2022
5 tasks
v-shenoy added 3 commits June 10, 2022 15:15
Signed-off-by: Vighnesh Shenoy <vshenoy@microsoft.com>
Signed-off-by: Vighnesh Shenoy <vshenoy@microsoft.com>
Signed-off-by: Vighnesh Shenoy <vshenoy@microsoft.com>
Signed-off-by: Vighnesh Shenoy <vshenoy@microsoft.com>
@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 10, 2022

/run-e2e
Update: You can check the progres here

@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 10, 2022

/run-e2e Update: You can check the progres here

I only just remembered I could also run tests, haha. Well, it works, and is going to be really helpful :D

@JorTurFer

v-shenoy added 2 commits June 10, 2022 18:15
Signed-off-by: Vighnesh Shenoy <vshenoy@microsoft.com>
Signed-off-by: Vighnesh Shenoy <vshenoy@microsoft.com>
@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 10, 2022

/run-e2e
Update: You can check the progres here

@JorTurFer
Copy link
Member

Another thing, I was worried about how to deal with panics, because if a test panics the cleanup code may not run. And this might leave the test resources in an unexpected state. But, this is no different than a test in ava with incorrect cleanup code.

I think that this problem is solved with this deletion "just in case" at the end of every e2e process 😄

@JorTurFer
Copy link
Member

I only just remembered I could also run tests, haha. Well, it works, and is going to be really helpful :D

😄

image

@JorTurFer
Copy link
Member

I have to recognize that I love the improvement in the loging, I mean, something as simple as like Current - 0, Target - 1 will help a lot IMO. Super nice improvement!

@JorTurFer
Copy link
Member

I'm thinking on what will happen in case of panic, and I'm not sure if we will face with stuck namespaces 🤔
I mean, we will try to delete all e2e nasmapces. but if there is any ScaledObject or ScaledJob at that moment, the namespace will be stuck because the finalizers will block the deletion.
Does Kustomize follow any criteria like 'delete CRDs before the others'?

@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 10, 2022

/run-e2e Update: You can check the progres here

The tests are passing, whew!

@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 10, 2022

I'm thinking on what will happen in case of panic, and I'm not sure if we will face with stuck namespaces 🤔 I mean, we will try to delete all e2e nasmapces. but if there is any ScaledObject or ScaledJob at that moment, the namespace will be stuck because the finalizers will block the deletion. Does Kustomize follow any criteria like 'delete CRDs before the others'?

I am not sure if kustomize does this. But maybe you can add delete all scaled objects / jobs in namespaces with label type=e2e (or rather all namespaces just to be sure) in the make undeploy command before the kustomize operation.

@JorTurFer
Copy link
Member

JorTurFer commented Jun 10, 2022

I was talking about doing something like this kubectl delete $(kubectl get scaledobjects,scaledjobs -oname) but including all the namespaces (I haven't tested the code below, I wrote in on-the-fly and maybe we need to adapt it):

while read -r namespace
do
    kubectl delete $(kubectl get scaledobjects,scaledjobs -oname -n "$namespace") -n "$namespace"
done < (kubectl get namespaces)

Doing this as part of the make undeploy before kustomize command should be enough to ensure that we delete all the KEDA resources with finalizers.
WDYT?

@v-shenoy
Copy link
Contributor Author

I was talking about doing something like this kubectl delete $(kubectl get scaledobjects,scaledjobs -oname) but including all the namespaces (I haven't tested the code below, I wrote in on-the-fly and maybe we need to adapt it):

while read -r namespace
do
    kubectl delete $(kubectl get scaledobjects,scaledjobs -oname -n "$namespace") -n "$namespace"
done < (kubectl get namespaces)

Doing this as part of the make undeploy before kustomize command should be enough to ensure that we delete all the KEDA resources with finalizers. WDYT?

Yup, I was thinking something exactly like this.

@zroubalik
Copy link
Member

zroubalik commented Jun 10, 2022

Don't forget to include TriggerAuth... :) And then finally namespaces.

@JorTurFer
Copy link
Member

JorTurFer commented Jun 10, 2022

Don't forget to include TriggerAuth... :)

TriggerAuth doesn't have finalizers, so I think that we can just delete them deleting the CRD, the problems are the resources with finalizers :/
I mean, delete de CRD will try to delete every resource, but the SO/SJ finalizers block the deletion if KEDA was killed before

@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 10, 2022

Don't forget to include TriggerAuth... :) And then finally namespaces.

The namespaces get deleted with make e2e-test clean already because of the e2e label, as long as they were created with the CreateNamespace helper method.

Signed-off-by: Vighnesh Shenoy <vshenoy@microsoft.com>
@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 11, 2022

/run-e2e
Update: You can check the progress here

@v-shenoy
Copy link
Contributor Author

v-shenoy commented Jun 11, 2022

/run-e2e Update: You can check the progress here

@JorTurFer @zroubalik I have added a make target e2e-test-clean-crds that deletes any scaled objects, jobs that are on the cluster using a shell script. I have checked that the script works with resources across multiple namespaces. And added this new target as a dependency for undeploy. You can see that it's running here.

The tests also seem to be running fine.

Any more changes expected in this PR?

Copy link
Member

@JorTurFer JorTurFer left a comment

Choose a reason for hiding this comment

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

LGTM!
Thanks for this incredible improvement ❤️

@v-shenoy v-shenoy requested a review from zroubalik June 12, 2022 14:56
Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

LGTM, awesome stuff! 🚀

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