tests: convert dom0 update test to core3 API
This commit is contained in:
parent
0307ec22f2
commit
fb74126e56
@ -25,9 +25,8 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
from qubes.qubes import QubesVmCollection
|
|
||||||
|
|
||||||
import qubes.qubes
|
import qubes
|
||||||
|
|
||||||
VM_PREFIX = "test-"
|
VM_PREFIX = "test-"
|
||||||
|
|
||||||
@ -100,15 +99,15 @@ enabled = 1
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TC_00_Dom0UpgradeMixin, self).setUp()
|
super(TC_00_Dom0UpgradeMixin, self).setUp()
|
||||||
self.updatevm = self.qc.add_new_vm(
|
self.init_default_template(self.template)
|
||||||
"QubesProxyVm",
|
self.updatevm = self.app.add_new_vm(
|
||||||
|
qubes.vm.appvm.AppVM,
|
||||||
name=self.make_vm_name("updatevm"),
|
name=self.make_vm_name("updatevm"),
|
||||||
template=self.qc.get_vm_by_name(self.template))
|
label='red'
|
||||||
self.updatevm.create_on_disk(verbose=False)
|
)
|
||||||
self.saved_updatevm = self.qc.get_updatevm_vm()
|
self.updatevm.create_on_disk()
|
||||||
self.qc.set_updatevm_vm(self.updatevm)
|
self.app.updatevm = self.updatevm
|
||||||
self.qc.save()
|
self.app.save()
|
||||||
self.qc.unlock_db()
|
|
||||||
subprocess.call(['sudo', 'rpm', '-e', self.pkg_name],
|
subprocess.call(['sudo', 'rpm', '-e', self.pkg_name],
|
||||||
stderr=open(os.devnull, 'w'))
|
stderr=open(os.devnull, 'w'))
|
||||||
subprocess.check_call(['sudo', 'rpm', '--import',
|
subprocess.check_call(['sudo', 'rpm', '--import',
|
||||||
@ -116,11 +115,6 @@ enabled = 1
|
|||||||
self.updatevm.start()
|
self.updatevm.start()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.qc.lock_db_for_writing()
|
|
||||||
self.qc.load()
|
|
||||||
|
|
||||||
self.qc.set_updatevm_vm(self.qc[self.saved_updatevm.qid])
|
|
||||||
self.qc.save()
|
|
||||||
super(TC_00_Dom0UpgradeMixin, self).tearDown()
|
super(TC_00_Dom0UpgradeMixin, self).tearDown()
|
||||||
|
|
||||||
subprocess.call(['sudo', 'rpm', '-e', self.pkg_name], stderr=open(
|
subprocess.call(['sudo', 'rpm', '-e', self.pkg_name], stderr=open(
|
||||||
@ -194,7 +188,7 @@ Test package
|
|||||||
|
|
||||||
logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt')
|
logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt')
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['sudo', 'qubes-dom0-update', '-y'] +
|
subprocess.check_call(['sudo', '-E', 'qubes-dom0-update', '-y'] +
|
||||||
self.dom0_update_common_opts,
|
self.dom0_update_common_opts,
|
||||||
stdout=open(logpath, 'w'),
|
stdout=open(logpath, 'w'),
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
@ -217,7 +211,7 @@ Test package
|
|||||||
|
|
||||||
logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt')
|
logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt')
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['sudo', 'qubes-dom0-update', '-y'] +
|
subprocess.check_call(['sudo', '-E', 'qubes-dom0-update', '-y'] +
|
||||||
self.dom0_update_common_opts + [
|
self.dom0_update_common_opts + [
|
||||||
self.pkg_name],
|
self.pkg_name],
|
||||||
stdout=open(logpath, 'w'),
|
stdout=open(logpath, 'w'),
|
||||||
@ -239,7 +233,7 @@ Test package
|
|||||||
|
|
||||||
logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt')
|
logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt')
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['sudo', 'qubes-dom0-update', '-y'] +
|
subprocess.check_call(['sudo', '-E', 'qubes-dom0-update', '-y'] +
|
||||||
self.dom0_update_common_opts + [
|
self.dom0_update_common_opts + [
|
||||||
self.pkg_name],
|
self.pkg_name],
|
||||||
stdout=open(logpath, 'w'),
|
stdout=open(logpath, 'w'),
|
||||||
@ -264,7 +258,7 @@ Test package
|
|||||||
|
|
||||||
logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt')
|
logpath = os.path.join(self.tmpdir, 'dom0-update-output.txt')
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(['sudo', 'qubes-dom0-update', '-y'] +
|
subprocess.check_call(['sudo', '-E', 'qubes-dom0-update', '-y'] +
|
||||||
self.dom0_update_common_opts +
|
self.dom0_update_common_opts +
|
||||||
[self.pkg_name],
|
[self.pkg_name],
|
||||||
stdout=open(logpath, 'w'),
|
stdout=open(logpath, 'w'),
|
||||||
@ -283,12 +277,9 @@ Test package
|
|||||||
|
|
||||||
def load_tests(loader, tests, pattern):
|
def load_tests(loader, tests, pattern):
|
||||||
try:
|
try:
|
||||||
qc = qubes.qubes.QubesVmCollection()
|
app = qubes.Qubes()
|
||||||
qc.lock_db_for_reading()
|
templates = [vm.name for vm in app.domains if
|
||||||
qc.load()
|
isinstance(vm, qubes.vm.templatevm.TemplateVM)]
|
||||||
qc.unlock_db()
|
|
||||||
templates = [vm.name for vm in qc.values() if
|
|
||||||
isinstance(vm, qubes.qubes.QubesTemplateVm)]
|
|
||||||
except OSError:
|
except OSError:
|
||||||
templates = []
|
templates = []
|
||||||
for template in templates:
|
for template in templates:
|
@ -269,6 +269,7 @@ fi
|
|||||||
%dir %{python_sitelib}/qubes/tests/int
|
%dir %{python_sitelib}/qubes/tests/int
|
||||||
%{python_sitelib}/qubes/tests/int/__init__.py*
|
%{python_sitelib}/qubes/tests/int/__init__.py*
|
||||||
%{python_sitelib}/qubes/tests/int/basic.py*
|
%{python_sitelib}/qubes/tests/int/basic.py*
|
||||||
|
%{python_sitelib}/qubes/tests/int/dom0_update.py*
|
||||||
|
|
||||||
%dir %{python_sitelib}/qubes/tests/int/tools
|
%dir %{python_sitelib}/qubes/tests/int/tools
|
||||||
%{python_sitelib}/qubes/tests/int/tools/__init__.py*
|
%{python_sitelib}/qubes/tests/int/tools/__init__.py*
|
||||||
|
Loading…
Reference in New Issue
Block a user