Esempio n. 1
0
    def test_heat_component(self, ccpcluster, k8s_actions, rally):
        """Heat pre-commit test
        Scenario:
        1. Fetch all repos
        2. Update heat source form local path
        3. Build images
        4. Deploy openstack
        5. check jobs are ready
        6. Check ppods are ready
        7. Run heat tests
        Duration 60 min
        """
        if settings.REGISTRY == '127.0.0.1:31500':
            LOG.info('Create registry')
            k8s_actions.create_registry()
            LOG.info('Fetch repositories...')
            ccpcluster.fetch()
            LOG.info('Update service...')
            ccpcluster.update_service('heat')
            LOG.info('Build images')
            ccpcluster.build('base-tools', suppress_output=False)
            ccpcluster.build(suppress_output=False)

        LOG.info('Deploy services')
        ccpcluster.deploy()
        LOG.info('Check jobs are ready')
        rally.prepare()
        rally.pull_image()
        rally.run()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api)
        LOG.info('Check pods are running')
        post_os_deploy_checks.check_pods_status(k8s_actions.api)

        rally.run_tempest('--regex tempest.api.orchestration')
Esempio n. 2
0
    def test_deploy_os_with_custom_sahara(self, ccpcluster, k8s_actions,
                                          underlay, rally):
        """
        Scenario:
            1. Install k8s
            2. Install fuel-ccp
            3. Fetch all repositories
            4. Fetch sahara from review
            5. Fetch containers from external registry
            6. Build sahara container
            7. Deploy Openstack
            8. Run tempest

        """

        if settings.REGISTRY == '127.0.0.1:31500':
            k8s_actions.create_registry()
            ccpcluster.fetch()
            ccpcluster.update_service('sahara')
            ccpcluster.build('base-tools', suppress_output=False)
            ccpcluster.build(suppress_output=False)

        ccpcluster.deploy()
        rally.prepare()
        rally.pull_image()
        rally.run()

        post_os_deploy_checks.check_jobs_status(k8s_actions.api,
                                                timeout=1500,
                                                namespace='ccp')
        post_os_deploy_checks.check_pods_status(k8s_actions.api,
                                                timeout=2500,
                                                namespace='ccp')
        rally.run_tempest('--regex ^tempest.api.data_processing.*')
Esempio n. 3
0
    def test_deploy_os_with_custom_keystone(
            self, ccpcluster, k8s_actions, underlay, rally):
        """
        Scenario:
            1. Install k8s
            2. Install fuel-ccp
            3. Fetch all repositories
            4. Fetch keystone from review
            5. Fetch containers from external registry
            6. Build keystone container
            7. Deploy Openstack
            8. Run tempest

        """
        if settings.REGISTRY == '127.0.0.1:31500':
            k8s_actions.create_registry()
            ccpcluster.fetch()
            ccpcluster.update_service('keystone')
            ccpcluster.build('base-tools', suppress_output=False)
            ccpcluster.build(suppress_output=False)

        ccpcluster.deploy()
        rally.prepare()
        rally.pull_image()
        rally.run()

        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=1500,
                                                namespace='ccp')
        post_os_deploy_checks.check_pods_status(k8s_actions.api, timeout=2500,
                                                namespace='ccp')
        rally.run_tempest('--regex ^tempest.api.identity.*')
Esempio n. 4
0
def test_deploy_and_reconfig_keystone(config, ccpcluster,
                                      k8s_actions, underlay):

    ccpcluster.deploy()
    post_os_deploy_checks.check_jobs_status(k8s_actions.api)
    post_os_deploy_checks.check_pods_status(k8s_actions.api)

    remote = underlay.remote(host=config.k8s.kube_host)
    remote.execute('virtualenv ~/venv && '
                   'source ~/venv/bin/activate && '
                   'pip install python-openstackclient')
    res = remote.execute('source ~/venv/bin/activate ; '
                         'source ~/openrc-ccp; openstack user list -f json')
    LOG.debug("List of users {}".format(res.stdout_str))
    users1 = json.loads(res.stdout_str)
    remote.execute(
        "echo 'keystone__public_port: 5001' >> {deploy_config}".format(
            deploy_config=settings.DEPLOY_CONFIG))
    ccpcluster.deploy('keystone')
    post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2500)
    post_os_deploy_checks.check_pods_status(k8s_actions.api)

    res = remote.execute('source ~/venv/bin/activate ;'
                         'source ~/openrc-ccp; openstack user list -f json')
    LOG.debug("List of users {}".format(res.stdout_str))
    users2 = json.loads(res.stdout_str)

    remote.close()
    assert users1 == users2
Esempio n. 5
0
    def test_deploy_os_with_custom_nova(
            self, ccpcluster, k8s_actions, rally):
        """
        Scenario:
            1. Install k8s
            2. Install fuel-ccp
            3. Fetch repos
            4. Upload repo with changes
            5. Build components
            6. Deploy components
            7. Run compute tempest suite

        """
        if settings.REGISTRY == '127.0.0.1:31500':
            k8s_actions.create_registry()
            ccpcluster.fetch()
            ccpcluster.update_service('nova')
            ccpcluster.build(suppress_output=False)

        ccpcluster.deploy()
        rally.prepare()
        rally.pull_image()
        rally.run()

        post_os_deploy_checks.check_jobs_status(k8s_actions.api)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        rally.run_tempest('--regex  tempest.api.compute')
Esempio n. 6
0
def test_deploy_and_reconfig_keystone(config, ccpcluster, k8s_actions,
                                      underlay):

    ccpcluster.deploy()
    post_os_deploy_checks.check_jobs_status(k8s_actions.api)
    post_os_deploy_checks.check_pods_status(k8s_actions.api)

    remote = underlay.remote(host=config.k8s.kube_host)
    remote.execute('virtualenv ~/venv && '
                   'source ~/venv/bin/activate && '
                   'pip install python-openstackclient')
    res = remote.execute('source ~/venv/bin/activate ; '
                         'source ~/openrc-ccp; openstack user list -f json')
    LOG.debug("List of users {}".format(res.stdout_str))
    users1 = json.loads(res.stdout_str)
    remote.execute(
        "echo 'keystone__public_port: 5001' >> {deploy_config}".format(
            deploy_config=settings.DEPLOY_CONFIG))
    ccpcluster.deploy('keystone')
    post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2500)
    post_os_deploy_checks.check_pods_status(k8s_actions.api)

    res = remote.execute('source ~/venv/bin/activate ;'
                         'source ~/openrc-ccp; openstack user list -f json')
    LOG.debug("List of users {}".format(res.stdout_str))
    users2 = json.loads(res.stdout_str)

    remote.close()
    assert users1 == users2
Esempio n. 7
0
    def test_fuel_ccp_deploy_microservices(
            self, underlay, config, ccpcluster, k8s_actions):
        """Deploy base environment

        Scenario:
        1. Revert snapshot
        2. Install microservices
        3. Deploy environment
        4. Check deployment

        Duration 35 min
        """
        if settings.REGISTRY == "127.0.0.1:31500":
            k8s_actions.create_registry()
            ccpcluster.build()

        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)

        remote = underlay.remote(host=config.k8s.kube_host)
        underlay.sudo_check_call("pip install python-openstackclient",
                                 host=config.k8s.kube_host)
        remote.check_call(
            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -k {0}"
            " -a create".format(
                settings.CCP_CONF["kubernetes"]["namespace"]),
            timeout=600)
