diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/test/testapi/deployment/deploy.py | 40 | ||||
-rw-r--r-- | utils/test/testapi/deployment/docker-compose.yml.template | 15 | ||||
-rw-r--r-- | utils/test/testapi/opnfv_testapi/resources/testcase_models.py | 88 |
3 files changed, 139 insertions, 4 deletions
diff --git a/utils/test/testapi/deployment/deploy.py b/utils/test/testapi/deployment/deploy.py new file mode 100644 index 000000000..748bd34f8 --- /dev/null +++ b/utils/test/testapi/deployment/deploy.py @@ -0,0 +1,40 @@ +import argparse +import os + +from jinja2 import Environment, FileSystemLoader + +env = Environment(loader=FileSystemLoader('./')) +docker_compose_yml = './docker-compose.yml' +docker_compose_template = './docker-compose.yml.template' + + +def render_docker_compose(port, swagger_url): + vars = { + "expose_port": port, + "swagger_url": swagger_url, + } + template = env.get_template(docker_compose_template) + yml = template.render(vars=vars) + + with open(docker_compose_yml, 'w') as f: + f.write(yml) + f.close() + + +def main(args): + render_docker_compose(args.expose_port, args.swagger_url) + os.system('docker-compose -f {} up -d'.format(docker_compose_yml)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Backup MongoDBs') + parser.add_argument('-p', '--expose-port', + type=int, + required=False, + default=8000, + help='testapi exposed port') + parser.add_argument('-su', '--swagger-url', + type=str, + required=True, + help='testapi exposed swagger-url') + main(parser.parse_args()) diff --git a/utils/test/testapi/deployment/docker-compose.yml.template b/utils/test/testapi/deployment/docker-compose.yml.template new file mode 100644 index 000000000..5b131f747 --- /dev/null +++ b/utils/test/testapi/deployment/docker-compose.yml.template @@ -0,0 +1,15 @@ +version: '2' +services: + mongo: + image: mongo:3.2.1 + container_name: opnfv-mongo + testapi: + image: opnfv/testapi:latest + container_name: opnfv-testapi + environment: + - mongodb_url=mongodb://mongo:27017/ + - swagger_url={{ vars.swagger_url }} + ports: + - "{{ vars.expose_port }}:8000" + links: + - mongo diff --git a/utils/test/testapi/opnfv_testapi/resources/testcase_models.py b/utils/test/testapi/opnfv_testapi/resources/testcase_models.py index e1f2fb650..0ed705f0f 100644 --- a/utils/test/testapi/opnfv_testapi/resources/testcase_models.py +++ b/utils/test/testapi/opnfv_testapi/resources/testcase_models.py @@ -11,10 +11,23 @@ from opnfv_testapi.tornado_swagger import swagger @swagger.model() class TestcaseCreateRequest(object): - def __init__(self, name, url=None, description=None): + def __init__(self, name, url=None, description=None, + tier=None, ci_loop=None, criteria=None, + blocking=None, dependencies=None, run=None, + domains=None, tags=None, version=None): self.name = name self.url = url self.description = description + self.tier = tier + self.ci_loop = ci_loop + self.criteria = criteria + self.blocking = blocking + self.dependencies = dependencies + self.run = run + self.domains = domains + self.tags = tags + self.version = version + self.trust = "Silver" def format(self): return { @@ -26,29 +39,66 @@ class TestcaseCreateRequest(object): @swagger.model() class TestcaseUpdateRequest(object): - def __init__(self, name=None, description=None, project_name=None): + def __init__(self, name=None, description=None, project_name=None, + tier=None, ci_loop=None, criteria=None, + blocking=None, dependencies=None, run=None, + domains=None, tags=None, version=None, trust=None): self.name = name self.description = description self.project_name = project_name + self.tier = tier + self.ci_loop = ci_loop + self.criteria = criteria + self.blocking = blocking + self.dependencies = dependencies + self.run = run + self.domains = domains + self.tags = tags + self.version = version + self.trust = trust def format(self): return { "name": self.name, "description": self.description, "project_name": self.project_name, + "tier": self.tier, + "ci_loop": self.ci_loop, + "criteria": self.criteria, + "blocking": self.blocking, + "dependencies": self.dependencies, + "run": self.run, + "domains": self.domains, + "tags": self.tags, + "version": self.version, + "trust": self.trust } @swagger.model() class Testcase(object): def __init__(self, _id=None, name=None, project_name=None, - description=None, url=None, creation_date=None): + description=None, url=None, creation_date=None, + tier=None, ci_loop=None, criteria=None, + blocking=None, dependencies=None, run=None, + domains=None, tags=None, version=None, + trust=None): self._id = None self.name = None self.project_name = None self.description = None self.url = None self.creation_date = None + self.tier=None + self.ci_loop=None + self.criteria=None + self.blocking=None + self.dependencies=None + self.run=None + self.domains=None + self.tags=None + self.version=None + self.trust=None @staticmethod def from_dict(a_dict): @@ -63,6 +113,16 @@ class Testcase(object): t.name = a_dict.get('name') t.description = a_dict.get('description') t.url = a_dict.get('url') + t.tier = a_dict.get('tier') + t.ci_loop = a_dict.get('ci_loop') + t.criteria = a_dict.get('criteria') + t.blocking = a_dict.get('blocking') + t.dependencies = a_dict.get('dependencies') + t.run = a_dict.get('run') + t.domains = a_dict.get('domains') + t.tags = a_dict.get('tags') + t.version = a_dict.get('version') + t.trust = a_dict.get('trust') return t @@ -72,7 +132,17 @@ class Testcase(object): "description": self.description, "project_name": self.project_name, "creation_date": str(self.creation_date), - "url": self.url + "url": self.url, + "tier": self.tier, + "ci_loop": self.ci_loop, + "criteria": self.criteria, + "blocking": self.blocking, + "dependencies": self.dependencies, + "run": self.run, + "domains": self.domains, + "tags": self.tags, + "version": self.version, + "trust": self.trust } def format_http(self): @@ -83,6 +153,16 @@ class Testcase(object): "description": self.description, "creation_date": str(self.creation_date), "url": self.url, + "tier": self.tier, + "ci_loop": self.ci_loop, + "criteria": self.criteria, + "blocking": self.blocking, + "dependencies": self.dependencies, + "run": self.run, + "domains": self.domains, + "tags": self.tags, + "version": self.version, + "trust": self.trust } |