Skip to content

chore(tests): introduce testcontainers into integration tests as a partial replacement for chainsaw #2083

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

Merged
merged 14 commits into from
Jul 25, 2025

Conversation

Baarsgaard
Copy link
Collaborator

@Baarsgaard Baarsgaard commented Jul 16, 2025

In a continued effort to improve CI stability, This PR introduces an External Grafana instance to Integration tests via testcontainers.

I mentioned wanting an cluster external grafana instance when running our Chainsaw E2E tests, but realised most of the benefits from that also applied to Integration tests.
Tp that end, the forced folder deletion and newly added datasource substitution tests have been migrated into Integration tests.

As unit tests are fast to run compared to integration tests, I added support for -short via make test-short.
When used, integration tests(Ginkgo) are skipped.
This allows significantly faster iteration when writing unit tests.

Refactored GetScopedMatchingInstances integration test with new variables and more from the suite.

Once merged, this allows testing positive Conditions like Synchronized as evident from the new tests.

Coverage of controllers has gone from 35.9% to 42.2%

@github-actions github-actions bot added the chore label Jul 16, 2025
@Baarsgaard Baarsgaard changed the title Chore e2e to testcontainers chore(tests) Translate E2E force delete folders to testcontainers Jul 16, 2025
@Baarsgaard Baarsgaard force-pushed the chore_e2e_to_testcontainers branch from 7ec5da8 to 74a20b6 Compare July 16, 2025 08:13
Copy link
Collaborator

@weisdd weisdd left a comment

Choose a reason for hiding this comment

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

#2073 can be merged, so you should no longer be blocked :)

@Baarsgaard Baarsgaard marked this pull request as ready for review July 17, 2025 15:56
Base automatically changed from chore_migrate_e2e_tests_to_env_test to master July 17, 2025 16:02
@Baarsgaard Baarsgaard force-pushed the chore_e2e_to_testcontainers branch 2 times, most recently from 55d375e to 1d6d6bf Compare July 17, 2025 19:38
@Baarsgaard Baarsgaard requested a review from weisdd July 17, 2025 19:50
@Baarsgaard Baarsgaard changed the title chore(tests) Translate E2E force delete folders to testcontainers chore(tests): Add External Grafana in Integration tests via testcontainers Jul 17, 2025
@Baarsgaard Baarsgaard changed the title chore(tests): Add External Grafana in Integration tests via testcontainers chore(tests): Create external Grafana during Integration tests via testcontainers Jul 17, 2025
@Baarsgaard Baarsgaard changed the title chore(tests): Create external Grafana during Integration tests via testcontainers chore(tests): Create Grafana container during integration tests via testcontainers Jul 17, 2025
Copy link
Collaborator

@weisdd weisdd left a comment

Choose a reason for hiding this comment

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

I think there's potential for code simplification and improved consistency, but I guess it's OK to do that later as reducing dependency on chainsaw and ability to test positive conditions are more important, so I don't want to block you.
I've made a few minor suggestions though on what you might want to improve right away.

@weisdd weisdd changed the title chore(tests): Create Grafana container during integration tests via testcontainers chore(tests): introduce testcontainers in integration tests as a partial replacement for chainsaw Jul 18, 2025
@weisdd weisdd changed the title chore(tests): introduce testcontainers in integration tests as a partial replacement for chainsaw chore(tests): introduce testcontainers into integration tests as a partial replacement for chainsaw Jul 18, 2025
@Baarsgaard Baarsgaard force-pushed the chore_e2e_to_testcontainers branch 2 times, most recently from c106c41 to 07050b0 Compare July 18, 2025 17:20
@Baarsgaard
Copy link
Collaborator Author

Baarsgaard commented Jul 18, 2025

Agreed, There's a likely a lot that could be done for consistency, naming, and similar.
As I have not worked with testcontainers before, any suggestions are welcome!

For example the added file controllers/e2e_force_delete_folder_test.go should maybe have been part of controllers/folder_controller_test.go but I wanted to experiment with how dedicated e2e files felt like.

@Baarsgaard Baarsgaard requested a review from weisdd July 18, 2025 17:28
@Baarsgaard Baarsgaard force-pushed the chore_e2e_to_testcontainers branch from 07050b0 to 8327f58 Compare July 23, 2025 16:21
@Baarsgaard Baarsgaard changed the base branch from master to fix_external_grafana_config_credentials_fallback July 23, 2025 16:21
@Baarsgaard Baarsgaard force-pushed the chore_e2e_to_testcontainers branch from 8327f58 to a6bf4d8 Compare July 23, 2025 16:47
@Baarsgaard Baarsgaard requested a review from weisdd July 23, 2025 16:53
@Baarsgaard Baarsgaard added the test this PR modifies test files/cases label Jul 23, 2025
Base automatically changed from fix_external_grafana_config_credentials_fallback to master July 25, 2025 15:32
@weisdd
Copy link
Collaborator

weisdd commented Jul 25, 2025

I've fixed the formatting issue, so now we should be good to merge the PR.

@Baarsgaard Baarsgaard added this pull request to the merge queue Jul 25, 2025
Merged via the queue into master with commit 56b67c4 Jul 25, 2025
16 checks passed
@Baarsgaard Baarsgaard deleted the chore_e2e_to_testcontainers branch July 25, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore test this PR modifies test files/cases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants