diff options
Diffstat (limited to 'test')
11 files changed, 711 insertions, 0 deletions
diff --git a/test/csit/scripts/multicloud-pike/generic_sim/Dockerfile b/test/csit/scripts/multicloud-pike/generic_sim/Dockerfile new file mode 100644 index 000000000..688b58afe --- /dev/null +++ b/test/csit/scripts/multicloud-pike/generic_sim/Dockerfile @@ -0,0 +1,12 @@ +FROM python:2.7 + +EXPOSE 8080 + +RUN mkdir -p /{tmp,etc}/generic_sim + +WORKDIR /opt/generic_sim/ + +COPY . . +RUN pip install --no-cache-dir -r requirements.txt + +CMD [ "python", "generic_sim.py" ] diff --git a/test/csit/scripts/multicloud-pike/generic_sim/aai/responses.yml b/test/csit/scripts/multicloud-pike/generic_sim/aai/responses.yml new file mode 100644 index 000000000..276280729 --- /dev/null +++ b/test/csit/scripts/multicloud-pike/generic_sim/aai/responses.yml @@ -0,0 +1,189 @@ +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne: + GET: + body: '{"cloud-owner":"CloudOwner","cloud-region-id":"RegionOne","cloud-type":"openstack","owner-defined-type":"t1","cloud-region-version":"RegionOne","identity-url":"http://keystone:8080/v3","cloud-zone":"z1","complex-name":"clli1","sriov-automation":false,"cloud-extra-info":"","resource-version":"1524845154715"}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/availability-zones/availability-zone/internal: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/availability-zones/availability-zone/internal","Node + Not Found:No Node of type availability-zone found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/availability-zones/availability-zone/internal","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/availability-zones/availability-zone/nova: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/availability-zones/availability-zone/nova","Node + Not Found:No Node of type availability-zone found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/availability-zones/availability-zone/nova","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/100: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/100","Node + Not Found:No Node of type flavor found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/100","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/110: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/110","Node + Not Found:No Node of type flavor found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/110","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/111: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/111","Node + Not Found:No Node of type flavor found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/111","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/112: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/112","Node + Not Found:No Node of type flavor found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/112","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/113: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/113","Node + Not Found:No Node of type flavor found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/113","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/114: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/114","Node + Not Found:No Node of type flavor found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/114","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/115: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/115","Node + Not Found:No Node of type flavor found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/115","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/116: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/116","Node + Not Found:No Node of type flavor found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/116","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/117: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/117","Node + Not Found:No Node of type flavor found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/117","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/660709df-e90b-471f-ac57-d8c2555e573d: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/660709df-e90b-471f-ac57-d8c2555e573d","Node + Not Found:No Node of type image found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/660709df-e90b-471f-ac57-d8c2555e573d","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3543226ffed44daf90a2f71f36c00b8d: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3543226ffed44daf90a2f71f36c00b8d","Node + Not Found:No Node of type tenant found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/3543226ffed44daf90a2f71f36c00b8d","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b8f5d85bbcd84af28d7caa62d39f05c7: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b8f5d85bbcd84af28d7caa62d39f05c7","Node + Not Found:No Node of type tenant found at: cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b8f5d85bbcd84af28d7caa62d39f05c7","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne: + GET: + body: '{"cloud-owner":"CloudOwner","cloud-region-id":"RegionOne","cloud-type":"openstack","owner-defined-type":"t1","cloud-region-version":"RegionOne","identity-url":"http://multicloud-pike:80/api/multicloud-titanium_cloud/v0/CloudOwner_RegionOne/identity/v2.0","cloud-zone":"z1","complex-name":"clli1","sriov-automation":false,"cloud-extra-info":"","resource-version":"1524845276291"}' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/esr-system-info-list: + GET: + body: '{"esr-system-info":[{"esr-system-info-id":"4ce895ad-82f7-4476-b5eb-d19d19585da2","service-url":"http://keystone:8080/v3","user-name":"admin","password":"secret","system-type":"VIM","ssl-insecure":true,"cloud-domain":"Default","default-tenant":"admin","resource-version":"1524845155617"}]}' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/pservers/pserver/compute-0: + GET: + body: '{"requestError":{"serviceException":{"messageId":"SVC3001","text":"Resource + not found for %1 using id %2 (msg=%3) (ec=%4)","variables":["GET","cloud-infrastructure/pservers/pserver/compute-0","Node + Not Found:No Node of type pserver found at: cloud-infrastructure/pservers/pserver/compute-0","ERR.5.4.6114"]}}}' + content_type: application/json + status_code: 200 + PUT: + body: '' + content_type: application/json + status_code: 200 +aai/v13/cloud-infrastructure/pservers/pserver/compute-0/relationship-list/relationship: + PUT: + body: '' + content_type: application/json + status_code: 200 diff --git a/test/csit/scripts/multicloud-pike/generic_sim/cinder/responses.yml b/test/csit/scripts/multicloud-pike/generic_sim/cinder/responses.yml new file mode 100644 index 000000000..d9657a5df --- /dev/null +++ b/test/csit/scripts/multicloud-pike/generic_sim/cinder/responses.yml @@ -0,0 +1,5 @@ +/snapshots/detail: + get: + body: '{"snapshots": []}' + content_type: application/json + status_code: 200 diff --git a/test/csit/scripts/multicloud-pike/generic_sim/generic_sim.py b/test/csit/scripts/multicloud-pike/generic_sim/generic_sim.py new file mode 100644 index 000000000..4392b6524 --- /dev/null +++ b/test/csit/scripts/multicloud-pike/generic_sim/generic_sim.py @@ -0,0 +1,109 @@ +# Copyright 2018 Intel Corporation, Inc +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import logging + +import web +from web import webapi +import yaml + +urls = ( + '/(.*)','MockController' +) + +def setup_logger(name, log_file, level=logging.DEBUG): + print("Configuring the logger...") + handler = logging.FileHandler(log_file) + formatter = logging.Formatter('%(message)s') + handler.setFormatter(formatter) + + logger = logging.getLogger(name) + logger.setLevel(level) + logger.addHandler(handler) + + return logger + + +class MockResponse: + def __init__(self, http_verb, status_code, + content_type="application/json", body="{}", + headers={}): + self.http_verb = http_verb.lower() + self.status_code = status_code + self.content_type = content_type + self.body = body + self.headers = headers + +def _parse_responses(parsed_responses): + result = {} + for path, responses in parsed_responses.iteritems(): + new_path = path + if path.startswith("/"): + new_path = path[1:] + + result[new_path] = [] + for http_verb, response in responses.iteritems(): + result[new_path].append(MockResponse(http_verb, **response)) + return result + +def load_responses(filename): + print("Loading responses from configuration file..") + with open(filename) as yaml_file: + responses_file = yaml.safe_load(yaml_file) + responses_map = _parse_responses(responses_file) + return responses_map + + +class MockController: + + def _do_action(self, action): + logger.info('{}'.format(web.ctx.env.get('wsgi.input').read())) + action = action.lower() + url = web.ctx['fullpath'] + try: + if url.startswith("/"): + url = url[1:] + response = [ r for r in responses_map[url] if r.http_verb == action][0] + for header, value in response.headers.iteritems(): + web.header(header, value) + web.header('Content-Type', response.content_type) + print(response.body) + return response.body + except: + webapi.NotFound() + + def DELETE(self, url): + return self._do_action("delete") + + def HEAD(self, url): + return self._do_action("head") + + def PUT(self, url): + return self._do_action("put") + + def GET(self, url): + return self._do_action("get") + + def POST(self, url): + return self._do_action("post") + + def PATCH(self, url): + return self._do_action("patch") + + +logger = setup_logger('mock_controller', '/tmp/generic_sim/output.log') +responses_map = load_responses('/etc/generic_sim/responses.yml') +app = web.application(urls, globals()) +if __name__ == "__main__": + app.run() diff --git a/test/csit/scripts/multicloud-pike/generic_sim/glance/responses.yml b/test/csit/scripts/multicloud-pike/generic_sim/glance/responses.yml new file mode 100644 index 000000000..d8422352b --- /dev/null +++ b/test/csit/scripts/multicloud-pike/generic_sim/glance/responses.yml @@ -0,0 +1,73 @@ +/v2/images: + get: + body: '{"images": [{"status": "active", "schema": "/v2/schemas/image", + "virtual_size": null, "description": "", "tags": [], "container_format": + "bare", "created_at": "2018-04-21T06:12:13Z", "disk_format": "raw", + "updated_at": "2018-04-21T06:12:24Z", "visibility": "public", "id": + "660709df-e90b-471f-ac57-d8c2555e573d", "owner": "b8f5d85bbcd84af28d7caa62d39f05c7", + "protected": false, "min_ram": 0, "file": "/v2/images/660709df-e90b-471f-ac57-d8c2555e573d/file", + "checksum": "683f86920d4c922cb5c55d99d646b895", "min_disk": 0, "size": + 1697597440, "self": "/v2/images/660709df-e90b-471f-ac57-d8c2555e573d", "store": + "file", "name": "tis4-centos-guest"}], "first": "/v2/images", "schema": + "/v2/schemas/images"}' + content_type: application/json + status_code: 200 +/v2/schemas/image: + get: + body: '{"additionalProperties": {"type": "string"}, "name": "image", + "links": [{"href": "{self}", "rel": "self"}, {"href": "{file}", + "rel": "enclosure"}, {"href": "{schema}", "rel": "describedby"}], + "properties": {"container_format": {"enum": [null, "ami", "ari", "aki", + "bare", "ovf", "ova", "docker"], "type": ["null", "string"], "description": + "Format of the container"}, "min_ram": {"type": "integer", "description": + "Amount of ram (in MB) required to boot image."}, "ramdisk_id": {"pattern": + "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$", + "type": ["null", "string"], "description": "ID of image stored in Glance + that should be used as the ramdisk when booting an AMI-style image.", "is_base": + false}, "locations": {"items": {"required": ["url", "metadata"], "type": + "object", "properties": {"url": {"type": "string", "maxLength": + 255}, "metadata": {"type": "object"}}}, "type": "array", "description": + "A set of URLs to access the image file kept in external store"}, "file": + {"readOnly": true, "type": "string", "description": "An image file + url"}, "owner": {"type": ["null", "string"], "description": "Owner + of the image", "maxLength": 255}, "id": {"pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$", + "type": "string", "description": "An identifier for the image"}, "size": + {"readOnly": true, "type": ["null", "integer"], "description": "Size + of image file in bytes"}, "os_distro": {"type": "string", "description": + "Common name of operating system distribution as specified in https://docs.openstack.org/python-glanceclient/latest/cli/property-keys.html", + "is_base": false}, "self": {"readOnly": true, "type": "string", "description": + "An image self url"}, "disk_format": {"enum": [null, "ami", "ari", + "aki", "vhd", "vhdx", "vmdk", "raw", "qcow2", "vdi", "iso", + "ploop"], "type": ["null", "string"], "description": "Format of the + disk"}, "os_version": {"type": "string", "description": "Operating + system version as specified by the distributor", "is_base": false}, "direct_url": + {"readOnly": true, "type": "string", "description": "URL to access + the image file kept in external store"}, "schema": {"readOnly": true, "type": + "string", "description": "An image schema url"}, "status": {"readOnly": + true, "enum": ["queued", "saving", "active", "killed", "deleted", + "pending_delete", "deactivated"], "type": "string", "description": + "Status of the image"}, "tags": {"items": {"type": "string", "maxLength": + 255}, "type": "array", "description": "List of strings related to the + image"}, "kernel_id": {"pattern": "^([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}$", + "type": ["null", "string"], "description": "ID of image stored in Glance + that should be used as the kernel when booting an AMI-style image.", "is_base": + false}, "visibility": {"enum": ["community", "public", "private", + "shared"], "type": "string", "description": "Scope of image accessibility"}, + "updated_at": {"readOnly": true, "type": "string", "description": + "Date and time of the last image modification"}, "min_disk": {"type": + "integer", "description": "Amount of disk space (in GB) required to boot + image."}, "virtual_size": {"readOnly": true, "type": ["null", "integer"], + "description": "Virtual size of image in bytes"}, "instance_uuid": {"type": + "string", "description": "Metadata which can be used to record which instance + this image is associated with. (Informational only, does not create an instance + snapshot.)", "is_base": false}, "name": {"type": ["null", "string"], + "description": "Descriptive name for the image", "maxLength": 255}, "checksum": + {"readOnly": true, "type": ["null", "string"], "description": "md5 + hash of image contents.", "maxLength": 32}, "created_at": {"readOnly": + true, "type": "string", "description": "Date and time of image registration"}, + "protected": {"type": "boolean", "description": "If true, image will + not be deletable."}, "architecture": {"type": "string", "description": + "Operating system architecture as specified in https://docs.openstack.org/python-glanceclient/latest/cli/property-keys.html", + "is_base": false}}}' + content_type: application/json + status_code: 200 diff --git a/test/csit/scripts/multicloud-pike/generic_sim/keystone/responses.yml b/test/csit/scripts/multicloud-pike/generic_sim/keystone/responses.yml new file mode 100644 index 000000000..422ec7b7b --- /dev/null +++ b/test/csit/scripts/multicloud-pike/generic_sim/keystone/responses.yml @@ -0,0 +1,44 @@ +projects: + get: + body: '{"projects": [{"is_domain": false, "description": "admin tenant", + "links": {"self": "http://keystone:8080/v3/projects/b8f5d85bbcd84af28d7caa62d39f05c7"}, + "enabled": true, "domain_id": "default", "parent_id": "default", "id": + "b8f5d85bbcd84af28d7caa62d39f05c7", "name": "admin"}, {"is_domain": + false, "description": "Tenant for the openstack services", "links": {"self": + "http://keystone:8080/v3/projects/3543226ffed44daf90a2f71f36c00b8d"}, + "enabled": true, "domain_id": "default", "parent_id": "default", "id": + "3543226ffed44daf90a2f71f36c00b8d", "name": "services"}], "links": {"self": + "http://keystone:8080/v3/projects", "next": null, "previous": null}}' + content_type: application/json + status_code: 200 +v3/auth/tokens: + post: + body: '{"token": {"methods": ["password"], "expires_at": "2019-11-06T15:32:17.893769Z", + "user": { "domain": {"id": "default", "name": "Default"}, + "id": "423f19a4ac1e4f48bbb4180756e6eb6c", "name": "admin", "password_expires_at": null }, + "audit_ids": [ "ZzZwkUflQfygX7pdYDBCQQ"], "catalog": [ + { "endpoints": [ + { "id": "1", "interface": "public", "region": "RegionOne", "url": "http://keystone:8080" }, + { "id": "2", "interface": "internal", "region": "RegionOne", "url": "http://keystone:8080" }, + { "id": "3", "interface": "admin", "region": "RegionOne", "url": "http://keystone:8080" } + ], "id": "1", "type": "identity", "name": "keystone"}, + { "endpoints": [ + { "id": "1", "interface": "public", "region": "RegionOne", "url": "http://glance:8080" }, + { "id": "2", "interface": "internal", "region": "RegionOne", "url": "http://glance:8080" }, + { "id": "3", "interface": "admin", "region": "RegionOne", "url": "http://glance:8080" } + ], "id": "2", "type": "image", "name": "glance"}, + { "endpoints": [ + { "id": "1", "interface": "public", "region": "RegionOne", "url": "http://cinder:8080" }, + { "id": "2", "interface": "internal", "region": "RegionOne", "url": "http://cinder:8080" }, + { "id": "3", "interface": "admin", "region": "RegionOne", "url": "http://cinder:8080" } + ], "id": "2", "type": "volumev3", "name": "cinder"}, + { "endpoints": [ + { "id": "1", "interface": "public", "region": "RegionOne", "url": "http://nova:8080" }, + { "id": "2", "interface": "internal", "region": "RegionOne", "url": "http://nova:8080" }, + { "id": "3", "interface": "admin", "region": "RegionOne", "url": "http://nova:8080" } + ], "id": "3", "type": "compute", "name": "nova"}], + "issued_at": "2015-11-06T14:32:17.893797Z"}}' + content_type: application/json + status_code: 200 + headers: + X-Subject-Token: 423f19a4ac1e4f48bbb4180756e6eb6c diff --git a/test/csit/scripts/multicloud-pike/generic_sim/log_parser.py b/test/csit/scripts/multicloud-pike/generic_sim/log_parser.py new file mode 100644 index 000000000..1334e608c --- /dev/null +++ b/test/csit/scripts/multicloud-pike/generic_sim/log_parser.py @@ -0,0 +1,61 @@ +import argparse + +import yaml + + +def _find_aai_response_content(inp): + return inp.split("||||")[1].split("with response content = ")[1] + +def _find_openstack_url(inp): + return inp.split("||||")[1].split("making request with URI:")[1] + +def _find_openstack_response_content(inp): + return inp.split("||||")[1].split("with content:")[1].replace("u'", "'") + +def _add_response(all_responses, url, http_verb, body, status_code=200, content_type="application/json"): + if url not in all_responses.keys(): + all_responses[url] = { + http_verb: { + "status_code": status_code, + "content_type": content_type, + "body": body + } + } + elif http_verb not in all_responses[url].keys(): + all_responses[url][http_verb] = { + "status_code": status_code, + "content_type": content_type, + "body": body + } + +def parse_lines(content, aai_ip): + aai_pattern = "https://%s:30233/" % aai_ip + openstack_pattern = "making request with URI:" + + openstack_responses = {} + aai_responses = {} + for i, line in enumerate(content): + current_line = line.strip() + if aai_pattern in current_line and "DEBUG" not in current_line: + url = current_line.split(" ")[8][:-1].replace(aai_pattern, "") + _add_response(aai_responses, url, current_line.split(" ")[9][:-1], + _find_aai_response_content(content[i + 3])) + elif openstack_pattern in current_line: + _add_response(openstack_responses, + _find_openstack_url(current_line), "get", + _find_openstack_response_content(content[i + 2])) + + return [ + { "file": "nova.yml", "responses": openstack_responses }, + { "file": "aai.yml", "responses": aai_responses } + ] + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Convert logs to responses YAML tree file.') + parser.add_argument('--log-file', type=argparse.FileType('r'), help="Log file to be parsed", required=True) + parser.add_argument('--aai-ip', help="A&AI IP Address", required=True) + args = parser.parse_args() + + for mock_responses in parse_lines(args.log_file.readlines(), args.aai_ip): + with open(mock_responses["file"], 'w') as yaml_file: + yaml.dump(mock_responses["responses"], yaml_file, default_flow_style=False) diff --git a/test/csit/scripts/multicloud-pike/generic_sim/nova/responses.yml b/test/csit/scripts/multicloud-pike/generic_sim/nova/responses.yml new file mode 100644 index 000000000..944697117 --- /dev/null +++ b/test/csit/scripts/multicloud-pike/generic_sim/nova/responses.yml @@ -0,0 +1,177 @@ +/flavors/110/os-extra_specs: + get: + body: '{"extra_specs": {"hw:cpu_policy": "dedicated", "hw:mem_page_size": + "large", "hw:cpu_sockets": "2", "hw:cpu_threads": "8", "hw:numa_mem.1": + "2048", "hw:numa_mem.0": "2048", "hw:capabilities:cpu_info:features": + "avx,acpi", "aggregate_instance_extra_specs:storage": "local_image", "hw:numa_nodes": + "2", "hw:numa_cpus.0": "0,1", "hw:numa_cpus.1": "2,3,4,5", "hw:cpu_cores": + "4", "hw:cpu_thread_policy": "prefer", "pci_passthrough:alias": "sriov-vf-intel-8086-15b3:4"}}' + content_type: application/json + status_code: 200 +/flavors/111/os-extra_specs: + get: + body: '{"extra_specs": {"aggregate_instance_extra_specs:storage": "local_image"}}' + content_type: application/json + status_code: 200 +/flavors/112/os-extra_specs: + get: + body: '{"extra_specs": {"hw:cpu_policy": "dedicated", "hw:cpu_thread_policy": + "isolate", "aggregate_instance_extra_specs:storage": "local_image"}}' + content_type: application/json + status_code: 200 +/flavors/113/os-extra_specs: + get: + body: '{"extra_specs": {"hw:cpu_cores": "8", "hw:cpu_threads": "16", + "aggregate_instance_extra_specs:storage": "local_image", "hw:cpu_sockets": + "2"}}' + content_type: application/json + status_code: 200 +/flavors/114/os-extra_specs: + get: + body: '{"extra_specs": {"aggregate_instance_extra_specs:storage": "local_image", + "hw:mem_page_size": "small"}}' + content_type: application/json + status_code: 200 +/flavors/115/os-extra_specs: + get: + body: '{"extra_specs": {"hw:numa_mem.1": "1024", "hw:numa_mem.0": "1024", + "aggregate_instance_extra_specs:storage": "local_image", "hw:numa_nodes": + "2", "hw:numa_cpus.0": "0,1", "hw:numa_cpus.1": "2,3"}}' + content_type: application/json + status_code: 200 +/flavors/116/os-extra_specs: + get: + body: '{"extra_specs": {"hw:capabilities:cpu_info:features": "avx,aes", + "aggregate_instance_extra_specs:storage": "local_image"}}' + content_type: application/json + status_code: 200 +/flavors/117/os-extra_specs: + get: + body: '{"extra_specs": {"aggregate_instance_extra_specs:storage": "local_image", + "pci_passthrough:alias": "sriov-vf-intel-8086-15b3:6"}}' + content_type: application/json + status_code: 200 +/flavors/detail: + get: + body: '{"flavors": [{"name": "f.small", "links": [{"href": "http://nova:8080/v2.1/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/100", + "rel": "self"}, {"href": "http://nova:8080/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/100", + "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, + "vcpus": 2, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": + 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 0, "id": "100"}, {"name": + "onap.hpa.all", "links": [{"href": "http://nova:8080/v2.1/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/110", + "rel": "self"}, {"href": "http://nova:8080/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/110", + "rel": "bookmark"}], "ram": 4096, "OS-FLV-DISABLED:disabled": false, + "vcpus": 6, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": + 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 0, "id": "110"}, {"name": + "onap.hpa.basic", "links": [{"href": "http://nova:8080/v2.1/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/111", + "rel": "self"}, {"href": "http://nova:8080/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/111", + "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, + "vcpus": 4, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": + 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 0, "id": "111"}, {"name": + "onap.hpa.cpupinning", "links": [{"href": "http://nova:8080/v2.1/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/112", + "rel": "self"}, {"href": "http://nova:8080/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/112", + "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, + "vcpus": 4, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": + 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 0, "id": "112"}, {"name": + "onap.hpa.cputopology", "links": [{"href": "http://nova:8080/v2.1/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/113", + "rel": "self"}, {"href": "http://nova:8080/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/113", + "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, + "vcpus": 2, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": + 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 0, "id": "113"}, {"name": + "onap.hpa.hugepage", "links": [{"href": "http://nova:8080/v2.1/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/114", + "rel": "self"}, {"href": "http://nova:8080/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/114", + "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, + "vcpus": 2, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": + 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 0, "id": "114"}, {"name": + "onap.hpa.numa", "links": [{"href": "http://nova:8080/v2.1/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/115", + "rel": "self"}, {"href": "http://nova:8080/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/115", + "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, + "vcpus": 4, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": + 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 0, "id": "115"}, {"name": + "onap.hpa.instruction", "links": [{"href": "http://nova:8080/v2.1/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/116", + "rel": "self"}, {"href": "http://nova:8080/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/116", + "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, + "vcpus": 2, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": + 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 0, "id": "116"}, {"name": + "onap.hpa.passthrough", "links": [{"href": "http://nova:8080/v2.1/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/117", + "rel": "self"}, {"href": "http://nova:8080/b8f5d85bbcd84af28d7caa62d39f05c7/flavors/117", + "rel": "bookmark"}], "ram": 2048, "OS-FLV-DISABLED:disabled": false, + "vcpus": 2, "swap": "", "os-flavor-access:is_public": true, "rxtx_factor": + 1.0, "OS-FLV-EXT-DATA:ephemeral": 0, "disk": 0, "id": "117"}]}' + content_type: application/json + status_code: 200 +/os-availability-zone/detail: + get: + body: '{"availabilityZoneInfo": [{"zoneState": {"available": true}, "hosts": + {"controller-0": {"nova-conductor": {"available": true, "active": true, + "updated_at": "2018-04-27T16:05:25.272674"}, "nova-consoleauth": {"available": + true, "active": true, "updated_at": "2018-04-27T16:05:21.875274"}, "nova-scheduler": + {"available": true, "active": true, "updated_at": "2018-04-27T16:05:25.286846"}}}, + "zoneName": "internal"}, {"zoneState": {"available": false}, "hosts": + null, "zoneName": "nova"}]}' + content_type: application/json + status_code: 200 +/os-hypervisors/detail: + get: + body: '{ + "hypervisors": [{ + "status": "disabled", + "service": { + "host": "compute-0", + "disabled_reason": null, + "id": 11 + }, + "vcpus_used": 0.0, + "hypervisor_type": "QEMU", + "id": 1, + "local_gb_used": 0, + "state": "down", + "hypervisor_hostname": "compute-0", + "host_ip": "192.168.204.162", + "memory_mb": 51562, + "current_workload": 0, + "vcpus": 42, + "free_ram_mb": 51562, + "running_vms": 0, + "free_disk_gb": 1740, + "hypervisor_version": 2010000, + "disk_available_least": 1740, + "local_gb": 1833, + "cpu_info": "{\"vendor\": \"Intel\", \"model\": \"IvyBridge\", \"arch\": \"x86_64\", \"features\": [\"pge\", \"avx\", \"xsaveopt\", \"clflush\", \"sep\", \"syscall\",\"tsc-deadline\",\"dtes64\",\"msr\",\"fsgsbase\",\"xsave\",\"vmx\",\"erms\",\"xtpr\",\"cmov\",\"smep\",\"pcid\",\"est\",\"pat\",\"monitor\",\"smx\",\"pbe\",\"lm\",\"tsc\",\"nx\",\"fxsr\",\"tm\",\"sse4.1\",\"pae\",\"sse4.2\",\"pclmuldq\",\"acpi\",\"vme\",\"popcnt\",\"mmx\",\"osxsave\",\"cx8\",\"mce\",\"de\",\"rdtscp\",\"ht\",\"dca\",\"lahf_lm\",\"pdcm\",\"mca\",\"pdpe1gb\",\"a pic\",\"sse\",\"f16c\",\"pse\",\"ds\",\"invtsc\",\"pni\",\"tm2\",\"aes\",\"sse2\",\"ss\",\"ds_cpl\",\"arat\",\"ssse3\",\"fpu\",\"cx16\",\"pse36\",\"mtrr\",\"rdrand\",\"x2apic\"],\"topology\": {\"cores\": 12,\"cells\": 2,\"threads\": 2,\"sockets\": 1}}", + "memory_mb_used ": 0 + }] +}' + content_type: application/json + status_code: 200 +/os-hypervisors/detail?hypervisor_hostname_pattern=controller-0: + get: + body: '{ + "hypervisors": [{ + "status": "disabled", + "service": { + "host": "compute-0", + "disabled_reason": null, + "id": 11 + }, + "vcpus_used": 0.0, + "hypervisor_type": "QEMU", + "id": 1, + "local_gb_used": 0, + "state": "down", + "hypervisor_hostname": "compute-0", + "host_ip": "192.168.204.162", + "memory_mb": 51562, + "current_workload": 0, + "vcpus": 42, + "free_ram_mb": 51562, + "running_vms": 0, + "free_disk_gb": 1740, + "hypervisor_version": 2010000, + "disk_available_least": 1740, + "local_gb": 1833, + "cpu_info": "{\"vendor\": \"Intel\", \"model\": \"IvyBridge\", \"arch\": \"x86_64\", \"features\": [\"pge\", \"avx\", \"xsaveopt\", \"clflush\", \"sep\", \"syscall\",\"tsc-deadline\",\"dtes64\",\"msr\",\"fsgsbase\",\"xsave\",\"vmx\",\"erms\",\"xtpr\",\"cmov\",\"smep\",\"pcid\",\"est\",\"pat\",\"monitor\",\"smx\",\"pbe\",\"lm\",\"tsc\",\"nx\",\"fxsr\",\"tm\",\"sse4.1\",\"pae\",\"sse4.2\",\"pclmuldq\",\"acpi\",\"vme\",\"popcnt\",\"mmx\",\"osxsave\",\"cx8\",\"mce\",\"de\",\"rdtscp\",\"ht\",\"dca\",\"lahf_lm\",\"pdcm\",\"mca\",\"pdpe1gb\",\"a pic\",\"sse\",\"f16c\",\"pse\",\"ds\",\"invtsc\",\"pni\",\"tm2\",\"aes\",\"sse2\",\"ss\",\"ds_cpl\",\"arat\",\"ssse3\",\"fpu\",\"cx16\",\"pse36\",\"mtrr\",\"rdrand\",\"x2apic\"],\"topology\": {\"cores\": 12,\"cells\": 2,\"threads\": 2,\"sockets\": 1}}", + "memory_mb_used ": 0 + }] +}' + content_type: application/json + status_code: 200 diff --git a/test/csit/scripts/multicloud-pike/generic_sim/requirements.txt b/test/csit/scripts/multicloud-pike/generic_sim/requirements.txt new file mode 100644 index 000000000..ac1d7dd77 --- /dev/null +++ b/test/csit/scripts/multicloud-pike/generic_sim/requirements.txt @@ -0,0 +1,2 @@ +PyYAML +web.py diff --git a/test/csit/tests/multicloud-pike/provision/hpa_multicloud.robot b/test/csit/tests/multicloud-pike/provision/hpa_multicloud.robot new file mode 100644 index 000000000..f96b542b3 --- /dev/null +++ b/test/csit/tests/multicloud-pike/provision/hpa_multicloud.robot @@ -0,0 +1,17 @@ +*** settings *** +Library Collections +Library RequestsLibrary + +*** Variables *** +@{return_ok_list}= 200 201 202 +${queryregistration_url} /api/multicloud-pike/v0/CloudOwner_RegionOne/registry + + +*** Test Cases *** +OcataRegistryTest + [Documentation] Register openstack cloud resources + ${headers} Create Dictionary Content-Type=application/json Accept=application/json + Create Session web_session http://${SERVICE_IP}:${SERVICE_PORT} headers=${headers} + ${resp}= Post Request web_session ${queryregistration_url} + ${response_code}= Convert To String ${resp.status_code} + List Should Contain Value ${return_ok_list} ${response_code} diff --git a/test/csit/tests/multicloud-pike/provision/sanity_test_multicloud.robot b/test/csit/tests/multicloud-pike/provision/sanity_test_multicloud.robot new file mode 100644 index 000000000..36fcea3f0 --- /dev/null +++ b/test/csit/tests/multicloud-pike/provision/sanity_test_multicloud.robot @@ -0,0 +1,22 @@ +*** settings *** +Library Collections +Library RequestsLibrary +Library OperatingSystem +Library json + +*** Variables *** +@{return_ok_list}= 200 201 202 +${queryswagger_pike_url} /api/multicloud-pike/v0/swagger.json + + +*** Test Cases *** +OcataSwaggerTest + [Documentation] query swagger info rest test + ${headers} Create Dictionary Content-Type=application/json Accept=application/json + Create Session web_session http://${SERVICE_IP}:${SERVICE_PORT} headers=${headers} + ${resp}= Get Request web_session ${queryswagger_pike_url} + ${response_code}= Convert To String ${resp.status_code} + List Should Contain Value ${return_ok_list} ${response_code} + ${response_json} json.loads ${resp.content} + ${swagger_version}= Convert To String ${response_json['swagger']} + Should Be Equal ${swagger_version} 2.0 |