-
-
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.
Showing
5 changed files
with
79 additions
and
74 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import subprocess | ||
import os | ||
import pytest | ||
|
||
@pytest.fixture() | ||
def setup_env(): | ||
os.environ['SENTRY_DOCKER_IO_DIR'] = os.path.join(os.getcwd(), 'sentry') | ||
os.environ['SKIP_USER_CREATION'] = "1" | ||
|
||
def test_backup(setup_env): | ||
# Docker was giving me permissioning issues when trying to create this file and write to it even after giving read + write access | ||
# to group and owner. Instead, try creating the empty file and then give everyone write access to the backup file | ||
file_path = os.path.join(os.getcwd(), 'sentry', 'backup.json') | ||
sentry_admin_sh = os.path.join(os.getcwd(), 'sentry-admin.sh') | ||
open(file_path, 'a', encoding='utf8').close() | ||
os.chmod(file_path, 0o666) | ||
assert os.path.getsize(file_path) == 0 | ||
subprocess.run([sentry_admin_sh, "export", "global", "/sentry-admin/backup.json", "--no-prompt"], check=True) | ||
assert os.path.getsize(file_path) > 0 | ||
|
||
def test_import(setup_env): | ||
# Bring postgres down and recreate the docker volume | ||
subprocess.run(["docker", "compose", "--ansi", "never", "stop", "postgres"], check=True) | ||
subprocess.run(["docker", "compose", "--ansi", "never", "rm", "-f", "-v", "postgres"], check=True) | ||
subprocess.run(["docker", "volume", "rm", "sentry-postgres"], check=True) | ||
subprocess.run(["docker", "volume", "create", "--name=sentry-postgres"], check=True) | ||
subprocess.run(["docker", "compose", "--ansi", "never", "run", "web", "upgrade", "--noinput"], check=True) | ||
subprocess.run(["docker", "compose", "--ansi", "never", "up", "-d"], check=True) | ||
sentry_admin_sh = os.path.join(os.getcwd(), 'sentry-admin.sh') | ||
subprocess.run([sentry_admin_sh, "import", "global", "/sentry-admin/backup.json", "--no-prompt"], check=True) |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import subprocess | ||
import os | ||
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 | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def configure_self_hosted_environment(): | ||
subprocess.run(["docker", "compose", "--ansi", "never", "up", "-d"], check=True) | ||
for i in range(TIMEOUT_SECONDS): | ||
try: | ||
response = httpx.get(SENTRY_TEST_HOST, follow_redirects=True) | ||
except httpx.ConnectionError: | ||
time.sleep(1) | ||
else: | ||
if response.status_code == 200: | ||
break | ||
else: | ||
raise AssertionError("timeout waiting for self-hosted to come up") | ||
|
||
# Create test user | ||
subprocess.run( | ||
[ | ||
"docker", | ||
"compose", | ||
"exec", | ||
"web", | ||
"sentry", | ||
"createuser", | ||
"--force-update", | ||
"--superuser", | ||
"--email", | ||
TEST_USER, | ||
"--password", | ||
TEST_PASS, | ||
"--no-input", | ||
], | ||
check=True, | ||
text=True, | ||
) |
This file was deleted.
Oops, something went wrong.
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