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

feat: improve test speed #560

Merged
merged 1 commit into from
Sep 16, 2024
Merged

feat: improve test speed #560

merged 1 commit into from
Sep 16, 2024

Conversation

kian99
Copy link
Contributor

@kian99 kian99 commented Aug 29, 2024

Description

This PR aims to improve the speed of several slow tests (tested using LXD, Microk8s specific tests have not been worked on). The current largest offenders are below (tests that takes >= 100s) based on running them locally on my laptop:

TestAcc_ResourceOffer (300.84s)
TestAcc_DataSourceOffer (146.42s)
TestAcc_ResourceIntegrationWithMultipleConsumers (298.13s)
TestAcc_ResourceIntegrationWithViaCIDRs (325.72s)
TestAcc_ResourceApplication_UpdatesRevisionConfig (139.34s)

The offer based tests are slow because they deploy the postgres charm and the provider then waits for the application storage to be ready which takes a while. Here we can opt to use the juju-qa-dummy-source and juju-qa-dummy-sink charms since the goal is to test offers rather than the postgres charm and storage (if there is a need to test the postgres charm it would likely be better suited for a separate test).

The second offender for the slow tests was the very lenient code in the client code offers.go which would wait up to 5m for an offer's connections to drop to 0. If the connections didn't drop to 0 within these 5 minutes, it would destroy an offer with the force flag set to true. I've dropped this to a more aggressive 30s.

Type of change

  • Change in tests (one or several tests have been changed)

@kian99 kian99 requested a review from hmlanigan August 29, 2024 10:23
@kian99 kian99 force-pushed the improve-test-speed branch from daa7397 to 36af57c Compare August 29, 2024 10:31
@hmlanigan
Copy link
Member

hmlanigan commented Aug 29, 2024

@kian, I just landed a PR, #557, which helps with the waiting for storage situation. Please review the times for tests to complete again. Using real charms in production is helpful to find bugs. The two charms being suggested are very simple test charms.

@kian99
Copy link
Contributor Author

kian99 commented Aug 30, 2024

@hmlanigan I've tested TestAcc_ResourceOffer with your changes included and it doesn't seem to have made a difference locally (I'll test the full suite later as it takes some time), which intuitively makes sense, waiting for the postgres charm to provision storage takes time and I don't believe was necessarily impacted by the bug that was fixed.

Looking at the integration test results of PR #557 vs the integration test results of this PR, you can compare and see a large difference in the test times for LXD tests (approx. 35m vs 17m)

Interestingly, the Microk8s based tests are quite quick taking 10-12 min.

Existing times
image
New Times
image

Finally, I agree that it's worthwhile testing real charms but these tests are testing the creation of offers and integrations, testing a Postgres charm that creates storage is imo stretching the goal of the test.

Copy link
Member

@hmlanigan hmlanigan left a comment

Choose a reason for hiding this comment

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

I'm happy to update the charms for this 1 test.

Reducing the wait time when destroying an offer is a no go.

internal/juju/offers.go Outdated Show resolved Hide resolved
- Don't use postgres charms that require storage when running offer tests.
@kian99 kian99 force-pushed the improve-test-speed branch from 36af57c to 1780628 Compare September 4, 2024 07:32
@kian99
Copy link
Contributor Author

kian99 commented Sep 4, 2024

@hmlanigan It's only 2 tests that have been updated now.

TestAcc_ResourceOffer
TestAcc_DataSourceOffer

Copy link
Member

@hmlanigan hmlanigan left a comment

Choose a reason for hiding this comment

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

Thank you. Let's merge once the tests all pass.

@kian99
Copy link
Contributor Author

kian99 commented Sep 10, 2024

@hmlanigan Please take another look when you get a chance, all the tests that usually pass are passing.

@kian99 kian99 requested a review from hmlanigan September 10, 2024 13:17
@hmlanigan hmlanigan added state/codefreeze this pr cannot land until the code freeze has lifted. and removed state/codefreeze this pr cannot land until the code freeze has lifted. labels Sep 10, 2024
@hmlanigan hmlanigan merged commit e96af9c into juju:main Sep 16, 2024
25 of 28 checks passed
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.

2 participants