def osd_out_in(self, services): """Run OSD out and OSD in tests. Remove OSDs and then add them back in on a unit checking that services are in the required state after each action :param services: Services expected to be restarted when config_file is changed. :type services: list """ zaza_model.block_until_service_status(self.lead_unit, services, 'running', model_name=self.model_name) zaza_model.block_until_unit_wl_status(self.lead_unit, 'active', model_name=self.model_name) zaza_model.run_action(self.lead_unit, 'osd-out', model_name=self.model_name) zaza_model.block_until_unit_wl_status(self.lead_unit, 'maintenance', model_name=self.model_name) zaza_model.block_until_all_units_idle(model_name=self.model_name) zaza_model.run_action(self.lead_unit, 'osd-in', model_name=self.model_name) zaza_model.block_until_unit_wl_status(self.lead_unit, 'active', model_name=self.model_name) zaza_model.block_until_all_units_idle(model_name=self.model_name) zaza_model.block_until_service_status(self.lead_unit, services, 'running', model_name=self.model_name)
def test_block_until_service_status_check_stopped(self): self.patch_object(model, 'get_juju_model', return_value='mname') self.block_until_service_status_base({'Stdout': ''}) model.block_until_service_status( 'app/2', ['test_svc'], 'stopped')
def nfs_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)} logging.info("NFS share config: {}".format(nfs_shares_conf)) _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"]: logging.info("Updating nfs-shares config option") 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", )
def test_block_until_service_status_check_running(self): self.patch_object(model, 'get_juju_model', return_value='mname') self.block_until_service_status_base({'Stdout': '152 409 54'}) model.block_until_service_status( 'app/2', ['test_svc'], 'running')
def test_block_until_service_status_check_stopped_fail(self): self.patch_object(model, 'get_juju_model', return_value='mname') self.block_until_service_status_base({'Stdout': '152 409 54'}) with self.assertRaises(asyncio.futures.TimeoutError): model.block_until_service_status( 'app/2', ['test_svc'], 'stopped')
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")
def test_services(self): """Verify the ceph services. Verify the expected services are running on the service units. """ logging.info('Checking radosgw services...') services = ['radosgw', 'haproxy'] for app in self.expected_apps: for unit in zaza_model.get_units(app): zaza_model.block_until_service_status(unit_name=unit.entity_id, services=services, target_status='running')
def test_100_services(self): """Verify the expected services are running. Ported from amulet tests. """ logging.info('Checking openstack-dashboard services...') unit_name = zaza_model.get_lead_unit_name('openstack-dashboard') openstack_services = ['apache2'] services = {} services[unit_name] = openstack_services for unit_name, unit_services in services.items(): zaza_model.block_until_service_status(unit_name=unit_name, services=unit_services, target_status='running')
def test_services(self): """Verify the ceph services. Verify the expected services are running on the service units. """ logging.info('Checking ceph-osd and ceph-mon services...') services = {} ceph_services = ['ceph-mon'] services['ceph-osd/0'] = ['ceph-osd'] services['ceph-mon/0'] = ceph_services services['ceph-mon/1'] = ceph_services services['ceph-mon/2'] = ceph_services for unit_name, unit_services in services.items(): zaza_model.block_until_service_status(unit_name=unit_name, services=unit_services, target_status='running')
def pause_resume(self, services): """Run Pause and resume tests. Override the default implementation since pausing ceph units doesn't stop the services. 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 config_file is changed. :type services: list """ zaza_model.block_until_service_status(self.lead_unit, services, 'running', model_name=self.model_name) zaza_model.block_until_unit_wl_status(self.lead_unit, 'active', model_name=self.model_name) zaza_model.run_action(self.lead_unit, 'pause', model_name=self.model_name) zaza_model.block_until_unit_wl_status(self.lead_unit, 'maintenance', model_name=self.model_name) zaza_model.block_until_all_units_idle(model_name=self.model_name) zaza_model.run_action(self.lead_unit, 'resume', model_name=self.model_name) zaza_model.block_until_unit_wl_status(self.lead_unit, 'active', model_name=self.model_name) zaza_model.block_until_all_units_idle(model_name=self.model_name) zaza_model.block_until_service_status(self.lead_unit, services, 'running', model_name=self.model_name)
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 config_file is changed. :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) 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 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)
def pause_resume(self, services): """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 config_file is changed. :type services: list """ model.block_until_service_status(self.lead_unit, services, 'running', model_name=self.model_name) model.block_until_unit_wl_status(self.lead_unit, 'active', model_name=self.model_name) 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) yield 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)