sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #06837
[Merge] ~igor-brovtsin/maas:fix-test-ps-pids into maas:master
Igor Brovtsin has proposed merging ~igor-brovtsin/maas:fix-test-ps-pids into maas:master.
Commit message:
Fixed possible duplicate PIDs in `test_ps.py`
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~igor-brovtsin/maas/+git/maas/+merge/440724
--
Your team MAAS Maintainers is requested to review the proposed merge of ~igor-brovtsin/maas:fix-test-ps-pids into maas:master.
diff --git a/src/provisioningserver/utils/tests/test_ps.py b/src/provisioningserver/utils/tests/test_ps.py
index 7644a85..c178b65 100644
--- a/src/provisioningserver/utils/tests/test_ps.py
+++ b/src/provisioningserver/utils/tests/test_ps.py
@@ -139,19 +139,15 @@ class TestGetRunningPIDsWithCommand(MAASTestCase):
proc_path = self.make_dir()
self.make_init_process(proc_path)
command = factory.make_name("command")
- pids_running_command = [random.randint(2, 999) for _ in range(3)]
+ pids_running_command = random.sample(range(2, 1000), 3)
for pid in pids_running_command:
self.make_process(proc_path, pid, command=command)
- pids_not_running_command = {
- random.randint(1000, 1999) for _ in range(3)
- }
+ pids_not_running_command = random.sample(range(1000, 2000), 3)
for pid in pids_not_running_command:
self.make_process(
proc_path, pid, command=factory.make_name("command")
)
- pids_running_command_in_container = {
- random.randint(2000, 2999) for _ in range(3)
- }
+ pids_running_command_in_container = random.sample(range(2000, 3000), 3)
for pid in pids_running_command_in_container:
self.make_process(
proc_path, pid, in_container=True, command=command
@@ -169,7 +165,7 @@ class TestGetRunningPIDsWithCommand(MAASTestCase):
proc_path = self.make_dir()
self.make_init_process(proc_path)
command = factory.make_name("command")
- pids_running_command = [random.randint(2, 999) for _ in range(3)]
+ pids_running_command = random.sample(range(2, 1000), 3)
for pid in pids_running_command:
self.make_process(proc_path, pid, command=command)
# Remove the comm file to test the exception handling.
@@ -182,14 +178,12 @@ class TestGetRunningPIDsWithCommand(MAASTestCase):
proc_path = self.make_dir()
self.make_init_process(proc_path, in_container=True)
command = factory.make_name("command")
- pids_running_command = [random.randint(2, 999) for _ in range(3)]
+ pids_running_command = random.sample(range(2, 1000), 3)
for pid in pids_running_command:
self.make_process(
proc_path, pid, in_container=True, command=command
)
- pids_not_running_command = {
- random.randint(1000, 1999) for _ in range(3)
- }
+ pids_not_running_command = random.sample(range(1000, 2000), 3)
for pid in pids_not_running_command:
self.make_process(
proc_path,
Follow ups