Skip to content
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

attempt to clean local directory before setting up test files #510

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading