Skip to content

Commit

Permalink
tests: allow testing minimal template as salt target...
Browse files Browse the repository at this point in the history
... using another template for management dvm. That other template can
be selected with QUBES_TEST_MGMT_TPL variable.

For this to fully work, test updating a template instead of AppVM, as it
will use updates proxy which should work with minimal template (contrary
to direct network access).
  • Loading branch information
marmarek committed Nov 30, 2024
1 parent 52d60e6 commit 3f4f65e
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions qubes/tests/integ/salt.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,28 @@ def setUp(self):
super(SaltVMTestMixin, self).setUp()
self.init_default_template(self.template)

mgmt_tpl = self.app.domains[self.template]
if "minimal" in self.template:
# minimal template doesn't support being mgmt vm, but still test
# it being a target
mgmt_tpl = os.environ.get("QUBES_TEST_MGMT_TPL")
if not mgmt_tpl:
mgmt_tpl = str(self.host_app.default_template)
print(
f"Using {mgmt_tpl} template for mgmt vm when testing "
f"minimal template as target. You can set "
f"QUBES_TEST_MGMT_TPL env variable to use "
f"different template for mgmt vm"
)
mgmt_tpl = self.app.domains[mgmt_tpl]

dispvm_tpl_name = self.make_vm_name("disp-tpl")
dispvm_tpl = self.app.add_new_vm(
"AppVM",
label="red",
template_for_dispvms=True,
name=dispvm_tpl_name,
template=mgmt_tpl,
)
self.loop.run_until_complete(dispvm_tpl.create_on_disk())
self.app.default_dispvm = dispvm_tpl
Expand Down Expand Up @@ -611,8 +627,10 @@ def test_002_grains_id(self):

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())
self.vm = self.app.add_new_vm("TemplateVM", name=vmname, label="red")
self.loop.run_until_complete(
self.vm.clone_disk_files(self.app.default_template)
)
# 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(
Expand Down

0 comments on commit 3f4f65e

Please sign in to comment.