示例#1
0
    def test_control_node(self):

        print("Checking output of services ...")
        services = check_output(*self.PREFIX, 'systemctl', 'status',
                                'snap.microstack.*', '--no-page')

        print("services: @@@")
        print(services)

        self.assertFalse('nova-' in services)
        self.assertTrue('neutron-' in services)
        self.assertTrue('keystone-' in services)

        self.passed = True
示例#2
0
    def _refresh_from(self, refresh_from='beta'):
        """Refresh test

        Like the basic test, but we refresh first.

        """
        print("Installing and verfying {} ...".format(refresh_from))
        host = self.get_host()
        host.install(snap="microstack", channel=refresh_from)
        host.init()
        prefix = host.prefix

        check(*prefix, '/snap/bin/microstack.launch', 'cirros', '--name',
              'breakfast', '--retry')

        if 'multipass' in prefix:
            self.verify_instance_networking(host, 'breakfast')

        print("Upgrading ...")
        host.install()  # Install compiled snap
        # Should not need to re-init

        print("Verifying that refresh completed successfully ...")

        # Check our existing instance, starting it if necessary.
        if json.loads(
                check_output(*prefix, '/snap/bin/microstack.openstack',
                             'server', 'show', 'breakfast', '--format',
                             'json'))['status'] == 'SHUTOFF':
            print("Starting breakfast (TODO: auto start.)")
            check(*prefix, '/snap/bin/microstack.openstack', 'server', 'start',
                  'breakfast')

        # Launch another instance
        check(*prefix, '/snap/bin/microstack.launch', 'cirros', '--name',
              'lunch', '--retry')

        # Verify networking
        if 'multipass' in prefix:
            self.verify_instance_networking(host, 'breakfast')
            self.verify_instance_networking(host, 'lunch')

        # Verify GUI
        self.verify_gui(host)
示例#3
0
    def test_control_node(self):
        """A control node has all services running, so this shouldn't be any
        different than our standard setup.

        """

        host = self.get_host()
        host.install()
        host.init(['--control'])

        print("Checking output of services ...")
        services = check_output(*host.prefix, 'systemctl', 'status',
                                'snap.microstack.*', '--no-page')

        print("services: @@@")
        print(services)

        self.assertTrue('neutron-' in services)
        self.assertTrue('keystone-' in services)
        self.assertTrue('nova-' in services)

        self.passed = True
