From 3e7bd0b894b347699226ba3df2104d7d2913362f Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Wed, 5 Jul 2017 16:20:54 +0800 Subject: bugfix: hardcoded testapi urls testapi webportal's urls are fixed in configure files this patch aims to modify them according to base_url provided when bringing up container Change-Id: I29c461fc3b837e54d4ff5330dcaa520637590ff7 Signed-off-by: SerenaFeng --- utils/test/testapi/3rd_party/static/testapi-ui/config.json | 2 +- utils/test/testapi/deployment/deploy.py | 10 +++++----- utils/test/testapi/deployment/docker-compose.yml.template | 2 +- utils/test/testapi/docker/Dockerfile | 2 +- utils/test/testapi/docker/prepare-env.sh | 8 ++++++-- utils/test/testapi/etc/config.ini | 4 ++-- 6 files changed, 16 insertions(+), 12 deletions(-) (limited to 'utils/test/testapi') diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/config.json b/utils/test/testapi/3rd_party/static/testapi-ui/config.json index 9fdd85fbb..5d48c7b12 100644 --- a/utils/test/testapi/3rd_party/static/testapi-ui/config.json +++ b/utils/test/testapi/3rd_party/static/testapi-ui/config.json @@ -1 +1 @@ -{"testapiApiUrl": "http://testresults.opnfv.org/test/api/v1"} +{"testapiApiUrl": "http://localhost:8000/api/v1"} diff --git a/utils/test/testapi/deployment/deploy.py b/utils/test/testapi/deployment/deploy.py index 748bd34f8..6433fa6b2 100644 --- a/utils/test/testapi/deployment/deploy.py +++ b/utils/test/testapi/deployment/deploy.py @@ -8,10 +8,10 @@ docker_compose_yml = './docker-compose.yml' docker_compose_template = './docker-compose.yml.template' -def render_docker_compose(port, swagger_url): +def render_docker_compose(port, base_url): vars = { "expose_port": port, - "swagger_url": swagger_url, + "base_url": base_url, } template = env.get_template(docker_compose_template) yml = template.render(vars=vars) @@ -22,7 +22,7 @@ def render_docker_compose(port, swagger_url): def main(args): - render_docker_compose(args.expose_port, args.swagger_url) + render_docker_compose(args.expose_port, args.base_url) os.system('docker-compose -f {} up -d'.format(docker_compose_yml)) @@ -33,8 +33,8 @@ if __name__ == '__main__': required=False, default=8000, help='testapi exposed port') - parser.add_argument('-su', '--swagger-url', + parser.add_argument('-l', '--base-url', type=str, required=True, - help='testapi exposed swagger-url') + help='testapi exposed base-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 index 5b131f747..cd684048e 100644 --- a/utils/test/testapi/deployment/docker-compose.yml.template +++ b/utils/test/testapi/deployment/docker-compose.yml.template @@ -8,7 +8,7 @@ services: container_name: opnfv-testapi environment: - mongodb_url=mongodb://mongo:27017/ - - swagger_url={{ vars.swagger_url }} + - base_url={{ vars.base_url }} ports: - "{{ vars.expose_port }}:8000" links: diff --git a/utils/test/testapi/docker/Dockerfile b/utils/test/testapi/docker/Dockerfile index e031e194c..5311f35b8 100644 --- a/utils/test/testapi/docker/Dockerfile +++ b/utils/test/testapi/docker/Dockerfile @@ -9,7 +9,7 @@ # # Execution: # $ docker run -dti -p 8001:8000 \ -# -e "swagger_url=http://10.63.243.17:8001" \ +# -e "base_url=http://10.63.243.17:8001" \ # -e "mongodb_url=mongodb://10.63.243.17:27017/" \ # opnfv/testapi:tag # diff --git a/utils/test/testapi/docker/prepare-env.sh b/utils/test/testapi/docker/prepare-env.sh index 9f07efbd1..4f1be7d6a 100755 --- a/utils/test/testapi/docker/prepare-env.sh +++ b/utils/test/testapi/docker/prepare-env.sh @@ -6,6 +6,10 @@ if [ "$mongodb_url" != "" ]; then sudo crudini --set --existing $FILE mongo url $mongodb_url fi -if [ "$swagger_url" != "" ]; then - sudo crudini --set --existing $FILE swagger base_url $swagger_url +if [ "$base_url" != "" ]; then + sudo crudini --set --existing $FILE api url $base_url/api/v1 + sudo crudini --set --existing $FILE swagger base_url $base_url + sudo crudini --set --existing $FILE ui url $base_url + sudo echo "{\"testapiApiUrl\": \"$base_url/api/v1\"}" > \ + /usr/local/lib/python2.7/dist-packages/opnfv_testapi/static/testapi-ui/config.json fi diff --git a/utils/test/testapi/etc/config.ini b/utils/test/testapi/etc/config.ini index dad59d2d0..9ae25209d 100644 --- a/utils/test/testapi/etc/config.ini +++ b/utils/test/testapi/etc/config.ini @@ -8,7 +8,7 @@ dbname = test_results_collection [api] # Listening port -url = http://testresults.opnfv.org/test/api/v1 +url = http://localhost:8000/api/v1 port = 8000 # Number of results for one page (integer value) @@ -22,7 +22,7 @@ authenticate = False base_url = http://localhost:8000 [ui] -url = http://testresults.opnfv.org/test +url = http://localhost:8000 [osid] -- cgit 1.2.3-korg