Esempio n. 8
0
    def test_fuel_ccp_deploy_microservices(self, underlay, config, ccpcluster,
                                           k8s_actions):
        """Deploy base environment

        Scenario:
        1. Revert snapshot
        2. Install microservices
        3. Deploy environment
        4. Check deployment

        Duration 35 min
        """
        if settings.BUILD_IMAGES:
            k8s_actions.create_registry()
            ccpcluster.build()
        else:
            if not settings.REGISTRY:
                raise ValueError("The REGISTRY variable should be set with "
                                 "external registry address, "
                                 "current value {0}".format(settings.REGISTRY))
        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)

        remote = underlay.remote(host=config.k8s.kube_host)
        underlay.sudo_check_call("pip install python-openstackclient",
                                 host=config.k8s.kube_host)
        remote.check_call(
            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -a"
            " create -i {1}".format(
                settings.CCP_CONF["kubernetes"]["namespace"],
                settings.IFACES['public']),
            timeout=600)
Esempio n. 9
0
    def test_rabbitmq_node_replacement(self, hardware, underlay, config,
                                       ccpcluster, k8s_actions, show_step,
                                       os_deployed, rabbit_client):
        """Rabbitmq node replacement

        Scenario:
        1. Revert snapshot with deployed rabbit
        2. Shutdown one rabbit node
        3. Add new rabbit node to config
        4. Re-deploy cluster
        5. Check rabbit cluster state
        6. Check queue, messages replication
        7. Create 2 vms

        Duration 30 min
        """
        rabbit_node = underlay.node_names()[1]
        rabbit_node_ip = underlay.host_by_node_name(rabbit_node)
        namespace = settings.CCP_CONF["kubernetes"]["namespace"]
        rabbit_pods = self.get_pods(k8s_actions)
        show_step(2)
        hardware.shutdown_node_by_ip(rabbit_node_ip)

        helpers.wait(lambda: (len(self.get_pods(k8s_actions)) ==
                              len(rabbit_pods) - 1),
                     timeout=600,
                     timeout_msg='Timeout waiting for rabbit pod'
                                 ' to be terminated')
        show_step(3)
        with underlay.yaml_editor(settings.CCP_DEPLOY_TOPOLOGY,
                                  host=config.k8s.kube_host) as editor:
            del editor.content['nodes']['node[1-3]']
            editor.content['nodes']['node[1-2]'] = {'roles': ['rabbitmq']}
            editor.content['nodes']['node4'] = {'roles': ['rabbitmq', 'etcd']}
        show_step(4)
        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)

        pods_after_replacement = self.get_pods(k8s_actions)
        remote = underlay.remote(host=config.k8s.kube_host)
        show_step(6)
        queue = rabbit_client.create_queue()
        message = rabbit_client.publish_message_to_queue(queue)
        rabbit_client.check_queue_message(message)
        show_step(5)
        for pod in pods_after_replacement:
            rabbit_cluster_nodes = rabbit_client.list_nodes(
                remote, pod.name, namespace)
            assert rabbit_cluster_nodes == len(pods_after_replacement),\
                "Expected to have {} nodes in cluster," \
                " got {}".format(len(pods_after_replacement),
                                 rabbit_cluster_nodes)
            rabbit_client.check_queue_replicated(queue, remote,
                                                 pod.name, namespace)
        rabbit_client.delete_queue(queue)
        show_step(7)
        remote.check_call(
            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -k {0}"
            " -a create".format(namespace), timeout=600)
Esempio n. 10
0
    def test_rabbitmq_cluster_shutdown(self, hardware, underlay, config,
                                       ccpcluster, k8s_actions, show_step,
                                       os_deployed, rabbit_client):
        """Rabbitmq cluster shutdown

        Scenario:
        1. Revert snapshot with deployed rabbit
        2. Shutdown all rabbit nodes and start them one by one
        3. Check rabbit cluster state
        4. Check queue, messages replication
        5. Create 2 vms

        Duration 30 min
        """
        rabbit_nodes = underlay.node_names()[:3]
        namespace = settings.CCP_CONF["kubernetes"]["namespace"]
        rabbit_pods = self.get_pods(k8s_actions)
        rabbit_node_ips = []
        show_step(2)
        for rabbit_node in rabbit_nodes:
            rabbit_node_ip = underlay.host_by_node_name(rabbit_node)
            rabbit_node_ips.append(rabbit_node_ip)
            hardware.shutdown_node_by_ip(rabbit_node_ip)
            hardware.wait_node_is_offline(rabbit_node_ip, 90)
        for rabbit_ip in rabbit_node_ips:
            hardware.start_node_by_ip(rabbit_ip)
            hardware.wait_node_is_online(rabbit_ip, 180)
        show_step(3)
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        pods_after_shutdown = self.get_pods(k8s_actions)
        assert len(rabbit_pods) == len(pods_after_shutdown),\
            "Different number of pods after shutdown, was {}," \
            " now {}".format(len(rabbit_pods), len(pods_after_shutdown))
        remote = underlay.remote(host=config.k8s.kube_host)
        show_step(4)
        host = config.k8s.kube_host
        rabbit_port = ''.join(remote.execute(
            "kubectl get service --namespace ccp rabbitmq -o yaml |"
            " awk '/nodePort: / {print $NF}'")['stdout'])
        rabbit_client = rabbit.RabbitClient(host, rabbit_port)
        queue = rabbit_client.create_queue()
        message = rabbit_client.publish_message_to_queue(queue)
        rabbit_client.check_queue_message(message)
        for pod in pods_after_shutdown:
            rabbit_cluster_nodes = rabbit_client.list_nodes(
                remote, pod.name, namespace)
            assert rabbit_cluster_nodes == len(pods_after_shutdown),\
                "Expected to have {} nodes in cluster," \
                " got {}".format(len(pods_after_shutdown),
                                 rabbit_cluster_nodes)
            rabbit_client.check_queue_replicated(queue, remote,
                                                 pod.name, namespace)
        rabbit_client.delete_queue(queue)
        remote.check_call(
            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -k {0}"
            " -a create".format(namespace), timeout=600)
    def test_fuel_ccp_containerized(
            self, underlay, config, k8scluster, ccp_actions, show_step):
        """Deploy environment using ccp in container

        Scenario:
        1. Revert snapshot
        2. Install ccp in container
        3. Deploy environment
        4. Check deployment

        Duration 35 min
        """

        ccp_actions.default_params = settings.CCP_CLI_PARAMS
        show_step(2)
        ccp_actions.fetch_ccp()
        ccp_actions.dockerize_ccp()

        ccp_actions.put_yaml_config(
            path=settings.CCP_DEPLOY_CONFIG,
            config=settings.CCP_DEFAULT_GLOBALS)
        ccp_actions.put_yaml_config(
            path=settings.CCP_SOURCES_CONFIG,
            config=settings.CCP_BUILD_SOURCES)
        ccp_actions.put_yaml_config(
            path=settings.CCP_FETCH_CONFIG,
            config=settings.CCP_FETCH_PARAMS)

        with open(config.ccp_deploy.topology_path, 'r') as f:
            ccp_actions.put_raw_config(
                path=settings.CCP_DEPLOY_TOPOLOGY,
                content=f.read())

        ccp_actions.init_default_config(include_files=[
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            settings.CCP_DEPLOY_TOPOLOGY,
            settings.CCP_FETCH_CONFIG])
        config.ccp.os_host = config.k8s.kube_host

        if settings.REGISTRY == "127.0.0.1:31500":
            k8scluster.create_registry()
            ccp_actions.build()
        show_step(3)
        ccp_actions.deploy()
        post_os_deploy_checks.check_jobs_status(k8scluster.api)
        post_os_deploy_checks.check_pods_status(k8scluster.api)
        show_step(4)
        remote = underlay.remote(host=config.k8s.kube_host)
        underlay.sudo_check_call("pip install python-openstackclient",
                                 host=config.k8s.kube_host)
        remote.check_call(
            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -k {0}"
            " -a create".format(
                settings.CCP_CONF["kubernetes"]["namespace"]),
            timeout=600)