示例#4
0
    def test_basics(self):
        """Basic test

        Install microstack, and verify that we can launch a machine and
        open the Horizon GUI.

        """
        launch = '/snap/bin/microstack.launch'
        openstack = '/snap/bin/microstack.openstack'

        print("Testing microstack.launch ...")

        check(*self.PREFIX, launch, 'cirros', '--name', 'breakfast', '--retry')

        endpoints = check_output(*self.PREFIX,
                                 '/snap/bin/microstack.openstack', 'endpoint',
                                 'list')

        # Endpoints should be listening on 10.20.20.1
        self.assertTrue("10.20.20.1" in endpoints)

        # Endpoints should not contain localhost
        self.assertFalse("localhost" in endpoints)

        # Verify that microstack.launch completed successfully

        # Ping the instance
        ip = None
        servers = check_output(*self.PREFIX, openstack, 'server', 'list',
                               '--format', 'json')
        servers = json.loads(servers)
        for server in servers:
            if server['Name'] == 'breakfast':
                ip = server['Networks'].split(",")[1].strip()
                break

        self.assertTrue(ip)

        pings = 1
        max_pings = 600  # ~10 minutes!
        while not call(*self.PREFIX, 'ping', '-c1', '-w1', ip):
            pings += 1
            if pings > max_pings:
                self.assertFalse(True, msg='Max pings reached!')

        print("Testing instances' ability to connect to the Internet")
        # Test Internet connectivity
        attempts = 1
        max_attempts = 300  # ~10 minutes!
        username = check_output(*self.PREFIX, 'whoami')

        while not call(*self.PREFIX, 'ssh', '-oStrictHostKeyChecking=no', '-i',
                       '/home/{}/.ssh/id_microstack'.format(username),
                       'cirros@{}'.format(ip), '--', 'ping', '-c1',
                       '91.189.94.250'):
            attempts += 1
            if attempts > max_attempts:
                self.assertFalse(True, msg='Unable to access the Internet!')
            time.sleep(1)

        if 'multipass' in self.PREFIX:
            print("Opening {}:80 up to the outside world".format(
                self.HORIZON_IP))

            with open('/tmp/_10_hosts.py', 'w') as hosts:
                hosts.write("""\
# Allow all hosts to connect to this machine
ALLOWED_HOSTS = ['*',]
""")
            check('multipass', 'copy-files', '/tmp/_10_hosts.py',
                  '{}:/tmp/_10_hosts.py'.format(self.MACHINE))
            check(*self.PREFIX, 'sudo', 'cp', '/tmp/_10_hosts.py',
                  '/var/snap/microstack/common/etc/horizon/local_settings.d/')
            check(*self.PREFIX, 'sudo', 'snap', 'restart', 'microstack')

        print('Verifying GUI for (IP: {})'.format(self.HORIZON_IP))
        # Verify that our GUI is working properly
        self.driver.get("http://{}/".format(self.HORIZON_IP))
        # Login to horizon!
        self.driver.find_element(By.ID, "id_username").click()
        self.driver.find_element(By.ID, "id_username").send_keys("admin")
        self.driver.find_element(By.ID, "id_password").send_keys("keystone")
        self.driver.find_element(By.CSS_SELECTOR, "#loginBtn > span").click()
        # Verify that we can click something on the dashboard -- e.g.,
        # we're still not sitting at the login screen.
        self.driver.find_element(By.LINK_TEXT, "Images").click()

        self.passed = True
示例#5
0
    def test_basics(self):
        """Basic test

        Install microstack, and verify that we can launch a machine and
        open the Horizon GUI.

        """
        host = self.get_host()
        host.install()
        host.init([
            '--auto', '--control', '--setup-loop-based-cinder-lvm-backend',
            '--loop-device-file-size=24'
        ])
        prefix = host.prefix

        endpoints = check_output(*prefix, '/snap/bin/microstack.openstack',
                                 'endpoint', 'list')

        control_ip = check_output(*prefix, 'sudo', 'snap', 'get', 'microstack',
                                  'config.network.control-ip')
        # 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
        print("Testing microstack.launch ...")
        check(*prefix, '/snap/bin/microstack.launch', 'cirros', '--name',
              'breakfast', '--retry')

        # ... and ping it
        # Skip these tests in the gate, as they are not reliable there.
        # TODO: fix these in the gate!
        if 'multipass' in prefix:
            self.verify_instance_networking(host, 'breakfast')
        else:
            # Artificial wait, to allow for stuff to settle for the GUI test.
            # TODO: get rid of this, when we drop the ping tests back int.
            time.sleep(10)

        # The Horizon Dashboard should function
        self.verify_gui(host)

        # 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 check_output(*prefix, 'ip', 'a'))

        check(*prefix, 'sudo', 'mkdir', '-p', '/tmp/snap.microstack-test/tmp')
        check(*prefix, 'sudo', 'cp',
              '/var/snap/microstack/common/etc/microstack.json',
              '/tmp/snap.microstack-test/tmp/microstack.json')
        check(*prefix, 'microstack-test.rally', 'db', 'recreate')
        check(*prefix, 'microstack-test.rally', 'deployment', 'create',
              '--filename', '/tmp/microstack.json', '--name', 'snap_generated')
        check(*prefix, 'microstack-test.tempest-init')
        check(*prefix, 'microstack-test.rally', 'verify', 'start',
              '--load-list',
              '/snap/microstack-test/current/2020.06-test-list.txt',
              '--detailed', '--concurrency', '2')
        check(*prefix, 'microstack-test.rally', 'verify', 'report', '--type',
              'json', '--to', '/tmp/verification-report.json')
        report = json.loads(
            check_output(
                *prefix, 'sudo', 'cat',
                '/tmp/snap.microstack-test/tmp/verification-report.json'))
        # Make sure there are no verification failures in the report.
        failures = list(report['verifications'].values())[0]['failures']
        self.assertEqual(failures, 0, 'Verification tests had failure.')

        # Try to remove the snap without sudo.
        self.assertFalse(
            call(*prefix, 'snap', 'remove', '--purge', 'microstack'))

        # Retry with sudo (should succeed).
        check(*prefix, 'sudo', 'snap', 'remove', '--purge', 'microstack')

        # Verify that MicroStack is gone.
        self.assertFalse(call(*prefix, 'snap', 'list', 'microstack'))

        # Verify that bridge is gone.
        self.assertFalse('br-ex' in check_output(*prefix, 'ip', 'a'))

        # We made it to the end. Set passed to True!
        self.passed = True
