X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=tests%2Fintegration%2Ftest_unit.py;h=bb349699faa796a51e5cd81b1d2d0491bd491aed;hp=1604c311cb5f403b61e61cf9d94cb4a109f34ed9;hb=b8a8281b1785358bd5632a119c016f21811172c6;hpb=dcdf82bbc1ef310379f746518b2dd3b006353cb3 diff --git a/tests/integration/test_unit.py b/tests/integration/test_unit.py index 1604c31..bb34969 100644 --- a/tests/integration/test_unit.py +++ b/tests/integration/test_unit.py @@ -1,8 +1,8 @@ import asyncio -import pytest - from tempfile import NamedTemporaryFile +import pytest + from .. import base @@ -25,6 +25,18 @@ async def test_run(event_loop): assert 'Stdout' in action.results break + for unit in app.units: + action = await unit.run('sleep 1', timeout=0.5) + assert isinstance(action, Action) + assert action.status == 'failed' + break + + for unit in app.units: + action = await unit.run('sleep 0.5', timeout=2) + assert isinstance(action, Action) + assert action.status == 'completed' + break + @base.bootstrapped @pytest.mark.asyncio @@ -46,12 +58,21 @@ async def test_run_action(event_loop): for unit in app.units: action = await run_action(unit) assert action.results == {'dir': '/var/git/myrepo.git'} + out = await model.get_action_output(action.entity_id, wait=5) + assert out == {'dir': '/var/git/myrepo.git'} + status = await model.get_action_status(uuid_or_prefix=action.entity_id) + assert status[action.entity_id] == 'completed' break @base.bootstrapped @pytest.mark.asyncio async def test_scp(event_loop): + # ensure that asyncio.subprocess will work; + try: + asyncio.get_child_watcher().attach_loop(event_loop) + except RuntimeError: + pytest.skip('test_scp will always fail outside of MainThread') async with base.CleanModel() as model: app = await model.deploy('ubuntu')