def main(): config = yaml.load(open(utils.get_fixture("config.yaml"))) auth = config.get("auth") cert_content = auth["public_ssl"]["cert_data"]["content"] if not cert_content: exit() ip = auth["public_vip"] hostname = auth["public_ssl"]["hostname"] script = utils.get_fixture("update_hosts.sh") subprocess.check_call(["sudo", script, ip, hostname])
def determinate_components_names(): with open(utils.get_fixture("components_names.yaml", ("tests", ))) as names_file: components_names = yaml.load(names_file) # TODO(rpromyshlennikov): temporary fix: ovs service was not included, # because openvswitch-agent is managed by pacemaker # ["neutron-openvswitch-agent", ""] components = components_names["mk"] return components
def main(self): config = { "env": {"type": "fuel"}, "nodes": self.nodes, "lma": self.get_lma_credentials(), "auth": self.get_openstack_credentials(), } config_filename = utils.get_fixture("config.yaml", check_existence=False) with file(config_filename, "w") as f: yaml.safe_dump(config, f, default_flow_style=False)
def setup_class(cls): cls.config = yaml.load(open(utils.get_fixture("config.yaml"))) nodes = cls.config.get("nodes") cls.cluster = objects.Cluster() for node_args in nodes: cls.cluster.add_host(objects.Host(**node_args)) lma = cls.config.get("lma") cls.influxdb_api = influxdb_grafana_api.InfluxdbApi( address=lma["influxdb_vip"], port=lma["influxdb_port"], username=lma["influxdb_username"], password=lma["influxdb_password"], db_name=lma["influxdb_db_name"]) cls.grafana_api = influxdb_grafana_api.GrafanaApi( address=lma["grafana_vip"], port=lma["grafana_port"], username=lma["grafana_username"], password=lma["grafana_password"], influxdb=cls.influxdb_api, ) cls.es_kibana_api = es_kibana_api.EsKibanaApi( host=lma["elasticsearch_vip"], port=lma["elasticsearch_port"], ) # NOTE(rpromyshlennikov): It may need refactor, # if we use deploy without SSL auth = cls.config.get("auth") public_vip = auth["public_vip"] auth_url = "http://{}:5000/".format(public_vip) cert = False if auth.get("public_ssl", None) is not None: cert_content = auth["public_ssl"]["cert_data"]["content"] cert = utils.write_cert(cert_content) if cert_content else False hostname = auth["public_ssl"]["hostname"] auth_url = "https://{}:5000/".format(hostname) cls.os_clients = os_clients.OfficialClientManager( username=auth["access"]["user"], password=auth["access"]["password"], tenant_name=auth["access"]["tenant"], auth_url=auth_url, cert=cert, domain=auth["access"].get("domain", "Default"), )
def determinate_components_names(): env_type = utils.load_config().get("env", {}).get("type", "") with open(utils.get_fixture("components_names.yaml", ("tests", ))) as names_file: components_names = yaml.load(names_file) # TODO(rpromyshlennikov): temporary fix: ovs service was not included, # because openvswitch-agent is managed by pacemaker # ["neutron-openvswitch-agent", ""] components = components_names["fuel"]["0"] if settings.INFLUXDB_GRAFANA_PLUGIN_VERSION.startswith("1."): components = components_names["fuel"]["1"] if env_type == "mk": components = components_names["mk"] return components
def main(self): config = { "env": {"type": "mk"}, } for application in settings.CONFIGURE_APPS: try: method = getattr(self, "generate_{}_config". format(application)) config.update({ application: method() }) LOG.info("INFO: {} configured".format(application)) except NoApplication: LOG.info("INFO: No {} installed, skip".format(application)) config_filename = utils.get_fixture("config.yaml", check_existence=False) LOG.info("INFO: Saving config to {}".format(config_filename)) with open(config_filename, "w") as f: yaml.safe_dump(config, f, default_flow_style=False)
def check_http_get_response(url, expected_code=200, msg=None, **kwargs): """Perform a HTTP GET request and assert that the HTTP server replies with the expected code. :param url: the requested URL :type url: str :param expected_code: the expected HTTP response code. Defaults to 200 :type expected_code: int :param msg: the assertion message. Defaults to None :type msg: str :returns: HTTP response object :rtype: requests.Response """ session = requests.Session() session.mount("https://", TestHTTPAdapter()) cert = utils.get_fixture("rootCA.pem") msg = msg or "%s responded with {0}, expected {1}" % url response = session.get(url, verify=cert, **kwargs) if expected_code is not None: assert response.status_code == expected_code, msg return response
def test_heat_notifications(self, os_clients, os_actions, es_client): """Check that Heat notifications are present in Elasticsearch Scenario: 1. Run Heat platform actions 2. Check that Heat notifications are present in current Elasticsearch index Duration 25m """ heat_event_types = [ # "orchestration.stack.check.start", # "orchestration.stack.check.end", "orchestration.stack.create.start", "orchestration.stack.create.end", "orchestration.stack.delete.start", "orchestration.stack.delete.end", # "orchestration.stack.resume.start", # "orchestration.stack.resume.end", # "orchestration.stack.rollback.start", # "orchestration.stack.rollback.end", # "orchestration.stack.suspend.start", # "orchestration.stack.suspend.end" ] name = utils.rand_name("heat-flavor-") flavor = os_actions.create_flavor(name) filepath = utils.get_fixture("heat_create_neutron_stack_template.yaml", parent_dirs=("heat", )) with open(filepath) as template_file: template = template_file.read() parameters = { 'InstanceType': flavor.name, 'ImageId': os_actions.get_cirros_image().id, 'network': os_actions.get_internal_network()["id"], } stack = os_actions.create_stack(template, parameters=parameters) # os_clients.orchestration.actions.suspend(stack.id) # utils.wait( # (lambda: # os_clients.orchestration.stacks.get( # stack.id).stack_status == "SUSPEND_COMPLETE"), # interval=10, # timeout=180, # ) resources = os_clients.orchestration.resources.list(stack.id) resource_server = [ res for res in resources if res.resource_type == "OS::Nova::Server" ][0] # instance = os_clients.compute.servers.get( # resource_server.physical_resource_id) # assert instance.status == "SUSPENDED" # # os_clients.orchestration.actions.resume(stack.id) # utils.wait( # (lambda: # os_clients.orchestration.stacks.get( # stack.id).stack_status == "RESUME_COMPLETE"), # interval=10, # timeout=180, # ) instance = os_clients.compute.servers.get( resource_server.physical_resource_id) assert instance.status == "ACTIVE" # os_clients.orchestration.actions.check(stack.id) # # utils.wait( # (lambda: # os_clients.orchestration.stacks.get( # stack.id).stack_status == "CHECK_COMPLETE"), # interval=10, # timeout=180, # ) os_clients.orchestration.stacks.delete(stack.id) os_clients.compute.flavors.delete(flavor.id) name = utils.rand_name("heat-flavor-") extra_large_flavor = os_actions.create_flavor(name, 1048576) parameters['InstanceType'] = extra_large_flavor.name stack = os_actions.create_stack(template, disable_rollback=False, parameters=parameters, wait_active=False) assert stack.stack_status == "CREATE_IN_PROGRESS" utils.wait( (lambda: os_clients.orchestration.stacks.get(stack.id).stack_status in ("DELETE_COMPLETE", "ROLLBACK_COMPLETE")), interval=10, timeout=360, ) resources = os_clients.orchestration.resources.list(stack.id) resource_servers = [ res for res in resources if res.resource_type == "OS::Nova::Server" ] assert (not resource_servers or resource_servers[0].physical_resource_id == "") os_clients.compute.flavors.delete(extra_large_flavor.id) es_client.check_notifications(heat_event_types, query_filter="Logger:heat", size=500)
def put_updated_hiera(self, ssh): ssh.put_file(utils.get_fixture("hiera"), "/tmp/hiera") ssh.exec_command("chmod +x /tmp/hiera")