Skip to content

Commit

Permalink
Clean local directory before setting up test files (MarkUsProject#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
pretendWhale authored and Donny Wong committed May 9, 2024
1 parent 03fcdd4 commit 39ca6da
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/autotest_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def run_test(settings_id, test_id, files_url, categories, user, test_env_vars):
redis_connection().hset("autotest:settings", key=settings_id, value=json.dumps(settings))
test_username, tests_path = tester_user()
try:
_clear_working_directory(tests_path, test_username)
_setup_files(settings_id, user, files_url, tests_path, test_username)
cmd = run_test_command(test_username=test_username)
results = _run_test_specs(cmd, settings, categories, tests_path, test_username, test_id, test_env_vars)
Expand Down
17 changes: 17 additions & 0 deletions server/autotest_server/tests/test_autotest_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,20 @@ def test_sticky():
autotest_server._clear_working_directory(autotest_worker_working_dir, autotest_worker)

assert os.path.exists(path) is False


def test_pre_remove():
workers = autotest_server.config["workers"]
autotest_worker = workers[0]["user"]
autotest_worker_working_dir = f"/home/docker/.autotesting/workers/{autotest_worker}"
path = f"{autotest_worker_working_dir}/__pycache__"

if not os.path.exists(path):
mkdir_cmd = f"sudo -u {autotest_worker} mkdir {path}"
chmod_cmd = f"sudo -u {autotest_worker} chmod 000 {path}"
subprocess.run(mkdir_cmd, shell=True)
subprocess.run(chmod_cmd, shell=True)

autotest_server._clear_working_directory(autotest_worker_working_dir, autotest_worker)

assert os.path.exists(path) is False

0 comments on commit 39ca6da

Please sign in to comment.