Exemplo n.º 1
0
 def create_data_pool(self):
     """Create data pool to back iscsi targets."""
     generic_utils.assertActionRanOK(
         zaza.model.run_action_on_leader(
             'ceph-mon',
             'create-pool',
             action_params={'name': self.DATA_POOL_NAME}))
Exemplo n.º 2
0
def sync_images():
    """Run image sync using an action.

    Execute an initial image sync using an action to ensure that the
    cloud is populated with images at the right point in time during
    deployment.
    """
    logging.info("Synchronising images using glance-simplestreams-sync")

    catalog = None
    try:
        for attempt in tenacity.Retrying(stop=tenacity.stop_after_attempt(3),
                                         wait=tenacity.wait_exponential(
                                             multiplier=1, min=2, max=10),
                                         reraise=True):
            with attempt:
                # Proactively retrieve the Keystone service catalog so that we
                # can log it in the event of a failure.
                catalog = _get_catalog()
                generic_utils.assertActionRanOK(
                    zaza_model.run_action_on_leader(
                        "glance-simplestreams-sync",
                        "sync-images",
                        raise_on_failure=True,
                        action_params={},
                    ))
    except Exception:
        logging.info('Contents of Keystone service catalog: "{}"'.format(
            pprint.pformat(catalog)))
        raise
Exemplo n.º 3
0
    def create_iscsi_target(self, ctxt):
        """Create target on gateway.

        :param ctxt: Base gateway context
        :type ctxt: Dict
        """
        generic_utils.assertActionRanOK(
            zaza.model.run_action_on_leader(
                'ceph-iscsi',
                'create-target',
                action_params={
                    'gateway-units':
                    '{} {}'.format(ctxt['gw1_entity_id'],
                                   ctxt['gw2_entity_id']),
                    'iqn':
                    self.GW_IQN,
                    'rbd-pool-name':
                    ctxt.get('pool_name', ''),
                    'ec-rbd-metadata-pool':
                    ctxt.get('ec_meta_pool_name', ''),
                    'image-size':
                    ctxt['img_size'],
                    'image-name':
                    ctxt['img_name'],
                    'client-initiatorname':
                    ctxt['client_initiatorname'],
                    'client-username':
                    ctxt['chap_username'],
                    'client-password':
                    ctxt['chap_password']
                }))
Exemplo n.º 4
0
 def create_iscsi_target(self, ctxt):
     """Create target on gateway."""
     generic_utils.assertActionRanOK(
         zaza.model.run_action_on_leader('ceph-iscsi',
                                         'create-target',
                                         action_params={
                                             'gateway-units':
                                             '{} {}'.format(
                                                 ctxt['gw1_entity_id'],
                                                 ctxt['gw2_entity_id']),
                                             'iqn':
                                             self.GW_IQN,
                                             'pool-name':
                                             self.DATA_POOL_NAME,
                                             'image-size':
                                             ctxt['img_size'],
                                             'image-name':
                                             ctxt['img_name'],
                                             'client-initiatorname':
                                             ctxt['client_initiatorname'],
                                             'client-username':
                                             ctxt['chap_username'],
                                             'client-password':
                                             ctxt['chap_password']
                                         }))
Exemplo n.º 5
0
 def test_ghost_nfs_share(self):
     """Ensure ghost-share action bind mounts NFS share."""
     generic_utils.assertActionRanOK(
         zaza_model.run_action(
             self.lead_unit,
             'ghost-share',
             action_params={'nfs-shares': '10.20.0.1:/srv/testing'},
             model_name=self.model_name))
Exemplo n.º 6
0
def basic_setup():
    """Run setup for testing Trilio.

    Setup for testing Trilio is currently part of functional
    tests.
    """
    logging.info("Configuring NFS Server")
    nfs_server_ip = zaza_model.get_app_ips("nfs-server-test-fixture")[0]
    trilio_wlm_unit = zaza_model.get_first_unit_name("trilio-wlm")

    nfs_shares_conf = {"nfs-shares": "{}:/srv/testing".format(nfs_server_ip)}
    _trilio_services = ["trilio-wlm", "trilio-data-mover"]

    conf_changed = False
    for juju_service in _trilio_services:
        app_config = zaza_model.get_application_config(juju_service)
        if app_config["nfs-shares"] != nfs_shares_conf["nfs-shares"]:
            zaza_model.set_application_config(juju_service, nfs_shares_conf)
            conf_changed = True

    if conf_changed:
        zaza_model.wait_for_agent_status()
        # NOTE(jamespage): wlm-api service must be running in order
        #                  to execute the setup actions
        zaza_model.block_until_service_status(
            unit_name=trilio_wlm_unit,
            services=["wlm-api"],
            target_status="active",
        )

    logging.info("Executing create-cloud-admin-trust")
    password = juju_utils.leader_get("keystone", "admin_passwd")

    generic_utils.assertActionRanOK(
        zaza_model.run_action_on_leader(
            "trilio-wlm",
            "create-cloud-admin-trust",
            raise_on_failure=True,
            action_params={"password": password},
        )
    )

    logging.info("Executing create-license")
    test_license = os.environ.get("TEST_TRILIO_LICENSE")
    if test_license and os.path.exists(test_license):
        zaza_model.attach_resource("trilio-wlm",
                                   resource_name='license',
                                   resource_path=test_license)
        generic_utils.assertActionRanOK(
            zaza_model.run_action_on_leader(
                "trilio-wlm", "create-license",
                raise_on_failure=True
            )
        )

    else:
        logging.error("Unable to find Trilio License file")
Exemplo n.º 7
0
 def _run_migrate_ovn_db_action(self):
     """Run migrate-ovn-db action."""
     logging.info('Running `migrate-ovn-db` action on '
                  'neutron-api-plugin-ovn/leader')
     generic_utils.assertActionRanOK(
         zaza.model.run_action_on_leader(
             'neutron-api-plugin-ovn',
             'migrate-ovn-db',
             action_params={'i-really-mean-it': True},
             raise_on_failure=True,
         ))
Exemplo n.º 8
0
 def _run_offline_neutron_morph_db_action(self):
     """Run offline-neutron-morph-db action."""
     logging.info('Running the optional `offline-neutron-morph-db` action '
                  'on neutron-api-plugin-ovn/leader')
     generic_utils.assertActionRanOK(
         zaza.model.run_action_on_leader(
             'neutron-api-plugin-ovn',
             'offline-neutron-morph-db',
             action_params={'i-really-mean-it': True},
             raise_on_failure=True,
         ))
    def pause_resume(self, services, pgrep_full=False):
        """Run Pause and resume tests.

        Pause and then resume a unit checking that services are in the
        required state after each action

        :param services: Services expected to be restarted when the unit is
                         paused/resumed.
        :type services: list
        :param pgrep_full: Should pgrep be used rather than pidof to identify
                           a service.
        :type  pgrep_full: bool
        """
        model.block_until_service_status(
            self.lead_unit,
            services,
            'running',
            model_name=self.model_name,
            pgrep_full=pgrep_full)
        model.block_until_unit_wl_status(
            self.lead_unit,
            'active',
            model_name=self.model_name)
        generic_utils.assertActionRanOK(model.run_action(
            self.lead_unit,
            'pause',
            model_name=self.model_name))
        model.block_until_unit_wl_status(
            self.lead_unit,
            'maintenance',
            model_name=self.model_name)
        model.block_until_all_units_idle(model_name=self.model_name)
        model.block_until_service_status(
            self.lead_unit,
            services,
            'stopped',
            model_name=self.model_name,
            pgrep_full=pgrep_full)
        yield
        generic_utils.assertActionRanOK(model.run_action(
            self.lead_unit,
            'resume',
            model_name=self.model_name))
        model.block_until_unit_wl_status(
            self.lead_unit,
            'active',
            model_name=self.model_name)
        model.block_until_all_units_idle(model_name=self.model_name)
        model.block_until_service_status(
            self.lead_unit,
            services,
            'running',
            model_name=self.model_name,
            pgrep_full=pgrep_full)
Exemplo n.º 10
0
def trust_setup():
    """Run setup Trilio trust setup."""
    logging.info("Executing create-cloud-admin-trust")
    password = juju_utils.leader_get("keystone", "admin_passwd")

    generic_utils.assertActionRanOK(
        zaza_model.run_action_on_leader(
            "trilio-wlm",
            "create-cloud-admin-trust",
            raise_on_failure=True,
            action_params={"password": password},
        ))
Exemplo n.º 11
0
    def test_update_trilio_action(self):
        """Test that the action runs succesfully."""
        action_name = 'update-trilio'
        actions = zaza_model.get_actions(self.application_name)
        if action_name not in actions:
            raise unittest.SkipTest(
                'Action {} not defined'.format(action_name))

        generic_utils.assertActionRanOK(
            zaza_model.run_action(self.lead_unit,
                                  action_name,
                                  action_params={},
                                  model_name=self.model_name))
Exemplo n.º 12
0
def sync_images():
    """Run image sync using an action.

    Execute an initial image sync using an action to ensure that the
    cloud is populated with images at the right point in time during
    deployment.
    """
    logging.info("Synchronising images using glance-simplestreams-sync")
    generic_utils.assertActionRanOK(
        zaza_model.run_action_on_leader(
            "glance-simplestreams-sync",
            "sync-images",
            raise_on_failure=True,
            action_params={},
        ))
Exemplo n.º 13
0
def license_setup():
    """Run setup Trilio license setup."""
    logging.info("Executing create-license")
    test_license = os.environ.get("TEST_TRILIO_LICENSE")
    if test_license and os.path.exists(test_license):
        zaza_model.attach_resource("trilio-wlm",
                                   resource_name='license',
                                   resource_path=test_license)
        generic_utils.assertActionRanOK(
            zaza_model.run_action_on_leader("trilio-wlm",
                                            "create-license",
                                            raise_on_failure=True))

    else:
        logging.error("Unable to find Trilio License file")
Exemplo n.º 14
0
    def _run_migrate_mtu_action(self):
        """Run migrate-mtu action with retry.

        The action is idempotent.

        Due to LP: #1854518 and the point in time of the test life cycle we run
        this action the probability for the Neutron API not being available
        for the script to do its job is high, thus we retry.
        """
        logging.info('Running `migrate-mtu` action on '
                     'neutron-api-plugin-ovn/leader')
        generic_utils.assertActionRanOK(
            zaza.model.run_action_on_leader(
                'neutron-api-plugin-ovn',
                'migrate-mtu',
                action_params={'i-really-mean-it': True},
                raise_on_failure=True,
            ))
Exemplo n.º 15
0
 def create_ec_data_pool(self):
     """Create data pool to back iscsi targets."""
     generic_utils.assertActionRanOK(
         zaza.model.run_action_on_leader('ceph-mon',
                                         'create-erasure-profile',
                                         action_params={
                                             'name': self.EC_PROFILE_NAME,
                                             'coding-chunks': 2,
                                             'data-chunks': 4,
                                             'plugin': 'jerasure'
                                         }))
     generic_utils.assertActionRanOK(
         zaza.model.run_action_on_leader('ceph-mon',
                                         'create-pool',
                                         action_params={
                                             'name':
                                             self.EC_DATA_POOL,
                                             'pool-type':
                                             'erasure-coded',
                                             'allow-ec-overwrites':
                                             True,
                                             'erasure-profile-name':
                                             self.EC_PROFILE_NAME
                                         }))
     generic_utils.assertActionRanOK(
         zaza.model.run_action_on_leader(
             'ceph-mon',
             'create-pool',
             action_params={'name': self.EC_METADATA_POOL}))
Exemplo n.º 16
0
    def test_cache_device(self):
        """Test replacing a disk in use."""
        logging.info('Running add-disk action with a caching device')
        mon = next(iter(zaza_model.get_units('ceph-mon'))).entity_id
        osds = [x.entity_id for x in zaza_model.get_units('ceph-osd')]
        params = []
        for unit in osds:
            loop_dev = self.loop_devs[unit]
            params.append({'unit': unit, 'device': loop_dev})
            action_obj = zaza_model.run_action(unit_name=unit,
                                               action_name='add-disk',
                                               action_params={
                                                   'osd-devices': loop_dev,
                                                   'partition-size': 5
                                               })
            zaza_utils.assertActionRanOK(action_obj)
        zaza_model.wait_for_application_states()

        logging.info('Removing previously added disks')
        for param in params:
            osd_id = self.get_local_osd_id(param['unit'])
            param.update({'osd-id': osd_id})
            action_obj = zaza_model.run_action(unit_name=param['unit'],
                                               action_name='remove-disk',
                                               action_params={
                                                   'osd-ids': osd_id,
                                                   'timeout': 5,
                                                   'format': 'json',
                                                   'purge': False
                                               })
            zaza_utils.assertActionRanOK(action_obj)
            results = json.loads(action_obj.data['results']['message'])
            results = results[next(iter(results))]
            self.assertEqual(results['osd-ids'], osd_id)
            zaza_model.run_on_unit(param['unit'], 'partprobe')
        zaza_model.wait_for_application_states()

        logging.info('Recycling previously removed OSDs')
        for param in params:
            action_obj = zaza_model.run_action(unit_name=param['unit'],
                                               action_name='add-disk',
                                               action_params={
                                                   'osd-devices':
                                                   param['device'],
                                                   'osd-ids': param['osd-id'],
                                                   'partition-size': 4
                                               })
            zaza_utils.assertActionRanOK(action_obj)
        zaza_model.wait_for_application_states()
        self.assertEqual(len(osds) * 2, self.get_num_osds(mon))

        # Finally, remove all the added OSDs that are backed by loop devices.
        for param in params:
            osd_id = self.get_local_osd_id(param['unit'])
            zaza_model.run_action(unit_name=param['unit'],
                                  action_name='remove-disk',
                                  action_params={
                                      'osd-ids': osd_id,
                                      'purge': True
                                  })