aboutsummaryrefslogtreecommitdiffstats
path: root/pyagl/tests/test_taskmanager.py
diff options
context:
space:
mode:
authorQiu Tingting <qiutt@fujitsu.com>2021-04-02 13:30:04 +0800
committerJan-Simon Möller <jsmoeller@linuxfoundation.org>2021-11-03 15:11:21 +0100
commitca09b3c315d4f103c0be27137e3e171c5f5d7d26 (patch)
treef0530f6a1dff24ac3d21cd9c3bfcf4df4a504bff /pyagl/tests/test_taskmanager.py
parentf1ba6e0b1bada4dfff863fb9f10ab59eb243cedf (diff)
Add testcase of get_extra_info and kill_process api to taskmanager service module.
Bug-AGL: SPEC-3946 Signed-off-by: Qiu Tingting <qiutt@fujitsu.com> Change-Id: Id9cb3e3df6f6c13c95acfa0875f708ed98fb29f6
Diffstat (limited to 'pyagl/tests/test_taskmanager.py')
-rw-r--r--pyagl/tests/test_taskmanager.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/pyagl/tests/test_taskmanager.py b/pyagl/tests/test_taskmanager.py
index 10c1855..fc1f489 100644
--- a/pyagl/tests/test_taskmanager.py
+++ b/pyagl/tests/test_taskmanager.py
@@ -21,6 +21,12 @@ import logging
from pyagl.services.base import AFBResponse, AFBT
from pyagl.services.taskmanager import TaskManagerService as TASK
+import multiprocessing
+import time
+
+def action(max):
+ time.sleep(max)
+
pytestmark = [pytest.mark.asyncio, pytest.mark.taskmanager]
@pytest.fixture(scope='module')
@@ -52,3 +58,21 @@ async def test_get_load_avg(event_loop, service: TASK):
msgid = await service.get_load_avg()
resp = await service.afbresponse()
assert resp.status == 'success'
+
+@pytest.mark.xfail(reason='Tests that are known to fail, until the agl-service-taskmanager is fixed in master.')
+async def test_get_extra_info(event_loop, service: TASK):
+ msgid = await service.get_extra_info(1)
+ resp = await service.afbresponse()
+ assert resp.status == 'success'
+
+async def test_kill_process(event_loop, service: TASK):
+ mp1 = multiprocessing.Process(target=action,args=(10,))
+ mp1.start()
+ time.sleep(3)
+ print(f'process id: '+str(mp1.pid))
+ msgid = await service.kill_process(mp1.pid)
+ resp = await service.afbresponse()
+ assert resp.status == 'not-replied'
+ time.sleep(1)
+ assert mp1.is_alive() == False
+