Esempio n. 12
0
    def test_deploy_os_with_custom_stack_light(self, ccpcluster, k8s_actions,
                                               underlay, config):
        """
        Scenario:
            1. Install k8s
            2. Install fuel-ccp
            3. Fetch all repositories
            4. Fetch stacklight from review
            5. Fetch repositories
            6. Build containers
            7. Deploy stack Light and openstack
            8. Run verification

        """
        remote = underlay.remote(host=config.k8s.kube_host)

        if settings.REGISTRY == '127.0.0.1:31500':
            k8s_actions.create_registry()
            ccpcluster.fetch()
            ccpcluster.update_service('stacklight')
            ccpcluster.build(suppress_output=False)

        topology_path = os.getcwd() + '/fuel_ccp_tests/templates/' \
                                      'k8s_templates/stacklight_topology.yaml'

        remote.upload(topology_path, settings.CCP_CLI_PARAMS['deploy-config'])
        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)

        post_os_deploy_checks.check_pod_status_by_name(
            name='grafana',
            k8sclient=k8s_actions.api,
            namespace='ccp',
            count=None)

        post_os_deploy_checks.check_pod_status_by_name(
            name='stacklight-collector',
            k8sclient=k8s_actions.api,
            namespace='ccp',
            count=None)

        # get grafana port
        cmd = ("kubectl get service --namespace ccp grafana "
               "-o yaml | awk '/nodePort: / {print $NF}'")
        res = remote.execute(cmd)['stdout'][0].strip()
        grafana_port = ''.join(res)
        ip = config.k8s.kube_host

        # Auth in Grafana
        url = "http://{0}:{1}/api/org/".format(ip, grafana_port)

        res = requests.get(url, auth=('admin', 'admin'))
        msg = 'Fail to auth in Grafana with {}'.format(res.status_code)
        assert res.status_code == 200, msg
Esempio n. 13
0
 def check_os_ready(self,
                    check_jobs_ready=True,
                    check_pods_ready=True):
     if check_jobs_ready:
         LOG.info("Checking openstack jobs statuses...")
         post_os_deploy_checks.check_jobs_status(self.__k8s_actions.api,
                                                 timeout=3600)
     if check_pods_ready:
         LOG.info("Checking openstack pods statuses...")
         post_os_deploy_checks.check_pods_status(self.__k8s_actions.api,
                                                 timeout=3600)
Esempio n. 14
0
 def check_os_ready(self,
                    check_jobs_ready=True,
                    check_pods_ready=True):
     if check_jobs_ready:
         LOG.info("Checking openstack jobs statuses...")
         post_os_deploy_checks.check_jobs_status(self.__k8s_actions.api,
                                                 timeout=4500)
     if check_pods_ready:
         LOG.info("Checking openstack pods statuses...")
         post_os_deploy_checks.check_pods_status(self.__k8s_actions.api,
                                                 timeout=4500)
Esempio n. 15
0
    def test_deploy_os_with_custom_etcd(
            self, ccpcluster, k8s_actions, config, underlay, show_step):
        """Precommit test for etcd
        :var SERVICE_PATH: path to fuel-ccp-mariadb repo

        Scenario:
        1. Install k8s
        2. Install fuel-ccp
        3. Upload all repositories
        4. Update etcd from review
        5. Build etcd container
        6. Deploy openstack
        7. Check etcd
        """
        show_step(1)
        show_step(2)
        if settings.REGISTRY == '127.0.0.1:31500':
            k8s_actions.create_registry()
            show_step(3)
            ccpcluster.fetch()
            show_step(4)
            ccpcluster.update_service('etcd')
            show_step(5)
            ccpcluster.build(suppress_output=False)

        show_step(6)
        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2500)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)

        show_step(7)
        remote = underlay.remote(host=config.k8s.kube_host)
        value = ['TEST', 'TEST_UPDATED']
        command = [
            'etcdctl set /message {0}'.format(value[0]),
            'etcdctl update /message {0}'.format(value[1])
        ]
        for cmd in command:
            LOG.info(
                "Running command '{cmd}' on node {node_name}".format(
                    cmd=command,
                    node_name=remote.hostname
                )
            )
            remote.check_call(cmd, verbose=True)

        cmd = 'etcdctl get /message'
        assert remote.check_call(cmd)['stdout_str'] == value[1], \
            "The value of key is not equal to {0}".format(value[1])
Esempio n. 16
0
    def test_deploy_openstack_run_tempest(self, underlay, config, ccpcluster,
                                          k8s_actions, rally):
        """Deploy base environment

        Scenario:
        1. Revert snapshot
        2. Install ccp
        3. Deploy environment
        4. Run tempest

        Duration 35 min
        """
        remote = underlay.remote(host=config.k8s.kube_host)
        if settings.BUILD_IMAGES:
            k8s_actions.create_registry()
            ccpcluster.build()
        else:
            if not settings.REGISTRY:
                raise ValueError("The REGISTRY variable should be set with "
                                 "external registry address, "
                                 "current value {0}".format(settings.REGISTRY))
        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=4500)
        post_os_deploy_checks.check_pods_status(k8s_actions.api, timeout=4500)

        # prepare rally
        rally.prepare()
        rally.pull_image()
        rally.run()
        # run tempest
        rally.run_tempest()

        LOG.info('Storing tests results...')
        res_file_name = 'result.json'
        file_prefix = 'results_' + datetime.datetime.now().strftime(
            '%Y%m%d_%H%M%S') + '_'
        file_dst = '{0}/logs/{1}{2}'.format(settings.LOGS_DIR, file_prefix,
                                            res_file_name)
        remote.download(
            '/home/{0}/rally/{1}'.format(settings.SSH_LOGIN, res_file_name),
            file_dst)
        res = json.load(
            remote.open('/home/{}/rally/result.json'.format(
                settings.SSH_LOGIN)))
        formatted_tc = []
        failed_cases = [
            res['test_cases'][case] for case in res['test_cases']
            if res['test_cases'][case]['status'] in 'fail'
        ]
Esempio n. 17
0
    def test_deploy_os_with_custom_mariadb(self,
                                           ccpcluster,
                                           k8s_actions,
                                           config,
                                           underlay,
                                           namespace='ccp'):
        """Precommit test for mariadb

        Scenario:
        1. Install k8s
        2. Install fuel-ccp
        3. Fetch all repositories
        4. Fetch mariadb from review
        6. Build containers
        7. Deploy openstack
        8. Check db
        """

        if settings.REGISTRY == '127.0.0.1:31500':
            k8s_actions.create_registry()
            ccpcluster.fetch()
            ccpcluster.update_service('mariadb')
            ccpcluster.build(suppress_output=False)

        ccpcluster.deploy()

        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2500)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)

        LOG.info("Getting pod id")
        cluster = k8s_actions.api
        cluster_list = cluster.pods.list(namespace=namespace)
        pod_id = [pod.name for pod in cluster_list if 'maria' in pod.name][0]
        LOG.info("Pod ID is {0}".format(pod_id))

        cmd = "mysql  -uroot -ppassword -s -e 'SHOW DATABASES;'"
        pod_exec = \
            "kubectl exec -i {pod_id} --namespace=ccp -- {cmd}".format(
                pod_id=pod_id, cmd=cmd)
        result = underlay.check_call(pod_exec, host=config.k8s.kube_host)
        base_databases = ['nova', 'keystone', 'neutron']
        result = [elem.rstrip() for elem in result['stdout']]

        assert set(base_databases).issubset(set(result)), \
            "Mariadb does not contain minimal set of databases, " \
            "cirrent set is {0}".format(set(result))
Esempio n. 18
0
    def test_deploy_os_with_custom_etcd(self, ccpcluster, k8s_actions, config,
                                        underlay, show_step):
        """Precommit test for etcd
        :var SERVICE_PATH: path to fuel-ccp-mariadb repo

        Scenario:
        1. Install k8s
        2. Install fuel-ccp
        3. Upload all repositories
        4. Update etcd from review
        5. Build etcd container
        6. Deploy openstack
        7. Check etcd
        """
        show_step(1)
        show_step(2)
        if settings.REGISTRY == '127.0.0.1:31500':
            k8s_actions.create_registry()
            show_step(3)
            ccpcluster.fetch()
            show_step(4)
            ccpcluster.update_service('etcd')
            show_step(5)
            ccpcluster.build(suppress_output=False)

        show_step(6)
        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2500)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)

        show_step(7)
        remote = underlay.remote(host=config.k8s.kube_host)
        value = ['TEST', 'TEST_UPDATED']
        command = [
            'etcdctl set /message {0}'.format(value[0]),
            'etcdctl update /message {0}'.format(value[1])
        ]
        for cmd in command:
            LOG.info("Running command '{cmd}' on node {node_name}".format(
                cmd=command, node_name=remote.hostname))
            remote.check_call(cmd, verbose=True)

        cmd = 'etcdctl get /message'
        assert remote.check_call(cmd)['stdout_str'] == value[1], \
            "The value of key is not equal to {0}".format(value[1])
Esempio n. 19
0
    def test_deploy_os_with_custom_neutron(self, ccpcluster, k8s_actions,
                                           rally, underlay, config):
        """
        Scenario:
            1. Install k8s
            2. Install fuel-ccp
            3. Fetch repos
            4. Upload repo with changes
            5. Build components
            6. Deploy components
            7. Run tempest suite

        """
        remote = underlay.remote(host=config.k8s.kube_host)

        if settings.REGISTRY == '127.0.0.1:31500':
            k8s_actions.create_registry()
            ccpcluster.fetch()
            ccpcluster.update_service('neutron')
            ccpcluster.build(suppress_output=False)

        ccpcluster.deploy()
        rally.prepare()
        rally.pull_image()
        rally.run()

        post_os_deploy_checks.check_jobs_status(k8s_actions.api)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        rally.run_tempest('--regex  tempest.api.network')
        LOG.info('Storing tests results...')
        res_file_name = 'result.html'
        file_prefix = 'results_' + datetime.datetime.now().strftime(
            '%Y%m%d_%H%M%S') + '_'
        file_dst = '{0}/logs/{1}{2}'.format(settings.LOGS_DIR, file_prefix,
                                            res_file_name)
        remote.download(
            '/home/{0}/rally/{1}'.format(settings.SSH_LOGIN, res_file_name),
            file_dst)
        res = json.load(
            remote.open('/home/{}/rally/result.json'.format(
                settings.SSH_LOGIN)))

        fail_msg = 'Tempest verification fails {}'.format(res)
        assert res['failures'] == 0, fail_msg
Esempio n. 20
0
    def test_deploy_os_with_custom_neutron(
            self, ccpcluster, k8s_actions, rally, underlay, config):
        """
        Scenario:
            1. Install k8s
            2. Install fuel-ccp
            3. Fetch repos
            4. Upload repo with changes
            5. Build components
            6. Deploy components
            7. Run tempest suite

        """
        remote = underlay.remote(host=config.k8s.kube_host)

        if settings.REGISTRY == '127.0.0.1:31500':
            k8s_actions.create_registry()
            ccpcluster.fetch()
            ccpcluster.update_service('neutron')
            ccpcluster.build(suppress_output=False)

        ccpcluster.deploy()
        rally.prepare()
        rally.pull_image()
        rally.run()

        post_os_deploy_checks.check_jobs_status(k8s_actions.api)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        rally.run_tempest('--regex  tempest.api.network')
        LOG.info('Storing tests results...')
        res_file_name = 'result.html'
        file_prefix = 'results_' + datetime.datetime.now().strftime(
            '%Y%m%d_%H%M%S') + '_'
        file_dst = '{0}/logs/{1}{2}'.format(
            settings.LOGS_DIR, file_prefix, res_file_name)
        remote.download(
            '/home/{0}/rally/{1}'.format(settings.SSH_LOGIN, res_file_name),
            file_dst)
        res = json.load(remote.open('/home/{}/rally/result.json'.format(
            settings.SSH_LOGIN)))

        fail_msg = 'Tempest verification fails {}'.format(res)
        assert res['failures'] == 0, fail_msg
Esempio n. 21
0
def galera_deployed(ccpcluster,
                    hardware,
                    underlay,
                    revert_snapshot,
                    config,
                    k8s_actions):
    """Deploy galera cluster
    """
    # If no snapshot was reverted, then try to revert the snapshot
    # that belongs to the fixture.
    # Note: keep fixtures in strict dependences from each other!
    if not config.os.running:
        general_config = deepcopy(settings.CCP_CONF)
        if settings.REGISTRY == "127.0.0.1:31500":
            k8s_actions.create_registry()
            ccpcluster.build()
        topology_path = \
            os.getcwd() + '/fuel_ccp_tests/templates/ccp_deploy_topology/' \
                          '3galera_1comp.yaml'
        remote = underlay.remote(host=config.k8s.kube_host)
        remote.upload(topology_path, '/tmp')
        ccpcluster.put_yaml_config('./config_1.yaml', general_config)
        ccpcluster.add_includes('./config_1.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/3galera_1comp.yaml'])

        underlay.sudo_check_call("pip install python-openstackclient",
                                 host=config.k8s.kube_host)
        ccpcluster.deploy(params={"config-file": "./config_1.yaml"},
                          use_cli_params=True)
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        # todo: add invocation of galera checker script
        remote.check_call(
            "source openrc-{}; bash fuel-ccp/tools/deploy-test-vms.sh -a"
            " create".format(
                settings.CCP_CONF["kubernetes"]["namespace"]),
            timeout=600)

        config.os.running = True
        hardware.create_snapshot(ext.SNAPSHOT.os_galera_deployed)
Esempio n. 22
0
    def test_deploy_os_with_custom_mariadb(
            self, ccpcluster, k8s_actions, config, underlay, namespace='ccp'):
        """Precommit test for mariadb

        Scenario:
        1. Install k8s
        2. Install fuel-ccp
        3. Fetch all repositories
        4. Fetch mariadb from review
        6. Build containers
        7. Deploy openstack
        8. Check db
        """

        if settings.REGISTRY == '127.0.0.1:31500':
            k8s_actions.create_registry()
            ccpcluster.fetch()
            ccpcluster.update_service('mariadb')
            ccpcluster.build(suppress_output=False)

        ccpcluster.deploy()

        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2500)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)

        LOG.info("Getting pod id")
        cluster = k8s_actions.api
        cluster_list = cluster.pods.list(namespace=namespace)
        pod_id = [pod.name for pod in cluster_list if 'maria' in pod.name][0]
        LOG.info("Pod ID is {0}".format(pod_id))

        cmd = "mysql  -uroot -ppassword -s -e 'SHOW DATABASES;'"
        pod_exec = \
            "kubectl exec -i {pod_id} --namespace=ccp -- {cmd}".format(
                pod_id=pod_id, cmd=cmd)
        result = underlay.check_call(pod_exec, host=config.k8s.kube_host)
        base_databases = ['nova', 'keystone', 'neutron']
        result = [elem.rstrip() for elem in result['stdout']]

        assert set(base_databases).issubset(set(result)), \
            "Mariadb does not contain minimal set of databases, " \
            "cirrent set is {0}".format(set(result))
