-
Notifications
You must be signed in to change notification settings - Fork 3
[TEST] test improvements #251
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
base: 8.0/edge
Are you sure you want to change the base?
Changes from all commits
9109ef4
9889ef9
aaff69d
4e078df
8ba7490
0318b5f
32ee7f9
b93b7de
ce99abe
5bf3ae9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| import os | ||
| import time | ||
| from collections.abc import Generator | ||
| from concurrent.futures import ThreadPoolExecutor | ||
| from contextlib import suppress | ||
|
|
||
| import jubilant_backports | ||
|
|
@@ -32,6 +33,7 @@ | |
| MYSQL_APP_1 = "db1" | ||
| MYSQL_APP_2 = "db2" | ||
| MYSQL_TEST_APP_NAME = "mysql-test-app" | ||
| MYSQL_ROUTER = "mysql-router-k8s" | ||
|
|
||
| MINUTE_SECS = 60 | ||
|
|
||
|
|
@@ -105,14 +107,23 @@ def test_build_and_deploy(first_model: str, second_model: str, charm: str) -> No | |
| ) | ||
|
|
||
| logging.info("Waiting for the applications to settle") | ||
| model_1.wait( | ||
| ready=wait_for_apps_status(jubilant_backports.all_active, MYSQL_APP_1), | ||
| timeout=10 * MINUTE_SECS, | ||
| ) | ||
| model_2.wait( | ||
| ready=wait_for_apps_status(jubilant_backports.all_active, MYSQL_APP_2), | ||
| timeout=10 * MINUTE_SECS, | ||
| ) | ||
|
|
||
| def wait_model_1(): | ||
| model_1.wait( | ||
| ready=wait_for_apps_status(jubilant_backports.all_active, MYSQL_APP_1), | ||
| timeout=10 * MINUTE_SECS, | ||
| ) | ||
|
|
||
| def wait_model_2(): | ||
| model_2.wait( | ||
| ready=wait_for_apps_status(jubilant_backports.all_active, MYSQL_APP_2), | ||
| timeout=10 * MINUTE_SECS, | ||
| ) | ||
|
|
||
| with ThreadPoolExecutor() as executor: | ||
| futures = [executor.submit(wait_model_1), executor.submit(wait_model_2)] | ||
| for future in futures: | ||
| future.result() | ||
|
Comment on lines
+111
to
+126
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious, what does this accomplish? Practically speaking, the execution won't go past this point until both |
||
|
|
||
| if path := os.getenv("DATA_SOURCE_PATH"): | ||
| logging.info("Loading test database") | ||
|
|
@@ -157,16 +168,29 @@ def test_deploy_test_app(first_model: str) -> None: | |
| charm=MYSQL_TEST_APP_NAME, | ||
| app=MYSQL_TEST_APP_NAME, | ||
| base="ubuntu@22.04", | ||
| channel="latest/edge", | ||
| channel="latest/edge/racing", | ||
| num_units=1, | ||
| constraints=constraints, | ||
| ) | ||
|
|
||
| model_1.deploy( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this intersect with https://warthogs.atlassian.net/browse/DPE-9668 ? |
||
| charm=MYSQL_ROUTER, | ||
| app=MYSQL_ROUTER, | ||
| base="ubuntu@22.04", | ||
| channel="8.0/edge", | ||
| num_units=1, | ||
| trust=True, | ||
| ) | ||
|
|
||
| logging.info("Relating the test application") | ||
| model_1.integrate( | ||
| f"{MYSQL_APP_1}:database", | ||
| f"{MYSQL_ROUTER}:database", | ||
| f"{MYSQL_TEST_APP_NAME}:database", | ||
| ) | ||
| model_1.integrate( | ||
| f"{MYSQL_ROUTER}:backend-database", | ||
| f"{MYSQL_APP_1}:database", | ||
| ) | ||
|
|
||
| model_1.wait( | ||
| ready=wait_for_apps_status(jubilant_backports.all_active, MYSQL_TEST_APP_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.
@sinclert-canonical , testing this here, but how should we expose timeout at this level?
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.
At the moment, timeouts can only be applied in an operation-per-operation basis, in the
BaseExecutorsubclasses (see code). That means that timeouts can only be applied when manually executing the Python / SQL operations via an executor class.I originally thought about exposing this argument one level up the chain, in the client classes, but it feels noisy to do in an operation-per-operation basis (i.e. every class method will have an additional arg), and a bit overkill in their constructors, as not every operation should have the same timeout.
Open to ideas.