Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/440'
Browse files Browse the repository at this point in the history
* origin/pr/440:
  tests: spurious double DispVM startup
  • Loading branch information
marmarek committed Feb 5, 2022
2 parents bc8747e + 251d8aa commit 80c94cd
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions qubes/tests/integ/dispvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def setUp(self):
)
self.loop.run_until_complete(self.testvm.create_on_disk())
self.app.save()
# used in test_01x
self.startup_counter = 0

def tearDown(self):
self.app.default_dispvm = None
Expand Down Expand Up @@ -108,6 +110,54 @@ def test_003_cleanup_destroyed(self):

self.assertNotIn(dispvm_name, self.app.domains)

def _count_dispvms(self, *args, **kwargs):
self.startup_counter += 1

def test_010_failed_start(self):
"""
Check if DispVM doesn't (attempt to) start twice.
:return:
"""
self.app.add_handler('domain-add', self._count_dispvms)
self.addCleanup(
self.app.remove_handler, 'domain-add', self._count_dispvms)

# make it fail to start
self.app.default_dispvm.memory = self.app.host.memory_total * 2

self.loop.run_until_complete(self.testvm.start())

p = self.loop.run_until_complete(
self.testvm.run("qvm-run-vm --dispvm true",
stdin=subprocess.PIPE, stdout=subprocess.PIPE))
timeout = 120
self.loop.run_until_complete(asyncio.wait_for(p.communicate(), timeout))
self.assertEqual(p.returncode, 126)
self.assertEqual(self.startup_counter, 1)

def test_011_failed_start_timeout(self):
"""
Check if DispVM doesn't (attempt to) start twice.
:return:
"""
self.app.add_handler('domain-add', self._count_dispvms)
self.addCleanup(
self.app.remove_handler, 'domain-add', self._count_dispvms)

# make it fail to start (timeout)
self.app.default_dispvm.qrexec_timeout = 3

self.loop.run_until_complete(self.testvm.start())

p = self.loop.run_until_complete(
self.testvm.run("qvm-run-vm --dispvm true",
stdin=subprocess.PIPE, stdout=subprocess.PIPE))
timeout = 120
self.loop.run_until_complete(asyncio.wait_for(p.communicate(), timeout))
self.assertEqual(p.returncode, 126)
self.assertEqual(self.startup_counter, 1)


class TC_20_DispVMMixin(object):

def setUp(self):
Expand Down

0 comments on commit 80c94cd

Please sign in to comment.