Esempio n. 23
0
    def test_fuel_ccp_dry_run(self, ccpcluster, k8scluster):
        """Deploy base environment

        Scenario:
        1. Revert snapshot
        2. Install microservices
        3. Create yaml templates
        4. Deploy environment
        4. Check deployment

        Duration 35 min
        """
        k8sclient = k8scluster.api
        k8scluster.create_registry()
        ccpcluster.build()
        export_dir = "/home/{user}/export".format(user=settings.SSH_LOGIN)
        ccpcluster.dry_deploy(export_dir=export_dir)
        k8scluster.create_objects(path=export_dir)
        post_os_deploy_checks.check_jobs_status(k8sclient, timeout=1500,
                                                namespace='default')
        post_os_deploy_checks.check_pods_status(k8sclient, timeout=2500,
                                                namespace='default')
Esempio n. 24
0
    def test_fuel_ccp_dry_run(self, ccpcluster, k8scluster):
        """Deploy base environment

        Scenario:
        1. Revert snapshot
        2. Install microservices
        3. Create yaml templates
        4. Deploy environment
        4. Check deployment

        Duration 35 min
        """
        k8sclient = k8scluster.api
        k8scluster.create_registry()
        ccpcluster.build()
        export_dir = "/home/{user}/export".format(user=settings.SSH_LOGIN)
        ccpcluster.dry_deploy(export_dir=export_dir)
        k8scluster.create_objects(path=export_dir)
        post_os_deploy_checks.check_jobs_status(k8sclient,
                                                timeout=1500,
                                                namespace='default')
        post_os_deploy_checks.check_pods_status(k8sclient,
                                                timeout=2500,
                                                namespace='default')
Esempio n. 25
0
    def test_deploy_openstack_run_tempest(self, underlay, config,
                                          ccpcluster, k8s_actions, rally):
        """Deploy base environment

        Scenario:
        1. Revert snapshot
        2. Install ccp
        3. Deploy environment
        4. Run tempest

        Duration 35 min
        """
        remote = underlay.remote(host=config.k8s.kube_host)
        if settings.REGISTRY == "127.0.0.1:31500":
            k8s_actions.create_registry()
            ccpcluster.build()

        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=4500)
        post_os_deploy_checks.check_pods_status(k8s_actions.api, timeout=4500)

        # prepare rally
        rally.prepare()
        rally.pull_image()
        rally.run()
        # run tempest
        rally.run_tempest()

        LOG.info('Storing tests results...')
        res_file_name = 'result.json'
        file_prefix = 'results_' + datetime.datetime.now().strftime(
            '%Y%m%d_%H%M%S') + '_'
        file_dst = '{0}/logs/{1}{2}'.format(
            settings.LOGS_DIR, file_prefix, res_file_name)
        remote.download(
            '/home/{0}/rally/{1}'.format(settings.SSH_LOGIN, res_file_name),
            file_dst)
        res = json.load(remote.open('/home/{}/rally/result.json'.format(
            settings.SSH_LOGIN)))
        formatted_tc = []
        failed_cases = [res['test_cases'][case]
                        for case in res['test_cases']
                        if res['test_cases'][case]['status']
                        in 'fail']
        for case in failed_cases:
            if case:
                tc = TestCase(case['name'])
                tc.add_failure_info(case['traceback'])
                formatted_tc.append(tc)

        skipped_cases = [res['test_cases'][case]
                         for case in res['test_cases']
                         if res['test_cases'][case]['status'] in 'skip']
        for case in skipped_cases:
            if case:
                tc = TestCase(case['name'])
                tc.add_skipped_info(case['reason'])
                formatted_tc.append(tc)

        error_cases = [res['test_cases'][case] for case in res['test_cases']
                       if res['test_cases'][case]['status'] in 'error']

        for case in error_cases:
            if case:
                tc = TestCase(case['name'])
                tc.add_error_info(case['traceback'])
                formatted_tc.append(tc)

        success = [res['test_cases'][case] for case in res['test_cases']
                   if res['test_cases'][case]['status'] in 'success']
        for case in success:
            if case:
                tc = TestCase(case['name'])
                formatted_tc.append(tc)

        ts = TestSuite("tempest", formatted_tc)
        with open('tempest.xml', 'w') as f:
            ts.to_file(f, [ts], prettyprint=False)
        fail_msg = 'Tempest verification fails {}'.format(res)
        assert res['failures'] == 0, fail_msg
Esempio n. 26
0
    def test_glance_api(self, config, underlay,
                        k8scluster, ccpcluster):
        """Glance api test
        Scenario:
        1. Install k8s
        2. Install microservices
        3. Fetch all repos
        4. Build images or use external registry
        5. Deploy openstack
        6. Download test script
        7. Test glance_api with script

        Duration 60 min
        """
        k8sclient = k8scluster.api
        remote = underlay.remote(host=config.k8s.kube_host)

        if settings.REGISTRY == '127.0.0.1:31500':
            k8scluster.create_registry()
            ccpcluster.fetch()
            ccpcluster.build()

        topology_path = os.getcwd() + '/fuel_ccp_tests/templates/' \
                                      'ccp_deploy_topology/' \
                                      'default_deploy_topology.yaml'
        remote.upload(topology_path, './')
        with remote.get_sudo(remote):
            ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8sclient, timeout=1500,
                                                namespace='ccp')
        post_os_deploy_checks.check_pods_status(k8sclient, timeout=2500,
                                                namespace='ccp')
        # run glance_api tests
        script = settings.TEMPEST_SCRIPT_PATH
        script_result = 'rally/result.json'
        remote.upload(script, './')
        script_dir = script.split('/')[-1]
        script_name = remote.execute('ls -1 {0}'.format(
            script_dir))['stdout'][0].rstrip()
        script_path = os.path.join(script_dir, script_name)
        command = [
            'chmod +x {0}'.format(script_path),
            'cd {0}; ./{1} "--regex tempest.api.image"'.format(
                script_dir, script_name),
            'test -e {0}'.format(script_result),
        ]
        for cmd in command:
            LOG.info(
                "Running command '{cmd}' on node {node_name}".format(
                    cmd=command,
                    node_name=remote.hostname
                )
            )
            result = remote.check_call(cmd, verbose=True)
            assert result['exit_code'] == 0
        remote.download(script_result, '/tmp/')
        with open('/tmp/{0}'.format(script_result.split('/')[-1]), 'r') \
                as json_path:
            data = json_path.read()
        result_dict = json.loads(data)
        if result_dict['failures'] != 0:
            raise ValueError(
                'The tempest tests were failed, number of failures is {0}, '
                'detailed log {1}:~/{2}'.format(
                    result_dict['failures'], remote.hostname, script_result))
