OpenStack in a snap!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.0 KiB

#!/usr/bin/env python
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 argparse
import os
import sys
import unittest
from tests.framework import Framework # noqa E402
class TestBasics(Framework):
snap_try = False
use_lvm = False
def test_basics(self):
"""Basic test
Install microstack, and verify that we can launch a machine and
open the Horizon GUI.
init_args = ['--auto', '--control']
if self.use_lvm:
endpoints = self._localhost.check_output(
['/snap/bin/microstack.openstack', 'endpoint', 'list']
control_ip = self._localhost.check_output(
['sudo', 'snap', 'get', 'microstack', ''],
# 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 ...")
['/snap/bin/microstack.launch', 'cirros',
'--name', instance_name, '--retry']
self.verify_instance_networking(self._localhost, instance_name)
# The Horizon Dashboard should function
# Verify that we can uninstall the snap cleanly, and that the
# ovs bridge goes away.
# Check to verify that our bridge is there.
'br-ex' in self._localhost.check_output(
['ip', 'a']).decode('utf-8'))
# Make sure there are no verification failures in the report.
failures = self._localhost.run_verifications(self.use_lvm)
self.assertEqual(failures, 0, 'Verification tests had failure.')
# Try to remove the snap without sudo.
'snap', 'remove', '--purge', 'microstack']), 1)
# Retry with sudo (should succeed).
['sudo', 'snap', 'remove', '--purge', 'microstack'])
# Verify that MicroStack is gone.
['snap', 'list', 'microstack']), 1)
# Verify that bridge is gone.
'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__':
parser = argparse.ArgumentParser()
parser.add_argument("--snap-try", help="Install snap as rw mount from "
"squashfs-root directory", action='store_true')
parser.add_argument("--use-lvm", help="Init snap with experimental lvm "
"support", action='store_true')
parser.add_argument('unittest_args', nargs='*')
args = parser.parse_args()
TestBasics.snap_try = args.snap_try
TestBasics.use_lvm = args.use_lvm
sys.argv[1:] = args.unittest_args
# 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.)