示例#6
0
    def test_cluster(self):

        # After the setUp step, we should have a control node running
        # in a multipass vm. Let's look up its cluster password and ip
        # address.

        openstack = '/snap/bin/microstack.openstack'
        control_host = self.get_host()
        control_host.install()
        control_host.init(['--control'])

        control_prefix = control_host.prefix
        cluster_password = check_output(*control_prefix, 'sudo', 'snap',
                                        'get', 'microstack',
                                        'config.cluster.password')
        control_ip = check_output(*control_prefix, 'sudo', 'snap',
                                  'get', 'microstack',
                                  'config.network.control-ip')

        self.assertTrue(cluster_password)
        self.assertTrue(control_ip)

        compute_host = self.add_host()
        compute_host.install()

        compute_machine = compute_host.machine
        compute_prefix = compute_host.prefix

        # TODO add the following to args for init
        check(*compute_prefix, 'sudo', 'snap', 'set', 'microstack',
              'config.network.control-ip={}'.format(control_ip))

        check(*compute_prefix, 'sudo', 'microstack.init', '--compute',
              '--cluster-password', cluster_password, '--debug')

        # Verify that our services look setup properly on compute node.
        services = check_output(
            *compute_prefix, 'systemctl', 'status', 'snap.microstack.*',
            '--no-page')

        self.assertTrue('nova-compute' in services)
        self.assertFalse('keystone-' in services)

        check(*compute_prefix, '/snap/bin/microstack.launch', 'cirros',
              '--name', 'breakfast', '--retry',
              '--availability-zone', 'nova:{}'.format(compute_machine))

        # TODO: verify horizon dashboard on control node.

        # Verify endpoints
        compute_ip = check_output(*compute_prefix, 'sudo', 'snap',
                                  'get', 'microstack',
                                  'config.network.compute-ip')
        self.assertFalse(compute_ip == control_ip)

        # Ping the instance
        ip = None
        servers = check_output(*compute_prefix, openstack,
                               'server', 'list', '--format', 'json')
        servers = json.loads(servers)
        for server in servers:
            if server['Name'] == 'breakfast':
                ip = server['Networks'].split(",")[1].strip()
                break

        self.assertTrue(ip)

        pings = 1
        max_pings = 60  # ~1 minutes
        # Ping the machine from the control node (we don't have
        # networking wired up for the other nodes).
        while not call(*control_prefix, 'ping', '-c1', '-w1', ip):
            pings += 1
            if pings > max_pings:
                self.assertFalse(
                    True,
                    msg='Max pings reached for instance on {}!'.format(
                        compute_machine))

        self.passed = True

        # Compute machine cleanup
        check('sudo', 'multipass', 'delete', compute_machine)