Esempio n. 27
0
    def test_rabbitmq_scale(self, hardware, underlay, config,
                            ccpcluster, k8s_actions, show_step,
                            os_deployed, rabbit_client):
        """Rabbit cluster scale

        Scenario:
        1. Revert snapshot with deployed rabbit
        2. Scale up rabbit to 5 replicas
        3. Check rabbit state
        4. Check number of rabbit pods
        5. Create 2 vms
        6. Scale down rabbit to 3 replicas
        7. Check rabbit state
        8. Check number of rabbit pods
        9. Create 2 vms

        Duration 30 min
        """
        show_step(2)
        with underlay.yaml_editor(settings.CCP_DEPLOY_TOPOLOGY,
                                  host=config.k8s.kube_host) as editor:
            del editor.content['nodes']['node[1-3]']
            editor.content['nodes']['node[1-5]'] = {'roles': ['rabbitmq']}

        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        namespace = settings.CCP_CONF["kubernetes"]["namespace"]
        remote = underlay.remote(host=config.k8s.kube_host)
        rabbit_pods = self.get_pods(k8s_actions)
        queue = rabbit_client.create_queue()
        message = rabbit_client.publish_message_to_queue(queue)
        rabbit_client.check_queue_message(message)
        for pod in rabbit_pods:
            rabbit_cluster_nodes = rabbit_client.list_nodes(
                remote, pod.name, namespace)
            assert rabbit_cluster_nodes == len(rabbit_pods),\
                "Expected to have {} nodes in cluster," \
                " got {}".format(len(rabbit_pods), rabbit_cluster_nodes)
            rabbit_client.check_queue_replicated(queue, remote,
                                                 pod.name, namespace)
        rabbit_client.delete_queue(queue)

        show_step(4)
        rabbit_pods = \
            k8s_actions.get_pods_number('rabbit', namespace)
        assert rabbit_pods == 5,\
            "Expcted to have 5 rabbit pods, got {}".format(rabbit_pods)

        show_step(5)
        remote.check_call(
            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -k {0}"
            " -a create".format(namespace), timeout=600)
        show_step(6)
        with underlay.yaml_editor(settings.CCP_DEPLOY_TOPOLOGY,
                                  host=config.k8s.kube_host) as editor:
            del editor.content['nodes']['node[1-5]']
            editor.content['nodes']['node[1-3]'] = {'roles': ['rabbitmq']}

        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        show_step(7)
        show_step(8)
        rabbit_pods = \
            k8s_actions.get_pods_number('rabbit', namespace)
        assert rabbit_pods == 3,\
            "Expcted to have 3 rabbit pods, got {}".format(rabbit_pods)
        show_step(9)
        remote.check_call(
            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -k {0}"
            " -a create".format(namespace), timeout=600)
Esempio n. 28
0
    def test_deploy_3_ctrl(self, underlay, config, ccpcluster, k8s_actions):
        """Deploy base environment

        Scenario:
        1. Revert snapshot
        2. Install microservices
        3. Deploy one OS cluster with 1 controller
        4. Check deployment
        5. Create flavor
        6. Deploy another OS cluster with 1 controller
        7. Check deployment
        8. Create flavor
        9. Deploy another OS cluster with 1 controller
        10. Check deployment
        11. Create flavor

        Duration 60 min
        """
        if settings.REGISTRY == "127.0.0.1:31500":
            k8s_actions.create_registry()
            ccpcluster.build()
        topology_path = \
            os.getcwd() + '/fuel_ccp_tests/templates/ccp_deploy_topology/' \
                          '1ctrl.yaml'
        remote = underlay.remote(host=config.k8s.kube_host)
        remote.upload(topology_path, '/tmp')
        ccpcluster.put_yaml_config('./config_1.yaml', settings.CCP_CONF)
        ccpcluster.add_includes('./config_1.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/1ctrl.yaml'])

        underlay.sudo_check_call("pip install python-openstackclient",
                                 host=config.k8s.kube_host)
        ccpcluster.deploy(params={"config-file": "./config_1.yaml"})
        post_os_deploy_checks.check_jobs_status(k8s_actions.api)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        remote.check_call(
            "source openrc-{}; openstack flavor create"
            " test".format(settings.CCP_CONF["kubernetes"]["namespace"]),
            timeout=600)

        remote.check_call("sed -i '/node[1-9]/c\  node2:' /tmp/1ctrl.yaml")

        conf = copy.deepcopy(settings.CCP_CONF)
        conf['kubernetes']['namespace'] = 'ccp-second'
        ccpcluster.put_yaml_config('./config_2.yaml', conf)
        ccpcluster.add_includes('./config_2.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/1ctrl.yaml'])

        ccpcluster.deploy(params={"config-file": "./config_2.yaml"})
        post_os_deploy_checks.check_jobs_status(k8s_actions.api,
                                                namespace="ccp-second")
        post_os_deploy_checks.check_pods_status(k8s_actions.api,
                                                namespace="ccp-second")
        remote.check_call(
            "source openrc-ccp-second;"
            " openstack flavor create test",
            timeout=600)
        remote.check_call("sed -i '/node[1-9]/c\  node3:' /tmp/1ctrl.yaml")
        conf = copy.deepcopy(settings.CCP_CONF)
        conf['kubernetes']['namespace'] = 'ccp-third'
        ccpcluster.put_yaml_config('./config_3.yaml', conf)
        ccpcluster.add_includes('./config_3.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/1ctrl.yaml'])
        ccpcluster.deploy(params={"config-file": "./config_3.yaml"})
        post_os_deploy_checks.check_jobs_status(k8s_actions.api,
                                                namespace="ccp-third")
        post_os_deploy_checks.check_pods_status(k8s_actions.api,
                                                namespace="ccp-third")
        remote.check_call(
            "source openrc-ccp-third;"
            " openstack flavor create test",
            timeout=600)
Esempio n. 29
0
    def test_deploy_two_os_same_ctrl(self, underlay, config,
                                     ccpcluster, k8s_actions):
        """Deploy base environment

        Scenario:
        1. Revert snapshot
        2. Install microservices
        3. Deploy one OS cluster
        4. Check deployment
        5. Create 2 vms
        6. Deploy another OS cluster, controller on the same node
        7. Check deployment
        8. Create 2 vms

        Duration 90 min
        """
        if settings.REGISTRY == "127.0.0.1:31500":
            k8s_actions.create_registry()
            ccpcluster.build()
        topology_path = \
            os.getcwd() + '/fuel_ccp_tests/templates/ccp_deploy_topology/' \
                          '1ctrl_1comp.yaml'
        remote = underlay.remote(host=config.k8s.kube_host)
        remote.upload(topology_path, '/tmp')
        ccpcluster.put_yaml_config('./config_1.yaml', settings.CCP_CONF)
        ccpcluster.add_includes('./config_1.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/1ctrl_1comp.yaml'])

        underlay.sudo_check_call("pip install python-openstackclient",
                                 host=config.k8s.kube_host)
        ccpcluster.deploy(params={"config-file": "./config_1.yaml"})
        post_os_deploy_checks.check_jobs_status(k8s_actions.api)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        remote.check_call(
            "source openrc-{}; bash fuel-ccp/tools/deploy-test-vms.sh -a"
            " create".format(
                settings.CCP_CONF["kubernetes"]["namespace"]),
            timeout=600)

        topology_path = \
            os.getcwd() + '/fuel_ccp_tests/templates/ccp_deploy_topology/' \
                          '1ctrl_1comp_same.yaml'
        remote.upload(topology_path, '/tmp')
        conf = copy.deepcopy(settings.CCP_CONF)
        conf['kubernetes']['namespace'] = 'ccp-second'
        ccpcluster.put_yaml_config('./config_2.yaml', conf)
        ccpcluster.add_includes('./config_2.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/1ctrl_1comp_same.yaml'])

        ccpcluster.deploy(params={"config-file": "./config_2.yaml"})
        post_os_deploy_checks.check_jobs_status(k8s_actions.api,
                                                namespace="ccp-second")
        post_os_deploy_checks.check_pods_status(k8s_actions.api,
                                                namespace="ccp-second")
        remote.check_call(
            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -k {0}"
            " -a create".format(
                settings.CCP_CONF["kubernetes"]["namespace"]),
            timeout=600)
