Testsuite - Fix several tests for local-config, and SlurmTestUser
diff --git a/testsuite/python/tests/test_100_2.py b/testsuite/python/tests/test_100_2.py
index 5179193..456c3c4 100644
--- a/testsuite/python/tests/test_100_2.py
+++ b/testsuite/python/tests/test_100_2.py
@@ -281,7 +281,6 @@
"-N1 --qos=qos1",
"false",
fatal=True,
- user=atf.properties["test-user"],
)
)
jobs.append(atf.submit_job("sbatch", "-N2 --qos=qos2", "false", fatal=True))
@@ -295,7 +294,6 @@
"-N1 --qos=qos1",
"sleep 300",
fatal=True,
- user=atf.properties["test-user"],
)
)
jobs.append(atf.submit_job("sbatch", "-N2 --qos=qos2", "sleep 300", fatal=True))
diff --git a/testsuite/python/tests/test_102_1.py b/testsuite/python/tests/test_102_1.py
index 73647d5..bfc2aea 100644
--- a/testsuite/python/tests/test_102_1.py
+++ b/testsuite/python/tests/test_102_1.py
@@ -54,6 +54,15 @@
)
+@pytest.fixture(scope="module", autouse=True)
+def clean_clusters():
+ yield
+ atf.run_command(
+ f"sacctmgr -i delete cluster {cluster_string}",
+ user=atf.properties["slurm-user"],
+ )
+
+
@pytest.fixture(scope="function")
def no_federations():
atf.run_command(
diff --git a/testsuite/python/tests/test_105_5.py b/testsuite/python/tests/test_105_5.py
index 9ba1ccc..ad39540 100644
--- a/testsuite/python/tests/test_105_5.py
+++ b/testsuite/python/tests/test_105_5.py
@@ -8,7 +8,7 @@
import pytest
import re
-user_name = atf.get_user_name()
+user_name = atf.properties["test-user"]
@pytest.fixture(scope="module", autouse=True)
diff --git a/testsuite/python/tests/test_115_1.py b/testsuite/python/tests/test_115_1.py
index 9a3d37b..c0cbb10 100644
--- a/testsuite/python/tests/test_115_1.py
+++ b/testsuite/python/tests/test_115_1.py
@@ -201,10 +201,10 @@
# Verify they were all populated with an id
for user in user1, user2:
if user not in user_account_id:
- atf.log_die(f"Account association for {user} was not created")
+ pytest.fail(f"Account association for {user} was not created")
for account in account1, account2, account3:
if account not in user_account_id[user]:
- atf.log_die(f"Association for {user} and {account} was not created")
+ pytest.fail(f"Association for {user} and {account} was not created")
# Populate user_wckey_id dictionary with user-wckey association ids
output = atf.run_command_output(
@@ -221,9 +221,9 @@
# Verify they were all populated with an id
for user in user1, user2:
if user not in user_wckey_id:
- atf.log_die(f"WCKey association for {user} was not created")
+ pytest.fail(f"WCKey association for {user} was not created")
if wckey1 not in user_wckey_id[user]:
- atf.log_die(f"Association for {user} and {wckey1} was not created")
+ pytest.fail(f"Association for {user} and {wckey1} was not created")
@pytest.fixture(scope="module")
@@ -284,17 +284,17 @@
rf"{cluster}\|{account1}\|{user_account_id[user1][account1]}\|{wckey1}\|{user_wckey_id[user1][wckey1]}\|{job1_start_string}\|{job1_end_string}\|{job1_duration_string}",
output,
):
- atf.log_die("The job accounting data was not loaded correctly for job1")
+ pytest.fail("The job accounting data was not loaded correctly for job1")
if not re.search(
rf"{cluster}\|{account3}\|{user_account_id[user2][account3]}\|{wckey1}\|{user_wckey_id[user2][wckey1]}\|{job2_start_string}\|{job2_end_string}\|{job2_duration_string}",
output,
):
- atf.log_die("The job accounting data was not loaded correctly for job2")
+ pytest.fail("The job accounting data was not loaded correctly for job2")
if not re.search(
rf"{cluster}\|{account2}\|{user_account_id[user1][account2]}\|{wckey1}\|{user_wckey_id[user1][wckey1]}\|{job3_start_string}\|{job3_end_string}\|{job3_duration_string}",
output,
):
- atf.log_die("The job accounting data was not loaded correctly for job3")
+ pytest.fail("The job accounting data was not loaded correctly for job3")
# Use sacctmgr to see if the node event loaded
output = atf.run_command_output(
@@ -306,14 +306,14 @@
rf"{cluster}\|\|{period_start_string}\|{period_end_string}\|{cluster_cpus}",
output,
):
- atf.log_die(
+ pytest.fail(
"The event accounting data was not loaded correctly for the cluster"
)
if not re.search(
rf"{cluster}\|{node0}\|{node0_start_string}\|{node0_end_string}\|{node0_cpus}",
output,
):
- atf.log_die("The event accounting data was not loaded correctly for node0")
+ pytest.fail("The event accounting data was not loaded correctly for node0")
# Use sacctmgr to roll up the time period
atf.run_command_output(
diff --git a/testsuite/python/tests/test_116_12.py b/testsuite/python/tests/test_116_12.py
index 3014cd0..619a207 100644
--- a/testsuite/python/tests/test_116_12.py
+++ b/testsuite/python/tests/test_116_12.py
@@ -126,7 +126,7 @@
fpc.remove_file(file_err)
# Test %u puts the user name in the file name
- user_name = atf.get_user_name()
+ user_name = atf.properties["test-user"]
file_out = fpc.create_file_path("u")
atf.run_job(f"--output={file_out} -N1 -O id")
file_out = fpc.get_tmp_file()
@@ -175,7 +175,6 @@
srun -O --output={file_out} true
done""",
)
- os.chmod(file_in, 0o0777)
job_id = atf.submit_job_sbatch(f"-N{node_count} --output /dev/null {str(file_in)}")
atf.wait_for_job_state(job_id, "DONE")
tmp_dir_list = os.listdir(tmp_path)
@@ -192,7 +191,6 @@
srun -O --error={file_err} true
done""",
)
- os.chmod(file_in, 0o0777)
job_id = atf.submit_job_sbatch(f"-N{node_count} --output /dev/null {str(file_in)}")
atf.wait_for_job_state(job_id, "DONE")
tmp_dir_list = os.listdir(tmp_path)
diff --git a/testsuite/python/tests/test_116_44.py b/testsuite/python/tests/test_116_44.py
index c58d8ff..8c5e007 100644
--- a/testsuite/python/tests/test_116_44.py
+++ b/testsuite/python/tests/test_116_44.py
@@ -25,7 +25,7 @@
num_tasks = 4
node_count = 1
- my_uid = os.getuid()
+ test_uid = atf.properties["test-user-uid"]
atf.make_bash_script(
task_prolog,
@@ -65,10 +65,10 @@
atf.wait_for_file(file_out_pre)
output = atf.run_command_output(f"cat {file_out_pre}")
- match_uid = re.findall(rf"uid={my_uid}", output)
+ match_uid = re.findall(rf"uid={test_uid}", output)
assert len(match_uid) == num_tasks, "Task prolog output is missing or uid mismatch"
atf.wait_for_file(file_out_post)
output = atf.run_command_output(f"cat {file_out_post}")
- match_uid = re.findall(rf"uid={my_uid}", output)
+ match_uid = re.findall(rf"uid={test_uid}", output)
assert len(match_uid) == num_tasks, "Task epilog output is missing or uid mismatch"
diff --git a/testsuite/python/tests/test_116_46.py b/testsuite/python/tests/test_116_46.py
index 98d23ea..058507d 100644
--- a/testsuite/python/tests/test_116_46.py
+++ b/testsuite/python/tests/test_116_46.py
@@ -2,7 +2,6 @@
# Copyright (C) SchedMD LLC.
############################################################################
import atf
-import os
import pytest
import re
@@ -31,7 +30,6 @@
sleep 20
""",
)
- os.chmod(file_in, 0o0755)
run_error = atf.run_command_error(
f"srun -n{task_count} -N{node_count} -O -W2 {file_in}"
)
diff --git a/testsuite/python/tests/test_116_47.py b/testsuite/python/tests/test_116_47.py
index 13c100f..22a0a11 100644
--- a/testsuite/python/tests/test_116_47.py
+++ b/testsuite/python/tests/test_116_47.py
@@ -2,7 +2,6 @@
# Copyright (C) SchedMD LLC.
############################################################################
import atf
-import os
import pytest
import re
@@ -21,7 +20,7 @@
# Verify that a job executes as the appropriate user and group
def test_uid(srun_output):
"""Verify that a job executes as the invoking user"""
- test_uid = os.geteuid()
+ test_uid = atf.properties["test-user-uid"]
job_uid = (
int(match.group(1)) if (match := re.search(r"uid=(\d+)", srun_output)) else None
)
@@ -30,7 +29,7 @@
def test_gid(srun_output):
"""Verify that a job executes as the invoking group"""
- test_gid = os.getegid()
+ test_gid = atf.properties["test-user-gid"]
job_gid = (
int(match.group(1)) if (match := re.search(r"gid=(\d+)", srun_output)) else None
)
diff --git a/testsuite/python/tests/test_123_4.py b/testsuite/python/tests/test_123_4.py
index c1e7b45..75e9036 100644
--- a/testsuite/python/tests/test_123_4.py
+++ b/testsuite/python/tests/test_123_4.py
@@ -32,10 +32,8 @@
result = atf.run_command(create_res, user=atf.properties["slurm-user"])
assert result["exit_code"] == 0, "Couldn't create the reservation!"
- # Try to run a job as atf
- result = atf.run_command(
- f"srun -N1 --reservation={res_name} true", user=atf.properties["test-user"]
- )
+ # Try to run a job as test-user
+ result = atf.run_command(f"srun -N1 --reservation={res_name} true")
assert result["exit_code"] != 0, "The job should have been denied for user!"
assert (
"Access denied" in result["stderr"]
diff --git a/testsuite/python/tests/test_123_5.py b/testsuite/python/tests/test_123_5.py
index 9b20de8..adddcae 100644
--- a/testsuite/python/tests/test_123_5.py
+++ b/testsuite/python/tests/test_123_5.py
@@ -86,7 +86,6 @@
# Try to run a job as in the wrong QOS
result = atf.run_command(
f"srun -N1 --reservation={res_name} --account={acct1} --qos=normal true",
- user=atf.properties["test-user"],
)
assert (
result["exit_code"] != 0
@@ -98,7 +97,6 @@
# Try to run a job as in the correct QOS
result = atf.run_command(
f"srun -N1 --reservation={res_name} --account={acct1} --qos=normal,{qos1} true",
- user=atf.properties["test-user"],
)
assert (
result["exit_code"] == 0
diff --git a/testsuite/python/tests/test_123_6.py b/testsuite/python/tests/test_123_6.py
index 1f940c8..2f52140 100644
--- a/testsuite/python/tests/test_123_6.py
+++ b/testsuite/python/tests/test_123_6.py
@@ -80,7 +80,6 @@
# Try to run a job as in the wrong partition
result = atf.run_command(
f"srun -N1 --reservation={res_name} --partition={partitions[1]} true",
- user=atf.properties["test-user"],
)
assert (
result["exit_code"] != 0
@@ -92,7 +91,6 @@
# Try to run a job that can use either partition
result = atf.run_command(
f"srun -N1 --reservation={res_name} --partition={partitions[1]},{partitions[0]} true",
- user=atf.properties["test-user"],
)
assert (
result["exit_code"] == 0