-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Faster and smarter backup/restore tests (#3516)
From ``` ================== 11 passed, 4 warnings in 762.35s (0:12:42) ================== ``` to ``` ================== 11 passed, 4 warnings in 343.58s (0:05:43) ================== ```
- Loading branch information
Showing
5 changed files
with
55 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,17 @@ | ||
import os | ||
from os.path import join | ||
import subprocess | ||
import time | ||
|
||
import httpx | ||
import pytest | ||
|
||
SENTRY_CONFIG_PY = "sentry/sentry.conf.py" | ||
SENTRY_TEST_HOST = os.getenv("SENTRY_TEST_HOST", "http://localhost:9000") | ||
TEST_USER = "[email protected]" | ||
TEST_PASS = "test123TEST" | ||
TIMEOUT_SECONDS = 60 | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--customizations", default="disabled") | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def configure_self_hosted_environment(request): | ||
subprocess.run( | ||
["docker", "compose", "--ansi", "never", "up", "-d"], | ||
check=True, | ||
capture_output=True, | ||
) | ||
for i in range(TIMEOUT_SECONDS): | ||
try: | ||
response = httpx.get(SENTRY_TEST_HOST, follow_redirects=True) | ||
except httpx.RequestError: | ||
time.sleep(1) | ||
else: | ||
if response.status_code == 200: | ||
break | ||
else: | ||
raise AssertionError("timeout waiting for self-hosted to come up") | ||
|
||
if request.config.getoption("--customizations") == "enabled": | ||
os.environ["TEST_CUSTOMIZATIONS"] = "enabled" | ||
script_content = """\ | ||
#!/bin/bash | ||
touch /created-by-enhance-image | ||
apt-get update | ||
apt-get install -y gcc libsasl2-dev python-dev-is-python3 libldap2-dev libssl-dev | ||
""" | ||
|
||
with open("sentry/enhance-image.sh", "w") as script_file: | ||
script_file.write(script_content) | ||
# Set executable permissions for the shell script | ||
os.chmod("sentry/enhance-image.sh", 0o755) | ||
|
||
# Write content to the requirements.txt file | ||
with open("sentry/requirements.txt", "w") as req_file: | ||
req_file.write("python-ldap\n") | ||
os.environ["MINIMIZE_DOWNTIME"] = "1" | ||
subprocess.run(["./install.sh"], check=True, capture_output=True) | ||
# Create test user | ||
subprocess.run( | ||
[ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
echo "${_group}Bootstrapping and migrating Snuba ..." | ||
|
||
$dcr snuba-api bootstrap --force | ||
if [[ -z "${SKIP_DB_MIGRATIONS:-}" ]]; then | ||
$dcr snuba-api bootstrap --force | ||
else | ||
echo "Skipped DB migrations due to SKIP_DB_MIGRATIONS=$SKIP_DB_MIGRATIONS" | ||
fi | ||
|
||
echo "${_endgroup}" |