Esempio n. 30
0
    def test_deploy_two_os(self, underlay, config, ccpcluster, k8s_actions):
        """Deploy base environment

        Scenario:
        1. Revert snapshot
        2. Install microservices
        3. Deploy one OS cluster
        4. Check deployment
        5. Create 2 vms
        6. Deploy another OS cluster on different nodes
        7. Check deployment
        8. Create 2 vms

        Duration 90 min
        """
        if not settings.REGISTRY:
            k8s_actions.create_registry()
            ccpcluster.build()
        topology_path = \
            os.getcwd() + '/fuel_ccp_tests/templates/k8s_templates/' \
                          '1ctrl_1comp.yaml'
        remote = underlay.remote(host=config.k8s.kube_host)
        remote.upload(topology_path, '/tmp')
        ccpcluster.put_yaml_config('./config_1.yaml', settings.CCP_CONF)
        ccpcluster.add_includes('./config_1.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/1ctrl_1comp.yaml'])

        underlay.sudo_check_call("pip install python-openstackclient",
                                 host=config.k8s.kube_host)
        ccpcluster.deploy(params={"config-file": "./config_1.yaml"})
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        remote.check_call(
            "source openrc-{}; bash fuel-ccp/tools/deploy-test-vms.sh -a"
            " create -i {1}".format(
                settings.CCP_CONF["kubernetes"]["namespace"],
                settings.IFACES['public']),
            timeout=600)

        topology_path = \
            os.getcwd() + '/fuel_ccp_tests/templates/k8s_templates/' \
                          '1ctrl_1comp_diff.yaml'
        remote.upload(topology_path, '/tmp')
        conf = copy.deepcopy(settings.CCP_CONF)
        conf['kubernetes']['namespace'] = 'ccp-second'
        ccpcluster.put_yaml_config('./config_2.yaml', conf)
        ccpcluster.add_includes('./config_2.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/1ctrl_1comp_diff.yaml'])

        ccpcluster.deploy(params={"config-file": "./config_2.yaml"})
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000,
                                                namespace="ccp-second")
        post_os_deploy_checks.check_pods_status(k8s_actions.api,
                                                namespace="ccp-second")
        remote.check_call(
            "source openrc-{}; bash fuel-ccp/tools/deploy-test-vms.sh -a"
            " create -i {1}".format(
                settings.CCP_CONF["kubernetes"]["namespace"],
                settings.IFACES['public']),
            timeout=600)
Esempio n. 31
0
    def test_deploy_3_ctrl(self, underlay, config, ccpcluster, k8s_actions):
        """Deploy base environment

        Scenario:
        1. Revert snapshot
        2. Install microservices
        3. Deploy one OS cluster with 1 controller
        4. Check deployment
        5. Create flavor
        6. Deploy another OS cluster with 1 controller
        7. Check deployment
        8. Create flavor
        9. Deploy another OS cluster with 1 controller
        10. Check deployment
        11. Create flavor

        Duration 60 min
        """
        if not settings.REGISTRY:
            k8s_actions.create_registry()
            ccpcluster.build()
        topology_path = \
            os.getcwd() + '/fuel_ccp_tests/templates/k8s_templates/' \
                          '1ctrl.yaml'
        remote = underlay.remote(host=config.k8s.kube_host)
        remote.upload(topology_path, '/tmp')
        ccpcluster.put_yaml_config('./config_1.yaml', settings.CCP_CONF)
        ccpcluster.add_includes('./config_1.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/1ctrl.yaml'])

        underlay.sudo_check_call("pip install python-openstackclient",
                                 host=config.k8s.kube_host)
        ccpcluster.deploy(params={"config-file": "./config_1.yaml"})
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        remote.check_call(
            "source openrc-{}; openstack flavor create"
            " test".format(settings.CCP_CONF["kubernetes"]["namespace"]),
            timeout=600)

        remote.check_call("sed -i '/node[1-9]/c\  node2:' /tmp/1ctrl.yaml")

        conf = copy.deepcopy(settings.CCP_CONF)
        conf['kubernetes']['namespace'] = 'ccp-second'
        ccpcluster.put_yaml_config('./config_2.yaml', conf)
        ccpcluster.add_includes('./config_2.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/1ctrl.yaml'])

        ccpcluster.deploy(params={"config-file": "./config_2.yaml"})
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000,
                                                namespace="ccp-second")
        post_os_deploy_checks.check_pods_status(k8s_actions.api,
                                                namespace="ccp-second")
        remote.check_call(
            "source openrc-ccp-second;"
            " openstack flavor create test",
            timeout=600)
        remote.check_call("sed -i '/node[1-9]/c\  node3:' /tmp/1ctrl.yaml")
        conf = copy.deepcopy(settings.CCP_CONF)
        conf['kubernetes']['namespace'] = 'ccp-third'
        ccpcluster.put_yaml_config('./config_3.yaml', conf)
        ccpcluster.add_includes('./config_3.yaml', [
            settings.CCP_DEPLOY_CONFIG,
            settings.CCP_SOURCES_CONFIG,
            '/tmp/1ctrl.yaml'])
        ccpcluster.deploy(params={"config-file": "./config_3.yaml"})
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000,
                                                namespace="ccp-third")
        post_os_deploy_checks.check_pods_status(k8s_actions.api,
                                                namespace="ccp-third")
        remote.check_call(
            "source openrc-ccp-third;"
            " openstack flavor create test",
            timeout=600)
Esempio n. 32
0
    def test_horizon_component(self, config, underlay,
                               k8scluster, ccpcluster):
        """Horizon pre-commit test

        pytest.mark: horizon_component

        Scenario:
        1. Fetch all repos
        2. Update horizon source form local path
        3. Build images
        4. Deploy openstack
        5. Create directory to build horizon image for tests
        6. Upload config file for horizon tests
        7. Update horizon dashboard in config file
        8. Build docker image
        9. Run horizon tests from docker
        Duration 60 min
        """
        k8sclient = k8scluster.api

        remote = underlay.remote(host=config.k8s.kube_host)

        if settings.REGISTRY == '127.0.0.1:31500':
            k8scluster.create_registry()
            ccpcluster.fetch()
            ccpcluster.update_service('horizon')
            ccpcluster.build()

        topology_path = os.getcwd() + '/fuel_ccp_tests/templates/' \
                                      'ccp_deploy_topology/' \
                                      'default_deploy_topology.yaml'
        remote.upload(topology_path, settings.CCP_CLI_PARAMS['deploy-config'])
        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8sclient, timeout=1500,
                                                namespace='ccp')
        post_os_deploy_checks.check_pods_status(k8sclient, timeout=1500,
                                                namespace='ccp')
        # run horizon tests
        remote.execute("mkdir /tmp/horizon-tests")
        horizon_port = ''.join(remote.execute(
            "kubectl get service --namespace ccp horizon -o yaml |"
            " awk '/nodePort: / {print $NF}'")['stdout'])
        remote.upload(
            os.getcwd() + '/fuel_ccp_tests/templates/misc/local-horizon.conf',
            "/tmp/horizon-tests")
        remote.execute(
            r"sed -i '/dashboard_url=/c\dashboard_url=http://{0}:{1}'"
            r" /tmp/horizon-tests/local-horizon.conf".format(
                config.k8s.kube_host, horizon_port))
        remote.execute(
            "echo -e '{}' >"
            " /tmp/horizon-tests/dockerfile".format(self.dockerfile))
        remote.execute(
            "docker build -t {}/horizon-test:test"
            " /tmp/horizon-tests/".format(settings.SSH_LOGIN))
        result = remote.execute(
            "docker run {}/horizon-test:test"
            " bash -c 'cd horizon-master;"
            " ./run_tests.sh -V'".format(settings.SSH_LOGIN))
        assert result['exit_code'] == 0,\
            "Horizon unit tests failed, result is {}".format(result)
        remote.close()
