Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/499'
Browse files Browse the repository at this point in the history
* origin/pr/499:
  typo fix in a comment
  tests: verify if update.qubes-vm works
  • Loading branch information
marmarek committed Nov 28, 2022
2 parents 2c0fbdd + 1a385d6 commit 13a2e49
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions qubes/tests/integ/salt.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def test_001_multi_state_highstate(self):
'Full output: ' + state_output)
json_data = state_output[len(expected_output):]
# workaround for https://github.com/saltstack/salt/issues/60476
# (fixed upstream, but hasen't flowed into Fedora yet)
# (fixed upstream, but hasn't flowed into Fedora yet)
if "Setuptools is replacing distutils" in json_data:
json_data = "\n".join(
l for l in json_data.splitlines()
Expand Down Expand Up @@ -489,7 +489,7 @@ def test_002_grans_id(self):

for name, output in ((tplname, tpl_output), (vmname, appvm_output)):
# workaround for https://github.com/saltstack/salt/issues/60476
# (fixed upstream, but hasen't flowed into Fedora yet)
# (fixed upstream, but hasn't flowed into Fedora yet)
if "Setuptools is replacing distutils" in output:
output = "\n".join(
l for l in output.splitlines()
Expand All @@ -507,6 +507,37 @@ def test_002_grans_id(self):
self.assertTrue(state_output_single['result'])
self.assertNotEqual(state_output_single['changes'], {})

def test_003_update(self):
vmname = self.make_vm_name('target')
self.vm = self.app.add_new_vm('AppVM', name=vmname, label='red')
self.loop.run_until_complete(self.vm.create_on_disk())
# start the VM manually, so it stays running after applying salt state
self.loop.run_until_complete(self.vm.start())
state_output = self.salt_call(
['--skip-dom0', '--show-output', '--targets=' + vmname,
'state.sls', 'update.qubes-vm'])
expected_output = vmname + ':\n'
self.assertTrue(state_output.startswith(expected_output),
'Full output: ' + state_output)
json_data = state_output[len(expected_output):]
# workaround for https://github.com/saltstack/salt/issues/60476
# (fixed upstream, but hasn't flowed into Fedora yet)
if "Setuptools is replacing distutils" in json_data:
json_data = "\n".join(
l for l in json_data.splitlines()
if "Setuptools is replacing distutils" not in l)
try:
state_output_json = json.loads(json_data)
except json.decoder.JSONDecodeError as e:
self.fail('{}: {}'.format(e, json_data))
self.assertIn(vmname, state_output_json)
self.assertNotEqual(state_output_json[vmname], {})
for state, result in state_output_json[vmname].items():
self.assertTrue(
result['result'],
"State {} failed: {!r}".format(state, result))


def create_testcases_for_templates():
return qubes.tests.create_testcases_for_templates('TC_10_VMSalt',
SaltVMTestMixin, qubes.tests.SystemTestCase,
Expand Down

0 comments on commit 13a2e49

Please sign in to comment.