tests: utils: Move all URI strings to URIs object

Non-functional change, just makes code org nicer
This commit is contained in:
Cole Robinson 2018-06-12 11:48:11 -04:00
parent e0e6ac6956
commit d68305eaab
5 changed files with 73 additions and 70 deletions

View File

@ -55,23 +55,22 @@ new_files = new_images
clean_files = (new_images + exist_images)
test_files = {
'URI-TEST': utils.uri_test,
'URI-TEST-FULL': utils.uri_test_full,
'URI-TEST-SUITE': utils.uri_test_suite,
'URI-TEST-REMOTE': utils.uri_test_remote,
'URI-KVM': utils.uri_kvm,
'URI-KVM-Q35': utils.uri_kvm_q35,
'URI-KVM-SESSION': utils.uri_kvm_session,
'URI-KVM-REMOTE': utils.uri_kvm + ",remote",
'URI-KVM-NODOMCAPS': utils.uri_kvm_nodomcaps,
'URI-KVM-ARMV7L': utils.uri_kvm_armv7l,
'URI-KVM-AARCH64': utils.uri_kvm_aarch64,
'URI-KVM-PPC64LE': utils.uri_kvm_ppc64le,
'URI-KVM-S390X': utils.uri_kvm_s390x,
'URI-KVM-S390X-KVMIBM': utils.uri_kvm_s390x_KVMIBM,
'URI-XEN': utils.uri_xen,
'URI-LXC': utils.uri_lxc,
'URI-VZ': utils.uri_vz,
'URI-TEST-FULL': utils.URIs.test_full,
'URI-TEST-SUITE': utils.URIs.test_suite,
'URI-TEST-REMOTE': utils.URIs.test_remote,
'URI-KVM': utils.URIs.kvm,
'URI-KVM-Q35': utils.URIs.kvm_q35,
'URI-KVM-SESSION': utils.URIs.kvm_session,
'URI-KVM-REMOTE': utils.URIs.kvm + ",remote",
'URI-KVM-NODOMCAPS': utils.URIs.kvm_nodomcaps,
'URI-KVM-ARMV7L': utils.URIs.kvm_armv7l,
'URI-KVM-AARCH64': utils.URIs.kvm_aarch64,
'URI-KVM-PPC64LE': utils.URIs.kvm_ppc64le,
'URI-KVM-S390X': utils.URIs.kvm_s390x,
'URI-KVM-S390X-KVMIBM': utils.URIs.kvm_s390x_KVMIBM,
'URI-XEN': utils.URIs.xen,
'URI-LXC': utils.URIs.lxc,
'URI-VZ': utils.URIs.vz,
'CLONE_DISK_XML': "%s/clone-disk.xml" % xmldir,
'CLONE_STORAGE_XML': "%s/clone-disk-managed.xml" % xmldir,

View File

@ -425,7 +425,7 @@ class AddHardware(uiutils.UITestCase):
"""
Adding LXC specific filesystems
"""
self.app.uri = tests.utils.uri_lxc
self.app.uri = tests.utils.URIs.lxc
details = self._open_details_window()
addhw = self._open_addhw_window(details)

View File

@ -136,7 +136,7 @@ class NewVM(uiutils.UITestCase):
New VM with URL and distro detection, plus having fun with
the storage browser and network selection.
"""
self.app.uri = tests.utils.uri_kvm
self.app.uri = tests.utils.URIs.kvm
newvm = self._open_create_wizard()
newvm.find_fuzzy("Network Install", "radio").click()
@ -167,7 +167,7 @@ class NewVM(uiutils.UITestCase):
"""
New PPC64 VM to test architecture selection
"""
self.app.uri = tests.utils.uri_kvm
self.app.uri = tests.utils.URIs.kvm
newvm = self._open_create_wizard()
newvm.find_fuzzy("Architecture options", "toggle").click()
@ -185,7 +185,7 @@ class NewVM(uiutils.UITestCase):
"""
New arm VM that requires kernel/initrd/dtb
"""
self.app.uri = tests.utils.uri_kvm_armv7l
self.app.uri = tests.utils.URIs.kvm_armv7l
newvm = self._open_create_wizard()
newvm.find_fuzzy("Architecture options", "toggle").click()
@ -234,7 +234,7 @@ class NewVM(uiutils.UITestCase):
"""
Simple LXC app install
"""
self.app.uri = tests.utils.uri_lxc
self.app.uri = tests.utils.URIs.lxc
newvm = self._open_create_wizard()
newvm.find_fuzzy("Application", "radio").click()
@ -256,7 +256,7 @@ class NewVM(uiutils.UITestCase):
"""
Simple LXC tree install
"""
self.app.uri = tests.utils.uri_lxc
self.app.uri = tests.utils.URIs.lxc
newvm = self._open_create_wizard()
newvm.find_fuzzy("Operating system", "radio").click()
@ -278,7 +278,7 @@ class NewVM(uiutils.UITestCase):
"""
Virtuozzo container install
"""
self.app.uri = tests.utils.uri_vz
self.app.uri = tests.utils.URIs.vz
newvm = self._open_create_wizard()
newvm.find_fuzzy("Container", "radio").click()
@ -299,7 +299,7 @@ class NewVM(uiutils.UITestCase):
"""
Test the create wizard with a fake xen PV install
"""
self.app.uri = tests.utils.uri_xen
self.app.uri = tests.utils.URIs.xen
newvm = self._open_create_wizard()
newvm.find_fuzzy("Architecture options", "toggle").click()

View File

@ -21,7 +21,7 @@ class UITestCase(unittest.TestCase):
Common testcase bits shared for ui tests
"""
def setUp(self):
self.app = VMMDogtailApp(tests.utils.uri_test)
self.app = VMMDogtailApp(tests.utils.URIs.test_full)
def tearDown(self):
self.app.stop()

View File

@ -29,44 +29,6 @@ class _CLIState(object):
clistate = _CLIState()
_capsprefix = ",caps=%s/tests/capabilities-xml/" % os.getcwd()
_domcapsprefix = ",domcaps=%s/tests/capabilities-xml/" % os.getcwd()
uri_test_default = "__virtinst_test__test:///default,predictable"
uri_test_full = "__virtinst_test__test:///%s/tests/testdriver.xml,predictable" % os.getcwd()
uri_test_suite = "__virtinst_test__test:///%s/tests/testsuite.xml,predictable" % os.getcwd()
uri_test = uri_test_full
uri_test_remote = uri_test + ",remote"
_uri_qemu = "%s,qemu" % uri_test
_uri_kvm_domcaps = (_uri_qemu + _domcapsprefix + "kvm-x86_64-domcaps.xml")
_uri_kvm_domcaps_q35 = (_uri_qemu + _domcapsprefix + "kvm-x86_64-domcaps-q35.xml")
_uri_kvm_aarch64_domcaps = (_uri_qemu + _domcapsprefix + "kvm-aarch64-domcaps.xml")
uri_kvm_nodomcaps = (_uri_qemu + _capsprefix + "kvm-x86_64.xml")
uri_kvm_rhel = (_uri_kvm_domcaps + _capsprefix + "kvm-x86_64-rhel7.xml")
uri_kvm = (_uri_kvm_domcaps + _capsprefix + "kvm-x86_64.xml")
uri_kvm_q35 = (_uri_kvm_domcaps_q35 + _capsprefix + "kvm-x86_64.xml")
uri_kvm_session = uri_kvm + ",session"
uri_kvm_armv7l = (_uri_kvm_domcaps + _capsprefix + "kvm-armv7l.xml")
uri_kvm_aarch64 = (_uri_kvm_aarch64_domcaps + _capsprefix + "kvm-aarch64.xml")
uri_kvm_ppc64le = (_uri_kvm_domcaps + _capsprefix + "kvm-ppc64le.xml")
uri_kvm_s390x = (_uri_kvm_domcaps + _capsprefix + "kvm-s390x.xml")
uri_kvm_s390x_KVMIBM = (_uri_kvm_domcaps + _capsprefix + "kvm-s390x-KVMIBM.xml")
uri_xen = uri_test + _capsprefix + "xen-rhel5.4.xml,xen"
uri_lxc = uri_test + _capsprefix + "lxc.xml,lxc"
uri_vz = uri_test + _capsprefix + "vz.xml,vz"
def _make_uri(base, connver=None, libver=None):
if connver:
base += ",connver=%s" % connver
if libver:
base += ",libver=%s" % libver
return base
class _URIs(object):
def __init__(self):
self._conn_cache = {}
@ -74,6 +36,41 @@ class _URIs(object):
self._testdriver_error = None
self._testdriver_default = None
_capspath = "%s/tests/capabilities-xml/" % os.getcwd()
def _domcaps(path):
return ",domcaps=" + _capspath + path
def _caps(path):
return ",caps=" + _capspath + path
_testtmpl = "__virtinst_test__test://%s,predictable"
self.test_default = _testtmpl % "/default"
self.test_full = _testtmpl % (os.getcwd() + "/tests/testdriver.xml")
self.test_suite = _testtmpl % (os.getcwd() + "/tests/testsuite.xml")
self.test_remote = self.test_full + ",remote"
self.xen = self.test_full + _caps("xen-rhel5.4.xml") + ",xen"
self.lxc = self.test_full + _caps("lxc.xml") + ",lxc"
self.vz = self.test_full + _caps("vz.xml") + ",vz"
_uri_qemu = "%s,qemu" % self.test_full
_uri_kvm = _uri_qemu + _domcaps("kvm-x86_64-domcaps.xml")
_uri_kvm_q35 = _uri_qemu + _domcaps("kvm-x86_64-domcaps-q35.xml")
_uri_kvm_aarch64 = _uri_qemu + _domcaps("kvm-aarch64-domcaps.xml")
self.kvm = _uri_kvm + _caps("kvm-x86_64.xml")
self.kvm_nodomcaps = _uri_qemu + _caps("kvm-x86_64.xml")
self.kvm_rhel = _uri_kvm + _caps("kvm-x86_64-rhel7.xml")
self.kvm_q35 = _uri_kvm_q35 + _caps("kvm-x86_64.xml")
self.kvm_session = self.kvm + ",session"
self.kvm_armv7l = _uri_kvm + _caps("kvm-armv7l.xml")
self.kvm_aarch64 = _uri_kvm_aarch64 + _caps("kvm-aarch64.xml")
self.kvm_ppc64le = _uri_kvm + _caps("kvm-ppc64le.xml")
self.kvm_s390x = _uri_kvm + _caps("kvm-s390x.xml")
self.kvm_s390x_KVMIBM = _uri_kvm + _caps("kvm-s390x-KVMIBM.xml")
def openconn(self, uri):
"""
Extra super caching to speed up the test suite. We basically
@ -104,7 +101,7 @@ class _URIs(object):
# For the basic test:///default URI, skip this caching, so we have
# an option to test the stock code
if uri == uri_test_default:
if uri == self.test_default:
return conn
if uri not in self._conn_cache:
@ -143,20 +140,27 @@ class _URIs(object):
state doesn't become polluted.
"""
if not self._testdriver_cache:
self._testdriver_cache = self.openconn(uri_test)
self._testdriver_cache = self.openconn(self.test_full)
return self._testdriver_cache
def open_testdefault_cached(self):
if not self._testdriver_default:
self._testdriver_default = self.openconn(uri_test_default)
self._testdriver_default = self.openconn(self.test_default)
return self._testdriver_default
def _make_uri(self, base, connver=None, libver=None):
if connver:
base += ",connver=%s" % connver
if libver:
base += ",libver=%s" % libver
return base
def open_kvm(self, connver=None, libver=None):
return self.openconn(_make_uri(uri_kvm, connver, libver))
return self.openconn(self._make_uri(self.kvm, connver, libver))
def open_kvm_rhel(self, connver=None):
return self.openconn(_make_uri(uri_kvm_rhel, connver))
return self.openconn(self._make_uri(self.kvm_rhel, connver))
def open_test_remote(self):
return self.openconn(uri_test_remote)
return self.openconn(self.test_remote)
URIs = _URIs()