Esempio n. 33
0
    def test_horizon_component(self, config, underlay,
                               k8scluster, ccpcluster):
        """Horizon pre-commit test

        pytest.mark: horizon_component

        Scenario:
        1. Fetch all repos
        2. Update horizon source form local path
        3. Build images
        4. Deploy openstack
        5. Create directory to build horizon image for tests
        6. Upload config file for horizon tests
        7. Update horizon dashboard in config file
        8. Build docker image
        9. Run horizon tests from docker
        Duration 60 min
        """
        k8sclient = k8scluster.api

        remote = underlay.remote(host=config.k8s.kube_host)

        if settings.REGISTRY == '127.0.0.1:31500':
            k8scluster.create_registry()
            ccpcluster.fetch()
            ccpcluster.update_service('horizon')
            ccpcluster.build()

        topology_path = os.getcwd() + '/fuel_ccp_tests/templates/' \
                                      'k8s_templates/k8s_topology.yaml'
        remote.upload(topology_path, settings.CCP_CLI_PARAMS['deploy-config'])
        ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8sclient, timeout=1500,
                                                namespace='ccp')
        post_os_deploy_checks.check_pods_status(k8sclient, timeout=1500,
                                                namespace='ccp')
        # run horizon tests
        remote.execute("mkdir /tmp/horizon-tests")
        horizon_port = ''.join(remote.execute(
            "kubectl get service --namespace ccp horizon -o yaml |"
            " awk '/nodePort: / {print $NF}'")['stdout'])
        remote.upload(
            os.getcwd() + '/fuel_ccp_tests/templates/misc/local-horizon.conf',
            "/tmp/horizon-tests")
        remote.execute(
            r"sed -i '/dashboard_url=/c\dashboard_url=http://{0}:{1}'"
            r" /tmp/horizon-tests/local-horizon.conf".format(
                config.k8s.kube_host, horizon_port))
        remote.execute(
            "echo -e '{}' >"
            " /tmp/horizon-tests/dockerfile".format(self.dockerfile))
        remote.execute(
            "docker build -t {}/horizon-test:test"
            " /tmp/horizon-tests/".format(settings.SSH_LOGIN))
        result = remote.execute(
            "docker run {}/horizon-test:test"
            " bash -c 'cd horizon-master;"
            " ./run_tests.sh -V'".format(settings.SSH_LOGIN))
        assert result['exit_code'] == 0,\
            "Horizon unit tests failed, result is {}".format(result)
        remote.close()
Esempio n. 34
0
    def test_glance_api(self, config, underlay,
                        k8scluster, ccpcluster):
        """Glance api test
        Scenario:
        1. Install k8s
        2. Install microservices
        3. Fetch all repos
        4. Build images or use external registry
        5. Deploy openstack
        6. Download test script
        7. Test glance_api with script

        Duration 60 min
        """
        k8sclient = k8scluster.api
        remote = underlay.remote(host=config.k8s.kube_host)

        if settings.REGISTRY == '127.0.0.1:31500':
            k8scluster.create_registry()
            ccpcluster.fetch()
            ccpcluster.build()

        topology_path = os.getcwd() + '/fuel_ccp_tests/templates/' \
                                      'k8s_templates/k8s_topology.yaml'
        remote.upload(topology_path, './')
        with remote.get_sudo(remote):
            ccpcluster.deploy()
        post_os_deploy_checks.check_jobs_status(k8sclient, timeout=1500,
                                                namespace='ccp')
        post_os_deploy_checks.check_pods_status(k8sclient, timeout=2500,
                                                namespace='ccp')
        # run glance_api tests
        script = settings.TEMPEST_SCRIPT_PATH
        script_result = 'rally/result.json'
        remote.upload(script, './')
        script_dir = script.split('/')[-1]
        script_name = remote.execute('ls -1 {0}'.format(
            script_dir))['stdout'][0].rstrip()
        script_path = os.path.join(script_dir, script_name)
        command = [
            'chmod +x {0}'.format(script_path),
            'cd {0}; ./{1} "--regex tempest.api.image"'.format(
                script_dir, script_name),
            'test -e {0}'.format(script_result),
        ]
        for cmd in command:
            LOG.info(
                "Running command '{cmd}' on node {node_name}".format(
                    cmd=command,
                    node_name=remote.hostname
                )
            )
            result = remote.check_call(cmd, verbose=True)
            assert result['exit_code'] == 0
        remote.download(script_result, '/tmp/')
        with open('/tmp/{0}'.format(script_result.split('/')[-1]), 'r') \
                as json_path:
            data = json_path.read()
        result_dict = json.loads(data)
        if result_dict['failures'] != 0:
            raise ValueError(
                'The tempest tests were failed, number of failures is {0}, '
                'detailed log {1}:~/{2}'.format(
                    result_dict['failures'], remote.hostname, script_result))
Esempio n. 35
0
    def test_galera_scale(self, hardware, underlay, config,
                          ccpcluster, k8s_actions, show_step,
                          galera_deployed):
        """Galera cluster scale

        Scenario:
        1. Revert snapshot with deployed galera
        2. Scale up galera to 5 replicas
        3. Check galera state
        4. Check number of galera pods
        5. Create 2 vms
        6. Scale down galera to 3 replicas
        7. Check galera state
        8. Check number of galera pods
        9. Create 2 vms

        Duration 30 min
        """
        show_step(2)
        with underlay.yaml_editor('/tmp/3galera_1comp.yaml',
                                  host=config.k8s.kube_host) as editor:
            del editor.content['nodes']['node[1-3]']
            editor.content['nodes']['node[1-5]'] = {'roles': ['galera']}

        ccpcluster.deploy(params={"config-file": "./config_1.yaml"},
                          use_cli_params=True)
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        show_step(3)
        # todo: add invocation of galera checker script
        show_step(4)
        galera_pods = \
            k8s_actions.get_pods_number('galera',
                                        settings.
                                        CCP_CONF['kubernetes']['namespace'])
        assert galera_pods == 5,\
            "Expcted tp have 5 galera pods, got {}".format(galera_pods)

        show_step(5)
        remote = underlay.remote(host=config.k8s.kube_host)
        remote.check_call(
            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -k {0}"
            " -a create".format(
                settings.CCP_CONF["kubernetes"]["namespace"]),
            timeout=600)
        show_step(6)
        with underlay.yaml_editor('/tmp/3galera_1comp.yaml',
                                  host=config.k8s.kube_host) as editor:
            del editor.content['nodes']['node[1-5]']
            editor.content['nodes']['node[1-3]'] = {'roles': ['galera']}

        ccpcluster.deploy(params={"config-file": "./config_1.yaml"},
                          use_cli_params=True)
        post_os_deploy_checks.check_jobs_status(k8s_actions.api, timeout=2000)
        post_os_deploy_checks.check_pods_status(k8s_actions.api)
        show_step(7)
        # todo: add invocation of galera checker script
        show_step(8)
        galera_pods = (
            k8s_actions.get_pods_number('galera',
                                        settings.
                                        CCP_CONF['kubernetes']['namespace']))
        assert galera_pods == 3, ("Expcted tp have 3 galera pods, "
                                  "got {}".format(galera_pods))
        show_step(9)
        remote.check_call(
            "source openrc-{0}; bash fuel-ccp/tools/deploy-test-vms.sh -k {0}"
            " -a create".format(
                settings.CCP_CONF["kubernetes"]["namespace"]),
            timeout=600)