
* Remove the dead code; * Rework the test types; * Restore the instance connectivity check; * Rework the clustering test to support the new node addition workflow; * Check whether a machine where MicroStack is installed has hardware virtualization capabilities for different architectures. If not, use software emulation; * the host model is used with KVM since the default QEMU CPU models on x86_64 are subject to vulnerabilities without certain CPU-specific features. This conflicts with being able to use live migration reliably across hosts with different CPUs. * Add a default-source-ip init argument to allow controlling the source IP of the installation host that will be used as a control ip or compute ip locally. * used in the clustering test so that the local host IP on the multipass network is used as a control IP instead of the IP through which the default gateway is available; * the IP through which the default gateway is accessible is used as a fallback for default-source-ip; * Given upstream CI has a low amount of resources allocated per machine use LXD to set up a dummy compute node; * Set RLIMIT_MEMLOCK to 'unlimited' in the LXD container profile (see the discussion in LP: #1906280); * set remember_owner to 0 in qemu.conf for libvirt to avoid the uses of XATTRS (the root user is used anyway so there is no need to remember a file owner), otherwise libvirt errors out in an unprivileged LXD container. * Use numeric versions of OpenStack packages in the python-packages section of the openstack-projects part since the resolver change in recent versions of pip disallows for constraints dependencies of packages that come from a URL or a path. https://github.com/pypa/pip/issues/8210 * The newest released version of pip is always used during builds since snapcraft uses venv to set up virtual environments and the ensurepip package is invoked such that a pip version shipped with the distro version of python is upgraded: https://github.com/python/cpython/blob/3.8/Lib/venv/__init__.py#L282-L289 cmd = [context.env_exe, '-Im', 'ensurepip', '--upgrade', '--default-pip'] * Environment variables are ignored when pip is installed in the venv: https://docs.python.org/3/using/cmdline.html#id2 (-I option) So there is no way to use the old pip version resolver. Minor clustering client and add-compute changes: * use stderr for diagnostic messages; * use stdout to output the connection string so that it can be easily picked up by CLI tools without parsing. Change-Id: I5cb3872c5d142c34da2c8b073652c67021d9ef55
107 lines
3.3 KiB
Python
Executable File
107 lines
3.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
"""
|
|
basic_test.py
|
|
|
|
This is a basic test of microstack functionality. We verify that:
|
|
|
|
1) We can install the snap.
|
|
2) We can launch a cirros image.
|
|
3) Horizon is running, and we can hit the landing page.
|
|
4) We can login to Horizon successfully.
|
|
|
|
The Horizon testing bits were are based on code generated by the Selinum
|
|
Web IDE.
|
|
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import unittest
|
|
|
|
sys.path.append(os.getcwd())
|
|
|
|
from tests.framework import Framework # noqa E402
|
|
|
|
|
|
class TestBasics(Framework):
|
|
|
|
def test_basics(self):
|
|
"""Basic test
|
|
|
|
Install microstack, and verify that we can launch a machine and
|
|
open the Horizon GUI.
|
|
|
|
"""
|
|
self._localhost.install_microstack(path='microstack_ussuri_amd64.snap')
|
|
self._localhost.init_microstack([
|
|
'--auto',
|
|
'--control',
|
|
'--setup-loop-based-cinder-lvm-backend',
|
|
'--loop-device-file-size=24'
|
|
])
|
|
endpoints = self._localhost.check_output(
|
|
['/snap/bin/microstack.openstack', 'endpoint', 'list']
|
|
).decode('utf-8')
|
|
|
|
control_ip = self._localhost.check_output(
|
|
['sudo', 'snap', 'get', 'microstack', 'config.network.control-ip'],
|
|
).decode('utf-8')
|
|
|
|
# Endpoints should contain the control IP.
|
|
self.assertTrue(control_ip in endpoints)
|
|
|
|
# Endpoints should not contain localhost
|
|
self.assertFalse("localhost" in endpoints)
|
|
|
|
# We should be able to launch an instance
|
|
instance_name = 'test-instance'
|
|
print("Testing microstack.launch ...")
|
|
self._localhost.check_output(
|
|
['/snap/bin/microstack.launch', 'cirros',
|
|
'--name', instance_name, '--retry']
|
|
)
|
|
self.verify_instance_networking(self._localhost, instance_name)
|
|
|
|
# The Horizon Dashboard should function
|
|
self.verify_gui(self._localhost)
|
|
|
|
# Verify that we can uninstall the snap cleanly, and that the
|
|
# ovs bridge goes away.
|
|
|
|
# Check to verify that our bridge is there.
|
|
self.assertTrue(
|
|
'br-ex' in self._localhost.check_output(
|
|
['ip', 'a']).decode('utf-8'))
|
|
|
|
self._localhost.setup_tempest_verifier()
|
|
# Make sure there are no verification failures in the report.
|
|
failures = self._localhost.run_verifications()
|
|
self.assertEqual(failures, 0, 'Verification tests had failure.')
|
|
|
|
# Try to remove the snap without sudo.
|
|
self.assertEqual(self._localhost.call([
|
|
'snap', 'remove', '--purge', 'microstack']), 1)
|
|
|
|
# Retry with sudo (should succeed).
|
|
self._localhost.check_call(
|
|
['sudo', 'snap', 'remove', '--purge', 'microstack'])
|
|
|
|
# Verify that MicroStack is gone.
|
|
self.assertEqual(self._localhost.call(
|
|
['snap', 'list', 'microstack']), 1)
|
|
|
|
# Verify that bridge is gone.
|
|
self.assertFalse(
|
|
'br-ex' in self._localhost.check_output(
|
|
['ip', 'a']).decode('utf-8'))
|
|
|
|
# We made it to the end. Set passed to True!
|
|
self.passed = True
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# Run our tests, ignoring deprecation warnings and warnings about
|
|
# unclosed sockets. (TODO: setup a selenium server so that we can
|
|
# move from PhantomJS, which is deprecated, to to Selenium headless.)
|
|
unittest.main(warnings='ignore')
|