-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added integration test for job cancelling
Relates to: #793 Relates to: #792 Implemented an integration test to verify that a job can be canceled via the DBus API provided by BlueChi. The test also uses various job attributes. Signed-off-by: Michael Engel <mengel@redhat.com>
- Loading branch information
Showing
5 changed files
with
55 additions
and
49 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
summary: Test if a job can be cancelled | ||
id: 6ebd2116-eb64-43b8-b346-8eb632122549 | ||
summary: Test if a job can be canceled | ||
id: 46f90231-3b9f-4a00-b58d-44092495d600 |
45 changes: 45 additions & 0 deletions
45
tests/tests/tier0/bluechi-job-cancel/python/start_and_cancel.py
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,45 @@ | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
||
import time | ||
import unittest | ||
|
||
from dasbus.error import DBusError | ||
|
||
from bluechi.api import Node, Job | ||
|
||
node_name_foo = "node-foo" | ||
service_simple = "simple.service" | ||
|
||
|
||
class TestStartAndCancel(unittest.TestCase): | ||
|
||
def _get_unit_state(self, node: Node, service: str) -> str: | ||
prop = node.get_unit_property(service, "org.freedesktop.systemd1.Unit", "ActiveState") | ||
return prop.get_string() | ||
|
||
def test_start_and_cancel(self): | ||
node_foo = Node(node_name_foo) | ||
job_path = node_foo.start_unit(service_simple, "replace") | ||
assert job_path != "" | ||
|
||
# delay job assertions a bit | ||
time.sleep(0.5) | ||
|
||
job = Job(job_path) | ||
assert job.node == node_foo.name | ||
assert job.state in ["waiting", "running"] | ||
assert self._get_unit_state(node_foo, service_simple) == "activating" | ||
|
||
job.cancel() | ||
|
||
# after cancelling: | ||
# - the job should be removed - so we expect another call to fail | ||
# - the started unit should still be activating (canceling job won't stop it) | ||
time.sleep(0.5) | ||
with self.assertRaises(DBusError): | ||
job.state | ||
assert self._get_unit_state(node_foo, service_simple) == "activating" | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
7 changes: 0 additions & 7 deletions
7
tests/tests/tier0/bluechi-job-cancel/systemd/requesting.service
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