From 586778c97325089286507cbcfe65532765af362e Mon Sep 17 00:00:00 2001 From: elinuxhenrik Date: Wed, 20 Jan 2021 14:55:41 +0100 Subject: [PATCH] Uplift from master and step versions Step enrichment-coordinator-service to 1.1.1. Step r-app-catalogue to 1.1.1. Step policy-agent to 2.2.1. This is squash of the following commits: git cherry-pick 7a09fbb9eeb282cf89b88d5b38e75f483be15350 git cherry-pick ff5f78e7e6b14e37b3ac1620e38c8e6bf5a191b8 git cherry-pick d1702a33a3527cf46527c7cd61f435bd7ed08522 git cherry-pick 1da5c887797ae8cb715ad0b16b388aae18cda948 git cherry-pick a1db481e9f360a136081bdb7c7b5b3683d1cff91 git cherry-pick 89b64ab194785ec389c8353e4b90e3e7edd08662 git cherry-pick e1eebe59d712b5439b2813d69944a870be1e93ad git cherry-pick bfe1c4049297589c4ade863b12e3d6a6cb7abc99 git cherry-pick 7851a89c67279990a6d1b063ca62d49fdcb5be87 git cherry-pick 81ba9036a53ea3fc0fb4699005d86c7794faf8d6 git cherry-pick c760c62129b21c31243a331cf3c8f1963a1058a3 git cherry-pick f2bfafab18e7fb197a7e351a4f6a89c2936cbb5c git cherry-pick bc89f17bf07fc2aca8e8004b769c52eaafb117b8 git cherry-pick b61264738a459de5f1b9333ee4cb486df9f3b9f4 git cherry-pick e912ee4367d6a305ac038c86dec816b5ce71191b git cherry-pick e0b665e3ff544bb78411bdc7f6b3ba2818fdeed4 git cherry-pick b7f412244f9b5e8698f57b7921b30dc86853434d git cherry-pick f0019c8168b9d59f132ba47e939e8aa3ef324b7d git cherry-pick 4f7f0cda2f07f62dcbb2e371fc09764b2337a8e9 git cherry-pick 10e254d9b7bc522bb2c25d590e6d203bf25a592d git cherry-pick 2dbde318f013212c81c4a1f477d7638ec3367aa5 git cherry-pick beb7839bbfce438d984a6362fc02cb90257851d7 git cherry-pick 32180137b6aca9c3a4519ac00cb573cbae9dca83 git cherry-pick 132dcaf425bc2ce6f13b0725f11a9dd99a08eccb git cherry-pick fed5fc967794cb3d9d9abf3d48283908eff36cc9 git cherry-pick 7f685c3b730ce857b32bbd4bdbb214795511ec62 git cherry-pick 1e539490bc37fed791895dd1f2f898caa3b0ca5c git cherry-pick 27db02f21e9d2fce2bb57f64a17cf6f7044e0a4f git cherry-pick d658528f47b628595d6f2355a411736b0e58691d git cherry-pick 64cb483277e5162c1fbc943df043f44aff7f85f9 git cherry-pick 6296305fad90e21103fa92e05e0d21a3ba1356a2 git cherry-pick 28ea034c54771d3680743f3885c97d6bc9eb7f7b git cherry-pick 7bef63e604a6391d6f9264c049a51e6d0680e07a git cherry-pick 38c1f88849d9b529007ac07daeeca2ca0291793b Signed-off-by: elinuxhenrik Signed-off-by: PatrikBuhr Issue-ID: NONRTRIC-385 Change-Id: Ia3ad7f4a3f058e9d180aa51d34f7c2b7ccf17f33 --- .gitignore | 2 + docker-compose/README.md | 81 +- .../docker-compose.yaml} | 27 - docker-compose/control-panel/config/nginx.conf | 19 + docker-compose/control-panel/docker-compose.yaml | 33 + docker-compose/docker-compose.yaml | 21 + .../{docker-compose.yml => docker-compose.yaml} | 13 +- .../{withDmaap_nosdnc => }/mr/MsgRtrApi.properties | 0 .../{withDmaap_nosdnc => }/mr/cadi.properties | 0 docker-compose/mr/docker-compose.yml | 10 +- .../{withDmaap_nosdnc => }/mr/logback.xml | 0 .../kafka => mr}/zk_client_jaas.conf | 0 .../zk => mr}/zk_server_jaas.conf | 0 .../config/application-policyagent.yaml | 0 .../application_configuration.controller.json} | 10 + .../application_configuration.nocontroller.json} | 0 docker-compose/policy-service/docker-compose.yaml | 40 + .../{docker-compose.yml => docker-compose.yaml} | 7 +- .../sdnc/config/application-policyagent.yaml | 37 - docker-compose/sdnc/docker-compose.yml | 59 +- .../pms/application-policyagent.yaml | 37 - .../pms/application_configuration.json | 39 - docs/api-docs.rst | 6 +- docs/conf.py | 2 +- .../api}/ecs-api.json | 209 +- enrichment-coordinator-service/api/ecs-api.yaml | 893 +++++++ .../config/application.yaml | 12 +- enrichment-coordinator-service/pom.xml | 24 +- .../java/org/oransc/enrichment/BeanFactory.java | 37 +- .../oransc/enrichment/clients/AsyncRestClient.java | 50 +- .../enrichment/clients/AsyncRestClientFactory.java | 21 +- .../configuration/ApplicationConfig.java | 41 +- .../enrichment/configuration/WebClientConfig.java | 9 + .../enrichment/controllers/VoidResponse.java | 2 +- .../controllers/consumer/ConsumerCallbacks.java | 69 +- .../controllers/consumer/ConsumerController.java | 48 +- .../controllers/producer/ProducerCallbacks.java | 59 +- .../controllers/producer/ProducerConsts.java | 2 +- .../controllers/producer/ProducerController.java | 167 +- .../controllers/producer/ProducerEiTypeInfo.java | 14 +- .../controllers/producer/ProducerJobInfo.java | 11 +- .../producer/ProducerRegistrationInfo.java | 8 +- .../org/oransc/enrichment/repository/EiJob.java | 5 + .../org/oransc/enrichment/repository/EiJobs.java | 31 +- .../oransc/enrichment/repository/EiProducer.java | 19 + .../oransc/enrichment/repository/EiProducers.java | 102 +- .../org/oransc/enrichment/repository/EiType.java | 22 - .../org/oransc/enrichment/repository/EiTypes.java | 84 +- .../org/oransc/enrichment/repository/MultiMap.java | 6 +- .../enrichment/tasks/ProducerSupervision.java | 46 +- .../org/oransc/enrichment/ApplicationTest.java | 231 +- .../enrichment/clients/AsyncRestClientTest.java | 2 +- .../controller/ConsumerSimulatorController.java | 2 +- .../controller/ProducerSimulatorController.java | 4 +- onap/oran | 2 +- policy-agent/.gitignore | 1 + policy-agent/README.md | 2 +- policy-agent/pom.xml | 2 +- pom.xml | 2 +- r-app-catalogue/Dockerfile | 4 +- r-app-catalogue/config/application.yaml | 28 +- .../config/r-app-catalogue-keystore.jks | Bin 0 -> 3641 bytes r-app-catalogue/eclipse-formatter.xml | 314 +++ r-app-catalogue/pom.xml | 42 +- .../api/GeneralRappCatalogueControllerAdvisor.java | 9 +- .../rappcatalogue/api/ServicesApiDelegateImpl.java | 288 +-- .../rappcatalogue/configuration/TomcatConfig.java | 56 + .../rappcatalogue/exception/HeaderException.java | 2 +- .../exception/InvalidServiceException.java | 2 +- .../exception/ServiceNotFoundException.java | 2 +- .../org/oransc/rappcatalogue/HttpsRequestTest.java | 113 + .../api/ServicesApiDelegateImplTest.java | 546 ++--- test/auto-test/.gitignore | 1 + test/auto-test/FTC1.sh | 64 +- test/auto-test/FTC10.sh | 59 +- test/auto-test/FTC100.sh | 81 +- test/auto-test/FTC110.sh | 85 +- test/auto-test/FTC1100.sh | 319 ++- test/auto-test/FTC150.sh | 25 +- test/auto-test/FTC1800.sh | 117 +- test/auto-test/FTC300.sh | 51 +- test/auto-test/FTC310.sh | 23 +- test/auto-test/FTC350.sh | 61 +- test/auto-test/FTC800.sh | 68 +- test/auto-test/FTC810.sh | 55 +- test/auto-test/FTC850.sh | 56 +- test/auto-test/FTC900.sh | 47 +- test/auto-test/FTC_HELM-RECEPIE.sh | 302 +++ test/auto-test/PM_DEMO.sh | 49 +- test/auto-test/PM_EI_DEMO.sh | 88 +- test/auto-test/README.md | 2 +- test/common/.gitignore | 1 + test/common/README.md | 22 +- test/common/agent_api_functions.sh | 292 ++- test/common/api_curl.sh | 49 +- test/common/clean_kube.sh | 91 + test/common/consul_cbs_functions.sh | 219 ++ test/common/control_panel_api_functions.sh | 172 ++ test/common/controller_api_functions.sh | 213 +- test/common/cr_api_functions.sh | 201 +- test/common/ecs_api_functions.sh | 664 ++++- test/common/http_proxy_api_functions.sh | 129 + test/common/mr_api_functions.sh | 511 ++++ test/common/prodstub_api_functions.sh | 176 +- test/common/rapp_catalogue_api_functions.sh | 147 +- test/common/ricsimulator_api_functions.sh | 241 +- test/common/test_env-onap-guilin.sh | 342 ++- test/common/test_env-onap-honolulu.sh | 341 +++ test/common/test_env-onap-master.sh | 201 -- test/common/test_env-oran-cherry.sh | 480 ++-- test/common/test_env-oran-dawn.sh | 359 +++ test/common/test_env.sh | 189 -- test/common/testcase_common.sh | 2564 +++++++++++--------- test/mrstub/app/main.py | 148 +- test/mrstub/app/nginx.conf | 8 +- test/mrstub/app/requirements.txt | 3 +- test/mrstub/basic_test.sh | 4 +- test/mrstub/mrstub-build-start.sh | 2 +- test/simulator-group/control_panel/app.yaml | 37 + .../control_panel/application.properties | 37 + .../control_panel/docker-compose.yml | 4 +- test/simulator-group/control_panel/svc.yaml | 21 + test/simulator-group/cr/app.yaml | 28 + test/simulator-group/cr/svc.yaml | 21 + test/simulator-group/dmaapmr/app.yaml | 178 ++ .../simulator-group/dmaapmr/docker-compose.yaml | 89 +- .../dmaapmr/mnt/kafka/zk_client_jaas.conf | 5 + .../dmaapmr/mnt/mr/KUBE-MsgRtrApi.properties | 173 ++ .../dmaapmr/mnt/mr/MsgRtrApi.properties | 173 ++ .../simulator-group/dmaapmr/mnt/mr/cadi.properties | 19 + test/simulator-group/dmaapmr/mnt/mr/logback.xml | 209 ++ .../dmaapmr/mnt/zk/zk_server_jaas.conf | 4 + test/simulator-group/dmaapmr/svc.yaml | 57 + test/simulator-group/ecs/app.yaml | 43 + test/simulator-group/ecs/application.yaml | 54 + test/simulator-group/ecs/pvc.yaml | 16 + test/simulator-group/ecs/svc.yaml | 21 + test/simulator-group/httpproxy/.gitignore | 1 + test/simulator-group/httpproxy/app.yaml | 30 + .../docker-compose.yaml} | 13 +- test/simulator-group/httpproxy/svc.yaml | 21 + test/simulator-group/{mr => mrstub}/.gitignore | 0 test/simulator-group/mrstub/app.yaml | 33 + test/simulator-group/{mr => mrstub}/cert/cert.crt | 0 test/simulator-group/{mr => mrstub}/cert/key.crt | 0 test/simulator-group/{mr => mrstub}/cert/pass | 0 .../docker-compose.yml} | 30 +- test/simulator-group/mrstub/svc.yaml | 21 + test/simulator-group/policy_agent/app.yaml | 42 + test/simulator-group/policy_agent/application.yaml | 66 + .../policy_agent/docker-compose.yml | 4 +- test/simulator-group/policy_agent/mnt/.gitignore | 1 + .../policy_agent/mnt/application.yaml | 66 + test/simulator-group/policy_agent/svc.yaml | 21 + test/simulator-group/prodstub/app.yaml | 28 + test/simulator-group/prodstub/svc.yaml | 21 + test/simulator-group/rapp_catalogue/app.yaml | 28 + .../rapp_catalogue/docker-compose.yml | 2 +- test/simulator-group/rapp_catalogue/svc.yaml | 21 + test/simulator-group/ric/app.yaml | 36 + test/simulator-group/ric/svc.yaml | 15 + test/simulator-group/sdnc/app.yaml | 72 + test/simulator-group/sdnc/docker-compose.yml | 2 +- test/simulator-group/sdnc/svc.yaml | 57 + test/simulator-group/sim-monitor.js | 10 +- 165 files changed, 11578 insertions(+), 3662 deletions(-) rename docker-compose/{nosdnc/docker-compose.yml => a1-sim/docker-compose.yaml} (57%) create mode 100644 docker-compose/control-panel/config/nginx.conf create mode 100644 docker-compose/control-panel/docker-compose.yaml create mode 100644 docker-compose/docker-compose.yaml rename docker-compose/ecs/{docker-compose.yml => docker-compose.yaml} (83%) rename docker-compose/{withDmaap_nosdnc => }/mr/MsgRtrApi.properties (100%) rename docker-compose/{withDmaap_nosdnc => }/mr/cadi.properties (100%) rename docker-compose/{withDmaap_nosdnc => }/mr/logback.xml (100%) rename docker-compose/{withDmaap_nosdnc/kafka => mr}/zk_client_jaas.conf (100%) rename docker-compose/{withDmaap_nosdnc/zk => mr}/zk_server_jaas.conf (100%) rename docker-compose/{nosdnc => policy-service}/config/application-policyagent.yaml (100%) rename docker-compose/{sdnc/config/application_configuration.json => policy-service/config/application_configuration.controller.json} (80%) rename docker-compose/{nosdnc/config/application_configuration.json => policy-service/config/application_configuration.nocontroller.json} (100%) create mode 100644 docker-compose/policy-service/docker-compose.yaml rename docker-compose/rapp/{docker-compose.yml => docker-compose.yaml} (95%) delete mode 100755 docker-compose/sdnc/config/application-policyagent.yaml delete mode 100755 docker-compose/withDmaap_nosdnc/pms/application-policyagent.yaml delete mode 100644 docker-compose/withDmaap_nosdnc/pms/application_configuration.json rename {docs/offeredapis/swagger => enrichment-coordinator-service/api}/ecs-api.json (82%) create mode 100644 enrichment-coordinator-service/api/ecs-api.yaml create mode 100644 r-app-catalogue/config/r-app-catalogue-keystore.jks create mode 100644 r-app-catalogue/eclipse-formatter.xml create mode 100644 r-app-catalogue/src/main/java/org/oransc/rappcatalogue/configuration/TomcatConfig.java create mode 100644 r-app-catalogue/src/test/java/org/oransc/rappcatalogue/HttpsRequestTest.java create mode 100755 test/auto-test/FTC_HELM-RECEPIE.sh create mode 100644 test/common/.gitignore create mode 100755 test/common/clean_kube.sh create mode 100644 test/common/consul_cbs_functions.sh create mode 100644 test/common/control_panel_api_functions.sh create mode 100644 test/common/http_proxy_api_functions.sh create mode 100644 test/common/mr_api_functions.sh create mode 100644 test/common/test_env-onap-honolulu.sh delete mode 100644 test/common/test_env-onap-master.sh create mode 100755 test/common/test_env-oran-dawn.sh delete mode 100644 test/common/test_env.sh create mode 100644 test/simulator-group/control_panel/app.yaml create mode 100644 test/simulator-group/control_panel/application.properties create mode 100644 test/simulator-group/control_panel/svc.yaml create mode 100644 test/simulator-group/cr/app.yaml create mode 100644 test/simulator-group/cr/svc.yaml create mode 100644 test/simulator-group/dmaapmr/app.yaml rename docker-compose/withDmaap_nosdnc/docker-compose.yml => test/simulator-group/dmaapmr/docker-compose.yaml (51%) create mode 100644 test/simulator-group/dmaapmr/mnt/kafka/zk_client_jaas.conf create mode 100644 test/simulator-group/dmaapmr/mnt/mr/KUBE-MsgRtrApi.properties create mode 100644 test/simulator-group/dmaapmr/mnt/mr/MsgRtrApi.properties create mode 100644 test/simulator-group/dmaapmr/mnt/mr/cadi.properties create mode 100644 test/simulator-group/dmaapmr/mnt/mr/logback.xml create mode 100644 test/simulator-group/dmaapmr/mnt/zk/zk_server_jaas.conf create mode 100644 test/simulator-group/dmaapmr/svc.yaml create mode 100644 test/simulator-group/ecs/app.yaml create mode 100644 test/simulator-group/ecs/application.yaml create mode 100644 test/simulator-group/ecs/pvc.yaml create mode 100644 test/simulator-group/ecs/svc.yaml create mode 100644 test/simulator-group/httpproxy/.gitignore create mode 100644 test/simulator-group/httpproxy/app.yaml rename test/simulator-group/{mr/docker-compose.yml => httpproxy/docker-compose.yaml} (79%) create mode 100644 test/simulator-group/httpproxy/svc.yaml rename test/simulator-group/{mr => mrstub}/.gitignore (100%) create mode 100644 test/simulator-group/mrstub/app.yaml rename test/simulator-group/{mr => mrstub}/cert/cert.crt (100%) rename test/simulator-group/{mr => mrstub}/cert/key.crt (100%) rename test/simulator-group/{mr => mrstub}/cert/pass (100%) rename test/simulator-group/{consul_cbs/consul/cbs_localhost_config.hcl => mrstub/docker-compose.yml} (63%) create mode 100644 test/simulator-group/mrstub/svc.yaml create mode 100644 test/simulator-group/policy_agent/app.yaml create mode 100644 test/simulator-group/policy_agent/application.yaml create mode 100644 test/simulator-group/policy_agent/mnt/.gitignore create mode 100644 test/simulator-group/policy_agent/mnt/application.yaml create mode 100644 test/simulator-group/policy_agent/svc.yaml create mode 100644 test/simulator-group/prodstub/app.yaml create mode 100644 test/simulator-group/prodstub/svc.yaml create mode 100644 test/simulator-group/rapp_catalogue/app.yaml create mode 100644 test/simulator-group/rapp_catalogue/svc.yaml create mode 100644 test/simulator-group/ric/app.yaml create mode 100644 test/simulator-group/ric/svc.yaml create mode 100644 test/simulator-group/sdnc/app.yaml create mode 100644 test/simulator-group/sdnc/svc.yaml diff --git a/.gitignore b/.gitignore index 26c6731d..02f4f986 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ .tox docs/_build/ .DS_STORE +.swagger* +docs/offeredapis/swagger/README.md # Eclipse .checkstyle diff --git a/docker-compose/README.md b/docker-compose/README.md index fdcb5f59..d2f25c28 100644 --- a/docker-compose/README.md +++ b/docker-compose/README.md @@ -1,25 +1,51 @@ -# O-RAN-SC docker-compose files - -The docker-compose.yml file will create an entire nonrtric system with one command: -docker-compose up - -Two docker-compose files are provided in this folder: - -nosdnc/docker-compose.yml -This file is to create nonrtric system without sdnc a1-controller - -sdnc/docker-compose.yml -This file is to create nonrtric system with sdnc a1-controller +## License +Copyright (C) 2020 Nordix Foundation. +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 -Howto: -cd nosdnc/ -docker-compose up + http://www.apache.org/licenses/LICENSE-2.0 -or +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. -cd sdnc/ -docker-compose up +For more information about license please see the [LICENSE](LICENSE.txt) file for details. +## O-RAN-SC docker-compose files: +The docker compose file helps the user to deploy all or partial components of nonrtric with one command. + +All the components in nonrtric has individual docker compose file so you can simply mix and match different components and deploy +it at your preference. + +For ex. +I want to Control Panel, A1 Policy Management Service & A1 Simulator, +docker-compose -f docker-compose.yaml -f control-panel/docker-compose.yaml -f policy-service/docker-compose.yaml -f a1-sim/docker-compose.yaml up -d + +To remove all the containers use the same command, +docker-compose -f docker-compose.yaml -f control-panel/docker-compose.yaml -f policy-service/docker-compose.yaml -f a1-sim/docker-compose.yaml down + +It can be used with any combination to deploy nonrtric components. + +## Policy Service Prerequisite: +The A1 Policy Service can perform A1 Policy management with or without A1 Adapter. To enable/disable A1 Adapter all you have to do is, +With SDNC A1 Adapter: +Rename application_configuration.controller.json to application_configuration.json & start the container. Don't forget to add the A1 Adapter url,username & password in the application_configuration.json file. +You also need to update the A1 Adapter url & credentials in the application_configuration file. +Ex: +For example if you use the OSC A1 Adapter then, +"baseUrl": "http://a1controller:8282" +"userName": "admin", +"password": "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" +docker-compose -f docker-compose.yaml -f policy-service/docker-compose.yaml -f a1-sim/docker-compose.yaml up -d +Without SDNC A1 Adapter: +Rename application_configuration.nocontroller.json to application_configuration.json & start the container. +Ex: +docker-compose -f docker-compose.yaml -f policy-service/docker-compose.yaml -f a1-sim/docker-compose.yaml up -d + +## To create sample data: The scripts in data/ will generate some dummy data in the running system. It will create: one policy type in a1-sim-OSC @@ -43,21 +69,4 @@ prepareEcsData.sh This is to generate some data into the ECS microservice prepareDmaapMsg.sh -This is to generate some data into the Dmaap MR, so that PMS reads message from MR - -## License - -Copyright (C) 2020 Nordix Foundation. -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. - -For more information about license please see the [LICENSE](LICENSE.txt) file for details. +This is to generate some data into the Dmaap MR, so that PMS reads message from MR \ No newline at end of file diff --git a/docker-compose/nosdnc/docker-compose.yml b/docker-compose/a1-sim/docker-compose.yaml similarity index 57% rename from docker-compose/nosdnc/docker-compose.yml rename to docker-compose/a1-sim/docker-compose.yaml index c57cd29e..25bcf747 100644 --- a/docker-compose/nosdnc/docker-compose.yml +++ b/docker-compose/a1-sim/docker-compose.yaml @@ -21,24 +21,6 @@ networks: name: nonrtric-docker-net services: - policy-agent: - image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent:2.2.0 - container_name: policy-agent - networks: - default: - aliases: - - policy-agent-container - ports: - - 8081:8081 - - 8433:8433 - volumes: - - ./config/application_configuration.json:/opt/app/policy-agent/data/application_configuration.json:ro - # For using own certs instead of the default ones (built into the container), - # place them in config/ directory, update the application-policyagent.yaml file, and uncomment the following lines - # - ./config/keystore-policyagent.jks:/opt/app/policy-agent/etc/cert/keystore.jks:ro - # - ./config/truststore-policyagent.jks:/opt/app/policy-agent/etc/cert/truststore.jks:ro - # - ./config/application-policyagent.yaml:/opt/app/policy-agent/config/application.yaml:ro - a1-sim-OSC: image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:2.1.0 container_name: a1-sim-OSC @@ -64,12 +46,3 @@ services: - A1_VERSION=STD_1.1.3 - REMOTE_HOSTS_LOGGING=1 - ALLOW_HTTP=true - - policy-control-panel: - image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel:2.2.0 - container_name: policy-control-panel - networks: - - default - ports: - - 8080:8080 - - 8082:8082 diff --git a/docker-compose/control-panel/config/nginx.conf b/docker-compose/control-panel/config/nginx.conf new file mode 100644 index 00000000..81102eb8 --- /dev/null +++ b/docker-compose/control-panel/config/nginx.conf @@ -0,0 +1,19 @@ +events{} + +http { + include /etc/nginx/mime.types; + + upstream backend { + server nonrtric-gateway:9090; + } + + server { + listen 8080; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + location /api/ { + proxy_pass http://backend; + } + } +} \ No newline at end of file diff --git a/docker-compose/control-panel/docker-compose.yaml b/docker-compose/control-panel/docker-compose.yaml new file mode 100644 index 00000000..bc56c3db --- /dev/null +++ b/docker-compose/control-panel/docker-compose.yaml @@ -0,0 +1,33 @@ +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# +version: '3.5' + +networks: + default: + driver: bridge + name: nonrtric-docker-net + +services: + policy-control-panel: + image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel:2.2.0 + container_name: policy-control-panel + networks: + - default + ports: + - 8080:8080 + - 8082:8082 + volumes: + - ./control-panel/config/nginx.conf:/etc/nginx/nginx.conf:ro diff --git a/docker-compose/docker-compose.yaml b/docker-compose/docker-compose.yaml new file mode 100644 index 00000000..67f38106 --- /dev/null +++ b/docker-compose/docker-compose.yaml @@ -0,0 +1,21 @@ +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# +version: '3.5' + +networks: + default: + driver: bridge + name: nonrtric-docker-net \ No newline at end of file diff --git a/docker-compose/ecs/docker-compose.yml b/docker-compose/ecs/docker-compose.yaml similarity index 83% rename from docker-compose/ecs/docker-compose.yml rename to docker-compose/ecs/docker-compose.yaml index 8b64e253..5cf391c5 100644 --- a/docker-compose/ecs/docker-compose.yml +++ b/docker-compose/ecs/docker-compose.yaml @@ -22,7 +22,7 @@ networks: services: ecs: - image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-enrichment-coordinator-service:1.1.0 + image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-enrichment-coordinator-service:1.1.1 container_name: ecs networks: default: @@ -31,16 +31,6 @@ services: ports: - 8083:8083 - 8434:8434 - - policy-control-panel: - image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel:2.2.0 - container_name: policy-control-panel - networks: - - default - ports: - - 8080:8080 - - 8082:8082 - producer: image: eexit/mirror-http-server container_name: producer @@ -48,4 +38,3 @@ services: - default ports: - 8088:80 - diff --git a/docker-compose/withDmaap_nosdnc/mr/MsgRtrApi.properties b/docker-compose/mr/MsgRtrApi.properties similarity index 100% rename from docker-compose/withDmaap_nosdnc/mr/MsgRtrApi.properties rename to docker-compose/mr/MsgRtrApi.properties diff --git a/docker-compose/withDmaap_nosdnc/mr/cadi.properties b/docker-compose/mr/cadi.properties similarity index 100% rename from docker-compose/withDmaap_nosdnc/mr/cadi.properties rename to docker-compose/mr/cadi.properties diff --git a/docker-compose/mr/docker-compose.yml b/docker-compose/mr/docker-compose.yml index 48cc04ce..e2948f40 100644 --- a/docker-compose/mr/docker-compose.yml +++ b/docker-compose/mr/docker-compose.yml @@ -38,7 +38,7 @@ services: KAFKA_OPTS: -Djava.security.auth.login.config=/etc/zookeeper/secrets/jaas/zk_server_jaas.conf -Dzookeeper.kerberos.removeHostFromPrincipal=true -Dzookeeper.kerberos.removeRealmFromPrincipal=true -Dzookeeper.authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider -Dzookeeper.requireClientAuthScheme=sasl ZOOKEEPER_SERVER_ID: 1 volumes: - - ./zk/zk_server_jaas.conf:/etc/zookeeper/secrets/jaas/zk_server_jaas.conf + - ./mr/zk/zk_server_jaas.conf:/etc/zookeeper/secrets/jaas/zk_server_jaas.conf networks: - default @@ -63,7 +63,7 @@ services: # Reduced the number of partitions only to avoid the timeout error for the first subscribe call in slow environment KAFKA_OFFSETS_TOPIC_NUM_PARTITIONS: 1 volumes: - - ./kafka/zk_client_jaas.conf:/etc/kafka/secrets/jaas/zk_client_jaas.conf + - ./mr/kafka/zk_client_jaas.conf:/etc/kafka/secrets/jaas/zk_client_jaas.conf networks: - default depends_on: @@ -78,9 +78,9 @@ services: environment: enableCadi: 'false' volumes: - - ./mr/MsgRtrApi.properties:/appl/dmaapMR1/bundleconfig/etc/appprops/MsgRtrApi.properties - - ./mr/logback.xml:/appl/dmaapMR1/bundleconfig/etc/logback.xml - - ./mr/cadi.properties:/appl/dmaapMR1/etc/cadi.properties + - ./mr/mr/MsgRtrApi.properties:/appl/dmaapMR1/bundleconfig/etc/appprops/MsgRtrApi.properties + - ./mr/mr/logback.xml:/appl/dmaapMR1/bundleconfig/etc/logback.xml + - ./mr/mr/cadi.properties:/appl/dmaapMR1/etc/cadi.properties networks: - default depends_on: diff --git a/docker-compose/withDmaap_nosdnc/mr/logback.xml b/docker-compose/mr/logback.xml similarity index 100% rename from docker-compose/withDmaap_nosdnc/mr/logback.xml rename to docker-compose/mr/logback.xml diff --git a/docker-compose/withDmaap_nosdnc/kafka/zk_client_jaas.conf b/docker-compose/mr/zk_client_jaas.conf similarity index 100% rename from docker-compose/withDmaap_nosdnc/kafka/zk_client_jaas.conf rename to docker-compose/mr/zk_client_jaas.conf diff --git a/docker-compose/withDmaap_nosdnc/zk/zk_server_jaas.conf b/docker-compose/mr/zk_server_jaas.conf similarity index 100% rename from docker-compose/withDmaap_nosdnc/zk/zk_server_jaas.conf rename to docker-compose/mr/zk_server_jaas.conf diff --git a/docker-compose/nosdnc/config/application-policyagent.yaml b/docker-compose/policy-service/config/application-policyagent.yaml similarity index 100% rename from docker-compose/nosdnc/config/application-policyagent.yaml rename to docker-compose/policy-service/config/application-policyagent.yaml diff --git a/docker-compose/sdnc/config/application_configuration.json b/docker-compose/policy-service/config/application_configuration.controller.json similarity index 80% rename from docker-compose/sdnc/config/application_configuration.json rename to docker-compose/policy-service/config/application_configuration.controller.json index 09257038..ae9ba770 100644 --- a/docker-compose/sdnc/config/application_configuration.json +++ b/docker-compose/policy-service/config/application_configuration.controller.json @@ -1,10 +1,19 @@ { "config":{ "//description":"Application configuration", + "controller": [ + { + "name": "controller1", + "baseUrl": "", + "userName": "", + "password": "" + } + ], "ric":[ { "name":"ric1", "baseUrl":"https://a1-sim-OSC:8185/", + "controller": "controller1", "managedElementIds":[ "kista_1", "kista_2" @@ -13,6 +22,7 @@ { "name":"ric2", "baseUrl":"https://a1-sim-STD:8185/", + "controller": "controller1", "managedElementIds":[ "kista_1", "kista_2" diff --git a/docker-compose/nosdnc/config/application_configuration.json b/docker-compose/policy-service/config/application_configuration.nocontroller.json similarity index 100% rename from docker-compose/nosdnc/config/application_configuration.json rename to docker-compose/policy-service/config/application_configuration.nocontroller.json diff --git a/docker-compose/policy-service/docker-compose.yaml b/docker-compose/policy-service/docker-compose.yaml new file mode 100644 index 00000000..af4c0abd --- /dev/null +++ b/docker-compose/policy-service/docker-compose.yaml @@ -0,0 +1,40 @@ +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# +version: '3.5' + +networks: + default: + driver: bridge + name: nonrtric-docker-net + +services: + policy-agent: + image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent:2.2.1 + container_name: policy-agent + networks: + default: + aliases: + - policy-agent-container + ports: + - 8081:8081 + - 8433:8433 + volumes: + - ./policy-service/config/application_configuration.json:/opt/app/policy-agent/data/application_configuration.json:ro + # For using own certs instead of the default ones (built into the container), + # place them in config/ directory, update the application-policyagent.yaml file, and uncomment the following lines + # - ./policy-service/config/keystore-policyagent.jks:/opt/app/policy-agent/etc/cert/keystore.jks:ro + # - ./policy-service/config/truststore-policyagent.jks:/opt/app/policy-agent/etc/cert/truststore.jks:ro + # - ./policy-service/config/application-policyagent.yaml:/opt/app/policy-agent/config/application.yaml:ro diff --git a/docker-compose/rapp/docker-compose.yml b/docker-compose/rapp/docker-compose.yaml similarity index 95% rename from docker-compose/rapp/docker-compose.yml rename to docker-compose/rapp/docker-compose.yaml index 3265408a..a7f215f1 100644 --- a/docker-compose/rapp/docker-compose.yml +++ b/docker-compose/rapp/docker-compose.yaml @@ -22,14 +22,13 @@ networks: services: r-app: - image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-r-app-catalogue:1.1.0 + image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-r-app-catalogue:1.1.1 container_name: r-app networks: default: aliases: - r-app-catalogue ports: - - 8080:8080 - - 8433:8433 - + - 8680:8680 + - 8633:8633 diff --git a/docker-compose/sdnc/config/application-policyagent.yaml b/docker-compose/sdnc/config/application-policyagent.yaml deleted file mode 100755 index e9146e01..00000000 --- a/docker-compose/sdnc/config/application-policyagent.yaml +++ /dev/null @@ -1,37 +0,0 @@ -spring: - profiles: - active: prod - main: - allow-bean-definition-overriding: true - aop: - auto: false -management: - endpoints: - web: - exposure: - include: "loggers,logfile,health,info,metrics,threaddump,heapdump" - -logging: - level: - ROOT: ERROR - org.springframework: ERROR - org.springframework.data: ERROR - org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR - org.oransc.policyagent: INFO - file: /var/log/policy-agent/application.log -server: - port : 8433 - http-port: 8081 - ssl: - key-store-type: JKS - key-store-password: policy_agent - key-store: /opt/app/policy-agent/etc/cert/keystore.jks - key-password: policy_agent - key-alias: policy_agent -app: - filepath: /opt/app/policy-agent/data/application_configuration.json - webclient: - trust-store-used: false - trust-store-password: policy_agent - trust-store: /opt/app/policy-agent/etc/cert/truststore.jks - diff --git a/docker-compose/sdnc/docker-compose.yml b/docker-compose/sdnc/docker-compose.yml index 9796ecee..fc5b0132 100644 --- a/docker-compose/sdnc/docker-compose.yml +++ b/docker-compose/sdnc/docker-compose.yml @@ -21,59 +21,6 @@ networks: name: nonrtric-docker-net services: - policy-agent: - image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent:2.2.0 - container_name: policy-agent - networks: - default: - aliases: - - policy-agent-container - ports: - - 8081:8081 - - 8433:8433 - volumes: - - ./config/application_configuration.json:/opt/app/policy-agent/data/application_configuration.json:ro - # For using own certs instead of the default ones (built into the container), - # place them in config/ directory, update the application-policyagent.yaml file, and uncomment the following lines - # - ./config/keystore-policyagent.jks:/opt/app/policy-agent/etc/cert/keystore.jks:ro - # - ./config/truststore-policyagent.jks:/opt/app/policy-agent/etc/cert/truststore.jks:ro - # - ./config/application-policyagent.yaml:/opt/app/policy-agent/config/application.yaml:ro - - a1-sim-OSC: - image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:2.1.0 - container_name: a1-sim-OSC - networks: - - default - ports: - - 30001:8085 - - 30002:8185 - environment: - - A1_VERSION=OSC_2.1.0 - - REMOTE_HOSTS_LOGGING=1 - - ALLOW_HTTP=true - - a1-sim-STD: - image: nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator:2.1.0 - container_name: a1-sim-STD - networks: - - default - ports: - - 30003:8085 - - 30004:8185 - environment: - - A1_VERSION=STD_1.1.3 - - REMOTE_HOSTS_LOGGING=1 - - ALLOW_HTTP=true - - policy-control-panel: - image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel:2.2.0 - container_name: policy-control-panel - networks: - - default - ports: - - 8080:8080 - - 8082:8082 - db: image: mysql/mysql-server:5.6 container_name: sdnc-db @@ -111,9 +58,9 @@ services: # For using own certs instead of the default ones (built into the container), # place them in config/ directory, update the https-props-a1controller.properties file, and uncomment the following lines #volumes: - # - ./config/keystore-a1controller.jks:/etc/ssl/certs/java/keystore.jks:ro - # - ./config/truststore-a1controller.jks:/etc/ssl/certs/java/truststore.jks:ro - # - ./config/https-props-a1controller.properties:/opt/onap/sdnc/data/properties/https-props.properties:ro + # - ./sdnc/config/keystore-a1controller.jks:/etc/ssl/certs/java/keystore.jks:ro + # - ./sdnc/config/truststore-a1controller.jks:/etc/ssl/certs/java/truststore.jks:ro + # - ./sdnc/config/https-props-a1controller.properties:/opt/onap/sdnc/data/properties/https-props.properties:ro logging: driver: "json-file" options: diff --git a/docker-compose/withDmaap_nosdnc/pms/application-policyagent.yaml b/docker-compose/withDmaap_nosdnc/pms/application-policyagent.yaml deleted file mode 100755 index 58b3f817..00000000 --- a/docker-compose/withDmaap_nosdnc/pms/application-policyagent.yaml +++ /dev/null @@ -1,37 +0,0 @@ -spring: - profiles: - active: prod - main: - allow-bean-definition-overriding: true - aop: - auto: false -management: - endpoints: - web: - exposure: - include: "loggers,logfile,health,info,metrics,threaddump,heapdump" - -logging: - level: - ROOT: ERROR - org.springframework: ERROR - org.springframework.data: ERROR - org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR - org.oransc.policyagent: TRACE - file: /var/log/policy-agent/application.log -server: - port : 8433 - http-port: 8081 - ssl: - key-store-type: JKS - key-store-password: policy_agent - key-store: /opt/app/policy-agent/etc/cert/keystore.jks - key-password: policy_agent - key-alias: policy_agent -app: - filepath: /opt/app/policy-agent/data/application_configuration.json - webclient: - trust-store-used: false - trust-store-password: policy_agent - trust-store: /opt/app/policy-agent/etc/cert/truststore.jks - diff --git a/docker-compose/withDmaap_nosdnc/pms/application_configuration.json b/docker-compose/withDmaap_nosdnc/pms/application_configuration.json deleted file mode 100644 index 09257038..00000000 --- a/docker-compose/withDmaap_nosdnc/pms/application_configuration.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "config":{ - "//description":"Application configuration", - "ric":[ - { - "name":"ric1", - "baseUrl":"https://a1-sim-OSC:8185/", - "managedElementIds":[ - "kista_1", - "kista_2" - ] - }, - { - "name":"ric2", - "baseUrl":"https://a1-sim-STD:8185/", - "managedElementIds":[ - "kista_1", - "kista_2" - ] - } - ], - "streams_publishes":{ - "dmaap_publisher":{ - "type":"message_router", - "dmaap_info":{ - "topic_url":"http://dmaap-mr:3904/events/A1-POLICY-AGENT-WRITE" - } - } - }, - "streams_subscribes":{ - "dmaap_subscriber":{ - "type":"message_router", - "dmaap_info":{ - "topic_url":"http://dmaap-mr:3904/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100" - } - } - } - } - } \ No newline at end of file diff --git a/docs/api-docs.rst b/docs/api-docs.rst index 5d0e1b10..9e438f67 100644 --- a/docs/api-docs.rst +++ b/docs/api-docs.rst @@ -37,10 +37,10 @@ Enrichment Coordinator Service See `ECS API <./ecs-api.html>`_ for how to use the API. .. csv-table:: - :header: "API name", "|swagger-icon|" - :widths: 10,5 + :header: "API name", "|swagger-icon|", "|yaml-icon|" + :widths: 10,5,5 - "ECS API", ":download:`link <./offeredapis/swagger/ecs-api.json>`" + "ECS API", ":download:`link <../enrichment-coordinator-service/api/ecs-api.json>`", ":download:`link <../enrichment-coordinator-service/api/ecs-api.yaml>`" rAPP Catalogue diff --git a/docs/conf.py b/docs/conf.py index 09eeb378..85721c6a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,7 +24,7 @@ redoc = [ { 'name': 'ECS API', 'page': 'ecs-api', - 'spec': './offeredapis/swagger/ecs-api.json', + 'spec': '../enrichment-coordinator-service/api/ecs-api.json', 'embed': True, } ] diff --git a/docs/offeredapis/swagger/ecs-api.json b/enrichment-coordinator-service/api/ecs-api.json similarity index 82% rename from docs/offeredapis/swagger/ecs-api.json rename to enrichment-coordinator-service/api/ecs-api.json index 3684c0ee..37416ac8 100644 --- a/docs/offeredapis/swagger/ecs-api.json +++ b/enrichment-coordinator-service/api/ecs-api.json @@ -20,7 +20,7 @@ "description": "request", "required": true }], - "tags": ["Producer Callbacks"], + "tags": ["Data Producer Job Control (example producer)"], "consumes": ["application/json"] }}, "/A1-EI/v1/eitypes/{eiTypeId}": {"get": { @@ -77,7 +77,7 @@ "required": true } ], - "tags": ["Consumer Callbacks"], + "tags": ["A1-EI (enrichment information) callbacks"], "consumes": ["application/json"] }}, "/ei-producer/v1/eitypes": {"get": { @@ -97,7 +97,7 @@ "403": {"description": "Forbidden"}, "404": {"description": "Not Found"} }, - "tags": ["Enrichment Data Producer API"] + "tags": ["Data Producer Registry API"] }}, "/A1-EI/v1/eitypes": {"get": { "summary": "EI type identifiers", @@ -126,7 +126,7 @@ "responses": { "200": { "schema": {"$ref": "#/definitions/producer_status"}, - "description": "EI jobs" + "description": "EI producer status" }, "401": {"description": "Unauthorized"}, "403": {"description": "Forbidden"}, @@ -142,7 +142,7 @@ "type": "string", "required": true }], - "tags": ["Enrichment Data Producer API"] + "tags": ["Data Producer Registry API"] }}, "/producer_simulator/ei_job/{eiJobId}": {"delete": { "summary": "Callback for EI job deletion", @@ -162,7 +162,7 @@ "type": "string", "required": true }], - "tags": ["Producer Callbacks"] + "tags": ["Data Producer Job Control (example producer)"] }}, "/ei-producer/v1/eiproducers": {"get": { "summary": "EI producer identifiers", @@ -181,34 +181,107 @@ "403": {"description": "Forbidden"}, "404": {"description": "Not Found"} }, - "tags": ["Enrichment Data Producer API"] - }}, - "/ei-producer/v1/eitypes/{eiTypeId}": {"get": { - "summary": "Individual EI type", - "deprecated": false, - "produces": ["application/json"], - "operationId": "getEiTypeUsingGET_1", - "responses": { - "200": { - "schema": {"$ref": "#/definitions/producer_ei_type_info"}, - "description": "EI type" - }, - "401": {"description": "Unauthorized"}, - "403": {"description": "Forbidden"}, - "404": { - "schema": {"$ref": "#/definitions/ProblemDetails"}, - "description": "Enrichment Information type is not found" - } - }, "parameters": [{ - "in": "path", - "name": "eiTypeId", - "description": "eiTypeId", + "in": "query", + "allowEmptyValue": false, + "name": "ei_type_id", + "description": "If given, only the producers for the EI Data type is returned.", "type": "string", - "required": true + "required": false }], - "tags": ["Enrichment Data Producer API"] + "tags": ["Data Producer Registry API"] }}, + "/ei-producer/v1/eitypes/{eiTypeId}": { + "get": { + "summary": "Individual EI type", + "deprecated": false, + "produces": ["application/json"], + "operationId": "getEiTypeUsingGET_1", + "responses": { + "200": { + "schema": {"$ref": "#/definitions/producer_ei_type_info"}, + "description": "EI type" + }, + "401": {"description": "Unauthorized"}, + "403": {"description": "Forbidden"}, + "404": { + "schema": {"$ref": "#/definitions/ProblemDetails"}, + "description": "Enrichment Information type is not found" + } + }, + "parameters": [{ + "in": "path", + "name": "eiTypeId", + "description": "eiTypeId", + "type": "string", + "required": true + }], + "tags": ["Data Producer Registry API"] + }, + "delete": { + "summary": "Individual EI type", + "deprecated": false, + "produces": ["application/json"], + "operationId": "deleteEiTypeUsingDELETE", + "responses": { + "200": {"description": "Not used"}, + "401": {"description": "Unauthorized"}, + "204": {"description": "Producer deleted"}, + "403": {"description": "Forbidden"}, + "404": { + "schema": {"$ref": "#/definitions/ProblemDetails"}, + "description": "Enrichment Information type is not found" + }, + "406": { + "schema": {"$ref": "#/definitions/ProblemDetails"}, + "description": "The Enrichment Information type has one or several active producers" + } + }, + "parameters": [{ + "in": "path", + "name": "eiTypeId", + "description": "eiTypeId", + "type": "string", + "required": true + }], + "tags": ["Data Producer Registry API"] + }, + "put": { + "summary": "Individual EI type", + "deprecated": false, + "produces": ["application/json"], + "operationId": "putEiTypeUsingPUT", + "responses": { + "200": {"description": "Type updated"}, + "201": {"description": "Type created"}, + "400": { + "schema": {"$ref": "#/definitions/ProblemDetails"}, + "description": "Bad request" + }, + "401": {"description": "Unauthorized"}, + "403": {"description": "Forbidden"}, + "404": {"description": "Not Found"} + }, + "parameters": [ + { + "in": "path", + "name": "eiTypeId", + "description": "eiTypeId", + "type": "string", + "required": true + }, + { + "schema": {"$ref": "#/definitions/producer_ei_type_info"}, + "in": "body", + "name": "registrationInfo", + "description": "registrationInfo", + "required": true + } + ], + "tags": ["Data Producer Registry API"], + "consumes": ["application/json"] + } + }, "/status": {"get": { "summary": "Returns status and statistics of this service", "deprecated": false, @@ -320,7 +393,7 @@ "responses": { "200": { "schema": {"$ref": "#/definitions/producer_registration_info"}, - "description": "EI jobs" + "description": "EI producer" }, "401": {"description": "Unauthorized"}, "403": {"description": "Forbidden"}, @@ -336,7 +409,7 @@ "type": "string", "required": true }], - "tags": ["Enrichment Data Producer API"] + "tags": ["Data Producer Registry API"] }, "delete": { "summary": "Individual EI producer", @@ -360,7 +433,7 @@ "type": "string", "required": true }], - "tags": ["Enrichment Data Producer API"] + "tags": ["Data Producer Registry API"] }, "put": { "summary": "Individual EI producer", @@ -390,7 +463,7 @@ "required": true } ], - "tags": ["Enrichment Data Producer API"], + "tags": ["Data Producer Registry API"], "consumes": ["application/json"] } }, @@ -408,7 +481,7 @@ "403": {"description": "Forbidden"}, "404": {"description": "Not Found"} }, - "tags": ["Producer Callbacks"] + "tags": ["Data Producer Job Control (example producer)"] }}, "/ei-producer/v1/eiproducers/{eiProducerId}/eijobs": {"get": { "summary": "EI job definitions", @@ -422,7 +495,7 @@ "type": "array", "items": {"$ref": "#/definitions/producer_ei_job_request"} }, - "description": "EI jobs" + "description": "EI producer" }, "401": {"description": "Unauthorized"}, "403": {"description": "Forbidden"}, @@ -438,7 +511,7 @@ "type": "string", "required": true }], - "tags": ["Enrichment Data Producer API"] + "tags": ["Data Producer Registry API"] }}, "/A1-EI/v1/eijobs": {"get": { "summary": "EI job identifiers", @@ -508,7 +581,6 @@ "tags": ["A1-EI (enrichment information)"] }} }, - "host": "localhost:34053", "definitions": { "producer_ei_job_request": { "description": "The body of the EI producer callbacks for EI job creation and deletion", @@ -524,6 +596,10 @@ "description": "Idenitity of the EI job", "type": "string" }, + "last_updated": { + "description": "The time when the job was last updated or created (ISO-8601)", + "type": "string" + }, "ei_job_data": { "description": "Json for the job data", "type": "object" @@ -543,22 +619,6 @@ "type": "object", "title": "EiTypeObject" }, - "producer_ei_type_registration_info": { - "description": "Information for an EI type", - "type": "object", - "title": "producer_ei_type_registration_info", - "required": ["ei_type_identity"], - "properties": { - "ei_type_identity": { - "description": "EI type identity", - "type": "string" - }, - "ei_job_data_schema": { - "description": "Json schema for the job data", - "type": "object" - } - } - }, "status_info": { "type": "object", "title": "status_info", @@ -584,25 +644,15 @@ } } }, - "Mono«ResponseEntity«object»»": { - "type": "object", - "title": "Mono«ResponseEntity«object»»" - }, "producer_ei_type_info": { "description": "Information for an EI type", "type": "object", "title": "producer_ei_type_info", - "properties": { - "ei_producer_ids": { - "description": "Registered producers", - "type": "array", - "items": {"type": "string"} - }, - "ei_job_data_schema": { - "description": "Json schema for the job data", - "type": "object" - } - } + "required": ["ei_job_data_schema"], + "properties": {"ei_job_data_schema": { + "description": "Json schema for the job data", + "type": "object" + }} }, "producer_registration_info": { "description": "Information for an EI producer", @@ -615,9 +665,9 @@ ], "properties": { "supported_ei_types": { - "description": "Supported EI types", + "description": "Supported EI type IDs", "type": "array", - "items": {"$ref": "#/definitions/producer_ei_type_registration_info"} + "items": {"type": "string"} }, "ei_producer_supervision_callback_url": { "description": "callback for producer supervision", @@ -661,11 +711,6 @@ } } }, - "Void": { - "description": "Void/empty", - "type": "object", - "title": "Void" - }, "EiJobStatusObject": { "description": "Status for an EI job", "type": "object", @@ -726,20 +771,20 @@ "description": "Consumer Controller" }, { - "name": "Consumer Callbacks", + "name": "A1-EI (enrichment information) callbacks", "description": "Consumer Simulator Controller" }, { - "name": "Enrichment Data Producer API", - "description": "Producer Controller" + "name": "Data Producer Job Control (example producer)", + "description": "Producer Simulator Controller" }, { - "name": "Producer Callbacks", - "description": "Producer Simulator Controller" + "name": "Data Producer Registry API", + "description": "Producer Controller" }, { "name": "Service status", "description": "Status Controller" } ] -} +} \ No newline at end of file diff --git a/enrichment-coordinator-service/api/ecs-api.yaml b/enrichment-coordinator-service/api/ecs-api.yaml new file mode 100644 index 00000000..d1aa1873 --- /dev/null +++ b/enrichment-coordinator-service/api/ecs-api.yaml @@ -0,0 +1,893 @@ +openapi: 3.0.1 +info: + title: Enrichment Data service + description: This page lists all the rest apis for the service. + version: "1.0" +servers: +- url: / +tags: +- name: A1-EI (enrichment information) + description: Consumer Controller +- name: A1-EI (enrichment information) callbacks + description: Consumer Simulator Controller +- name: Data Producer Job Control (example producer) + description: Producer Simulator Controller +- name: Data Producer Registry API + description: Producer Controller +- name: Service status + description: Status Controller +paths: + /producer_simulator/ei_job: + post: + tags: + - Data Producer Job Control (example producer) + summary: Callback for EI job creation + operationId: jobCreatedCallbackUsingPOST + requestBody: + description: request + content: + application/json: + schema: + $ref: '#/components/schemas/producer_ei_job_request' + required: true + responses: + 200: + description: OK + content: {} + 201: + description: Created + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /A1-EI/v1/eitypes/{eiTypeId}: + get: + tags: + - A1-EI (enrichment information) + summary: Individual EI type + operationId: getEiTypeUsingGET + parameters: + - name: eiTypeId + in: path + description: eiTypeId + required: true + schema: + type: string + responses: + 200: + description: EI type + content: + application/json: + schema: + $ref: '#/components/schemas/EiTypeObject' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information type is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /consumer_simulator/eijobs/{eiJobId}/status: + post: + tags: + - A1-EI (enrichment information) callbacks + summary: Callback for EI job status + operationId: jobStatusCallbackUsingPOST + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + requestBody: + description: status + content: + application/json: + schema: + $ref: '#/components/schemas/EiJobStatusObject' + required: true + responses: + 200: + description: OK + content: {} + 201: + description: Created + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /ei-producer/v1/eitypes: + get: + tags: + - Data Producer Registry API + summary: EI type identifiers + operationId: getEiTypeIdentifiersUsingGET_1 + responses: + 200: + description: EI type identifiers + content: + application/json: + schema: + type: array + items: + type: string + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /A1-EI/v1/eitypes: + get: + tags: + - A1-EI (enrichment information) + summary: EI type identifiers + operationId: getEiTypeIdentifiersUsingGET + responses: + 200: + description: EI type identifiers + content: + application/json: + schema: + type: array + items: + type: string + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /ei-producer/v1/eiproducers/{eiProducerId}/status: + get: + tags: + - Data Producer Registry API + summary: EI producer status + operationId: getEiProducerStatusUsingGET + parameters: + - name: eiProducerId + in: path + description: eiProducerId + required: true + schema: + type: string + responses: + 200: + description: EI producer status + content: + application/json: + schema: + $ref: '#/components/schemas/producer_status' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information producer is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /producer_simulator/ei_job/{eiJobId}: + delete: + tags: + - Data Producer Job Control (example producer) + summary: Callback for EI job deletion + operationId: jobDeletedCallbackUsingDELETE + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + responses: + 200: + description: OK + content: {} + 204: + description: No Content + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + deprecated: false + /ei-producer/v1/eiproducers: + get: + tags: + - Data Producer Registry API + summary: EI producer identifiers + operationId: getEiProducerIdentifiersUsingGET + parameters: + - name: ei_type_id + in: query + description: If given, only the producers for the EI Data type is returned. + allowEmptyValue: false + schema: + type: string + responses: + 200: + description: EI producer identifiers + content: + application/json: + schema: + type: array + items: + type: string + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /ei-producer/v1/eitypes/{eiTypeId}: + get: + tags: + - Data Producer Registry API + summary: Individual EI type + operationId: getEiTypeUsingGET_1 + parameters: + - name: eiTypeId + in: path + description: eiTypeId + required: true + schema: + type: string + responses: + 200: + description: EI type + content: + application/json: + schema: + $ref: '#/components/schemas/producer_ei_type_info' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information type is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + put: + tags: + - Data Producer Registry API + summary: Individual EI type + operationId: putEiTypeUsingPUT + parameters: + - name: eiTypeId + in: path + description: eiTypeId + required: true + schema: + type: string + requestBody: + description: registrationInfo + content: + application/json: + schema: + $ref: '#/components/schemas/producer_ei_type_info' + required: true + responses: + 200: + description: Type updated + content: {} + 201: + description: Type created + content: {} + 400: + description: Bad request + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + delete: + tags: + - Data Producer Registry API + summary: Individual EI type + operationId: deleteEiTypeUsingDELETE + parameters: + - name: eiTypeId + in: path + description: eiTypeId + required: true + schema: + type: string + responses: + 200: + description: Not used + content: {} + 204: + description: Producer deleted + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information type is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + 406: + description: The Enrichment Information type has one or several active producers + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /status: + get: + tags: + - Service status + summary: Returns status and statistics of this service + operationId: getStatusUsingGET + responses: + 200: + description: Service is living + content: + application/json: + schema: + $ref: '#/components/schemas/status_info' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /A1-EI/v1/eijobs/{eiJobId}: + get: + tags: + - A1-EI (enrichment information) + summary: Individual EI job + operationId: getIndividualEiJobUsingGET + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + responses: + 200: + description: EI job + content: + application/json: + schema: + $ref: '#/components/schemas/EiJobObject' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information job is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + put: + tags: + - A1-EI (enrichment information) + summary: Individual EI job + operationId: putIndividualEiJobUsingPUT + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + requestBody: + description: eiJobObject + content: + application/json: + schema: + $ref: '#/components/schemas/EiJobObject' + required: true + responses: + 200: + description: Job updated + content: {} + 201: + description: Job created + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information type is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + delete: + tags: + - A1-EI (enrichment information) + summary: Individual EI job + operationId: deleteIndividualEiJobUsingDELETE + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + responses: + 200: + description: Not used + content: {} + 204: + description: Job deleted + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information job is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /ei-producer/v1/eiproducers/{eiProducerId}: + get: + tags: + - Data Producer Registry API + summary: Individual EI producer + operationId: getEiProducerUsingGET + parameters: + - name: eiProducerId + in: path + description: eiProducerId + required: true + schema: + type: string + responses: + 200: + description: EI producer + content: + application/json: + schema: + $ref: '#/components/schemas/producer_registration_info' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information producer is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + put: + tags: + - Data Producer Registry API + summary: Individual EI producer + operationId: putEiProducerUsingPUT + parameters: + - name: eiProducerId + in: path + description: eiProducerId + required: true + schema: + type: string + requestBody: + description: registrationInfo + content: + application/json: + schema: + $ref: '#/components/schemas/producer_registration_info' + required: true + responses: + 200: + description: Producer updated + content: {} + 201: + description: Producer created + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + delete: + tags: + - Data Producer Registry API + summary: Individual EI producer + operationId: deleteEiProducerUsingDELETE + parameters: + - name: eiProducerId + in: path + description: eiProducerId + required: true + schema: + type: string + responses: + 200: + description: Not used + content: {} + 204: + description: Producer deleted + content: {} + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Producer is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /producer_simulator/health_check: + get: + tags: + - Data Producer Job Control (example producer) + summary: Producer supervision + operationId: producerSupervisionUsingGET + responses: + 200: + description: OK + content: + application/json: + schema: + type: string + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Not Found + content: {} + deprecated: false + /ei-producer/v1/eiproducers/{eiProducerId}/eijobs: + get: + tags: + - Data Producer Registry API + summary: EI job definitions + description: EI job definitions for one EI producer + operationId: getEiProducerJobsUsingGET + parameters: + - name: eiProducerId + in: path + description: eiProducerId + required: true + schema: + type: string + responses: + 200: + description: EI producer + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/producer_ei_job_request' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information producer is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /A1-EI/v1/eijobs: + get: + tags: + - A1-EI (enrichment information) + summary: EI job identifiers + description: query for EI job identifiers + operationId: getEiJobIdsUsingGET + parameters: + - name: eiTypeId + in: query + description: selects EI jobs of matching EI type + allowEmptyValue: false + schema: + type: string + - name: owner + in: query + description: selects EI jobs for one EI job owner + allowEmptyValue: false + schema: + type: string + responses: + 200: + description: EI job identifiers + content: + application/json: + schema: + type: array + items: + type: string + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information type is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false + /A1-EI/v1/eijobs/{eiJobId}/status: + get: + tags: + - A1-EI (enrichment information) + summary: EI job status + operationId: getEiJobStatusUsingGET + parameters: + - name: eiJobId + in: path + description: eiJobId + required: true + schema: + type: string + responses: + 200: + description: EI job status + content: + application/json: + schema: + $ref: '#/components/schemas/EiJobStatusObject' + 401: + description: Unauthorized + content: {} + 403: + description: Forbidden + content: {} + 404: + description: Enrichment Information job is not found + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + deprecated: false +components: + schemas: + producer_ei_job_request: + title: producer_ei_job_request + required: + - ei_job_identity + type: object + properties: + owner: + type: string + description: The owner of the job + ei_job_identity: + type: string + description: Idenitity of the EI job + last_updated: + type: string + description: The time when the job was last updated or created (ISO-8601) + ei_job_data: + type: object + properties: {} + description: Json for the job data + target_uri: + type: string + description: URI for the target of the EI + ei_type_identity: + type: string + description: Type idenitity for the job + description: The body of the EI producer callbacks for EI job creation and deletion + EiTypeObject: + title: EiTypeObject + type: object + description: Information for an EI type + status_info: + title: status_info + type: object + properties: + no_of_producers: + type: integer + description: Number of EI producers + format: int32 + no_of_jobs: + type: integer + description: Number of EI jobs + format: int32 + no_of_types: + type: integer + description: Number of EI types + format: int32 + status: + type: string + description: status text + producer_ei_type_info: + title: producer_ei_type_info + required: + - ei_job_data_schema + type: object + properties: + ei_job_data_schema: + type: object + properties: {} + description: Json schema for the job data + description: Information for an EI type + producer_registration_info: + title: producer_registration_info + required: + - ei_job_callback_url + - ei_producer_supervision_callback_url + - supported_ei_types + type: object + properties: + supported_ei_types: + type: array + description: Supported EI type IDs + items: + type: string + ei_producer_supervision_callback_url: + type: string + description: callback for producer supervision + ei_job_callback_url: + type: string + description: callback for EI job + description: Information for an EI producer + producer_status: + title: producer_status + required: + - operational_state + type: object + properties: + operational_state: + type: string + description: |- + Operational state, values: + ENABLED: TBD + DISABLED: TBD. + enum: + - ENABLED + - DISABLED + description: Status for an EI Producer + ProblemDetails: + title: ProblemDetails + type: object + properties: + detail: + type: string + description: A human-readable explanation specific to this occurrence of + the problem. + example: EI job type not found + status: + type: integer + description: The HTTP status code generated by the origin server for this + occurrence of the problem. + format: int32 + example: 404 + description: A problem detail to carry details in a HTTP response according + to RFC 7807 + EiJobStatusObject: + title: EiJobStatusObject + required: + - eiJobStatus + type: object + properties: + eiJobStatus: + type: string + description: |- + values: + ENABLED: the A1-EI producer is able to deliver EI result for the EI job + DISABLED: the A1-EI producer is unable to deliver EI result for the EI job + enum: + - ENABLED + - DISABLED + description: Status for an EI job + EiJobObject: + title: EiJobObject + required: + - eiTypeId + - jobDefinition + - jobOwner + - jobResultUri + type: object + properties: + eiTypeId: + type: string + description: EI type Idenitifier of the EI job + jobResultUri: + type: string + description: The target URI of the EI data + jobOwner: + type: string + description: Identity of the owner of the job + jobStatusNotificationUri: + type: string + description: The target of EI job status notifications + jobDefinition: + type: object + properties: {} + description: EI type specific job data + description: Information for an Enrichment Information Job diff --git a/enrichment-coordinator-service/config/application.yaml b/enrichment-coordinator-service/config/application.yaml index 850dc67f..5900d63d 100644 --- a/enrichment-coordinator-service/config/application.yaml +++ b/enrichment-coordinator-service/config/application.yaml @@ -9,9 +9,11 @@ management: endpoints: web: exposure: + # Enabling of springboot actuator features. See springboot documentation. include: "loggers,logfile,health,info,metrics,threaddump,heapdump" logging: + # Configuration of logging level: ROOT: ERROR org.springframework: ERROR @@ -21,6 +23,8 @@ logging: file: name: /var/log/enrichment-coordinator-service/application.log server: + # Configuration of the HTTP/REST server. The parameters are defined and handeled by the springboot framework. + # See springboot documentation. port : 8434 http-port: 8083 ssl: @@ -30,10 +34,16 @@ server: key-password: policy_agent key-alias: policy_agent app: - filepath: /opt/app/enrichment-coordinator-service/data/application_configuration.json webclient: + # Configuration of the trust store used for the HTTP client (outgoing requests) + # The file location and the password for the truststore is only relevant if trust-store-used == true + # Note that the same keystore as for the server is used. trust-store-used: false trust-store-password: policy_agent trust-store: /opt/app/enrichment-coordinator-service/etc/cert/truststore.jks + # Configuration of usage of HTTP Proxy for the southbound accesses. + # The HTTP proxy (if configured) will only be used for accessing NearRT RIC:s + http.proxy-host: + http.proxy-port: 0 vardata-directory: /var/enrichment-coordinator-service diff --git a/enrichment-coordinator-service/pom.xml b/enrichment-coordinator-service/pom.xml index d34c9a6b..afb9abdf 100644 --- a/enrichment-coordinator-service/pom.xml +++ b/enrichment-coordinator-service/pom.xml @@ -31,7 +31,7 @@ org.o-ran-sc.nonrtric enrichment-coordinator-service - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT The Apache Software License, Version 2.0 @@ -56,6 +56,7 @@ 3.8.0 2.12.2 1.24.3 + 3.0.11 0.30.0 1.1.11 2.1.1 @@ -280,6 +281,27 @@ + + io.swagger.codegen.v3 + swagger-codegen-maven-plugin + ${swagger-codegen-maven-plugin.version} + + + test + + generate + + + ${project.basedir}/api/ecs-api.json + openapi-yaml + ${project.basedir}/api + + ecs-api.yaml + + + + + io.fabric8 docker-maven-plugin diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java index c5d2bec7..f5aca7e6 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/BeanFactory.java @@ -26,8 +26,8 @@ import java.lang.invoke.MethodHandles; import org.apache.catalina.connector.Connector; import org.oransc.enrichment.configuration.ApplicationConfig; +import org.oransc.enrichment.controllers.producer.ProducerCallbacks; import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducers; import org.oransc.enrichment.repository.EiTypes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,6 +46,10 @@ class BeanFactory { private final ApplicationConfig applicationConfig = new ApplicationConfig(); private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + private ProducerCallbacks producerCallbacks; + private EiTypes eiTypes; + private EiJobs eiJobs; + @Bean public ObjectMapper mapper() { return new ObjectMapper(); @@ -62,23 +66,36 @@ class BeanFactory { @Bean public EiJobs eiJobs() { - EiJobs jobs = new EiJobs(getApplicationConfig()); - try { - jobs.restoreJobsFromDatabase(); - } catch (Exception e) { - logger.error("Could not restore jobs from database: {}", e.getMessage()); + if (eiJobs == null) { + eiJobs = new EiJobs(getApplicationConfig(), producerCallbacks()); + try { + eiJobs.restoreJobsFromDatabase(); + } catch (Exception e) { + logger.error("Could not restore jobs from database: {}", e.getMessage()); + } } - return jobs; + return eiJobs; } @Bean public EiTypes eiTypes() { - return new EiTypes(); + if (this.eiTypes == null) { + eiTypes = new EiTypes(getApplicationConfig()); + try { + eiTypes.restoreTypesFromDatabase(); + } catch (Exception e) { + logger.error("Could not restore EI types from database: {}", e.getMessage()); + } + } + return eiTypes; } @Bean - public EiProducers eiProducers() { - return new EiProducers(); + public ProducerCallbacks producerCallbacks() { + if (this.producerCallbacks == null) { + producerCallbacks = new ProducerCallbacks(getApplicationConfig()); + } + return this.producerCallbacks; } @Bean diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java index 76da6246..f0f6c4b1 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClient.java @@ -28,6 +28,7 @@ import io.netty.handler.timeout.WriteTimeoutHandler; import java.lang.invoke.MethodHandles; import java.util.concurrent.atomic.AtomicInteger; +import org.oransc.enrichment.configuration.WebClientConfig.HttpProxyConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; @@ -42,6 +43,7 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti import reactor.core.publisher.Mono; import reactor.netty.http.client.HttpClient; import reactor.netty.resources.ConnectionProvider; +import reactor.netty.tcp.ProxyProvider.Proxy; import reactor.netty.tcp.TcpClient; /** @@ -54,19 +56,12 @@ public class AsyncRestClient { private final String baseUrl; private static final AtomicInteger sequenceNumber = new AtomicInteger(); private final SslContext sslContext; + private final HttpProxyConfig httpProxyConfig; - /** - * Note that only http (not https) will work when this constructor is used. - * - * @param baseUrl - */ - public AsyncRestClient(String baseUrl) { - this(baseUrl, null); - } - - public AsyncRestClient(String baseUrl, SslContext sslContext) { + public AsyncRestClient(String baseUrl, @Nullable SslContext sslContext, @Nullable HttpProxyConfig httpProxyConfig) { this.baseUrl = baseUrl; this.sslContext = sslContext; + this.httpProxyConfig = httpProxyConfig; } public Mono> postForEntity(String uri, @Nullable String body) { @@ -188,7 +183,7 @@ public class AsyncRestClient { logger.debug("{} HTTP error status = '{}', body '{}'", traceTag, exception.getStatusCode(), exception.getResponseBodyAsString()); } else { - logger.debug("{} HTTP error", traceTag, t); + logger.debug("{} HTTP error {}", traceTag, t.getMessage()); } } @@ -200,27 +195,31 @@ public class AsyncRestClient { } } - private TcpClient createTcpClientSecure(SslContext sslContext) { - return TcpClient.create(ConnectionProvider.newConnection()) // - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) // - .secure(c -> c.sslContext(sslContext)) // - .doOnConnected(connection -> { - connection.addHandlerLast(new ReadTimeoutHandler(30)); - connection.addHandlerLast(new WriteTimeoutHandler(30)); - }); + private boolean isHttpProxyConfigured() { + return httpProxyConfig != null && httpProxyConfig.httpProxyPort() > 0 + && !httpProxyConfig.httpProxyHost().isEmpty(); } - private TcpClient createTcpClientInsecure() { - return TcpClient.create(ConnectionProvider.newConnection()) // + private TcpClient createTcpClient() { + TcpClient client = TcpClient.create(ConnectionProvider.newConnection()) // .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) // .doOnConnected(connection -> { connection.addHandlerLast(new ReadTimeoutHandler(30)); connection.addHandlerLast(new WriteTimeoutHandler(30)); }); + if (this.sslContext != null) { + client = client.secure(c -> c.sslContext(sslContext)); + } + if (isHttpProxyConfigured()) { + client = client.proxy(proxy -> proxy.type(Proxy.HTTP).host(httpProxyConfig.httpProxyHost()) + .port(httpProxyConfig.httpProxyPort())); + } + return client; } private WebClient createWebClient(String baseUrl, TcpClient tcpClient) { HttpClient httpClient = HttpClient.from(tcpClient); + ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient); ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() // .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) // @@ -235,13 +234,8 @@ public class AsyncRestClient { private Mono getWebClient() { if (this.webClient == null) { try { - if (this.sslContext != null) { - TcpClient tcpClient = createTcpClientSecure(sslContext); - this.webClient = createWebClient(this.baseUrl, tcpClient); - } else { - TcpClient tcpClient = createTcpClientInsecure(); - this.webClient = createWebClient(this.baseUrl, tcpClient); - } + TcpClient tcpClient = createTcpClient(); + this.webClient = createWebClient(this.baseUrl, tcpClient); } catch (Exception e) { logger.error("Could not create WebClient {}", e.getMessage()); return Mono.error(e); diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java index 07f23e9e..4865df56 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/clients/AsyncRestClientFactory.java @@ -42,6 +42,7 @@ import java.util.stream.Collectors; import javax.net.ssl.KeyManagerFactory; import org.oransc.enrichment.configuration.WebClientConfig; +import org.oransc.enrichment.configuration.WebClientConfig.HttpProxyConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.ResourceUtils; @@ -53,25 +54,38 @@ public class AsyncRestClientFactory { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final SslContextFactory sslContextFactory; + private final HttpProxyConfig httpProxyConfig; public AsyncRestClientFactory(WebClientConfig clientConfig) { if (clientConfig != null) { this.sslContextFactory = new CachingSslContextFactory(clientConfig); + this.httpProxyConfig = clientConfig.httpProxyConfig(); } else { + logger.warn("No configuration for web client defined, HTTPS will not work"); this.sslContextFactory = null; + this.httpProxyConfig = null; } } - public AsyncRestClient createRestClient(String baseUrl) { + public AsyncRestClient createRestClientNoHttpProxy(String baseUrl) { + return createRestClient(baseUrl, false); + } + + public AsyncRestClient createRestClientUseHttpProxy(String baseUrl) { + return createRestClient(baseUrl, true); + } + + private AsyncRestClient createRestClient(String baseUrl, boolean useHttpProxy) { if (this.sslContextFactory != null) { try { - return new AsyncRestClient(baseUrl, this.sslContextFactory.createSslContext()); + return new AsyncRestClient(baseUrl, this.sslContextFactory.createSslContext(), + useHttpProxy ? httpProxyConfig : null); } catch (Exception e) { String exceptionString = e.toString(); logger.error("Could not init SSL context, reason: {}", exceptionString); } } - return new AsyncRestClient(baseUrl); + return new AsyncRestClient(baseUrl, null, httpProxyConfig); } private class SslContextFactory { @@ -175,5 +189,4 @@ public class AsyncRestClientFactory { } } - } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/ApplicationConfig.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/ApplicationConfig.java index 89374649..db4201b9 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/ApplicationConfig.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/ApplicationConfig.java @@ -20,10 +20,9 @@ package org.oransc.enrichment.configuration; -import javax.validation.constraints.NotEmpty; - import lombok.Getter; +import org.oransc.enrichment.configuration.WebClientConfig.HttpProxyConfig; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -31,10 +30,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties @EnableConfigurationProperties @ConfigurationProperties() public class ApplicationConfig { - @NotEmpty - @Getter - @Value("${app.filepath}") - private String localConfigurationFilePath; @Getter @Value("${app.vardata-directory}") @@ -61,16 +56,32 @@ public class ApplicationConfig { @Value("${app.webclient.trust-store}") private String sslTrustStore = ""; + @Value("${app.webclient.http.proxy-host:\"\"}") + private String httpProxyHost = ""; + + @Value("${app.webclient.http.proxy-port:0}") + private int httpProxyPort = 0; + + private WebClientConfig webClientConfig = null; + public WebClientConfig getWebClientConfig() { - return ImmutableWebClientConfig.builder() // - .keyStoreType(this.sslKeyStoreType) // - .keyStorePassword(this.sslKeyStorePassword) // - .keyStore(this.sslKeyStore) // - .keyPassword(this.sslKeyPassword) // - .isTrustStoreUsed(this.sslTrustStoreUsed) // - .trustStore(this.sslTrustStore) // - .trustStorePassword(this.sslTrustStorePassword) // - .build(); + if (this.webClientConfig == null) { + HttpProxyConfig httpProxyConfig = ImmutableHttpProxyConfig.builder() // + .httpProxyHost(this.httpProxyHost) // + .httpProxyPort(this.httpProxyPort) // + .build(); + this.webClientConfig = ImmutableWebClientConfig.builder() // + .keyStoreType(this.sslKeyStoreType) // + .keyStorePassword(this.sslKeyStorePassword) // + .keyStore(this.sslKeyStore) // + .keyPassword(this.sslKeyPassword) // + .isTrustStoreUsed(this.sslTrustStoreUsed) // + .trustStore(this.sslTrustStore) // + .trustStorePassword(this.sslTrustStorePassword) // + .httpProxyConfig(httpProxyConfig) // + .build(); + } + return this.webClientConfig; } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/WebClientConfig.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/WebClientConfig.java index 61d0f5ad..0b682486 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/WebClientConfig.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/configuration/WebClientConfig.java @@ -42,4 +42,13 @@ public interface WebClientConfig { public String trustStore(); + @Value.Immutable + public interface HttpProxyConfig { + public String httpProxyHost(); + + public int httpProxyPort(); + } + + public HttpProxyConfig httpProxyConfig(); + } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java index b28da8d2..b2ffd7eb 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/VoidResponse.java @@ -25,7 +25,7 @@ import io.swagger.annotations.ApiModel; import org.immutables.gson.Gson; @Gson.TypeAdapters -@ApiModel(value = "Void", description = "Void/empty") +@ApiModel(value = "Void", description = "Void/empty ") public class VoidResponse { private VoidResponse() { } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerCallbacks.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerCallbacks.java index 9087355e..7ccf61d0 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerCallbacks.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerCallbacks.java @@ -24,20 +24,23 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.lang.invoke.MethodHandles; +import java.util.Collection; import org.oransc.enrichment.clients.AsyncRestClient; import org.oransc.enrichment.clients.AsyncRestClientFactory; import org.oransc.enrichment.configuration.ApplicationConfig; import org.oransc.enrichment.repository.EiJob; import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducer; +import org.oransc.enrichment.repository.EiProducers; import org.oransc.enrichment.repository.EiType; -import org.oransc.enrichment.repository.EiTypes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + /** * Callbacks to the EiProducer */ @@ -49,55 +52,39 @@ public class ConsumerCallbacks { private static Gson gson = new GsonBuilder().create(); private final AsyncRestClient restClient; - private final EiTypes eiTypes; private final EiJobs eiJobs; + private final EiProducers eiProducers; @Autowired - public ConsumerCallbacks(ApplicationConfig config, EiTypes eiTypes, EiJobs eiJobs) { + public ConsumerCallbacks(ApplicationConfig config, EiJobs eiJobs, EiProducers eiProducers) { AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config.getWebClientConfig()); - this.restClient = restClientFactory.createRestClient(""); - this.eiTypes = eiTypes; + this.restClient = restClientFactory.createRestClientUseHttpProxy(""); this.eiJobs = eiJobs; + this.eiProducers = eiProducers; } - public void notifyConsumersProducerDeleted(EiProducer eiProducer) { - for (EiType type : eiProducer.getEiTypes()) { - if (this.eiTypes.get(type.getId()) == null) { - // The type is removed - for (EiJob job : this.eiJobs.getJobsForType(type)) { - if (job.isLastStatusReportedEnabled()) { - noifyJobOwner(job, new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.DISABLED)); - job.setLastReportedStatus(false); - } - } - } - } - } - - public void notifyConsumersProducerAdded(EiProducer eiProducer) { - for (EiType type : eiProducer.getEiTypes()) { - notifyConsumersTypeAdded(type); - } + public Flux notifyJobStatus(Collection eiTypes) { + return Flux.fromIterable(eiTypes) // + .flatMap(eiType -> Flux.fromIterable(this.eiJobs.getJobsForType(eiType))) // + .filter(eiJob -> !eiJob.getJobStatusUrl().isEmpty()) // + .filter(eiJob -> this.eiProducers.isJobEnabled(eiJob) != eiJob.isLastStatusReportedEnabled()) + .flatMap(this::noifyStatusToJobOwner); } - public void notifyConsumersTypeAdded(EiType eiType) { - for (EiJob job : this.eiJobs.getJobsForType(eiType)) { - if (!job.isLastStatusReportedEnabled()) { - noifyJobOwner(job, new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.ENABLED)); - job.setLastReportedStatus(true); - } - } - } + private Mono noifyStatusToJobOwner(EiJob job) { + boolean isJobEnabled = this.eiProducers.isJobEnabled(job); + ConsumerEiJobStatus status = + isJobEnabled ? new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.ENABLED) + : new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.DISABLED); + String body = gson.toJson(status); + return this.restClient.post(job.getJobStatusUrl(), body) // + .doOnNext(response -> logger.debug("Consumer notified OK {}", job.getId())) // + .doOnNext(response -> job.setLastReportedStatus(isJobEnabled)) // + .onErrorResume(throwable -> { + logger.warn("Consumer notify failed {} {}", job.getJobStatusUrl(), throwable.toString()); + return Mono.empty(); + }); - private void noifyJobOwner(EiJob job, ConsumerEiJobStatus status) { - if (!job.getJobStatusUrl().isEmpty()) { - String body = gson.toJson(status); - this.restClient.post(job.getJobStatusUrl(), body) // - .subscribe(notUsed -> logger.debug("Consumer notified OK {}", job.getId()), // - throwable -> logger.warn("Consumer notify failed {} {}", job.getJobStatusUrl(), - throwable.toString()), // - null); - } } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java index f45ff736..8267b6af 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/consumer/ConsumerController.java @@ -30,10 +30,9 @@ import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import java.lang.invoke.MethodHandles; import java.util.ArrayList; -import java.util.Collection; import java.util.List; -import java.util.Vector; import org.everit.json.schema.Schema; import org.everit.json.schema.loader.SchemaLoader; @@ -45,9 +44,11 @@ import org.oransc.enrichment.controllers.producer.ProducerCallbacks; import org.oransc.enrichment.exceptions.ServiceException; import org.oransc.enrichment.repository.EiJob; import org.oransc.enrichment.repository.EiJobs; -import org.oransc.enrichment.repository.EiProducer; +import org.oransc.enrichment.repository.EiProducers; import org.oransc.enrichment.repository.EiType; import org.oransc.enrichment.repository.EiTypes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -68,6 +69,8 @@ import reactor.core.publisher.Mono; @RequestMapping(path = ConsumerConsts.API_ROOT, produces = MediaType.APPLICATION_JSON_VALUE) public class ConsumerController { + private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + @Autowired ApplicationConfig applicationConfig; @@ -77,6 +80,9 @@ public class ConsumerController { @Autowired private EiTypes eiTypes; + @Autowired + private EiProducers eiProducers; + @Autowired ProducerCallbacks producerCallbacks; @@ -205,20 +211,11 @@ public class ConsumerController { } } - private Collection getProducers(EiJob eiJob) { - try { - return this.eiTypes.getType(eiJob.getTypeId()).getProducers(); - } catch (Exception e) { - return new Vector<>(); - } - } - private ConsumerEiJobStatus toEiJobStatus(EiJob job) { - if (getProducers(job).isEmpty()) { - return new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.DISABLED); - } else { - return new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.ENABLED); - } + return this.eiProducers.isJobEnabled(job) + ? new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.ENABLED) + : new ConsumerEiJobStatus(ConsumerEiJobStatus.EiJobStatusValues.DISABLED); + } @DeleteMapping(path = "/eijobs/{eiJobId}", produces = MediaType.APPLICATION_JSON_VALUE) @@ -235,8 +232,7 @@ public class ConsumerController { @PathVariable("eiJobId") String eiJobId) { try { EiJob job = this.eiJobs.getJob(eiJobId); - this.eiJobs.remove(job); - this.producerCallbacks.notifyProducersJobDeleted(job); + this.eiJobs.remove(job, this.eiProducers); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); @@ -263,21 +259,17 @@ public class ConsumerController { final boolean isNewJob = this.eiJobs.get(eiJobId) == null; return validatePutEiJob(eiJobId, eiJobObject) // - .flatMap(this::notifyProducersNewJob) // + .flatMap(this::startEiJob) // .doOnNext(newEiJob -> this.eiJobs.put(newEiJob)) // .flatMap(newEiJob -> Mono.just(new ResponseEntity<>(isNewJob ? HttpStatus.CREATED : HttpStatus.OK))) .onErrorResume(throwable -> Mono.just(ErrorResponse.create(throwable, HttpStatus.NOT_FOUND))); } - private Mono notifyProducersNewJob(EiJob newEiJob) { - return this.producerCallbacks.notifyProducersJobStarted(newEiJob) // - .flatMap(noOfAcceptingProducers -> { - if (noOfAcceptingProducers.intValue() > 0) { - return Mono.just(newEiJob); - } else { - return Mono.error(new ServiceException("Job not accepted by any producers", HttpStatus.CONFLICT)); - } - }); + private Mono startEiJob(EiJob newEiJob) { + return this.producerCallbacks.startEiJob(newEiJob, eiProducers) // + .doOnNext(noOfAcceptingProducers -> this.logger.debug( + "Started EI job {}, number of activated producers: {}", newEiJob.getId(), noOfAcceptingProducers)) // + .flatMap(noOfAcceptingProducers -> Mono.just(newEiJob)); } private Mono validatePutEiJob(String eiJobId, ConsumerEiJobInfo eiJobInfo) { diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerCallbacks.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerCallbacks.java index dc732e12..9b489cdf 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerCallbacks.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerCallbacks.java @@ -26,7 +26,6 @@ import com.google.gson.GsonBuilder; import java.lang.invoke.MethodHandles; import java.time.Duration; import java.util.Collection; -import java.util.Vector; import org.oransc.enrichment.clients.AsyncRestClient; import org.oransc.enrichment.clients.AsyncRestClientFactory; @@ -34,11 +33,9 @@ import org.oransc.enrichment.configuration.ApplicationConfig; import org.oransc.enrichment.repository.EiJob; import org.oransc.enrichment.repository.EiJobs; import org.oransc.enrichment.repository.EiProducer; -import org.oransc.enrichment.repository.EiTypes; +import org.oransc.enrichment.repository.EiProducers; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -47,7 +44,6 @@ import reactor.util.retry.Retry; /** * Callbacks to the EiProducer */ -@Component @SuppressWarnings("java:S3457") // No need to call "toString()" method as formatting and string .. public class ProducerCallbacks { @@ -55,20 +51,22 @@ public class ProducerCallbacks { private static Gson gson = new GsonBuilder().create(); private final AsyncRestClient restClient; - private final EiTypes eiTypes; - @Autowired - public ProducerCallbacks(ApplicationConfig config, EiTypes eiTypes) { + public ProducerCallbacks(ApplicationConfig config) { AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config.getWebClientConfig()); - this.restClient = restClientFactory.createRestClient(""); - this.eiTypes = eiTypes; + this.restClient = restClientFactory.createRestClientNoHttpProxy(""); } - public void notifyProducersJobDeleted(EiJob eiJob) { - for (EiProducer producer : getProducers(eiJob)) { + public Mono healthCheck(EiProducer producer) { + return restClient.get(producer.getProducerSupervisionCallbackUrl()); + } + + public void stopEiJob(EiJob eiJob, EiProducers eiProducers) { + for (EiProducer producer : getProducersForJob(eiJob, eiProducers)) { String url = producer.getJobCallbackUrl() + "/" + eiJob.getId(); + producer.setJobDisabled(eiJob); restClient.delete(url) // - .subscribe(notUsed -> logger.debug("Producer job deleted OK {}", producer.getId()), // + .subscribe(response -> logger.debug("Producer job deleted OK {}", producer.getId()), // throwable -> logger.warn("Producer job delete failed {} {}", producer.getId(), throwable.getMessage()), null); @@ -76,40 +74,35 @@ public class ProducerCallbacks { } /** - * Calls all producers for an EiJob activation. + * Start a job in all producers that suports the job type * * @param eiJob an EI job * @return the number of producers that returned OK */ - public Mono notifyProducersJobStarted(EiJob eiJob) { + public Mono startEiJob(EiJob eiJob, EiProducers eiProducers) { Retry retrySpec = Retry.fixedDelay(1, Duration.ofSeconds(1)); - return Flux.fromIterable(getProducers(eiJob)) // - .flatMap(eiProducer -> notifyProducerJobStarted(eiProducer, eiJob, retrySpec)) // + return Flux.fromIterable(getProducersForJob(eiJob, eiProducers)) // + .flatMap(eiProducer -> startEiJob(eiProducer, eiJob, retrySpec)) // .collectList() // .flatMap(okResponses -> Mono.just(Integer.valueOf(okResponses.size()))); // } /** - * Restart all jobs for one producer + * Start all jobs for one producer * * @param producer * @param eiJobs */ - public void restartJobs(EiProducer producer, EiJobs eiJobs) { + public Flux startEiJobs(EiProducer producer, EiJobs eiJobs) { final int maxNoOfParalellRequests = 10; Retry retrySpec = Retry.backoff(3, Duration.ofSeconds(1)); - Flux.fromIterable(producer.getEiTypes()) // + return Flux.fromIterable(producer.getEiTypes()) // .flatMap(type -> Flux.fromIterable(eiJobs.getJobsForType(type))) // - .flatMap(job -> notifyProducerJobStarted(producer, job, retrySpec), maxNoOfParalellRequests) // - .onErrorResume(t -> { - logger.error("Could not restart EI Job for producer: {}, reason :{}", producer.getId(), t.getMessage()); - return Flux.empty(); - }) // - .subscribe(); + .flatMap(job -> startEiJob(producer, job, retrySpec), maxNoOfParalellRequests); } - private Mono notifyProducerJobStarted(EiProducer producer, EiJob eiJob, Retry retrySpec) { + public Mono startEiJob(EiProducer producer, EiJob eiJob, Retry retrySpec) { ProducerJobInfo request = new ProducerJobInfo(eiJob); String body = gson.toJson(request); @@ -117,17 +110,15 @@ public class ProducerCallbacks { .retryWhen(retrySpec) // .doOnNext(resp -> logger.debug("Job subscription {} started OK {}", eiJob.getId(), producer.getId())) // .onErrorResume(throwable -> { + producer.setJobDisabled(eiJob); logger.warn("Job subscription failed {}", producer.getId(), throwable.toString()); return Mono.empty(); - }); + }) // + .doOnNext(resp -> producer.setJobEnabled(eiJob)); } - private Collection getProducers(EiJob eiJob) { - try { - return this.eiTypes.getType(eiJob.getTypeId()).getProducers(); - } catch (Exception e) { - return new Vector<>(); - } + private Collection getProducersForJob(EiJob eiJob, EiProducers eiProducers) { + return eiProducers.getProducersForType(eiJob.getTypeId()); } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerConsts.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerConsts.java index 9722594f..7c46117e 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerConsts.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerConsts.java @@ -23,7 +23,7 @@ package org.oransc.enrichment.controllers.producer; public class ProducerConsts { public static final String API_ROOT = "/ei-producer/v1"; - public static final String PRODUCER_API_NAME = "Enrichment Data Producer API"; + public static final String PRODUCER_API_NAME = "Data Producer Registry API"; private ProducerConsts() { } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java index e517b3a9..7e905dab 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerController.java @@ -25,26 +25,24 @@ import com.google.gson.GsonBuilder; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; -import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.oransc.enrichment.controllers.ErrorResponse; import org.oransc.enrichment.controllers.VoidResponse; -import org.oransc.enrichment.controllers.consumer.ConsumerCallbacks; -import org.oransc.enrichment.controllers.producer.ProducerRegistrationInfo.ProducerEiTypeRegistrationInfo; +import org.oransc.enrichment.exceptions.ServiceException; import org.oransc.enrichment.repository.EiJob; import org.oransc.enrichment.repository.EiJobs; import org.oransc.enrichment.repository.EiProducer; import org.oransc.enrichment.repository.EiProducers; import org.oransc.enrichment.repository.EiType; import org.oransc.enrichment.repository.EiTypes; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.oransc.enrichment.repository.ImmutableEiProducerRegistrationInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -54,6 +52,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally @@ -61,8 +60,6 @@ import org.springframework.web.bind.annotation.RestController; @Api(tags = {ProducerConsts.PRODUCER_API_NAME}) public class ProducerController { - private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private static Gson gson = new GsonBuilder().create(); @Autowired @@ -74,12 +71,6 @@ public class ProducerController { @Autowired private EiProducers eiProducers; - @Autowired - ProducerCallbacks producerCallbacks; - - @Autowired - ConsumerCallbacks consumerCallbacks; - @GetMapping(path = ProducerConsts.API_ROOT + "/eitypes", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "EI type identifiers", notes = "") @ApiResponses( @@ -120,6 +111,54 @@ public class ProducerController { } } + @PutMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE) + @ApiResponses( + value = { // + @ApiResponse(code = 200, message = "Type updated", response = VoidResponse.class), // + @ApiResponse(code = 201, message = "Type created", response = VoidResponse.class), // + @ApiResponse(code = 400, message = "Bad request", response = ErrorResponse.ErrorInfo.class)}) + + @ApiOperation(value = "Individual EI type", notes = "") + public ResponseEntity putEiType( // + @PathVariable("eiTypeId") String eiTypeId, @RequestBody ProducerEiTypeInfo registrationInfo) { + + EiType previousDefinition = this.eiTypes.get(eiTypeId); + if (registrationInfo.jobDataSchema == null) { + return ErrorResponse.create("No schema provided", HttpStatus.BAD_REQUEST); + } + this.eiTypes.put(new EiType(eiTypeId, registrationInfo.jobDataSchema)); + return new ResponseEntity<>(previousDefinition == null ? HttpStatus.CREATED : HttpStatus.OK); + } + + @DeleteMapping(path = ProducerConsts.API_ROOT + "/eitypes/{eiTypeId}", produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "Individual EI type", notes = "") + @ApiResponses( + value = { // + @ApiResponse(code = 200, message = "Not used", response = VoidResponse.class), + @ApiResponse(code = 204, message = "Producer deleted", response = VoidResponse.class), + @ApiResponse( + code = 404, + message = "Enrichment Information type is not found", + response = ErrorResponse.ErrorInfo.class), + @ApiResponse( + code = 406, + message = "The Enrichment Information type has one or several active producers", + response = ErrorResponse.ErrorInfo.class)}) + public ResponseEntity deleteEiType( // + @PathVariable("eiTypeId") String eiTypeId) { + + EiType type = this.eiTypes.get(eiTypeId); + if (type == null) { + return ErrorResponse.create("EI type not found", HttpStatus.NOT_FOUND); + } + if (!this.eiProducers.getProducersForType(type).isEmpty()) { + String firstProducerId = this.eiProducers.getProducersForType(type).iterator().next().getId(); + return ErrorResponse.create("The type has active producers: " + firstProducerId, HttpStatus.NOT_ACCEPTABLE); + } + this.eiTypes.remove(type); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + @GetMapping(path = ProducerConsts.API_ROOT + "/eiproducers", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "EI producer identifiers", notes = "") @ApiResponses( @@ -131,9 +170,15 @@ public class ProducerController { responseContainer = "List"), // }) public ResponseEntity getEiProducerIdentifiers( // + @ApiParam( + name = "ei_type_id", + required = false, + value = "If given, only the producers for the EI Data type is returned.") // + @RequestParam(name = "ei_type_id", required = false) String typeId // ) { List result = new ArrayList<>(); - for (EiProducer eiProducer : this.eiProducers.getAllProducers()) { + for (EiProducer eiProducer : typeId == null ? this.eiProducers.getAllProducers() + : this.eiProducers.getProducersForType(typeId)) { result.add(eiProducer.getId()); } @@ -146,7 +191,7 @@ public class ProducerController { @ApiOperation(value = "Individual EI producer", notes = "") @ApiResponses( value = { // - @ApiResponse(code = 200, message = "EI jobs", response = ProducerRegistrationInfo.class), // + @ApiResponse(code = 200, message = "EI producer", response = ProducerRegistrationInfo.class), // @ApiResponse( code = 404, message = "Enrichment Information producer is not found", @@ -168,7 +213,11 @@ public class ProducerController { @ApiOperation(value = "EI job definitions", notes = "EI job definitions for one EI producer") @ApiResponses( value = { // - @ApiResponse(code = 200, message = "EI jobs", response = ProducerJobInfo.class, responseContainer = "List"), // + @ApiResponse( + code = 200, + message = "EI producer", + response = ProducerJobInfo.class, + responseContainer = "List"), // @ApiResponse( code = 404, message = "Enrichment Information producer is not found", @@ -197,7 +246,7 @@ public class ProducerController { @ApiOperation(value = "EI producer status") @ApiResponses( value = { // - @ApiResponse(code = 200, message = "EI jobs", response = ProducerStatusInfo.class), // + @ApiResponse(code = 200, message = "EI producer status", response = ProducerStatusInfo.class), // @ApiResponse( code = 404, message = "Enrichment Information producer is not found", @@ -220,46 +269,26 @@ public class ProducerController { } @PutMapping( - path = ProducerConsts.API_ROOT + "/eiproducers/{eiProducerId}", + path = ProducerConsts.API_ROOT + "/eiproducers/{eiProducerId}", // produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Individual EI producer", notes = "") @ApiResponses( value = { // @ApiResponse(code = 201, message = "Producer created", response = VoidResponse.class), // - @ApiResponse(code = 200, message = "Producer updated", response = VoidResponse.class)}// + @ApiResponse(code = 200, message = "Producer updated", response = VoidResponse.class)} // ) public ResponseEntity putEiProducer( // @PathVariable("eiProducerId") String eiProducerId, // @RequestBody ProducerRegistrationInfo registrationInfo) { try { EiProducer previousDefinition = this.eiProducers.get(eiProducerId); - if (previousDefinition != null) { - for (EiType type : previousDefinition.getEiTypes()) { - type.removeProducer(previousDefinition); - } - } - - EiProducer producer = registerProducer(eiProducerId, registrationInfo); - if (previousDefinition != null) { - purgeTypes(previousDefinition.getEiTypes()); - this.consumerCallbacks.notifyConsumersProducerDeleted(previousDefinition); - } - this.consumerCallbacks.notifyConsumersProducerAdded(producer); - + this.eiProducers.registerProducer(toEiProducerRegistrationInfo(eiProducerId, registrationInfo)); return new ResponseEntity<>(previousDefinition == null ? HttpStatus.CREATED : HttpStatus.OK); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); } } - private void purgeTypes(Collection types) { - for (EiType type : types) { - if (type.getProducerIds().isEmpty()) { - this.eiTypes.remove(type); - } - } - } - @DeleteMapping( path = ProducerConsts.API_ROOT + "/eiproducers/{eiProducerId}", produces = MediaType.APPLICATION_JSON_VALUE) @@ -272,57 +301,39 @@ public class ProducerController { public ResponseEntity deleteEiProducer(@PathVariable("eiProducerId") String eiProducerId) { try { final EiProducer producer = this.eiProducers.getProducer(eiProducerId); - this.eiProducers.deregisterProducer(producer, this.eiTypes, this.eiJobs); - this.consumerCallbacks.notifyConsumersProducerDeleted(producer); + this.eiProducers.deregisterProducer(producer); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } catch (Exception e) { return ErrorResponse.create(e, HttpStatus.NOT_FOUND); } } - private EiType registerType(ProducerEiTypeRegistrationInfo typeInfo) { - EiType type = this.eiTypes.get(typeInfo.eiTypeId); - if (type == null) { - type = new EiType(typeInfo.eiTypeId, typeInfo.jobDataSchema); - this.eiTypes.put(type); - this.consumerCallbacks.notifyConsumersTypeAdded(type); + private ProducerRegistrationInfo toEiProducerRegistrationInfo(EiProducer p) { + Collection types = new ArrayList<>(); + for (EiType type : p.getEiTypes()) { + types.add(type.getId()); } - return type; - } - - EiProducer createProducer(Collection types, String producerId, ProducerRegistrationInfo registrationInfo) { - return new EiProducer(producerId, types, registrationInfo.jobCallbackUrl, - registrationInfo.producerSupervisionCallbackUrl); + return new ProducerRegistrationInfo(types, p.getJobCallbackUrl(), p.getProducerSupervisionCallbackUrl()); } - private EiProducer registerProducer(String producerId, ProducerRegistrationInfo registrationInfo) { - ArrayList typesForProducer = new ArrayList<>(); - EiProducer producer = createProducer(typesForProducer, producerId, registrationInfo); - for (ProducerEiTypeRegistrationInfo typeInfo : registrationInfo.types) { - EiType type = registerType(typeInfo); - typesForProducer.add(type); - type.addProducer(producer); // - } - this.eiProducers.put(producer); - - producerCallbacks.restartJobs(producer, this.eiJobs); - - return producer; + private ProducerEiTypeInfo toEiTypeInfo(EiType t) { + return new ProducerEiTypeInfo(t.getJobDataSchema()); } - ProducerRegistrationInfo toEiProducerRegistrationInfo(EiProducer p) { - Collection types = new ArrayList<>(); - for (EiType type : p.getEiTypes()) { - types.add(toEiTypeRegistrationInfo(type)); + private EiProducers.EiProducerRegistrationInfo toEiProducerRegistrationInfo(String eiProducerId, + ProducerRegistrationInfo info) throws ServiceException { + Collection supportedTypes = new ArrayList<>(); + for (String typeId : info.supportedTypeIds) { + EiType type = this.eiTypes.getType(typeId); + supportedTypes.add(type); } - return new ProducerRegistrationInfo(types, p.getJobCallbackUrl(), p.getProducerSupervisionCallbackUrl()); - } - private ProducerEiTypeRegistrationInfo toEiTypeRegistrationInfo(EiType type) { - return new ProducerEiTypeRegistrationInfo(type.getJobDataSchema(), type.getId()); + return ImmutableEiProducerRegistrationInfo.builder() // + .id(eiProducerId) // + .jobCallbackUrl(info.jobCallbackUrl) // + .producerSupervisionCallbackUrl(info.producerSupervisionCallbackUrl) // + .supportedTypes(supportedTypes) // + .build(); } - private ProducerEiTypeInfo toEiTypeInfo(EiType t) { - return new ProducerEiTypeInfo(t.getJobDataSchema(), t.getProducerIds()); - } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerEiTypeInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerEiTypeInfo.java index f13f9813..d2b89ef3 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerEiTypeInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerEiTypeInfo.java @@ -26,27 +26,19 @@ import com.google.gson.annotations.SerializedName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.util.Collection; - import org.immutables.gson.Gson; @Gson.TypeAdapters @ApiModel(value = "producer_ei_type_info", description = "Information for an EI type") public class ProducerEiTypeInfo { - @ApiModelProperty(value = "Json schema for the job data") + @ApiModelProperty(value = "Json schema for the job data", required = true) @SerializedName("ei_job_data_schema") - @JsonProperty("ei_job_data_schema") + @JsonProperty(value = "ei_job_data_schema", required = true) public Object jobDataSchema; - @ApiModelProperty(value = "Registered producers") - @SerializedName("ei_producer_ids") - @JsonProperty(value = "ei_producer_ids", required = true) - public Collection producerIds; - - public ProducerEiTypeInfo(Object jobDataSchema, Collection producers) { + public ProducerEiTypeInfo(Object jobDataSchema) { this.jobDataSchema = jobDataSchema; - this.producerIds = producers; } public ProducerEiTypeInfo() { diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerJobInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerJobInfo.java index c02c280e..bc3dba2e 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerJobInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerJobInfo.java @@ -60,16 +60,23 @@ public class ProducerJobInfo { @JsonProperty("owner") public String owner; - public ProducerJobInfo(Object jobData, String id, String typeId, String targetUri, String owner) { + @ApiModelProperty(value = "The time when the job was last updated or created (ISO-8601)") + @SerializedName("last_updated") + @JsonProperty("last_updated") + public String lastUpdated; + + public ProducerJobInfo(Object jobData, String id, String typeId, String targetUri, String owner, + String lastUpdated) { this.id = id; this.jobData = jobData; this.typeId = typeId; this.targetUri = targetUri; this.owner = owner; + this.lastUpdated = lastUpdated; } public ProducerJobInfo(EiJob job) { - this(job.getJobData(), job.getId(), job.getTypeId(), job.getTargetUrl(), job.getOwner()); + this(job.getJobData(), job.getId(), job.getTypeId(), job.getTargetUrl(), job.getOwner(), job.getLastUpdated()); } public ProducerJobInfo() { diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerRegistrationInfo.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerRegistrationInfo.java index 3f785803..94ae4a6a 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerRegistrationInfo.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/controllers/producer/ProducerRegistrationInfo.java @@ -57,10 +57,10 @@ public class ProducerRegistrationInfo { } } - @ApiModelProperty(value = "Supported EI types", required = true) + @ApiModelProperty(value = "Supported EI type IDs", required = true) @SerializedName("supported_ei_types") @JsonProperty(value = "supported_ei_types", required = true) - public Collection types; + public Collection supportedTypeIds; @ApiModelProperty(value = "callback for EI job", required = true) @SerializedName("ei_job_callback_url") @@ -72,9 +72,9 @@ public class ProducerRegistrationInfo { @JsonProperty(value = "ei_producer_supervision_callback_url", required = true) public String producerSupervisionCallbackUrl; - public ProducerRegistrationInfo(Collection types, String jobCallbackUrl, + public ProducerRegistrationInfo(Collection types, String jobCallbackUrl, String producerSupervisionCallbackUrl) { - this.types = types; + this.supportedTypeIds = types; this.jobCallbackUrl = jobCallbackUrl; this.producerSupervisionCallbackUrl = producerSupervisionCallbackUrl; } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java index 9825ab7c..46602f33 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJob.java @@ -21,6 +21,7 @@ package org.oransc.enrichment.repository; import java.lang.invoke.MethodHandles; +import java.time.Instant; import lombok.Builder; import lombok.Getter; @@ -53,6 +54,10 @@ public class EiJob { @Getter private final String jobStatusUrl; + @Getter + @Builder.Default + private String lastUpdated = Instant.now().toString(); + @Getter @Builder.Default private boolean isLastStatusReportedEnabled = true; diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java index bff5be2c..f5224f25 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiJobs.java @@ -39,6 +39,7 @@ import java.util.ServiceLoader; import java.util.Vector; import org.oransc.enrichment.configuration.ApplicationConfig; +import org.oransc.enrichment.controllers.producer.ProducerCallbacks; import org.oransc.enrichment.exceptions.ServiceException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,11 +58,14 @@ public class EiJobs { private final ApplicationConfig config; private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - public EiJobs(ApplicationConfig config) { + private final ProducerCallbacks producerCallbacks; + + public EiJobs(ApplicationConfig config, ProducerCallbacks producerCallbacks) { this.config = config; GsonBuilder gsonBuilder = new GsonBuilder(); ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); this.gson = gsonBuilder.create(); + this.producerCallbacks = producerCallbacks; } public synchronized void restoreJobsFromDatabase() throws IOException { @@ -71,13 +75,13 @@ public class EiJobs { for (File file : dbDir.listFiles()) { String json = Files.readString(file.toPath()); EiJob job = gson.fromJson(json, EiJob.class); - this.put(job, false); + this.doPut(job); } - } public synchronized void put(EiJob job) { - this.put(job, true); + this.doPut(job); + storeJobInFile(job); } public synchronized Collection getJobs() { @@ -108,15 +112,15 @@ public class EiJobs { return allEiJobs.get(id); } - public synchronized EiJob remove(String id) { + public synchronized EiJob remove(String id, EiProducers eiProducers) { EiJob job = allEiJobs.get(id); if (job != null) { - remove(job); + remove(job, eiProducers); } return job; } - public synchronized void remove(EiJob job) { + public synchronized void remove(EiJob job, EiProducers eiProducers) { this.allEiJobs.remove(job.getId()); jobsByType.remove(job.getTypeId(), job.getId()); jobsByOwner.remove(job.getOwner(), job.getId()); @@ -126,7 +130,7 @@ public class EiJobs { } catch (IOException e) { logger.warn("Could not remove file: {}", e.getMessage()); } - + this.producerCallbacks.stopEiJob(job, eiProducers); } public synchronized int size() { @@ -137,6 +141,10 @@ public class EiJobs { this.allEiJobs.clear(); this.jobsByType.clear(); jobsByOwner.clear(); + clearDatabase(); + } + + private void clearDatabase() { try { FileSystemUtils.deleteRecursively(Path.of(getDatabaseDirectory())); Files.createDirectories(Paths.get(getDatabaseDirectory())); @@ -145,13 +153,10 @@ public class EiJobs { } } - private void put(EiJob job, boolean storePersistently) { + private void doPut(EiJob job) { allEiJobs.put(job.getId(), job); jobsByType.put(job.getTypeId(), job.getId(), job); jobsByOwner.put(job.getOwner(), job.getId(), job); - if (storePersistently) { - storeJobInFile(job); - } } private void storeJobInFile(EiJob job) { @@ -173,7 +178,7 @@ public class EiJobs { } private String getDatabaseDirectory() { - return config.getVardataDirectory() + "/database"; + return config.getVardataDirectory() + "/eijobs"; } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducer.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducer.java index 63e5d4c9..d8b20158 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducer.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducer.java @@ -21,6 +21,8 @@ package org.oransc.enrichment.repository; import java.util.Collection; +import java.util.HashSet; +import java.util.Set; import lombok.Getter; @@ -37,6 +39,8 @@ public class EiProducer { @Getter private final String producerSupervisionCallbackUrl; + private final Set enabledJobs = new HashSet<>(); + private int unresponsiveCounter = 0; public EiProducer(String id, Collection eiTypes, String jobCallbackUrl, @@ -63,4 +67,19 @@ public class EiProducer { return this.unresponsiveCounter == 0; } + public synchronized void setJobEnabled(EiJob job) { + this.enabledJobs.add(job.getId()); + } + + public synchronized void setJobDisabled(EiJob job) { + this.enabledJobs.remove(job.getId()); + } + + /** + * Is the job enabled for this producer? + */ + public synchronized boolean isJobEnabled(EiJob job) { + return this.enabledJobs.contains(job.getId()); + } + } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducers.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducers.java index 801e7fcc..f0fc49ff 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducers.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiProducers.java @@ -21,25 +21,83 @@ package org.oransc.enrichment.repository; import java.lang.invoke.MethodHandles; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Vector; +import org.immutables.value.Value.Immutable; +import org.oransc.enrichment.controllers.consumer.ConsumerCallbacks; +import org.oransc.enrichment.controllers.producer.ProducerCallbacks; import org.oransc.enrichment.exceptions.ServiceException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; /** * Dynamic representation of all EiProducers. */ @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally +@Component public class EiProducers { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final Map allEiProducers = new HashMap<>(); + private final MultiMap producersByType = new MultiMap<>(); - public synchronized void put(EiProducer producer) { + @Autowired + private ProducerCallbacks producerCallbacks; + + @Autowired + private ConsumerCallbacks consumerCallbacks; + + @Autowired + private EiJobs eiJobs; + + @Immutable + public interface EiProducerRegistrationInfo { + String id(); + + Collection supportedTypes(); + + String jobCallbackUrl(); + + String producerSupervisionCallbackUrl(); + } + + public EiProducer registerProducer(EiProducerRegistrationInfo producerInfo) { + final String producerId = producerInfo.id(); + EiProducer previousDefinition = this.get(producerId); + if (previousDefinition != null) { + for (EiType type : previousDefinition.getEiTypes()) { + producersByType.remove(type.getId(), producerId); + } + allEiProducers.remove(producerId); + } + + EiProducer producer = createProducer(producerInfo); allEiProducers.put(producer.getId(), producer); + for (EiType type : producer.getEiTypes()) { + producersByType.put(type.getId(), producer.getId(), producer); + } + + Collection previousTypes = + previousDefinition != null ? previousDefinition.getEiTypes() : new ArrayList<>(); + + producerCallbacks.startEiJobs(producer, this.eiJobs) // + .collectList() // + .flatMapMany(list -> consumerCallbacks.notifyJobStatus(producer.getEiTypes())) // + .collectList() // + .flatMapMany(list -> consumerCallbacks.notifyJobStatus(previousTypes)) // + .subscribe(); + + return producer; + } + + private EiProducer createProducer(EiProducerRegistrationInfo producerInfo) { + return new EiProducer(producerInfo.id(), producerInfo.supportedTypes(), producerInfo.jobCallbackUrl(), + producerInfo.producerSupervisionCallbackUrl()); } public synchronized Collection getAllProducers() { @@ -58,33 +116,49 @@ public class EiProducers { return allEiProducers.get(id); } - public synchronized void remove(String id) { - this.allEiProducers.remove(id); - } - public synchronized int size() { return allEiProducers.size(); } public synchronized void clear() { this.allEiProducers.clear(); + this.producersByType.clear(); } - public void deregisterProducer(EiProducer producer, EiTypes eiTypes, EiJobs eiJobs) { - this.remove(producer); + public void deregisterProducer(EiProducer producer) { + allEiProducers.remove(producer.getId()); for (EiType type : producer.getEiTypes()) { - boolean removed = type.removeProducer(producer) != null; - if (!removed) { + if (producersByType.remove(type.getId(), producer.getId()) == null) { this.logger.error("Bug, no producer found"); } - if (type.getProducerIds().isEmpty()) { - eiTypes.remove(type); - } } + this.consumerCallbacks.notifyJobStatus(producer.getEiTypes()) // + .subscribe(); + } + + public synchronized Collection getProducersForType(EiType type) { + return this.producersByType.get(type.getId()); } - private synchronized void remove(EiProducer producer) { - this.allEiProducers.remove(producer.getId()); + public synchronized Collection getProducersForType(String typeId) { + return this.producersByType.get(typeId); + } + + public synchronized Collection getProducerIdsForType(String typeId) { + Collection producerIds = new ArrayList<>(); + for (EiProducer p : this.getProducersForType(typeId)) { + producerIds.add(p.getId()); + } + return producerIds; + } + + public synchronized boolean isJobEnabled(EiJob job) { + for (EiProducer producer : this.producersByType.get(job.getTypeId())) { + if (producer.isJobEnabled(job)) { + return true; + } + } + return false; } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiType.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiType.java index a354198a..5d9057a6 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiType.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiType.java @@ -20,11 +20,6 @@ package org.oransc.enrichment.repository; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - import lombok.Getter; public class EiType { @@ -34,26 +29,9 @@ public class EiType { @Getter private final Object jobDataSchema; - private final Map producers = new HashMap<>(); - public EiType(String id, Object jobDataSchema) { this.id = id; this.jobDataSchema = jobDataSchema; } - public synchronized Collection getProducers() { - return Collections.unmodifiableCollection(producers.values()); - } - - public synchronized Collection getProducerIds() { - return Collections.unmodifiableCollection(producers.keySet()); - } - - public synchronized void addProducer(EiProducer producer) { - this.producers.put(producer.getId(), producer); - } - - public synchronized EiProducer removeProducer(EiProducer producer) { - return this.producers.remove(producer.getId()); - } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java index d0bf53a5..363a65e2 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java @@ -20,15 +20,29 @@ package org.oransc.enrichment.repository; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.TypeAdapterFactory; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; import java.lang.invoke.MethodHandles; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.ServiceLoader; import java.util.Vector; +import org.oransc.enrichment.configuration.ApplicationConfig; import org.oransc.enrichment.exceptions.ServiceException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.util.FileSystemUtils; /** * Dynamic representation of all EI types in the system. @@ -37,9 +51,30 @@ import org.slf4j.LoggerFactory; public class EiTypes { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final Map allEiTypes = new HashMap<>(); + private final ApplicationConfig config; + private final Gson gson; + + public EiTypes(ApplicationConfig config) { + this.config = config; + GsonBuilder gsonBuilder = new GsonBuilder(); + ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); + this.gson = gsonBuilder.create(); + } + + public synchronized void restoreTypesFromDatabase() throws IOException { + Files.createDirectories(Paths.get(getDatabaseDirectory())); + File dbDir = new File(getDatabaseDirectory()); + + for (File file : dbDir.listFiles()) { + String json = Files.readString(file.toPath()); + EiType type = gson.fromJson(json, EiType.class); + allEiTypes.put(type.getId(), type); + } + } public synchronized void put(EiType type) { allEiTypes.put(type.getId(), type); + storeInFile(type); } public synchronized Collection getAllEiTypes() { @@ -49,7 +84,7 @@ public class EiTypes { public synchronized EiType getType(String id) throws ServiceException { EiType type = allEiTypes.get(id); if (type == null) { - throw new ServiceException("Could not find EI type: " + id); + throw new ServiceException("EI type not found: " + id); } return type; } @@ -58,12 +93,13 @@ public class EiTypes { return allEiTypes.get(id); } - public synchronized void remove(String id) { - allEiTypes.remove(id); - } - public synchronized void remove(EiType type) { - this.remove(type.getId()); + allEiTypes.remove(type.getId()); + try { + Files.delete(getPath(type)); + } catch (IOException e) { + logger.warn("Could not remove file: {} {}", type.getId(), e.getMessage()); + } } public synchronized int size() { @@ -72,5 +108,41 @@ public class EiTypes { public synchronized void clear() { this.allEiTypes.clear(); + clearDatabase(); + } + + private void clearDatabase() { + try { + FileSystemUtils.deleteRecursively(Path.of(getDatabaseDirectory())); + Files.createDirectories(Paths.get(getDatabaseDirectory())); + } catch (IOException e) { + logger.warn("Could not delete database : {}", e.getMessage()); + } + } + + private void storeInFile(EiType type) { + try { + try (PrintStream out = new PrintStream(new FileOutputStream(getFile(type)))) { + out.print(gson.toJson(type)); + } + } catch (Exception e) { + logger.warn("Could not save job: {} {}", type.getId(), e.getMessage()); + } + } + + private File getFile(EiType type) { + return getPath(type).toFile(); + } + + private Path getPath(EiType type) { + return getPath(type.getId()); + } + + private Path getPath(String typeId) { + return Path.of(getDatabaseDirectory(), typeId); + } + + private String getDatabaseDirectory() { + return config.getVardataDirectory() + "/eitypes"; } } diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/MultiMap.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/MultiMap.java index c2b82704..25e559ce 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/MultiMap.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/MultiMap.java @@ -38,14 +38,16 @@ public class MultiMap { this.map.computeIfAbsent(key, k -> new HashMap<>()).put(id, value); } - public void remove(String key, String id) { + public T remove(String key, String id) { Map innerMap = this.map.get(key); if (innerMap != null) { - innerMap.remove(id); + T removedElement = innerMap.remove(id); if (innerMap.isEmpty()) { this.map.remove(key); } + return removedElement; } + return null; } public Collection get(String key) { diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java index e2421665..c2e4b975 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/tasks/ProducerSupervision.java @@ -20,14 +20,15 @@ package org.oransc.enrichment.tasks; -import org.oransc.enrichment.clients.AsyncRestClient; -import org.oransc.enrichment.clients.AsyncRestClientFactory; +import java.time.Duration; + import org.oransc.enrichment.configuration.ApplicationConfig; import org.oransc.enrichment.controllers.consumer.ConsumerCallbacks; +import org.oransc.enrichment.controllers.producer.ProducerCallbacks; +import org.oransc.enrichment.repository.EiJob; import org.oransc.enrichment.repository.EiJobs; import org.oransc.enrichment.repository.EiProducer; import org.oransc.enrichment.repository.EiProducers; -import org.oransc.enrichment.repository.EiTypes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -37,6 +38,7 @@ import org.springframework.stereotype.Component; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import reactor.util.retry.Retry; /** * Regularly checks the availability of the EI Producers @@ -49,18 +51,15 @@ public class ProducerSupervision { private final EiProducers eiProducers; private final EiJobs eiJobs; - private final EiTypes eiTypes; - private final AsyncRestClient restClient; + private final ProducerCallbacks producerCallbacks; private final ConsumerCallbacks consumerCallbacks; @Autowired public ProducerSupervision(ApplicationConfig applicationConfig, EiProducers eiProducers, EiJobs eiJobs, - EiTypes eiTypes, ConsumerCallbacks consumerCallbacks) { - AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(applicationConfig.getWebClientConfig()); - this.restClient = restClientFactory.createRestClient(""); - this.eiJobs = eiJobs; + ProducerCallbacks producerCallbacks, ConsumerCallbacks consumerCallbacks) { this.eiProducers = eiProducers; - this.eiTypes = eiTypes; + this.eiJobs = eiJobs; + this.producerCallbacks = producerCallbacks; this.consumerCallbacks = consumerCallbacks; } @@ -76,21 +75,40 @@ public class ProducerSupervision { } private Mono checkOneProducer(EiProducer producer) { - return restClient.get(producer.getProducerSupervisionCallbackUrl()) // + return this.producerCallbacks.healthCheck(producer) // .onErrorResume(throwable -> { handleNonRespondingProducer(throwable, producer); return Mono.empty(); })// .doOnNext(response -> handleRespondingProducer(response, producer)) - .flatMap(response -> Mono.just(producer)); + .flatMap(response -> checkProducerJobs(producer)) // + .flatMap(responses -> Mono.just(producer)); + } + + private Mono checkProducerJobs(EiProducer producer) { + return getEiJobs(producer) // + .filter(eiJob -> !producer.isJobEnabled(eiJob)) // + .flatMap(eiJob -> startEiJob(producer, eiJob), 1) // + .collectList() // + .flatMapMany(eiJob -> consumerCallbacks.notifyJobStatus(producer.getEiTypes())) // + .collectList(); + } + + private Mono startEiJob(EiProducer producer, EiJob eiJob) { + Retry retrySpec = Retry.fixedDelay(1, Duration.ofSeconds(1)); + return producerCallbacks.startEiJob(producer, eiJob, retrySpec); + } + + private Flux getEiJobs(EiProducer producer) { + return Flux.fromIterable(producer.getEiTypes()) // + .flatMap(eiType -> Flux.fromIterable(eiJobs.getJobsForType(eiType))); } private void handleNonRespondingProducer(Throwable throwable, EiProducer producer) { logger.warn("Unresponsive producer: {} exception: {}", producer.getId(), throwable.getMessage()); producer.setAliveStatus(false); if (producer.isDead()) { - this.eiProducers.deregisterProducer(producer, this.eiTypes, this.eiJobs); - this.consumerCallbacks.notifyConsumersProducerDeleted(producer); + this.eiProducers.deregisterProducer(producer); } } diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java index c5ee82aa..a863c103 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/ApplicationTest.java @@ -34,8 +34,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; import java.lang.invoke.MethodHandles; -import java.util.ArrayList; -import java.util.Collection; +import java.util.Arrays; import org.json.JSONObject; import org.junit.jupiter.api.AfterEach; @@ -45,15 +44,19 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.oransc.enrichment.clients.AsyncRestClient; import org.oransc.enrichment.clients.AsyncRestClientFactory; import org.oransc.enrichment.configuration.ApplicationConfig; +import org.oransc.enrichment.configuration.ImmutableHttpProxyConfig; import org.oransc.enrichment.configuration.ImmutableWebClientConfig; import org.oransc.enrichment.configuration.WebClientConfig; +import org.oransc.enrichment.configuration.WebClientConfig.HttpProxyConfig; import org.oransc.enrichment.controller.ConsumerSimulatorController; import org.oransc.enrichment.controller.ProducerSimulatorController; import org.oransc.enrichment.controllers.consumer.ConsumerConsts; import org.oransc.enrichment.controllers.consumer.ConsumerEiJobInfo; import org.oransc.enrichment.controllers.consumer.ConsumerEiJobStatus; import org.oransc.enrichment.controllers.consumer.ConsumerEiTypeInfo; +import org.oransc.enrichment.controllers.producer.ProducerCallbacks; import org.oransc.enrichment.controllers.producer.ProducerConsts; +import org.oransc.enrichment.controllers.producer.ProducerEiTypeInfo; import org.oransc.enrichment.controllers.producer.ProducerJobInfo; import org.oransc.enrichment.controllers.producer.ProducerRegistrationInfo; import org.oransc.enrichment.controllers.producer.ProducerRegistrationInfo.ProducerEiTypeRegistrationInfo; @@ -61,6 +64,7 @@ import org.oransc.enrichment.controllers.producer.ProducerStatusInfo; import org.oransc.enrichment.exceptions.ServiceException; import org.oransc.enrichment.repository.EiJob; import org.oransc.enrichment.repository.EiJobs; +import org.oransc.enrichment.repository.EiProducer; import org.oransc.enrichment.repository.EiProducers; import org.oransc.enrichment.repository.EiType; import org.oransc.enrichment.repository.EiTypes; @@ -125,6 +129,9 @@ class ApplicationTest { @Autowired ProducerSupervision producerSupervision; + @Autowired + ProducerCallbacks producerCallbacks; + private static Gson gson = new GsonBuilder().create(); /** @@ -161,8 +168,12 @@ class ApplicationTest { ResponseEntity resp = restClient().getForEntity(url).block(); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); - String indented = (new JSONObject(resp.getBody())).toString(4); - try (PrintStream out = new PrintStream(new FileOutputStream("../docs/offeredapis/swagger/ecs-api.json"))) { + JSONObject jsonObj = new JSONObject(resp.getBody()); + jsonObj.remove("host"); + assertThat(jsonObj.getJSONObject("definitions").remove("Mono«ResponseEntity«object»»")).isNotNull(); + assertThat(jsonObj.getJSONObject("definitions").remove("Void")).isNotNull(); + String indented = jsonObj.toString(4); + try (PrintStream out = new PrintStream(new FileOutputStream("api/ecs-api.json"))) { out.print(indented); } } @@ -182,6 +193,19 @@ class ApplicationTest { assertThat(rsp).isEqualTo("[]"); } + @Test + void testPutEiType() throws JsonMappingException, JsonProcessingException, ServiceException { + assertThat(putEiType(EI_TYPE_ID)).isEqualTo(HttpStatus.CREATED); + assertThat(putEiType(EI_TYPE_ID)).isEqualTo(HttpStatus.OK); + } + + @Test + void testPutEiType_noSchema() { + String url = ProducerConsts.API_ROOT + "/eitypes/" + EI_TYPE_ID; + String body = "{}"; + testErrorCode(restClient().put(url, body), HttpStatus.BAD_REQUEST, "No schema provided"); + } + @Test void testGetEiType() throws Exception { putEiProducerWithOneType(EI_PRODUCER_ID, "test"); @@ -191,10 +215,29 @@ class ApplicationTest { assertThat(info).isNotNull(); } + @Test + void testDeleteEiType() throws Exception { + putEiType(EI_TYPE_ID); + String url = ProducerConsts.API_ROOT + "/eitypes/" + EI_TYPE_ID; + restClient().delete(url).block(); + assertThat(this.eiTypes.size()).isEqualTo(0); + + testErrorCode(restClient().delete(url), HttpStatus.NOT_FOUND, "EI type not found"); + } + + @Test + void testDeleteEiTypeExistingProducer() throws Exception { + putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); + String url = ProducerConsts.API_ROOT + "/eitypes/" + EI_TYPE_ID; + testErrorCode(restClient().delete(url), HttpStatus.NOT_ACCEPTABLE, + "The type has active producers: " + EI_PRODUCER_ID); + assertThat(this.eiTypes.size()).isEqualTo(1); + } + @Test void testGetEiTypeNotFound() throws Exception { String url = ConsumerConsts.API_ROOT + "/eitypes/junk"; - testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND, "Could not find EI type: junk"); + testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND, "EI type not found: junk"); } @Test @@ -299,19 +342,24 @@ class ApplicationTest { assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); EiJob job = this.eiJobs.getJob("jobId"); assertThat(job.getOwner()).isEqualTo("owner"); + + verifyJobStatus(EI_JOB_ID, "ENABLED"); } @Test void putEiProducerWithOneType_rejecting() throws JsonMappingException, JsonProcessingException, ServiceException { putEiProducerWithOneTypeRejecting("simulateProducerError", EI_TYPE_ID); - String url = ConsumerConsts.API_ROOT + "/eijobs/jobId"; + String url = ConsumerConsts.API_ROOT + "/eijobs/" + EI_JOB_ID; String body = gson.toJson(eiJobInfo()); - testErrorCode(restClient().put(url, body), HttpStatus.CONFLICT, "Job not accepted by any producers"); + restClient().put(url, body).block(); ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults(); // There is one retry -> 2 calls await().untilAsserted(() -> assertThat(simulatorResults.noOfRejectedCreate).isEqualTo(2)); assertThat(simulatorResults.noOfRejectedCreate).isEqualTo(2); + + verifyJobStatus(EI_JOB_ID, "DISABLED"); + } @Test @@ -342,20 +390,6 @@ class ApplicationTest { assertThat(resp.getBody()).contains(EI_TYPE_ID_2); } - @Test - void testReplacingEiProducerTypes() throws Exception { - final String REPLACED_TYPE_ID = "replaced"; - putEiProducerWithOneType(EI_PRODUCER_ID, REPLACED_TYPE_ID); - putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); - - String url = ProducerConsts.API_ROOT + "/eitypes"; - - ResponseEntity resp = restClient().getForEntity(url).block(); - assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(resp.getBody()).contains(EI_TYPE_ID); - assertThat(resp.getBody()).doesNotContain(REPLACED_TYPE_ID); - } - @Test void testChangingEiTypeGetRejected() throws Exception { putEiProducerWithOneType("producer1", "typeId1"); @@ -370,6 +404,7 @@ class ApplicationTest { @Test void testPutEiProducer() throws Exception { + this.putEiType(EI_TYPE_ID); String url = ProducerConsts.API_ROOT + "/eiproducers/eiProducerId"; String body = gson.toJson(producerEiRegistratioInfo(EI_TYPE_ID)); @@ -377,8 +412,7 @@ class ApplicationTest { assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(this.eiTypes.size()).isEqualTo(1); - EiType type = this.eiTypes.getType(EI_TYPE_ID); - assertThat(type.getProducerIds()).contains("eiProducerId"); + assertThat(this.eiProducers.getProducersForType(EI_TYPE_ID).size()).isEqualTo(1); assertThat(this.eiProducers.size()).isEqualTo(1); assertThat(this.eiProducers.get("eiProducerId").getEiTypes().iterator().next().getId()).isEqualTo(EI_TYPE_ID); @@ -404,8 +438,16 @@ class ApplicationTest { assertThat(request.id).isEqualTo("jobId"); } + @Test + void testPutEiProducer_noType() throws Exception { + String url = ProducerConsts.API_ROOT + "/eiproducers/eiProducerId"; + String body = gson.toJson(producerEiRegistratioInfo(EI_TYPE_ID)); + testErrorCode(restClient().put(url, body), HttpStatus.NOT_FOUND, "EI type not found"); + } + @Test void testPutProducerAndEiJob() throws Exception { + this.putEiType(EI_TYPE_ID); String url = ProducerConsts.API_ROOT + "/eiproducers/eiProducerId"; String body = gson.toJson(producerEiRegistratioInfo(EI_TYPE_ID)); restClient().putForEntity(url, body).block(); @@ -449,19 +491,19 @@ class ApplicationTest { assertThat(this.eiProducers.size()).isEqualTo(2); EiType type = this.eiTypes.getType(EI_TYPE_ID); - assertThat(type.getProducerIds()).contains("eiProducerId"); - assertThat(type.getProducerIds()).contains("eiProducerId2"); + assertThat(this.eiProducers.getProducerIdsForType(type.getId())).contains("eiProducerId"); + assertThat(this.eiProducers.getProducerIdsForType(type.getId())).contains("eiProducerId2"); putEiJob(EI_TYPE_ID, "jobId"); assertThat(this.eiJobs.size()).isEqualTo(1); deleteEiProducer("eiProducerId"); assertThat(this.eiProducers.size()).isEqualTo(1); - assertThat(this.eiTypes.getType(EI_TYPE_ID).getProducerIds()).doesNotContain("eiProducerId"); + assertThat(this.eiProducers.getProducerIdsForType(EI_TYPE_ID)).doesNotContain("eiProducerId"); verifyJobStatus("jobId", "ENABLED"); deleteEiProducer("eiProducerId2"); assertThat(this.eiProducers.size()).isZero(); - assertThat(this.eiTypes.size()).isZero(); + assertThat(this.eiTypes.size()).isEqualTo(1); verifyJobStatus("jobId", "DISABLED"); } @@ -478,7 +520,7 @@ class ApplicationTest { deleteEiProducer("eiProducerId2"); assertThat(this.eiTypes.size()).isEqualTo(1); // The type remains, one producer left deleteEiProducer("eiProducerId"); - assertThat(this.eiTypes.size()).isZero(); // The type is gone + assertThat(this.eiTypes.size()).isEqualTo(1); // The type remains assertThat(this.eiJobs.size()).isEqualTo(1); // The job remains await().untilAsserted(() -> assertThat(consumerCalls.status.size()).isEqualTo(1)); assertThat(consumerCalls.status.get(0).state).isEqualTo(ConsumerEiJobStatus.EiJobStatusValues.DISABLED); @@ -496,7 +538,7 @@ class ApplicationTest { putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); putEiJob(EI_TYPE_ID, EI_JOB_ID); - // change the type for the producer, the EI_TYPE_ID is deleted + // change the type for the producer, the job shall be disabled putEiProducerWithOneType(EI_PRODUCER_ID, "junk"); verifyJobStatus(EI_JOB_ID, "DISABLED"); ConsumerSimulatorController.TestResults consumerCalls = this.consumerSimulator.getTestResults(); @@ -514,7 +556,8 @@ class ApplicationTest { putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); String url = ProducerConsts.API_ROOT + "/eitypes/" + EI_TYPE_ID; ResponseEntity resp = restClient().getForEntity(url).block(); - assertThat(resp.getBody()).contains(EI_PRODUCER_ID); + ProducerEiTypeInfo info = gson.fromJson(resp.getBody(), ProducerEiTypeInfo.class); + assertThat(info.jobDataSchema).isNotNull(); } @Test @@ -523,17 +566,32 @@ class ApplicationTest { String url = ProducerConsts.API_ROOT + "/eiproducers"; ResponseEntity resp = restClient().getForEntity(url).block(); assertThat(resp.getBody()).contains(EI_PRODUCER_ID); + + url = ProducerConsts.API_ROOT + "/eiproducers?ei_type_id=" + EI_TYPE_ID; + resp = restClient().getForEntity(url).block(); + assertThat(resp.getBody()).contains(EI_PRODUCER_ID); + + url = ProducerConsts.API_ROOT + "/eiproducers?ei_type_id=junk"; + resp = restClient().getForEntity(url).block(); + assertThat(resp.getBody()).isEqualTo("[]"); } @Test void testProducerSupervision() throws JsonMappingException, JsonProcessingException, ServiceException { + + ConsumerSimulatorController.TestResults consumerResults = this.consumerSimulator.getTestResults(); putEiProducerWithOneTypeRejecting("simulateProducerError", EI_TYPE_ID); { // Create a job putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); putEiJob(EI_TYPE_ID, EI_JOB_ID); + verifyJobStatus(EI_JOB_ID, "ENABLED"); deleteEiProducer(EI_PRODUCER_ID); + // A Job disabled status notification shall now be received + await().untilAsserted(() -> assertThat(consumerResults.status.size()).isEqualTo(1)); + assertThat(consumerResults.status.get(0).state).isEqualTo(ConsumerEiJobStatus.EiJobStatusValues.DISABLED); + verifyJobStatus(EI_JOB_ID, "DISABLED"); } assertThat(this.eiProducers.size()).isEqualTo(1); @@ -543,22 +601,45 @@ class ApplicationTest { this.producerSupervision.createTask().blockLast(); this.producerSupervision.createTask().blockLast(); - // Now we have one producer that is disabled, but the job will be enabled until - // the producer/type is removed + // Now we have one producer that is disabled assertThat(this.eiProducers.size()).isEqualTo(1); assertProducerOpState("simulateProducerError", ProducerStatusInfo.OperationalState.DISABLED); - verifyJobStatus(EI_JOB_ID, "ENABLED"); - // After 3 failed checks, the producer and the type shall be deregisterred + // After 3 failed checks, the producer shall be deregisterred this.producerSupervision.createTask().blockLast(); - assertThat(this.eiProducers.size()).isEqualTo(0); - assertThat(this.eiTypes.size()).isEqualTo(0); + assertThat(this.eiProducers.size()).isEqualTo(0); // The producer is removed + assertThat(this.eiTypes.size()).isEqualTo(1); // The type remains + + // Now we have one disabled job, and no producer. + // PUT a producer, then a Job ENABLED status notification shall be received + putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); + await().untilAsserted(() -> assertThat(consumerResults.status.size()).isEqualTo(2)); + assertThat(consumerResults.status.get(1).state).isEqualTo(ConsumerEiJobStatus.EiJobStatusValues.ENABLED); + verifyJobStatus(EI_JOB_ID, "ENABLED"); + } + + @Test + void testProducerSupervision2() throws JsonMappingException, JsonProcessingException, ServiceException { + // Test that supervision enables not enabled jobs and sends a notification when + // suceeded + + putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); + putEiJob(EI_TYPE_ID, EI_JOB_ID); + + EiProducer producer = this.eiProducers.getProducer(EI_PRODUCER_ID); + EiJob job = this.eiJobs.getJob(EI_JOB_ID); + // Pretend that the producer did reject the job and the a DISABLED notification + // is sent for the job + producer.setJobDisabled(job); + job.setLastReportedStatus(false); verifyJobStatus(EI_JOB_ID, "DISABLED"); - // Job disabled status notification shall be received + // Run the supervision and wait for the job to get started in the producer + this.producerSupervision.createTask().blockLast(); ConsumerSimulatorController.TestResults consumerResults = this.consumerSimulator.getTestResults(); await().untilAsserted(() -> assertThat(consumerResults.status.size()).isEqualTo(1)); - assertThat(consumerResults.status.get(0).state).isEqualTo(ConsumerEiJobStatus.EiJobStatusValues.DISABLED); + assertThat(consumerResults.status.get(0).state).isEqualTo(ConsumerEiJobStatus.EiJobStatusValues.ENABLED); + verifyJobStatus(EI_JOB_ID, "ENABLED"); } @Test @@ -580,22 +661,55 @@ class ApplicationTest { assertThat(this.eiJobs.size()).isEqualTo(2); { + EiJob savedJob = this.eiJobs.getJob("jobId1"); // Restore the jobs - EiJobs jobs = new EiJobs(this.applicationConfig); + EiJobs jobs = new EiJobs(this.applicationConfig, this.producerCallbacks); jobs.restoreJobsFromDatabase(); assertThat(jobs.size()).isEqualTo(2); - jobs.remove("jobId1"); - jobs.remove("jobId2"); + EiJob restoredJob = jobs.getJob("jobId1"); + assertThat(restoredJob.getId()).isEqualTo("jobId1"); + assertThat(restoredJob.getLastUpdated()).isEqualTo(savedJob.getLastUpdated()); + + jobs.remove("jobId1", this.eiProducers); + jobs.remove("jobId2", this.eiProducers); } { // Restore the jobs, no jobs in database - EiJobs jobs = new EiJobs(this.applicationConfig); + EiJobs jobs = new EiJobs(this.applicationConfig, this.producerCallbacks); jobs.restoreJobsFromDatabase(); assertThat(jobs.size()).isEqualTo(0); } logger.warn("Test removing a job when the db file is gone"); - this.eiJobs.remove("jobId1"); + this.eiJobs.remove("jobId1", this.eiProducers); assertThat(this.eiJobs.size()).isEqualTo(1); + + ProducerSimulatorController.TestResults simulatorResults = this.producerSimulator.getTestResults(); + await().untilAsserted(() -> assertThat(simulatorResults.jobsStopped.size()).isEqualTo(3)); + } + + @Test + void testEiTypesDatabase() throws Exception { + putEiProducerWithOneType(EI_PRODUCER_ID, EI_TYPE_ID); + + assertThat(this.eiTypes.size()).isEqualTo(1); + + { + // Restore the types + EiTypes types = new EiTypes(this.applicationConfig); + types.restoreTypesFromDatabase(); + assertThat(types.size()).isEqualTo(1); + + } + { + // Restore the jobs, no jobs in database + EiTypes types = new EiTypes(this.applicationConfig); + types.clear(); + types.restoreTypesFromDatabase(); + assertThat(types.size()).isEqualTo(0); + } + logger.warn("Test removing a job when the db file is gone"); + this.eiTypes.remove(this.eiTypes.getType(EI_TYPE_ID)); + assertThat(this.eiJobs.size()).isEqualTo(0); } private void deleteEiProducer(String eiProducerId) { @@ -624,18 +738,14 @@ class ApplicationTest { ProducerRegistrationInfo producerEiRegistratioInfoRejecting(String typeId) throws JsonMappingException, JsonProcessingException { - Collection types = new ArrayList<>(); - types.add(producerEiTypeRegistrationInfo(typeId)); - return new ProducerRegistrationInfo(types, // + return new ProducerRegistrationInfo(Arrays.asList(typeId), // baseUrl() + ProducerSimulatorController.JOB_ERROR_URL, baseUrl() + ProducerSimulatorController.SUPERVISION_ERROR_URL); } ProducerRegistrationInfo producerEiRegistratioInfo(String typeId) throws JsonMappingException, JsonProcessingException { - Collection types = new ArrayList<>(); - types.add(producerEiTypeRegistrationInfo(typeId)); - return new ProducerRegistrationInfo(types, // + return new ProducerRegistrationInfo(Arrays.asList(typeId), // baseUrl() + ProducerSimulatorController.JOB_URL, baseUrl() + ProducerSimulatorController.SUPERVISION_URL); } @@ -687,21 +797,34 @@ class ApplicationTest { return this.eiJobs.getJob(jobId); } + private HttpStatus putEiType(String eiTypeId) + throws JsonMappingException, JsonProcessingException, ServiceException { + String url = ProducerConsts.API_ROOT + "/eitypes/" + eiTypeId; + String body = gson.toJson(producerEiTypeRegistrationInfo(eiTypeId)); + ResponseEntity resp = restClient().putForEntity(url, body).block(); + this.eiTypes.getType(eiTypeId); + return resp.getStatusCode(); + + } + private EiType putEiProducerWithOneTypeRejecting(String producerId, String eiTypeId) throws JsonMappingException, JsonProcessingException, ServiceException { + this.putEiType(eiTypeId); String url = ProducerConsts.API_ROOT + "/eiproducers/" + producerId; String body = gson.toJson(producerEiRegistratioInfoRejecting(eiTypeId)); - restClient().putForEntity(url, body).block(); return this.eiTypes.getType(eiTypeId); } private EiType putEiProducerWithOneType(String producerId, String eiTypeId) throws JsonMappingException, JsonProcessingException, ServiceException { + this.putEiType(eiTypeId); + String url = ProducerConsts.API_ROOT + "/eiproducers/" + producerId; String body = gson.toJson(producerEiRegistratioInfo(eiTypeId)); restClient().putForEntity(url, body).block(); + return this.eiTypes.getType(eiTypeId); } @@ -711,6 +834,10 @@ class ApplicationTest { private AsyncRestClient restClient(boolean useTrustValidation) { WebClientConfig config = this.applicationConfig.getWebClientConfig(); + HttpProxyConfig httpProxyConfig = ImmutableHttpProxyConfig.builder() // + .httpProxyHost("") // + .httpProxyPort(0) // + .build(); config = ImmutableWebClientConfig.builder() // .keyStoreType(config.keyStoreType()) // .keyStorePassword(config.keyStorePassword()) // @@ -719,10 +846,10 @@ class ApplicationTest { .isTrustStoreUsed(useTrustValidation) // .trustStore(config.trustStore()) // .trustStorePassword(config.trustStorePassword()) // - .build(); + .httpProxyConfig(httpProxyConfig).build(); AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config); - return restClientFactory.createRestClient(baseUrl()); + return restClientFactory.createRestClientNoHttpProxy(baseUrl()); } private AsyncRestClient restClient() { diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/clients/AsyncRestClientTest.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/clients/AsyncRestClientTest.java index f879c7be..364203a2 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/clients/AsyncRestClientTest.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/clients/AsyncRestClientTest.java @@ -58,7 +58,7 @@ class AsyncRestClientTest { InternalLoggerFactory.setDefaultFactory(JdkLoggerFactory.INSTANCE); Loggers.useJdkLoggers(); mockWebServer = new MockWebServer(); - clientUnderTest = new AsyncRestClient(mockWebServer.url(BASE_URL).toString()); + clientUnderTest = new AsyncRestClient(mockWebServer.url(BASE_URL).toString(), null, null); } @AfterAll diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ConsumerSimulatorController.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ConsumerSimulatorController.java index 562f2869..e8bb659c 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ConsumerSimulatorController.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ConsumerSimulatorController.java @@ -45,7 +45,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @RestController("ConsumerSimulatorController") -@Api(tags = {"Consumer Callbacks"}) +@Api(tags = {"A1-EI (enrichment information) callbacks"}) public class ConsumerSimulatorController { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); diff --git a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java index 2a3688cf..726cef7e 100644 --- a/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java +++ b/enrichment-coordinator-service/src/test/java/org/oransc/enrichment/controller/ProducerSimulatorController.java @@ -48,7 +48,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; @RestController("ProducerSimulatorController") -@Api(tags = {"Producer Callbacks"}) +@Api(tags = {"Data Producer Job Control (example producer)"}) public class ProducerSimulatorController { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -134,7 +134,7 @@ public class ProducerSimulatorController { } @DeleteMapping(path = JOB_ERROR_URL + "/{eiJobId}", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Callback for EI job creation, returns error", notes = "", hidden = true) + @ApiOperation(value = "Callback for EI job deletion, returns error", notes = "", hidden = true) @ApiResponses( value = { // @ApiResponse(code = 200, message = "OK", response = VoidResponse.class)}// diff --git a/onap/oran b/onap/oran index 3b56b4ff..be0ae3e1 160000 --- a/onap/oran +++ b/onap/oran @@ -1 +1 @@ -Subproject commit 3b56b4ff40eba05108651d04df4b9a2ef3a4eb1d +Subproject commit be0ae3e197f5d5032c0766a59050b03e2a4deb99 diff --git a/policy-agent/.gitignore b/policy-agent/.gitignore index 602050b4..7daab979 100644 --- a/policy-agent/.gitignore +++ b/policy-agent/.gitignore @@ -6,3 +6,4 @@ target .checkstyle policy-agent.iml config +/bin/ diff --git a/policy-agent/README.md b/policy-agent/README.md index d660df91..e73d1dec 100644 --- a/policy-agent/README.md +++ b/policy-agent/README.md @@ -34,7 +34,7 @@ volumes: The target paths in the container should not be modified. Example docker run command for mounting new files (assuming they are located in the current directory): -docker run -p 8081:8081 -p 8433:8433 --name=policy-agent-container --network=nonrtric-docker-net --volume "$PWD/new_keystore.jks:/opt/app/policy-agent/etc/cert/keystore.jks" --volume "$PWD/new_truststore.jks:/opt/app/policy-agent/etc/cert/truststore.jks" --volume "$PWD/new_application.yaml:/opt/app/policy-agent/config/application.yaml" o-ran-sc/nonrtric-policy-agent:2.2.0-SNAPSHOT +docker run -p 8081:8081 -p 8433:8433 --name=policy-agent-container --network=nonrtric-docker-net --volume "$PWD/new_keystore.jks:/opt/app/policy-agent/etc/cert/keystore.jks" --volume "$PWD/new_truststore.jks:/opt/app/policy-agent/etc/cert/truststore.jks" --volume "$PWD/new_application.yaml:/opt/app/policy-agent/config/application.yaml" o-ran-sc/nonrtric-policy-agent:2.2.1-SNAPSHOT To Run Policy Agent in Local: diff --git a/policy-agent/pom.xml b/policy-agent/pom.xml index d18c9f75..92f8d5ac 100644 --- a/policy-agent/pom.xml +++ b/policy-agent/pom.xml @@ -31,7 +31,7 @@ org.o-ran-sc.nonrtric policy-agent - 2.2.0-SNAPSHOT + 2.2.1-SNAPSHOT The Apache Software License, Version 2.0 diff --git a/pom.xml b/pom.xml index d8717090..b7b64a90 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ org.o-ran-sc nonrtric - 2.2.0-SNAPSHOT + 2.2.1-SNAPSHOT pom nonrtric diff --git a/r-app-catalogue/Dockerfile b/r-app-catalogue/Dockerfile index a85f57d6..cd2efc9b 100644 --- a/r-app-catalogue/Dockerfile +++ b/r-app-catalogue/Dockerfile @@ -23,10 +23,12 @@ ARG JAR WORKDIR /opt/app/r-app-catalogue RUN mkdir -p /var/log/r-app-catalogue +RUN mkdir -p /opt/app/r-app-catalogue/etc/cert/ -EXPOSE 8081 8433 +EXPOSE 8680 8633 ADD /config/application.yaml /opt/app/r-app-catalogue/config/application.yaml +ADD /config/r-app-catalogue-keystore.jks /opt/app/r-app-catalogue/etc/cert/keystore.jks ADD target/${JAR} /opt/app/r-app-catalogue/r-app-catalogue.jar diff --git a/r-app-catalogue/config/application.yaml b/r-app-catalogue/config/application.yaml index fadf7d24..1ef0bdcc 100644 --- a/r-app-catalogue/config/application.yaml +++ b/r-app-catalogue/config/application.yaml @@ -1,4 +1,30 @@ + # ========================LICENSE_START================================= + # Copyright (C) 2021 Nordix Foundation. All rights reserved. + # ====================================================================== + # 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. + # ========================LICENSE_END=================================== + spring: profiles: active: prod - +server: + # Configuration of the HTTP/REST server. The parameters are defined and handled by the springboot framework. + # See springboot documentation. + port : 8633 + http-port: 8680 + ssl: + key-store-type: JKS + key-store: /opt/app/r-app-catalogue/etc/cert/keystore.jks + key-store-password: r-app-catalogue + key-password: r-app-catalogue + key-alias: server-cert diff --git a/r-app-catalogue/config/r-app-catalogue-keystore.jks b/r-app-catalogue/config/r-app-catalogue-keystore.jks new file mode 100644 index 0000000000000000000000000000000000000000..192fe173951fcb9e958b3996f5270c01cceab681 GIT binary patch literal 3641 zcmY+EbyO1$_r?bsF_4m00qK^(7^z4|jFJ!pB!&!W5UI(eTR^%)LL8$JkWtdzAV>+) z-Q7Qb-}A;r%@qiG2vK>M&U$9E>DH$FSUY0-E9LS$+`Y-+k z@h5QkABg}7@+Uz2#m0ZjfROZGTX#tC@U#3umk@u@DTJ4h}r~n!dLY9|&mG0{Mfw(5y2@FI;Yxm&VF_Jx<*oUo5*n)b7YNM7+-nSjC+% zFDR;j4z~aluEmd)d~H7NN7<<1OE|MKe?EmD3Uw_4A5(_z-ZKbgMy*ha%p7zZJv29> z&re~u^~fK^s*DWyEjAnY?4)sRO6MJMJ~14r66YfGP9MOYJ=c|n`m0>ck5(Dw+;5yj zMb^E?X;Ic9=f!w<&sJslZ&=PmiHb~15Kyyi#|&yxDL6433C-w?xsDiP1>#ODk~!t+N~NIFP##bPB=OkH1W(#(Ta}C#X;1r#u>kyaa}LO-%?-pdk=Blbm%a@sPe}8O)Zmz{Bq2g z-ZhyoF#ohcU`D#m(ql)O^h^3S<8f^>(qzHB`eW`3H*I88e|1Q}+oPlh2Do^ET{O`( zN1=4kr(i`1Igv#HHhWtpRbNBa0hTsn9UXcFBjO@SqOGSf(nVf1_rI2nsbT2EA1sLP z&}Mn{y#)Hpslu^F_Ayq2EQD_X*iP^_7ljmOcE!D3fQmG!H8I+Ds zS40AGw{8oCvqWi4b^>I&a;Io(j5#j|kC^b&k3CY{MMbbRKa=6i0jNxsXHvCzW@pi2 zX|3jSRo_SClHMGkBZ*5y)7&E~bs9pKIDhDq*R4CmZm99hXeN@4B?-4^>I6QBTRU7MlDTCL?&tm~rt;x&Hn0aQNzc5c2PSeh zf-!5~zDRFqrE3X*>eM;DE+#*U==`m>=E(gq1*r0b&9X(sBrmGmzNljRIF^JQB%DJM z`7Cwf=Osg?Fi;u`ih=hNt3OIPqFdXE`vZtE?2PWJKHkG|2q2f)?;|It?XJ48y6!TQ zpXH(oH@}3YzEW?!e=)-E&0I&;5{p`kdgI2w`BnLcJDEnYj@6%9WO$gl$e!udYpH1) z>zrZ5euE^5B}Ny))uF~LzzZeN>CmHK@A$5XJj1|Kzm(une|&jdvHoD!;3mIca7BW^ z%DFDvU13KNc73u#!1~kLcbBn0d}C?yN`m;TmSW{BY53*}uBY-BbBpvyOt+&%J>yB; zpJ$W*HV8>U<5cIFr+t8p=7oJErs;Dxh!(-;AMN3e+^tg#i&$B{d&S7Hcfn78@hW1< zztjR3s2b=HK~r&m@+4BXHX;*ypt3WW`lb=}_y*T0BVnsge3%mJL~8rXbwBsL`0b7Ppt75!SV3`e~0{k6}!=puRw?)`H_{NaH8;g?Mj(kRek*zMm*rFb#)%$+o{MGD(uoaBiD2(~ZLwYqz{`0M|bg&ZB zd(A?hs6ec;JxR7iB`C<@cWyv6(%()vS&_%Gp+w=CEff zX9DI!7^$!7J9*Wz??Up0JLEG^#X>&7q1BqBaNgb$voE@&xPeH>|<}#jNftd}0 z6*9{tJ3J<&(d)Dua0Bq~th7AY(&;LiLMA1puEDVs7gTO}_HxA}%uR@{7-97CWg+b` zr3g+--wo3K=uUaj-Rogkp9jPUGb-2)#0w|N5XxObOG?y75dKsS>ksLc7~U*WQ+}e` z`ZSh5X_>E+hl#;u42cQ%OROAvV0mtR%X-;Sv23jgA-d^}831%X(^i?$uhR+l+DsjW z(XBv?Bm>{x1K_OZzUrV_N31ugVbGIRnqg*sRE*?&52uv>oTU{)q)tM5(sq}$3UFKSxDi_ zt(rjMdopP2n?d(^iqpxaDO-3BBsg2Kqyn(x$` zZLKmi#WV5Q4ya6RNa6Ti&NmV}K-?(WA4MR3k`fS*C+uFnDG-PZT6Xxp6?QrHM=s1_ z^7&H(*qwb?;UpRKxs@J=f^9%Da&OGESX_~xJ?UGf4OPDNe5-CERxCLEkONz|svso# z0r%QRIeVR>!TQIoF#V)&o4I#jnR{#5dBw=}sC?zF$RF*|^$vruOCflfwOXQ896tm{%@47bK)|{sTx-eJv*QxXvC%D6CO7c0 z_=s0iV%3hwwC7Ru9Ew`Qi!-TW*4;UbHIaDav;uED-=p4jtyU>@MYk|g)ff01)H&ao z>!jg5L(m!!tCq_ipYGOl=d^Zjx^Sq;I@Q(=Pn*Y8{e2#gXJN%hA@UO`y(k(QVyAD! zv8RE*LIHK3Z+hK5z`4UO?RM{I_XEhcE*@H()$;|HAC_iD+m%-dU^4W|(@R|UdYCoE zAvXslTUmyfpQ9L%O9NuQ_Mz-qF|O)_!VN@?=#2V)dG*h!o@Fi5T28jRU!w0y{n}adr?)-!Qh9)IxgUJ9YUt$J z_ZrMu53JhT!dLp_pspYqHkM6GE|!wX3Q2~EoVO;l1#5m3Q6zdHATS2r!ms-jtQj(`~F@!4PQ0ddrQ_c!K%I$ij2@MRIX#mn@$KYtxojXahR$N zfnEcpuUL-eHYb|V*^9;+Mt|PtsT8)N8R6|rfunnD)05&9L&B3|H7JyJO93E7r)IqJWJ_sb`4ICe>8G0V#7b<`;EPygmKNdOda<3nBJ<}??K~PEAVJ33A zTcwjZQwIp{9cvFdaLaf0dWqOE9N=t!WW0M>n9%qk*$QIEVvuXDBT&aVZ;>Wj;61on zn`ExnBKlbWylxO@(aK8`U^U*H$|P&9K%g(r8@-OlK6K@iRzjoCTMV#ae7Ni3YWHpq zeOxQB({X0-yLhw8-?=Vy_i#E}cIl%3X>ek8(wi#b?Xa5qSzpQv#8Bdf3rIufxhX6S zkF#4DyBee#4_>Bwr=73q97tl?hKMO71p&GZU<8b(heP5YY}1p#S}1qTPsyWSXK+Yj zI<5k$H8{IETBD7)V|*!0-{Xl4Bdb9xiW2+r=rMu_kqg2mSCDyc0}AFM!qWndRq2~v z4~g#F8Ke%nd!xfm`|Mi!Y-8~=`wH4QWV2PQ>aI${3w)=3aHPzH0#riN;cCI~?ETzz zKtzWb28)_}9I#PY(C0*)Oz?@)>SU~5L?KWJA_HNCfC&ls$$|Ly2ml}&hg;oABdUY> s(zSQLk>0AT`>MQ-Ae#5mdioUE7w7y-RG)O4U8f#Ikec8F@q)Ad4{ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/r-app-catalogue/pom.xml b/r-app-catalogue/pom.xml index a2e05656..70982216 100644 --- a/r-app-catalogue/pom.xml +++ b/r-app-catalogue/pom.xml @@ -31,7 +31,7 @@ org.o-ran-sc.nonrtric r-app-catalogue - 1.1.0-SNAPSHOT + 1.1.1-SNAPSHOT The Apache Software License, Version 2.0 @@ -45,6 +45,8 @@ 0.2.1 4.3.1 3.0.11 + 2.12.2 + 1.24.3 0.8.6 0.30.0 @@ -155,6 +157,17 @@ junit-jupiter-engine test + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.httpcomponents + httpclient + test + + @@ -180,6 +193,7 @@ org.oransc.rappcatalogue true + true @@ -205,6 +219,32 @@ + + net.revelc.code.formatter + formatter-maven-plugin + ${formatter-maven-plugin.version} + + ${project.basedir}/eclipse-formatter.xml + + + + + com.diffplug.spotless + spotless-maven-plugin + ${spotless-maven-plugin.version} + + + + + com,java,javax,org + + + + + org.jacoco jacoco-maven-plugin diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisor.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisor.java index 939f7bf9..072a5a0e 100644 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisor.java +++ b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/GeneralRappCatalogueControllerAdvisor.java @@ -35,22 +35,19 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcep @ControllerAdvice public class GeneralRappCatalogueControllerAdvisor extends ResponseEntityExceptionHandler { @ExceptionHandler(InvalidServiceException.class) - public ResponseEntity handleInvalidServiceException( - InvalidServiceException ex) { + public ResponseEntity handleInvalidServiceException(InvalidServiceException ex) { return new ResponseEntity<>(getErrorInformation(ex, BAD_REQUEST), BAD_REQUEST); } @ExceptionHandler(ServiceNotFoundException.class) - public ResponseEntity handleServiceNotFoundException( - ServiceNotFoundException ex) { + public ResponseEntity handleServiceNotFoundException(ServiceNotFoundException ex) { return new ResponseEntity<>(getErrorInformation(ex, NOT_FOUND), NOT_FOUND); } @ExceptionHandler(HeaderException.class) - public ResponseEntity handleHeaderException( - HeaderException ex) { + public ResponseEntity handleHeaderException(HeaderException ex) { return new ResponseEntity<>(getErrorInformation(ex, INTERNAL_SERVER_ERROR), INTERNAL_SERVER_ERROR); } diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImpl.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImpl.java index bb3a6dc6..4615d69c 100644 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImpl.java +++ b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImpl.java @@ -1,141 +1,147 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. All rights reserved. - * ====================================================================== - * 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. - * ========================LICENSE_END=================================== - */ - -package org.oransc.rappcatalogue.api; - -import java.io.IOException; -import java.sql.Date; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.oransc.rappcatalogue.exception.HeaderException; -import org.oransc.rappcatalogue.exception.InvalidServiceException; -import org.oransc.rappcatalogue.exception.ServiceNotFoundException; -import org.oransc.rappcatalogue.model.InputService; -import org.oransc.rappcatalogue.model.Service; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; - -@org.springframework.stereotype.Service -public class ServicesApiDelegateImpl implements ServicesApiDelegate { - - private static final String LOCATION_HEADER = "Location"; - - @Autowired - private NativeWebRequest nativeWebRequest; - - private ConcurrentHashMap registeredServices = new ConcurrentHashMap<>(); - - ServicesApiDelegateImpl(NativeWebRequest nativeWebRequest) { - this.nativeWebRequest = nativeWebRequest; - } - - @Override - public Optional getRequest() { - return Optional.of(nativeWebRequest); - } - - @Override - public ResponseEntity getIndividualService(String serviceName) { - Service service = registeredServices.get(serviceName); - if (service != null) { - return ResponseEntity.ok(service); - } else { - throw new ServiceNotFoundException(serviceName); - } - } - - @Override - public ResponseEntity> getServices() { - return ResponseEntity.ok(new ArrayList<>(registeredServices.values())); - } - - @Override - public ResponseEntity putIndividualService(String serviceName, InputService inputService) { - if (isServiceValid(inputService)) { - if (registeredServices.put(serviceName, createService(serviceName, inputService)) == null) { - try { - getRequest().ifPresent(request -> addLocationHeaderToResponse(serviceName, request)); - } catch (Exception e) { - registeredServices.remove(serviceName); - throw e; - } - return new ResponseEntity<>(HttpStatus.CREATED); - } else { - return new ResponseEntity<>(HttpStatus.OK); - } - } else { - throw new InvalidServiceException(); - } - } - - private void addLocationHeaderToResponse(String serviceName, NativeWebRequest request) { - try { - HttpServletRequest nativeRequest = request.getNativeRequest(HttpServletRequest.class); - HttpServletResponse nativeResponse = request.getNativeResponse(HttpServletResponse.class); - if (nativeRequest != null && nativeResponse != null) { - StringBuffer requestURL = nativeRequest.getRequestURL(); - nativeResponse.addHeader(LOCATION_HEADER, requestURL.toString()); - nativeResponse.getWriter().print(""); - } else { - throw new HeaderException(LOCATION_HEADER, serviceName, - new Exception("Native Request or Response missing")); - } - } catch (IOException e) { - throw new HeaderException(LOCATION_HEADER, serviceName, e); - } - } - - @Override - public ResponseEntity deleteIndividualService(String serviceName) { - registeredServices.remove(serviceName); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - /* - * java:S2589: Boolean expressions should not be gratuitous. - * Even though the version property is marked as @NotNull, it might be null coming from the client, hence the null - * check is needed. - */ - @SuppressWarnings("java:S2589") - private boolean isServiceValid(InputService service) { - String version = service.getVersion(); - return version != null && !version.isBlank(); - } - - private Service createService(String serviceName, InputService inputService) { - Service service = new Service(); - service.setName(serviceName); - service.setDescription(inputService.getDescription()); - service.setDisplayName(inputService.getDisplayName()); - service.setVersion(inputService.getVersion()); - service.setRegistrationDate(getTodaysDate()); - return service; - } - - private String getTodaysDate() { - long millis = System.currentTimeMillis(); - Date date = new Date(millis); - return date.toString(); - } -} +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * ====================================================================== + * 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. + * ========================LICENSE_END=================================== + */ + +package org.oransc.rappcatalogue.api; + +import java.io.IOException; +import java.sql.Date; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.oransc.rappcatalogue.exception.HeaderException; +import org.oransc.rappcatalogue.exception.InvalidServiceException; +import org.oransc.rappcatalogue.exception.ServiceNotFoundException; +import org.oransc.rappcatalogue.model.InputService; +import org.oransc.rappcatalogue.model.Service; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +@org.springframework.stereotype.Service +public class ServicesApiDelegateImpl implements ServicesApiDelegate { + + private static final String LOCATION_HEADER = "Location"; + + @Autowired + private NativeWebRequest nativeWebRequest; + + private ConcurrentHashMap registeredServices = new ConcurrentHashMap<>(); + + ServicesApiDelegateImpl(NativeWebRequest nativeWebRequest) { + this.nativeWebRequest = nativeWebRequest; + } + + @Override + public Optional getRequest() { + return Optional.of(nativeWebRequest); + } + + @Override + public ResponseEntity getIndividualService(String serviceName) throws ServiceNotFoundException { + Service service = registeredServices.get(serviceName); + if (service != null) { + return ResponseEntity.ok(service); + } else { + throw new ServiceNotFoundException(serviceName); + } + } + + @Override + public ResponseEntity> getServices() { + return ResponseEntity.ok(new ArrayList<>(registeredServices.values())); + } + + @Override + public ResponseEntity putIndividualService(String serviceName, InputService inputService) + throws InvalidServiceException, HeaderException { + if (isServiceValid(inputService)) { + if (registeredServices.put(serviceName, createService(serviceName, inputService)) == null) { + try { + Optional request = getRequest(); + if (request.isPresent()) { + addLocationHeaderToResponse(serviceName, request.get()); + } + } catch (HeaderException e) { + registeredServices.remove(serviceName); + throw e; + } + return new ResponseEntity<>(HttpStatus.CREATED); + } else { + return new ResponseEntity<>(HttpStatus.OK); + } + } else { + throw new InvalidServiceException(); + } + } + + private void addLocationHeaderToResponse(String serviceName, NativeWebRequest request) throws HeaderException { + try { + HttpServletRequest nativeRequest = request.getNativeRequest(HttpServletRequest.class); + HttpServletResponse nativeResponse = request.getNativeResponse(HttpServletResponse.class); + if (nativeRequest != null && nativeResponse != null) { + StringBuffer requestURL = nativeRequest.getRequestURL(); + nativeResponse.addHeader(LOCATION_HEADER, requestURL.toString()); + nativeResponse.getWriter().print(""); + } else { + throw new HeaderException(LOCATION_HEADER, serviceName, + new Exception("Native Request or Response missing")); + } + } catch (IOException e) { + throw new HeaderException(LOCATION_HEADER, serviceName, e); + } + } + + @Override + public ResponseEntity deleteIndividualService(String serviceName) { + registeredServices.remove(serviceName); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + /* + * java:S2589: Boolean expressions should not be gratuitous. Even though the + * version property is marked as @NotNull, it might be null coming from the + * client, hence the null check is needed. + */ + @SuppressWarnings("java:S2589") + private boolean isServiceValid(InputService service) { + String version = service.getVersion(); + return version != null && !version.isBlank(); + } + + private Service createService(String serviceName, InputService inputService) { + Service service = new Service(); + service.setName(serviceName); + service.setDescription(inputService.getDescription()); + service.setDisplayName(inputService.getDisplayName()); + service.setVersion(inputService.getVersion()); + service.setRegistrationDate(getTodaysDate()); + return service; + } + + private String getTodaysDate() { + long millis = System.currentTimeMillis(); + Date date = new Date(millis); + return date.toString(); + } +} diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/configuration/TomcatConfig.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/configuration/TomcatConfig.java new file mode 100644 index 00000000..a04a3323 --- /dev/null +++ b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/configuration/TomcatConfig.java @@ -0,0 +1,56 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * 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. + * ========================LICENSE_END=================================== + */ + +package org.oransc.rappcatalogue.configuration; + +import org.apache.catalina.connector.Connector; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; +import org.springframework.boot.web.servlet.server.ServletWebServerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Configure embedded Tomcat + */ + +@Configuration +public class TomcatConfig { + + @Value("${server.http-port}") + private int httpPort = 0; + + // Embedded Tomcat with HTTP and HTTPS support + @Bean + public ServletWebServerFactory servletContainer() { + TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); + + if (httpPort > 0) { + tomcat.addAdditionalTomcatConnectors(getHttpConnector(httpPort)); + } + return tomcat; + } + + private static Connector getHttpConnector(int httpPort) { + Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL); + connector.setScheme("http"); + connector.setPort(httpPort); + connector.setSecure(false); + return connector; + } +} diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/HeaderException.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/HeaderException.java index 676ae1c1..8f64449f 100644 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/HeaderException.java +++ b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/HeaderException.java @@ -18,7 +18,7 @@ package org.oransc.rappcatalogue.exception; -public class HeaderException extends RuntimeException { +public class HeaderException extends Exception { private static final long serialVersionUID = -7798178963078284655L; diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/InvalidServiceException.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/InvalidServiceException.java index dce815b9..45ec7692 100644 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/InvalidServiceException.java +++ b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/InvalidServiceException.java @@ -18,7 +18,7 @@ package org.oransc.rappcatalogue.exception; -public class InvalidServiceException extends RuntimeException { +public class InvalidServiceException extends Exception { private static final long serialVersionUID = 3849219105170316564L; public InvalidServiceException() { diff --git a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/ServiceNotFoundException.java b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/ServiceNotFoundException.java index 26b4b271..8411cf42 100644 --- a/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/ServiceNotFoundException.java +++ b/r-app-catalogue/src/main/java/org/oransc/rappcatalogue/exception/ServiceNotFoundException.java @@ -18,7 +18,7 @@ package org.oransc.rappcatalogue.exception; -public class ServiceNotFoundException extends RuntimeException { +public class ServiceNotFoundException extends Exception { private static final long serialVersionUID = 6579271315716003988L; public ServiceNotFoundException(String serviceName) { diff --git a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/HttpsRequestTest.java b/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/HttpsRequestTest.java new file mode 100644 index 00000000..3cf2c2e7 --- /dev/null +++ b/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/HttpsRequestTest.java @@ -0,0 +1,113 @@ +/*- + * ========================LICENSE_START================================= + * Copyright (C) 2021 Nordix Foundation. All rights reserved. + * ====================================================================== + * 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. + * ========================LICENSE_END=================================== + */ + +package org.oransc.rappcatalogue; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import javax.net.ssl.SSLContext; + +import org.apache.http.client.HttpClient; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.util.ResourceUtils; +import org.springframework.web.client.ResourceAccessException; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@TestPropertySource( + properties = { // + "server.ssl.key-store=./config/r-app-catalogue-keystore.jks", // + "server.http-port=0"}) +public class HttpsRequestTest { + + @Value("${server.ssl.key-store-password}") + private String keyStorePassword; // inject password from config + + @Value("${server.ssl.key-store}") + private String keyStore; // inject keyStore from config + + @LocalServerPort + private int port; + + @Autowired + private AbstractConfigurableWebServerFactory webServerFactory; + + @Test + public void testSsl() { + assertEquals(this.webServerFactory.getSsl().isEnabled(), true); + } + + @Test + public void rest_OverPlainHttp_GetsBadRequestRequiresTLS() throws Exception { + TestRestTemplate template = new TestRestTemplate(); + ResponseEntity responseEntity = + template.getForEntity("http://localhost:" + port + "/services", String.class); + assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); + assertTrue(responseEntity.getBody().contains("This combination of host and port requires TLS")); + } + + @Test + public void rest_WithoutSSLConfiguration_ThrowsSSLExceptionUnableFindValidCertPath() throws Exception { + TestRestTemplate template = new TestRestTemplate(); + + ResourceAccessException thrown = assertThrows(ResourceAccessException.class, () -> { + template.getForEntity("https://localhost:" + port + "/services", String.class); + }); + assertTrue(thrown.getMessage().contains("unable to find valid certification path to requested target")); + } + + @Test + public void rest_WithTwoWaySSL_AuthenticatesAndGetsExpectedResponse() throws Exception { + + SSLContext sslContext = new SSLContextBuilder().loadKeyMaterial(ResourceUtils.getFile(keyStore), + keyStorePassword.toCharArray(), keyStorePassword.toCharArray()).build(); + + SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext); + HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); + HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient); + RestTemplateBuilder rtb = + new RestTemplateBuilder().requestFactory(() -> factory).rootUri("https://localhost:" + port); + + TestRestTemplate template = new TestRestTemplate(rtb, null, null, HttpClientOption.SSL); + + ResponseEntity responseEntity = template.getForEntity("/services", String.class); + assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); + assertEquals("[]", responseEntity.getBody()); + } + +} diff --git a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImplTest.java b/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImplTest.java index f2f30ff6..dd10a650 100644 --- a/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImplTest.java +++ b/r-app-catalogue/src/test/java/org/oransc/rappcatalogue/api/ServicesApiDelegateImplTest.java @@ -1,271 +1,275 @@ -package org.oransc.rappcatalogue.api; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.springframework.http.HttpStatus.CREATED; -import static org.springframework.http.HttpStatus.NO_CONTENT; -import static org.springframework.http.HttpStatus.OK; - -import java.io.IOException; -import java.io.PrintWriter; -import java.sql.Date; -import java.util.Arrays; -import java.util.List; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.oransc.rappcatalogue.exception.HeaderException; -import org.oransc.rappcatalogue.exception.InvalidServiceException; -import org.oransc.rappcatalogue.exception.ServiceNotFoundException; -import org.oransc.rappcatalogue.model.InputService; -import org.oransc.rappcatalogue.model.Service; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; - -@ExtendWith(MockitoExtension.class) -class ServicesApiDelegateImplTest { - - @Mock - NativeWebRequest webRequestMock; - - private static final String INVALID_SERVICE_MESSAGE = "Service is missing required property: version"; - private static final String SERVICE_NAME = "Service Name"; - private static final String SERVICE_DESCRIPTION = "description"; - private static final String SERVICE_VERSION = "1.0"; - private static final String SERVICE_DISPLAY_NAME = "Display Name"; - - @Test - void getAddedService_shouldReturnService() { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - InputService service = new InputService(); - service.setDescription(SERVICE_DESCRIPTION); - service.setVersion(SERVICE_VERSION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - whenPrintResponseShouldWork(); - - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - - ResponseEntity response = delegateUnderTest.getIndividualService(SERVICE_NAME); - - assertThat(response.getStatusCode()).isEqualTo(OK); - assertThat(response.getBody().getName()).isEqualTo(SERVICE_NAME); - } - - @Test - void getMissingService_shouldThrowException() { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(null); - - Exception exception = assertThrows(ServiceNotFoundException.class, () -> { - delegateUnderTest.getIndividualService(SERVICE_NAME); - }); - - String expectedMessage = "Service " + SERVICE_NAME + " not found"; - String actualMessage = exception.getMessage(); - - assertThat(actualMessage).isEqualTo(expectedMessage); - } - - @Test - void putNewValidService_shouldBeCreatedAndRegisteredAndUrlToNewServiceAddedToLocationHeaderInResponse() { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - InputService service = new InputService(); - service.setDescription(SERVICE_DESCRIPTION); - service.setVersion(SERVICE_VERSION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - String urlToCreatedService = "URL to created Service"; - HttpServletResponse servletResponseMock = whenPrintResponseShouldWork(urlToCreatedService); - - ResponseEntity putResponse = delegateUnderTest.putIndividualService(SERVICE_NAME, service); - - assertThat(putResponse.getStatusCode()).isEqualTo(CREATED); - verify(servletResponseMock).addHeader("Location", urlToCreatedService); - - ResponseEntity getResponse = delegateUnderTest.getIndividualService(SERVICE_NAME); - - assertThat(getResponse.getStatusCode()).isEqualTo(OK); - Service body = getResponse.getBody(); - assertThat(body.getName()).isEqualTo(SERVICE_NAME); - assertThat(body.getRegistrationDate()).isEqualTo(getTodaysDate()); - } - - @Test - void putModifiedService_shouldBeModified() { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - InputService service = new InputService(); - service.setDescription(SERVICE_DESCRIPTION); - service.setVersion(SERVICE_VERSION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - whenPrintResponseShouldWork(); - - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - - String newDescription = "New description"; - service.setDescription(newDescription); - ResponseEntity putResponse = delegateUnderTest.putIndividualService(SERVICE_NAME, service); - - assertThat(putResponse.getStatusCode()).isEqualTo(OK); - - ResponseEntity getResponse = delegateUnderTest.getIndividualService(SERVICE_NAME); - - assertThat(getResponse.getStatusCode()).isEqualTo(OK); - assertThat(getResponse.getBody().getDescription()).isEqualTo(newDescription); - } - - @Test - void putServiceWithVersionNull_shouldThrowException() { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(null); - - InputService service = new InputService(); - service.setDescription(SERVICE_DESCRIPTION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - Exception exception = assertThrows(InvalidServiceException.class, () -> { - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - }); - - assertThat(exception.getMessage()).isEqualTo(INVALID_SERVICE_MESSAGE); - } - - @Test - void putServiceWithBlankVersion_shouldThrowException() { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(null); - - InputService service = new InputService(); - service.setVersion(""); - service.setDescription(SERVICE_DESCRIPTION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - Exception exception = assertThrows(InvalidServiceException.class, () -> { - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - }); - - assertThat(exception.getMessage()).isEqualTo(INVALID_SERVICE_MESSAGE); - } - - @Test - void putServiceWhenIoExceptionAddingHeader_shouldThrowExceptionAndNoServiceCreated() throws Exception { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - whenGetRequestUrlThenReturnUrl(); - HttpServletResponse servletResponseMock = mock(HttpServletResponse.class); - when(webRequestMock.getNativeResponse(HttpServletResponse.class)).thenReturn(servletResponseMock); - when(servletResponseMock.getWriter()).thenThrow(new IOException("Error")); - - InputService service = new InputService(); - service.setVersion("1.0"); - service.setDescription(SERVICE_DESCRIPTION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - Exception exception = assertThrows(HeaderException.class, () -> { - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - }); - - assertThat(exception.getMessage()) - .isEqualTo("Unable to set header Location in put response for service " + SERVICE_NAME + ". Cause: Error"); - - ResponseEntity> response = delegateUnderTest.getServices(); - assertThat(response.getBody()).isEmpty(); - } - - @Test - void getServices_shouldProvideArrayOfAddedServiceNames() throws Exception { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - InputService service1 = new InputService(); - service1.setDescription("description 1"); - service1.setVersion(SERVICE_VERSION); - service1.setDisplayName("Display Name 1"); - - InputService service2 = new InputService(); - service2.setDescription("description 2"); - service2.setVersion(SERVICE_VERSION); - service2.setDisplayName("Display Name 2"); - - whenPrintResponseShouldWork(); - - String serviceName1 = "Service Name 1"; - delegateUnderTest.putIndividualService(serviceName1, service1); - String serviceName2 = "Service Name 2"; - delegateUnderTest.putIndividualService(serviceName2, service2); - - ResponseEntity> response = delegateUnderTest.getServices(); - - assertThat(response.getStatusCode()).isEqualTo(OK); - List services = response.getBody(); - assertThat(services).hasSize(2); - List expectedServiceNames = Arrays.asList(serviceName1, serviceName2); - assertThat(expectedServiceNames).contains(services.get(0).getName()) // - .contains(services.get(1).getName()); - } - - @Test - void deleteService_shouldBeOk() { - ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); - - InputService service = new InputService(); - service.setDescription(SERVICE_DESCRIPTION); - service.setVersion(SERVICE_VERSION); - service.setDisplayName(SERVICE_DISPLAY_NAME); - - whenPrintResponseShouldWork(); - - delegateUnderTest.putIndividualService(SERVICE_NAME, service); - - ResponseEntity> servicesResponse = delegateUnderTest.getServices(); - - assertThat(servicesResponse.getBody()).hasSize(1); - - ResponseEntity deleteResponse = delegateUnderTest.deleteIndividualService(SERVICE_NAME); - - assertThat(deleteResponse.getStatusCode()).isEqualTo(NO_CONTENT); - - servicesResponse = delegateUnderTest.getServices(); - - assertThat(servicesResponse.getBody()).isEmpty(); - } - - private void whenGetRequestUrlThenReturnUrl() { - whenGetRequestUrlThenReturnUrl("URL"); - } - - private void whenGetRequestUrlThenReturnUrl(String url) { - HttpServletRequest servletRequestMock = mock(HttpServletRequest.class); - when(webRequestMock.getNativeRequest(HttpServletRequest.class)).thenReturn(servletRequestMock); - when(servletRequestMock.getRequestURL()).thenReturn(new StringBuffer(url)); - } - - private HttpServletResponse whenPrintResponseShouldWork() { - return whenPrintResponseShouldWork("URL"); - } - - private HttpServletResponse whenPrintResponseShouldWork(String url) { - whenGetRequestUrlThenReturnUrl(url); - HttpServletResponse servletResponseMock = mock(HttpServletResponse.class); - when(webRequestMock.getNativeResponse(HttpServletResponse.class)).thenReturn(servletResponseMock); - PrintWriter printWriterMock = mock(PrintWriter.class); - try { - when(servletResponseMock.getWriter()).thenReturn(printWriterMock); - } catch (IOException e) { - // Nothing - } - return servletResponseMock; - } - - private String getTodaysDate() { - long millis = System.currentTimeMillis(); - Date date = new Date(millis); - return date.toString(); - } -} + +package org.oransc.rappcatalogue.api; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.NO_CONTENT; +import static org.springframework.http.HttpStatus.OK; + +import java.io.IOException; +import java.io.PrintWriter; +import java.sql.Date; +import java.util.Arrays; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.oransc.rappcatalogue.exception.HeaderException; +import org.oransc.rappcatalogue.exception.InvalidServiceException; +import org.oransc.rappcatalogue.exception.ServiceNotFoundException; +import org.oransc.rappcatalogue.model.InputService; +import org.oransc.rappcatalogue.model.Service; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +@ExtendWith(MockitoExtension.class) +class ServicesApiDelegateImplTest { + + @Mock + NativeWebRequest webRequestMock; + + private static final String INVALID_SERVICE_MESSAGE = "Service is missing required property: version"; + private static final String SERVICE_NAME = "Service Name"; + private static final String SERVICE_DESCRIPTION = "description"; + private static final String SERVICE_VERSION = "1.0"; + private static final String SERVICE_DISPLAY_NAME = "Display Name"; + + @Test + void getAddedService_shouldReturnService() throws Exception { + ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); + + InputService service = new InputService(); + service.setDescription(SERVICE_DESCRIPTION); + service.setVersion(SERVICE_VERSION); + service.setDisplayName(SERVICE_DISPLAY_NAME); + + whenPrintResponseShouldWork(); + + delegateUnderTest.putIndividualService(SERVICE_NAME, service); + + ResponseEntity response = delegateUnderTest.getIndividualService(SERVICE_NAME); + + assertThat(response.getStatusCode()).isEqualTo(OK); + assertThat(response.getBody().getName()).isEqualTo(SERVICE_NAME); + } + + @Test + void getMissingService_shouldThrowException() { + ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(null); + + Exception exception = assertThrows(ServiceNotFoundException.class, () -> { + delegateUnderTest.getIndividualService(SERVICE_NAME); + }); + + String expectedMessage = "Service " + SERVICE_NAME + " not found"; + String actualMessage = exception.getMessage(); + + assertThat(actualMessage).isEqualTo(expectedMessage); + } + + @Test + void putNewValidService_shouldBeCreatedAndRegisteredAndUrlToNewServiceAddedToLocationHeaderInResponse() + throws Exception { + ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); + + InputService service = new InputService(); + service.setDescription(SERVICE_DESCRIPTION); + service.setVersion(SERVICE_VERSION); + service.setDisplayName(SERVICE_DISPLAY_NAME); + + String urlToCreatedService = "URL to created Service"; + HttpServletResponse servletResponseMock = whenPrintResponseShouldWork(urlToCreatedService); + + ResponseEntity putResponse = delegateUnderTest.putIndividualService(SERVICE_NAME, service); + + assertThat(putResponse.getStatusCode()).isEqualTo(CREATED); + verify(servletResponseMock).addHeader("Location", urlToCreatedService); + + ResponseEntity getResponse = delegateUnderTest.getIndividualService(SERVICE_NAME); + + assertThat(getResponse.getStatusCode()).isEqualTo(OK); + Service body = getResponse.getBody(); + assertThat(body.getName()).isEqualTo(SERVICE_NAME); + assertThat(body.getRegistrationDate()).isEqualTo(getTodaysDate()); + } + + @Test + void putModifiedService_shouldBeModified() throws Exception { + ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); + + InputService service = new InputService(); + service.setDescription(SERVICE_DESCRIPTION); + service.setVersion(SERVICE_VERSION); + service.setDisplayName(SERVICE_DISPLAY_NAME); + + whenPrintResponseShouldWork(); + + delegateUnderTest.putIndividualService(SERVICE_NAME, service); + + String newDescription = "New description"; + service.setDescription(newDescription); + ResponseEntity putResponse = delegateUnderTest.putIndividualService(SERVICE_NAME, service); + + assertThat(putResponse.getStatusCode()).isEqualTo(OK); + + ResponseEntity getResponse = delegateUnderTest.getIndividualService(SERVICE_NAME); + + assertThat(getResponse.getStatusCode()).isEqualTo(OK); + assertThat(getResponse.getBody().getDescription()).isEqualTo(newDescription); + } + + @Test + void putServiceWithVersionNull_shouldThrowException() { + ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(null); + + InputService service = new InputService(); + service.setDescription(SERVICE_DESCRIPTION); + service.setDisplayName(SERVICE_DISPLAY_NAME); + + Exception exception = assertThrows(InvalidServiceException.class, () -> { + delegateUnderTest.putIndividualService(SERVICE_NAME, service); + }); + + assertThat(exception.getMessage()).isEqualTo(INVALID_SERVICE_MESSAGE); + } + + @Test + void putServiceWithBlankVersion_shouldThrowException() { + ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(null); + + InputService service = new InputService(); + service.setVersion(""); + service.setDescription(SERVICE_DESCRIPTION); + service.setDisplayName(SERVICE_DISPLAY_NAME); + + Exception exception = assertThrows(InvalidServiceException.class, () -> { + delegateUnderTest.putIndividualService(SERVICE_NAME, service); + }); + + assertThat(exception.getMessage()).isEqualTo(INVALID_SERVICE_MESSAGE); + } + + @Test + void putServiceWhenIoExceptionAddingHeader_shouldThrowExceptionAndNoServiceCreated() throws Exception { + ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); + + whenGetRequestUrlThenReturnUrl(); + HttpServletResponse servletResponseMock = mock(HttpServletResponse.class); + when(webRequestMock.getNativeResponse(HttpServletResponse.class)).thenReturn(servletResponseMock); + when(servletResponseMock.getWriter()).thenThrow(new IOException("Error")); + + InputService service = new InputService(); + service.setVersion("1.0"); + service.setDescription(SERVICE_DESCRIPTION); + service.setDisplayName(SERVICE_DISPLAY_NAME); + + Exception exception = assertThrows(HeaderException.class, () -> { + delegateUnderTest.putIndividualService(SERVICE_NAME, service); + }); + + assertThat(exception.getMessage()) + .isEqualTo("Unable to set header Location in put response for service " + SERVICE_NAME + ". Cause: Error"); + + ResponseEntity> response = delegateUnderTest.getServices(); + assertThat(response.getBody()).isEmpty(); + } + + @Test + void getServices_shouldProvideArrayOfAddedServiceNames() throws Exception { + ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); + + InputService service1 = new InputService(); + service1.setDescription("description 1"); + service1.setVersion(SERVICE_VERSION); + service1.setDisplayName("Display Name 1"); + + InputService service2 = new InputService(); + service2.setDescription("description 2"); + service2.setVersion(SERVICE_VERSION); + service2.setDisplayName("Display Name 2"); + + whenPrintResponseShouldWork(); + + String serviceName1 = "Service Name 1"; + delegateUnderTest.putIndividualService(serviceName1, service1); + String serviceName2 = "Service Name 2"; + delegateUnderTest.putIndividualService(serviceName2, service2); + + ResponseEntity> response = delegateUnderTest.getServices(); + + assertThat(response.getStatusCode()).isEqualTo(OK); + List services = response.getBody(); + assertThat(services).hasSize(2); + List expectedServiceNames = Arrays.asList(serviceName1, serviceName2); + assertThat(expectedServiceNames).contains(services.get(0).getName()) // + .contains(services.get(1).getName()); + } + + @Test + void deleteService_shouldBeOk() throws Exception { + ServicesApiDelegateImpl delegateUnderTest = new ServicesApiDelegateImpl(webRequestMock); + + InputService service = new InputService(); + service.setDescription(SERVICE_DESCRIPTION); + service.setVersion(SERVICE_VERSION); + service.setDisplayName(SERVICE_DISPLAY_NAME); + + whenPrintResponseShouldWork(); + + delegateUnderTest.putIndividualService(SERVICE_NAME, service); + + ResponseEntity> servicesResponse = delegateUnderTest.getServices(); + + assertThat(servicesResponse.getBody()).hasSize(1); + + ResponseEntity deleteResponse = delegateUnderTest.deleteIndividualService(SERVICE_NAME); + + assertThat(deleteResponse.getStatusCode()).isEqualTo(NO_CONTENT); + + servicesResponse = delegateUnderTest.getServices(); + + assertThat(servicesResponse.getBody()).isEmpty(); + } + + private void whenGetRequestUrlThenReturnUrl() { + whenGetRequestUrlThenReturnUrl("URL"); + } + + private void whenGetRequestUrlThenReturnUrl(String url) { + HttpServletRequest servletRequestMock = mock(HttpServletRequest.class); + when(webRequestMock.getNativeRequest(HttpServletRequest.class)).thenReturn(servletRequestMock); + when(servletRequestMock.getRequestURL()).thenReturn(new StringBuffer(url)); + } + + private HttpServletResponse whenPrintResponseShouldWork() { + return whenPrintResponseShouldWork("URL"); + } + + private HttpServletResponse whenPrintResponseShouldWork(String url) { + whenGetRequestUrlThenReturnUrl(url); + HttpServletResponse servletResponseMock = mock(HttpServletResponse.class); + when(webRequestMock.getNativeResponse(HttpServletResponse.class)).thenReturn(servletResponseMock); + PrintWriter printWriterMock = mock(PrintWriter.class); + try { + when(servletResponseMock.getWriter()).thenReturn(printWriterMock); + } catch (IOException e) { + // Nothing + } + return servletResponseMock; + } + + private String getTodaysDate() { + long millis = System.currentTimeMillis(); + Date date = new Date(millis); + return date.toString(); + } +} diff --git a/test/auto-test/.gitignore b/test/auto-test/.gitignore index 6091e4ac..6009a541 100644 --- a/test/auto-test/.gitignore +++ b/test/auto-test/.gitignore @@ -15,3 +15,4 @@ logs .pid* .result* tmp +NO-CHECKIN diff --git a/test/auto-test/FTC1.sh b/test/auto-test/FTC1.sh index 144ac364..8ecd60a6 100755 --- a/test/auto-test/FTC1.sh +++ b/test/auto-test/FTC1.sh @@ -20,19 +20,30 @@ TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and Agent REST/DMAAP with/without SDNC controller" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR DMAAPMR PA RICSIM SDNC" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh -. ../common/ricsimulator_api_functions.sh +. ../common/consul_cbs_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh . ../common/cr_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/ricsimulator_api_functions.sh -#### TEST BEGIN #### +#### TEST BEGIN #### generate_uuid @@ -49,8 +60,7 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" echo "#####################################################################" - # Clean container and start all needed containers # - clean_containers + clean_environment if [ $__httpx == "HTTPS" ]; then use_agent_rest_https @@ -58,13 +68,13 @@ for __httpx in $TESTED_PROTOCOLS ; do use_agent_rest_http fi - start_policy_agent + start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml set_agent_trace # Create service to be able to receive events when rics becomes available # Must use rest towards the agent since dmaap is not configured yet - api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration" + api_put_service 201 "ric-registration" 0 "$CR_SERVICE_PATH/ric-registration" if [ $__httpx == "HTTPS" ]; then use_cr_https @@ -102,9 +112,11 @@ for __httpx in $TESTED_PROTOCOLS ; do start_cr - start_control_panel + start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties - start_consul_cbs + if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs + fi if [[ $interface = *"SDNC"* ]]; then start_sdnc @@ -113,7 +125,11 @@ for __httpx in $TESTED_PROTOCOLS ; do prepare_consul_config NOSDNC ".consul_config.json" fi - consul_config_app ".consul_config.json" + if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" + else + consul_config_app ".consul_config.json" + fi mr_equal requests_submitted 0 @@ -123,7 +139,7 @@ for __httpx in $TESTED_PROTOCOLS ; do sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json - api_equal json:rics 3 60 + api_equal json:rics 3 300 api_equal json:policy-types 3 120 @@ -136,7 +152,7 @@ for __httpx in $TESTED_PROTOCOLS ; do cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1 else - api_equal json:rics 2 60 + api_equal json:rics 2 300 api_equal json:policy_schemas 2 120 @@ -157,7 +173,7 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "##### Service registry and supervision #####" echo "############################################" - api_put_service 201 "serv1" 1000 "$CR_PATH/1" + api_put_service 201 "serv1" 1000 "$CR_SERVICE_PATH/1" api_get_service_ids 200 "serv1" "ric-registration" @@ -178,7 +194,7 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "############################################" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi @@ -237,16 +253,16 @@ for __httpx in $TESTED_PROTOCOLS ; do fi if [[ $interface = *"SDNC"* ]]; then - sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" - sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" + sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME + sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME if [ "$PMS_VERSION" == "V2" ]; then - sim_contains_str ricsim_g3_1 remote_hosts "a1-controller" + sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME fi else - sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" - sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" + sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME + sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME if [ "$PMS_VERSION" == "V2" ]; then - sim_contains_str ricsim_g3_1 remote_hosts "policy-agent" + sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME fi fi @@ -268,4 +284,4 @@ done print_result -auto_clean_containers +auto_clean_environment diff --git a/test/auto-test/FTC10.sh b/test/auto-test/FTC10.sh index ca545b2e..01ba86f8 100755 --- a/test/auto-test/FTC10.sh +++ b/test/auto-test/FTC10.sh @@ -19,14 +19,26 @@ TC_ONELINE_DESCR="Basic use case, register service, create/update policy, delete policy, de-register service using both STD and OSC interface while mixing REST and Dmaap" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES=" MR CR PA RICSIM CP" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh +. ../common/consul_cbs_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh +. ../common/cr_api_functions.sh +. ../common/mr_api_functions.sh . ../common/ricsimulator_api_functions.sh #### TEST BEGIN #### @@ -38,7 +50,7 @@ use_mr_http use_agent_rest_http -clean_containers +clean_environment start_ric_simulators ricsim_g1 3 OSC_2.1.0 @@ -50,19 +62,28 @@ fi start_mr -start_consul_cbs +start_cr -prepare_consul_config NOSDNC ".consul_config.json" -consul_config_app ".consul_config.json" +if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs +fi -start_control_panel +start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties -start_policy_agent +start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml set_agent_debug use_agent_rest_http +prepare_consul_config NOSDNC ".consul_config.json" + +if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" +else + consul_config_app ".consul_config.json" +fi + api_get_status 200 sim_print ricsim_g1_1 interface @@ -77,22 +98,22 @@ sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json if [ "$PMS_VERSION" == "V2" ]; then sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json - api_equal json:policy-types 3 60 + api_equal json:policy-types 3 300 else - api_equal json:policy_types 2 60 + api_equal json:policy_types 2 300 fi # Create policies if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi use_agent_rest_http -api_put_service 201 "service1" 3600 "$CR_PATH/1" +api_put_service 201 "service1" 3600 "$CR_SERVICE_PATH/1" api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1 @@ -137,7 +158,7 @@ fi #Update policies use_agent_rest_http -api_put_service 200 "service1" 3600 "$CR_PATH/1" +api_put_service 200 "service1" 3600 "$CR_SERVICE_PATH/1" api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1 @@ -228,10 +249,10 @@ fi # Check remote host access to simulator -sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" -sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" +sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME +sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME if [ "$PMS_VERSION" == "V2" ]; then - sim_contains_str ricsim_g3_1 remote_hosts "policy-agent" + sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME fi # Check policy removal @@ -260,4 +281,4 @@ store_logs END print_result -auto_clean_containers \ No newline at end of file +auto_clean_environment \ No newline at end of file diff --git a/test/auto-test/FTC100.sh b/test/auto-test/FTC100.sh index 4b2e1629..3b9dcd74 100755 --- a/test/auto-test/FTC100.sh +++ b/test/auto-test/FTC100.sh @@ -20,17 +20,28 @@ TC_ONELINE_DESCR="Full agent API walkthrough using agent REST/DMAAP and with/without SDNC A1 Controller" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh -. ../common/ricsimulator_api_functions.sh +. ../common/consul_cbs_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh . ../common/cr_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/ricsimulator_api_functions.sh + #### TEST BEGIN #### @@ -52,7 +63,7 @@ for __httpx in $TESTED_PROTOCOLS ; do echo "#####################################################################" # Clean container and start all needed containers # - clean_containers + clean_environment if [ $__httpx == "HTTPS" ]; then use_cr_https @@ -62,13 +73,13 @@ for __httpx in $TESTED_PROTOCOLS ; do use_cr_http fi - start_policy_agent + start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml - set_agent_trace + set_agent_debug # Create service to be able to receive events when rics becomes available # Must use rest towards the agent since dmaap is not configured yet - api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration" + api_put_service 201 "ric-registration" 0 "$CR_SERVICE_PATH/ric-registration" if [ $__httpx == "HTTPS" ]; then @@ -105,9 +116,11 @@ for __httpx in $TESTED_PROTOCOLS ; do start_cr - start_control_panel + start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties - start_consul_cbs + if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs + fi if [[ $interface = *"SDNC"* ]]; then start_sdnc @@ -116,7 +129,11 @@ for __httpx in $TESTED_PROTOCOLS ; do prepare_consul_config NOSDNC ".consul_config.json" fi - consul_config_app ".consul_config.json" + if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" + else + consul_config_app ".consul_config.json" + fi sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json @@ -125,7 +142,7 @@ for __httpx in $TESTED_PROTOCOLS ; do sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json - api_equal json:rics 3 60 + api_equal json:rics 3 300 api_equal json:policy-types 5 120 @@ -133,7 +150,7 @@ for __httpx in $TESTED_PROTOCOLS ; do api_equal json:policy-instances 0 else - api_equal json:rics 2 60 + api_equal json:rics 2 300 api_equal json:policy_schemas 3 120 @@ -163,14 +180,14 @@ for __httpx in $TESTED_PROTOCOLS ; do api_get_services 404 "service1" - api_put_service 201 "service1" 1000 "$CR_PATH/1" + api_put_service 201 "service1" 1000 "$CR_SERVICE_PATH/1" - api_put_service 200 "service1" 2000 "$CR_PATH/1" + api_put_service 200 "service1" 2000 "$CR_SERVICE_PATH/1" - api_put_service 400 "service2" -1 "$CR_PATH/2" + api_put_service 400 "service2" -1 "$CR_SERVICE_PATH/2" - api_put_service 400 "service2" "wrong" "$CR_PATH/2" + api_put_service 400 "service2" "wrong" "$CR_SERVICE_PATH/2" api_put_service 400 "service2" 100 "/test" @@ -178,20 +195,20 @@ for __httpx in $TESTED_PROTOCOLS ; do api_put_service 201 "service2" 300 "ftp://localhost:80/test" - api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1" + api_get_services 200 "service1" "service1" 2000 "$CR_SERVICE_PATH/1" api_get_service_ids 200 "service1" "service2" "ric-registration" - api_put_service 201 "service3" 5000 "$CR_PATH/3" + api_put_service 201 "service3" 5000 "$CR_SERVICE_PATH/3" api_get_service_ids 200 "service1" "service2" "service3" "ric-registration" - api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1" + api_get_services 200 "service1" "service1" 2000 "$CR_SERVICE_PATH/1" - api_get_services 200 NOSERVICE "service1" 2000 "$CR_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_PATH/3" "ric-registration" 0 "$CR_PATH/ric-registration" + api_get_services 200 NOSERVICE "service1" 2000 "$CR_SERVICE_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_SERVICE_PATH/3" "ric-registration" 0 "$CR_SERVICE_PATH/ric-registration" api_get_services 200 @@ -220,7 +237,7 @@ for __httpx in $TESTED_PROTOCOLS ; do api_get_service_ids 200 "service2" "service3" "ric-registration" - api_put_service 201 "service1" 50 "$CR_PATH/1" + api_put_service 201 "service1" 50 "$CR_SERVICE_PATH/1" api_get_service_ids 200 "service1" "service2" "service3" "ric-registration" @@ -355,10 +372,10 @@ for __httpx in $TESTED_PROTOCOLS ; do - api_put_service 201 "service10" 3600 "$CR_PATH/1" + api_put_service 201 "service10" 3600 "$CR_SERVICE_PATH/1" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi @@ -529,16 +546,16 @@ for __httpx in $TESTED_PROTOCOLS ; do fi if [[ $interface = *"SDNC"* ]]; then - sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" - sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" + sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME + sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME if [ "$PMS_VERSION" == "V2" ]; then - sim_contains_str ricsim_g3_1 remote_hosts "a1-controller" + sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME fi else - sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" - sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" + sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME + sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME if [ "$PMS_VERSION" == "V2" ]; then - sim_contains_str ricsim_g3_1 remote_hosts "policy-agent" + sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME fi fi @@ -560,4 +577,4 @@ done print_result -auto_clean_containers +auto_clean_environment diff --git a/test/auto-test/FTC110.sh b/test/auto-test/FTC110.sh index 0406c405..81aa95ca 100755 --- a/test/auto-test/FTC110.sh +++ b/test/auto-test/FTC110.sh @@ -20,16 +20,26 @@ TC_ONELINE_DESCR="Testing of service registration timeouts and keepalive" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh -. ../common/ricsimulator_api_functions.sh +. ../common/consul_cbs_functions.sh +. ../common/control_panel_api_functions.sh . ../common/cr_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/ricsimulator_api_functions.sh generate_uuid @@ -41,7 +51,7 @@ use_agent_rest_http #### TEST BEGIN #### -clean_containers +clean_environment start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 @@ -53,14 +63,21 @@ start_mr start_cr -start_consul_cbs +if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs +fi -prepare_consul_config NOSDNC ".consul_config.json" -consul_config_app ".consul_config.json" +start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties -start_control_panel +start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml -start_policy_agent +prepare_consul_config NOSDNC ".consul_config.json" + +if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" +else + consul_config_app ".consul_config.json" +fi set_agent_debug @@ -76,60 +93,60 @@ if [ "$PMS_VERSION" == "V2" ]; then sim_print ricsim_g3_1 interface fi -api_put_service 201 "service1" 15 "$CR_PATH/service1" +api_put_service 201 "service1" 15 "$CR_SERVICE_PATH/service1" -api_get_services 200 "service1" "service1" 15 "$CR_PATH/service1" +api_get_services 200 "service1" "service1" 15 "$CR_SERVICE_PATH/service1" -api_put_service 201 "service2" 120 "$CR_PATH/service2" +api_put_service 201 "service2" 120 "$CR_SERVICE_PATH/service2" -api_get_services 200 "service2" "service2" 120 "$CR_PATH/service2" +api_get_services 200 "service2" "service2" 120 "$CR_SERVICE_PATH/service2" -api_put_service 200 "service1" 50 "$CR_PATH/service1" -api_put_service 200 "service2" 180 "$CR_PATH/service2" +api_put_service 200 "service1" 50 "$CR_SERVICE_PATH/service1" +api_put_service 200 "service2" 180 "$CR_SERVICE_PATH/service2" -api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1" -api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2" +api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_PATH/service1" +api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_PATH/service2" api_get_service_ids 200 "service1" "service2" sleep_wait 30 "Waiting for keep alive timeout" -api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1" -api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2" +api_get_services 200 "service1" "service1" 50 "$CR_SERVICE_PATH/service1" +api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_PATH/service2" sleep_wait 100 "Waiting for keep alive timeout" api_get_services 404 "service1" -api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2" +api_get_services 200 "service2" "service2" 180 "$CR_SERVICE_PATH/service2" api_delete_services 204 "service2" api_get_services 404 "service1" api_get_services 404 "service2" -api_put_service 201 "service3" 60 "$CR_PATH/service3" +api_put_service 201 "service3" 60 "$CR_SERVICE_PATH/service3" -api_get_services 200 "service3" "service3" 60 "$CR_PATH/service3" +api_get_services 200 "service3" "service3" 60 "$CR_SERVICE_PATH/service3" sleep_wait 30 "Waiting for keep alive timeout" -api_put_service 200 "service3" 60 "$CR_PATH/service3" +api_put_service 200 "service3" 60 "$CR_SERVICE_PATH/service3" sleep_wait 100 "Waiting for keep alive timeout" api_get_services 404 "service3" -api_put_service 201 "service4" 120 "$CR_PATH/service4" +api_put_service 201 "service4" 120 "$CR_SERVICE_PATH/service4" sleep_wait 60 "Waiting for keep alive timeout" -api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4" +api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_PATH/service4" api_put_services_keepalive 200 "service4" sleep_wait 90 "Waiting for keep alive timeout" -api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4" +api_get_services 200 "service4" "service4" 120 "$CR_SERVICE_PATH/service4" api_delete_services 204 "service4" @@ -152,7 +169,7 @@ api_put_services_keepalive 404 "service3" api_put_services_keepalive 404 "service4" # Policy delete after timeout -api_put_service 201 "service10" 600 "$CR_PATH/service10" +api_put_service 201 "service10" 600 "$CR_SERVICE_PATH/service10" sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json @@ -160,7 +177,7 @@ if [ "$PMS_VERSION" == "V2" ]; then sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json - api_equal json:rics 3 60 + api_equal json:rics 3 300 #api_equal json:policy_schemas 2 120 @@ -168,7 +185,7 @@ if [ "$PMS_VERSION" == "V2" ]; then api_equal json:policies 0 else - api_equal json:rics 2 60 + api_equal json:rics 2 300 api_equal json:policy_schemas 2 120 @@ -178,7 +195,7 @@ else fi if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi @@ -232,7 +249,7 @@ if [ "$PMS_VERSION" == "V2" ]; then sim_equal ricsim_g3_1 num_instances 1 fi -api_put_service 200 "service10" 10 "$CR_PATH/service10" +api_put_service 200 "service10" 10 "$CR_SERVICE_PATH/service10" #Wait for service expiry api_equal json:policies 0 120 @@ -256,4 +273,4 @@ store_logs END print_result -auto_clean_containers \ No newline at end of file +auto_clean_environment \ No newline at end of file diff --git a/test/auto-test/FTC1100.sh b/test/auto-test/FTC1100.sh index 4672cb2b..d312caa7 100755 --- a/test/auto-test/FTC1100.sh +++ b/test/auto-test/FTC1100.sh @@ -20,22 +20,32 @@ TC_ONELINE_DESCR="ECS full intefaces walkthrough" -#App names to include in the test, space separated list -INCLUDED_IMAGES="ECS PRODSTUB CR RICSIM CP" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="ECS PRODSTUB CR RICSIM CP" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES=" PRODSTUB CR ECS RICSIM CP " +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES=" " + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/ecs_api_functions.sh . ../common/prodstub_api_functions.sh . ../common/cr_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh +. ../common/ricsimulator_api_functions.sh #### TEST BEGIN #### FLAT_A1_EI="1" -clean_containers +clean_environment use_ecs_rest_https @@ -45,13 +55,17 @@ use_simulator_https use_cr_https -start_ecs +start_ecs $SIM_GROUP/$ECS_COMPOSE_DIR/application.yaml + +if [ $RUNMODE == "KUBE" ]; then + ecs_api_admin_reset +fi start_prod_stub set_ecs_trace -start_control_panel +start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties if [ "$PMS_VERSION" == "V2" ]; then start_ric_simulators ricsim_g3 4 STD_2.0.0 @@ -59,19 +73,19 @@ fi start_cr -CB_JOB="$PROD_STUB_HTTPX://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/job" -CB_SV="$PROD_STUB_HTTPX://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/supervision" +CB_JOB="$PROD_STUB_SERVICE_PATH$PROD_STUB_JOB_CALLBACK" +CB_SV="$PROD_STUB_SERVICE_PATH$PROD_STUB_SUPERVISION_CALLBACK" TARGET1="$RIC_SIM_HTTPX://ricsim_g3_1:$RIC_SIM_PORT/datadelivery" TARGET2="$RIC_SIM_HTTPX://ricsim_g3_2:$RIC_SIM_PORT/datadelivery" TARGET3="$RIC_SIM_HTTPX://ricsim_g3_3:$RIC_SIM_PORT/datadelivery" TARGET8="$RIC_SIM_HTTPX://ricsim_g3_4:$RIC_SIM_PORT/datadelivery" TARGET10="$RIC_SIM_HTTPX://ricsim_g3_4:$RIC_SIM_PORT/datadelivery" -STATUS1="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job1-status" -STATUS2="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job2-status" -STATUS3="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job3-status" -STATUS8="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job8-status" -STATUS10="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job10-status" +STATUS1="$CR_SERVICE_PATH/job1-status" +STATUS2="$CR_SERVICE_PATH/job2-status" +STATUS3="$CR_SERVICE_PATH/job3-status" +STATUS8="$CR_SERVICE_PATH/job8-status" +STATUS10="$CR_SERVICE_PATH/job10-status" ### Setup prodstub sim to accept calls for producers, types and jobs ## prod-a type1 @@ -138,11 +152,19 @@ ecs_api_a1_get_type_ids 200 EMPTY ecs_api_a1_get_type 404 test-type ecs_api_edp_get_type_ids 200 EMPTY -ecs_api_edp_get_type 404 test-type - -ecs_api_edp_get_producer_ids 200 EMPTY -ecs_api_edp_get_producer 404 test-prod +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_type 404 test-type +else + ecs_api_edp_get_type_2 404 test-type +fi +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 EMPTY + ecs_api_edp_get_producer 404 test-prod +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE EMPTY + ecs_api_edp_get_producer_2 404 test-prod +fi ecs_api_edp_get_producer_status 404 test-prod ecs_api_edp_delete_producer 404 test-prod @@ -171,12 +193,39 @@ fi ecs_api_edp_get_producer_jobs 404 test-prod +if [ $ECS_VERSION == "V1-2" ]; then + ecs_api_edp_get_type_2 404 test-type + ecs_api_edp_delete_type_2 404 test-type +fi ### Setup of producer/job and testing apis ### ## Setup prod-a -ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json -ecs_api_edp_put_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + ecs_api_edp_put_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json +else + #V1-2 + ecs_api_edp_get_type_ids 200 EMPTY + ecs_api_edp_get_type_2 404 type1 + ecs_api_edp_put_producer_2 404 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 + + # Create type, delete and create again + ecs_api_edp_put_type_2 201 type1 testdata/ecs/ei-type-1.json + ecs_api_edp_get_type_2 200 type1 + ecs_api_edp_get_type_ids 200 type1 + ecs_api_edp_delete_type_2 204 type1 + ecs_api_edp_get_type_2 404 type1 + ecs_api_edp_get_type_ids 200 EMPTY + ecs_api_edp_put_type_2 201 type1 testdata/ecs/ei-type-1.json + ecs_api_edp_get_type_ids 200 type1 + ecs_api_edp_get_type_2 200 type1 testdata/ecs/ei-type-1.json + + ecs_api_edp_put_producer_2 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 + ecs_api_edp_put_producer_2 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 + + ecs_api_edp_delete_type_2 406 type1 +fi ecs_api_a1_get_type_ids 200 type1 @@ -187,11 +236,25 @@ else fi ecs_api_edp_get_type_ids 200 type1 -ecs_api_edp_get_type 200 type1 testdata/ecs/ei-type-1.json prod-a +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_type 200 type1 testdata/ecs/ei-type-1.json prod-a +else + ecs_api_edp_get_type_2 200 type1 testdata/ecs/ei-type-1.json +fi -ecs_api_edp_get_producer_ids 200 prod-a +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a + ecs_api_edp_get_producer_ids_2 200 type1 prod-a + ecs_api_edp_get_producer_ids_2 200 type2 EMPTY +fi -ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json +else + ecs_api_edp_get_producer_2 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 +fi ecs_api_edp_get_producer_status 200 prod-a ENABLED @@ -275,7 +338,13 @@ prodstub_equal create/prod-a/job2 1 ecs_api_edp_get_producer_jobs 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json job2 type1 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json ## Setup prod-b -ecs_api_edp_put_producer 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 testdata/ecs/ei-type-2.json +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 testdata/ecs/ei-type-2.json +else + ecs_api_edp_put_type_2 201 type2 testdata/ecs/ei-type-2.json + ecs_api_edp_put_producer_2 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 +fi + ecs_api_a1_get_type_ids 200 type1 type2 if [ -z "$FLAT_A1_EI" ]; then @@ -287,14 +356,27 @@ else fi ecs_api_edp_get_type_ids 200 type1 type2 -ecs_api_edp_get_type 200 type1 testdata/ecs/ei-type-1.json prod-a -ecs_api_edp_get_type 200 type2 testdata/ecs/ei-type-2.json prod-b - -ecs_api_edp_get_producer_ids 200 prod-a prod-b +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_type 200 type1 testdata/ecs/ei-type-1.json prod-a + ecs_api_edp_get_type 200 type2 testdata/ecs/ei-type-2.json prod-b +else + ecs_api_edp_get_type_2 200 type1 testdata/ecs/ei-type-1.json + ecs_api_edp_get_type_2 200 type2 testdata/ecs/ei-type-2.json +fi -ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json -ecs_api_edp_get_producer 200 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 testdata/ecs/ei-type-2.json +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-b +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-b +fi +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + ecs_api_edp_get_producer 200 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 testdata/ecs/ei-type-2.json +else + ecs_api_edp_get_producer_2 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 + ecs_api_edp_get_producer_2 200 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 +fi ecs_api_edp_get_producer_status 200 prod-b ENABLED @@ -332,14 +414,27 @@ ecs_api_edp_get_producer_jobs 200 prod-b job3 type2 $TARGET3 ricsim_g3_3 testdat ## Setup prod-c (no types) -ecs_api_edp_put_producer 201 prod-c $CB_JOB/prod-c $CB_SV/prod-c NOTYPE - +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 201 prod-c $CB_JOB/prod-c $CB_SV/prod-c NOTYPE +else + ecs_api_edp_put_producer_2 201 prod-c $CB_JOB/prod-c $CB_SV/prod-c NOTYPE +fi -ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-b prod-c +fi -ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json -ecs_api_edp_get_producer 200 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 testdata/ecs/ei-type-2.json -ecs_api_edp_get_producer 200 prod-c $CB_JOB/prod-c $CB_SV/prod-c EMPTY +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + ecs_api_edp_get_producer 200 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 testdata/ecs/ei-type-2.json + ecs_api_edp_get_producer 200 prod-c $CB_JOB/prod-c $CB_SV/prod-c EMPTY +else + ecs_api_edp_get_producer_2 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 + ecs_api_edp_get_producer_2 200 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 + ecs_api_edp_get_producer_2 200 prod-c $CB_JOB/prod-c $CB_SV/prod-c EMPTY +fi ecs_api_edp_get_producer_status 200 prod-c ENABLED @@ -348,7 +443,11 @@ ecs_api_edp_get_producer_status 200 prod-c ENABLED # Delete job then producer ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2 job3 -ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-b prod-c +fi if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_delete_job 204 type2 job3 @@ -357,25 +456,42 @@ else fi ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2 -ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-b prod-c +fi ecs_api_edp_delete_producer 204 prod-b ecs_api_edp_get_producer_status 404 prod-b ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2 -ecs_api_edp_get_producer_ids 200 prod-a prod-c +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-c +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-c +fi prodstub_equal delete/prod-b/job3 1 if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_put_job 404 type2 job3 $TARGET3 ricsim_g3_3 testdata/ecs/job-template.json else - ecs_api_a1_put_job 404 job3 type2 $TARGET3 ricsim_g3_3 $STATUS3 testdata/ecs/job-template.json + if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_a1_put_job 404 job3 type2 $TARGET3 ricsim_g3_3 $STATUS3 testdata/ecs/job-template.json + else + ecs_api_a1_put_job 201 job3 type2 $TARGET3 ricsim_g3_3 $STATUS3 testdata/ecs/job-template.json + ecs_api_a1_get_job_status 200 job3 DISABLED + fi fi # Put producer then job -ecs_api_edp_put_producer 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 testdata/ecs/ei-type-2.json +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 testdata/ecs/ei-type-2.json +else + ecs_api_edp_put_producer_2 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 +fi ecs_api_edp_get_producer_status 200 prod-b ENABLED @@ -383,16 +499,28 @@ if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_put_job 201 type2 job3 $TARGET3 ricsim_g3_3 testdata/ecs/job-template2.json ecs_api_a1_get_job_status 200 type2 job3 ENABLED else - ecs_api_a1_put_job 201 job3 type2 $TARGET3 ricsim_g3_3 $STATUS3 testdata/ecs/job-template2.json + if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_a1_put_job 201 job3 type2 $TARGET3 ricsim_g3_3 $STATUS3 testdata/ecs/job-template2.json + else + ecs_api_a1_put_job 200 job3 type2 $TARGET3 ricsim_g3_3 $STATUS3 testdata/ecs/job-template2.json + fi ecs_api_a1_get_job_status 200 job3 ENABLED fi prodstub_check_jobdata 200 prod-b job3 type2 $TARGET3 ricsim_g3_3 testdata/ecs/job-template2.json ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2 job3 -ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-b prod-c +fi -prodstub_equal create/prod-b/job3 2 +if [ $ECS_VERSION == "V1-1" ]; then + prodstub_equal create/prod-b/job3 2 +else + prodstub_equal create/prod-b/job3 3 +fi prodstub_equal delete/prod-b/job3 1 # Delete only the producer @@ -401,7 +529,11 @@ ecs_api_edp_delete_producer 204 prod-b ecs_api_edp_get_producer_status 404 prod-b ecs_api_a1_get_job_ids 200 NOTYPE NOWNER job1 job2 job3 -ecs_api_edp_get_producer_ids 200 prod-a prod-c +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-c +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-c +fi if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type2 job3 DISABLED @@ -414,7 +546,11 @@ cr_equal received_callbacks?id=job3-status 1 cr_api_check_all_ecs_events 200 job3-status DISABLED # Re-create the producer -ecs_api_edp_put_producer 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 testdata/ecs/ei-type-2.json +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 testdata/ecs/ei-type-2.json +else + ecs_api_edp_put_producer_2 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type2 +fi ecs_api_edp_get_producer_status 200 prod-b ENABLED @@ -432,7 +568,12 @@ prodstub_check_jobdata 200 prod-b job3 type2 $TARGET3 ricsim_g3_3 testdata/ecs/j ## Setup prod-d -ecs_api_edp_put_producer 201 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 testdata/ecs/ei-type-1.json +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 201 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 testdata/ecs/ei-type-4.json +else + ecs_api_edp_put_type_2 201 type4 testdata/ecs/ei-type-1.json + ecs_api_edp_put_producer_2 201 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 +fi ecs_api_a1_get_job_ids 200 type4 NOWNER EMPTY @@ -456,7 +597,11 @@ else fi # Re-PUT the producer with zero types -ecs_api_edp_put_producer 200 prod-d $CB_JOB/prod-d $CB_SV/prod-d NOTYPE +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 200 prod-d $CB_JOB/prod-d $CB_SV/prod-d NOTYPE +else + ecs_api_edp_put_producer_2 200 prod-d $CB_JOB/prod-d $CB_SV/prod-d NOTYPE +fi if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_ids 404 type4 NOWNER @@ -479,7 +624,12 @@ prodstub_equal create/prod-d/job8 1 prodstub_equal delete/prod-d/job8 0 ## Re-setup prod-d -ecs_api_edp_put_producer 200 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 testdata/ecs/ei-type-1.json +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 200 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 testdata/ecs/ei-type-4.json +else + ecs_api_edp_put_type_2 200 type4 testdata/ecs/ei-type-4.json + ecs_api_edp_put_producer_2 200 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 +fi if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_ids 404 type4 NOWNER @@ -508,7 +658,12 @@ prodstub_equal delete/prod-d/job8 0 ## Setup prod-e -ecs_api_edp_put_producer 201 prod-e $CB_JOB/prod-e $CB_SV/prod-e type6 testdata/ecs/ei-type-6.json +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 201 prod-e $CB_JOB/prod-e $CB_SV/prod-e type6 testdata/ecs/ei-type-6.json +else + ecs_api_edp_put_type_2 201 type6 testdata/ecs/ei-type-6.json + ecs_api_edp_put_producer_2 201 prod-e $CB_JOB/prod-e $CB_SV/prod-e type6 +fi ecs_api_a1_get_job_ids 200 type6 NOWNER EMPTY @@ -532,7 +687,12 @@ else fi ## Setup prod-f -ecs_api_edp_put_producer 201 prod-f $CB_JOB/prod-f $CB_SV/prod-f type6 testdata/ecs/ei-type-6.json +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 201 prod-f $CB_JOB/prod-f $CB_SV/prod-f type6 testdata/ecs/ei-type-6.json +else + ecs_api_edp_put_type_2 200 type6 testdata/ecs/ei-type-6.json + ecs_api_edp_put_producer_2 201 prod-f $CB_JOB/prod-f $CB_SV/prod-f type6 +fi ecs_api_a1_get_job_ids 200 type6 NOWNER job10 @@ -551,7 +711,11 @@ fi ## Status updates prod-a and jobs -ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c prod-d prod-e prod-f +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c prod-d prod-e prod-f +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-b prod-c prod-d prod-e prod-f +fi ecs_api_edp_get_producer_status 200 prod-a ENABLED ecs_api_edp_get_producer_status 200 prod-b ENABLED @@ -566,7 +730,11 @@ prodstub_arm_producer 200 prod-a 400 # Wait for producer prod-a to go disabled ecs_api_edp_get_producer_status 200 prod-a DISABLED 360 -ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c prod-d prod-e prod-f +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c prod-d prod-e prod-f +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-b prod-c prod-d prod-e prod-f +fi ecs_api_edp_get_producer_status 200 prod-a DISABLED ecs_api_edp_get_producer_status 200 prod-b ENABLED @@ -596,7 +764,11 @@ prodstub_arm_producer 200 prod-a 200 # Wait for producer prod-a to go enabled ecs_api_edp_get_producer_status 200 prod-a ENABLED 360 -ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c prod-d prod-e prod-f +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c prod-d prod-e prod-f +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-b prod-c prod-d prod-e prod-f +fi ecs_api_edp_get_producer_status 200 prod-a ENABLED ecs_api_edp_get_producer_status 200 prod-b ENABLED @@ -625,7 +797,11 @@ prodstub_arm_producer 200 prod-a 400 # Wait for producer prod-a to go disabled ecs_api_edp_get_producer_status 200 prod-a DISABLED 360 -ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c prod-d prod-e prod-f +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-a prod-b prod-c prod-d prod-e prod-f +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-a prod-b prod-c prod-d prod-e prod-f +fi ecs_api_edp_get_producer_status 200 prod-a DISABLED ecs_api_edp_get_producer_status 200 prod-b ENABLED @@ -651,7 +827,12 @@ fi # Wait for producer prod-a to be removed ecs_equal json:ei-producer/v1/eiproducers 5 1000 -ecs_api_edp_get_producer_ids 200 prod-b prod-c prod-d prod-e prod-f +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-b prod-c prod-d prod-e prod-f +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-b prod-c prod-d prod-e prod-f +fi + ecs_api_edp_get_producer_status 404 prod-a ecs_api_edp_get_producer_status 200 prod-b ENABLED @@ -687,7 +868,11 @@ prodstub_arm_producer 200 prod-e 400 ecs_api_edp_get_producer_status 200 prod-e DISABLED 1000 -ecs_api_edp_get_producer_ids 200 prod-b prod-c prod-d prod-e prod-f +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-b prod-c prod-d prod-e prod-f +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-b prod-c prod-d prod-e prod-f +fi ecs_api_edp_get_producer_status 404 prod-a ecs_api_edp_get_producer_status 200 prod-b ENABLED @@ -725,11 +910,15 @@ prodstub_arm_job_create 200 prod-e job10 200 ecs_api_edp_get_producer_status 200 prod-e ENABLED 360 -ecs_api_edp_get_producer_ids 200 prod-b prod-c prod-d prod-e prod-f +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-b prod-c prod-d prod-e prod-f +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-b prod-c prod-d prod-e prod-f +fi + +#Wait for job to be updated +sleep_wait 120 -#Job 10 should be updated when the producer goes enabled -deviation "Job 10 should be updated when the producer prod-e goes enabled" -prodstub_check_jobdata 200 prod-e job10 type6 $TARGET10 ricsim_g3_4 testdata/ecs/job-template2.json prodstub_check_jobdata 200 prod-f job10 type6 $TARGET10 ricsim_g3_4 testdata/ecs/job-template2.json prodstub_arm_producer 200 prod-f 400 @@ -738,7 +927,11 @@ ecs_api_edp_get_producer_status 200 prod-f DISABLED 360 ecs_equal json:ei-producer/v1/eiproducers 4 1000 -ecs_api_edp_get_producer_ids 200 prod-b prod-c prod-d prod-e +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_get_producer_ids 200 prod-b prod-c prod-d prod-e +else + ecs_api_edp_get_producer_ids_2 200 NOTYPE prod-b prod-c prod-d prod-e +fi ecs_api_edp_get_producer_status 404 prod-a ecs_api_edp_get_producer_status 200 prod-b ENABLED @@ -771,4 +964,4 @@ store_logs END print_result -auto_clean_containers +auto_clean_environment diff --git a/test/auto-test/FTC150.sh b/test/auto-test/FTC150.sh index daeb3c7c..905d4f87 100755 --- a/test/auto-test/FTC150.sh +++ b/test/auto-test/FTC150.sh @@ -20,11 +20,17 @@ TC_ONELINE_DESCR="Sample tests of the SDNC A1 controller restconf API using http/https (no agent)" -#App names to include in the test, space separated list -INCLUDED_IMAGES="RICSIM SDNC" - -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="RICSIM SDNC" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES=" RICSIM SDNC " +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES=" " + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/controller_api_functions.sh @@ -32,11 +38,6 @@ SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" #### TEST BEGIN #### -FLAVOUR="ORAN" -if [[ $SDNC_A1_CONTROLLER_IMAGE == *"onap"* ]]; then - FLAVOUR="ONAP" -fi - generate_uuid #Test agent and simulator protocol versions (others are http only) @@ -54,7 +55,7 @@ for __nb_httpx in $NB_TESTED_PROTOCOLS ; do # Clean container and start all needed containers # - clean_containers + clean_environment start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 @@ -141,4 +142,4 @@ done print_result -auto_clean_containers \ No newline at end of file +auto_clean_environment \ No newline at end of file diff --git a/test/auto-test/FTC1800.sh b/test/auto-test/FTC1800.sh index caec9398..90ea3b5a 100755 --- a/test/auto-test/FTC1800.sh +++ b/test/auto-test/FTC1800.sh @@ -20,38 +20,48 @@ TC_ONELINE_DESCR="ECS Create 10000 jobs and restart, test job persisency" -#App names to include in the test, space separated list -INCLUDED_IMAGES="ECS PRODSTUB CR CP" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="ECS PRODSTUB CR CP" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="ECS PRODSTUB CP CR" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/ecs_api_functions.sh . ../common/prodstub_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh +. ../common/cr_api_functions.sh #### TEST BEGIN #### FLAT_A1_EI="1" -clean_containers +clean_environment use_ecs_rest_http use_prod_stub_http -start_ecs +start_ecs $SIM_GROUP/$ECS_COMPOSE_DIR/application.yaml start_prod_stub set_ecs_trace -start_control_panel +start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties start_cr -CB_JOB="http://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/job" -CB_SV="http://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/supervision" +CB_JOB="$PROD_STUB_SERVICE_PATH$PROD_STUB_JOB_CALLBACK" +CB_SV="$PROD_STUB_SERVICE_PATH$PROD_STUB_SUPERVISION_CALLBACK" TARGET="http://localhost:80/target" # Dummy target NUM_JOBS=10000 @@ -96,13 +106,32 @@ do fi done -ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json +if [ $ECS_VERSION == "V1-1" ]; then + + ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + + ecs_api_edp_put_producer 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type1 testdata/ecs/ei-type-1.json type2 testdata/ecs/ei-type-2.json -ecs_api_edp_put_producer 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type1 testdata/ecs/ei-type-1.json type2 testdata/ecs/ei-type-2.json + ecs_api_edp_put_producer 201 prod-c $CB_JOB/prod-c $CB_SV/prod-c type1 testdata/ecs/ei-type-1.json type2 testdata/ecs/ei-type-2.json type3 testdata/ecs/ei-type-3.json -ecs_api_edp_put_producer 201 prod-c $CB_JOB/prod-c $CB_SV/prod-c type1 testdata/ecs/ei-type-1.json type2 testdata/ecs/ei-type-2.json type3 testdata/ecs/ei-type-3.json + ecs_api_edp_put_producer 201 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 testdata/ecs/ei-type-4.json type5 testdata/ecs/ei-type-5.json + +else -ecs_api_edp_put_producer 201 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 testdata/ecs/ei-type-4.json type5 testdata/ecs/ei-type-5.json + ecs_api_edp_put_type_2 201 type1 testdata/ecs/ei-type-1.json + ecs_api_edp_put_type_2 201 type2 testdata/ecs/ei-type-2.json + ecs_api_edp_put_type_2 201 type3 testdata/ecs/ei-type-3.json + ecs_api_edp_put_type_2 201 type4 testdata/ecs/ei-type-4.json + ecs_api_edp_put_type_2 201 type5 testdata/ecs/ei-type-5.json + + ecs_api_edp_put_producer_2 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 + + ecs_api_edp_put_producer_2 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type1 type2 + + ecs_api_edp_put_producer_2 201 prod-c $CB_JOB/prod-c $CB_SV/prod-c type1 type2 type3 + + ecs_api_edp_put_producer_2 201 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 type5 +fi ecs_equal json:ei-producer/v1/eiproducers 4 @@ -114,43 +143,43 @@ ecs_api_edp_get_producer_status 200 prod-d ENABLED for ((i=1; i<=$NUM_JOBS; i++)) do if [ $(($i%5)) -eq 0 ]; then - ecs_api_a1_put_job 201 job$i type1 $TARGET ric1 $CR_PATH/job_status_ric1 testdata/ecs/job-template.json + ecs_api_a1_put_job 201 job$i type1 $TARGET ric1 $CR_SERVICE_PATH/job_status_ric1 testdata/ecs/job-template.json if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type1 job$i ENABLED else - ecs_api_a1_get_job_status 200 job$i ENABLED + ecs_api_a1_get_job_status 200 job$i ENABLED 120 fi fi if [ $(($i%5)) -eq 1 ]; then - ecs_api_a1_put_job 201 job$i type2 $TARGET ric1 $CR_PATH/job_status_ric1 testdata/ecs/job-template.json + ecs_api_a1_put_job 201 job$i type2 $TARGET ric1 $CR_SERVICE_PATH/job_status_ric1 testdata/ecs/job-template.json if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type2 job$i ENABLED else - ecs_api_a1_get_job_status 200 job$i ENABLED + ecs_api_a1_get_job_status 200 job$i ENABLED 120 fi fi if [ $(($i%5)) -eq 2 ]; then - ecs_api_a1_put_job 201 job$i type3 $TARGET ric1 $CR_PATH/job_status_ric1 testdata/ecs/job-template.json + ecs_api_a1_put_job 201 job$i type3 $TARGET ric1 $CR_SERVICE_PATH/job_status_ric1 testdata/ecs/job-template.json if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type3 job$i ENABLED else - ecs_api_a1_get_job_status 200 job$i ENABLED + ecs_api_a1_get_job_status 200 job$i ENABLED 120 fi fi if [ $(($i%5)) -eq 3 ]; then - ecs_api_a1_put_job 201 job$i type4 $TARGET ric1 $CR_PATH/job_status_ric1 testdata/ecs/job-template.json + ecs_api_a1_put_job 201 job$i type4 $TARGET ric1 $CR_SERVICE_PATH/job_status_ric1 testdata/ecs/job-template.json if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type4 job$i ENABLED else - ecs_api_a1_get_job_status 200 job$i ENABLED + ecs_api_a1_get_job_status 200 job$i ENABLED 120 fi fi if [ $(($i%5)) -eq 4 ]; then - ecs_api_a1_put_job 201 job$i type5 $TARGET ric1 $CR_PATH/job_status_ric1 testdata/ecs/job-template.json + ecs_api_a1_put_job 201 job$i type5 $TARGET ric1 $CR_SERVICE_PATH/job_status_ric1 testdata/ecs/job-template.json if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type5 job$i ENABLED else - ecs_api_a1_get_job_status 200 job$i ENABLED + ecs_api_a1_get_job_status 200 job$i ENABLED 120 fi fi done @@ -206,47 +235,59 @@ do if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type1 job$i DISABLED else - ecs_api_a1_get_job_status 200 job$i DISABLED + ecs_api_a1_get_job_status 200 job$i DISABLED 120 fi fi if [ $(($i%5)) -eq 1 ]; then if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type2 job$i DISABLED else - ecs_api_a1_get_job_status 200 job$i DISABLED + ecs_api_a1_get_job_status 200 job$i DISABLED 120 fi fi if [ $(($i%5)) -eq 2 ]; then if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type3 job$i DISABLED else - ecs_api_a1_get_job_status 200 job$i DISABLED + ecs_api_a1_get_job_status 200 job$i DISABLED 120 fi fi if [ $(($i%5)) -eq 3 ]; then if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type4 job$i DISABLED else - ecs_api_a1_get_job_status 200 job$i DISABLED + ecs_api_a1_get_job_status 200 job$i DISABLED 120 fi fi if [ $(($i%5)) -eq 4 ]; then if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type5 job$i DISABLED else - ecs_api_a1_get_job_status 200 job$i DISABLED + ecs_api_a1_get_job_status 200 job$i DISABLED 120 fi fi done +if [ $ECS_VERSION == "V1-1" ]; then + + ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + + ecs_api_edp_put_producer 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type1 testdata/ecs/ei-type-1.json type2 testdata/ecs/ei-type-2.json + + ecs_api_edp_put_producer 201 prod-c $CB_JOB/prod-c $CB_SV/prod-c type1 testdata/ecs/ei-type-1.json type2 testdata/ecs/ei-type-2.json type3 testdata/ecs/ei-type-3.json -ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + ecs_api_edp_put_producer 201 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 testdata/ecs/ei-type-4.json type5 testdata/ecs/ei-type-5.json -ecs_api_edp_put_producer 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type1 testdata/ecs/ei-type-1.json type2 testdata/ecs/ei-type-2.json +else + ecs_api_edp_put_producer_2 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 + + ecs_api_edp_put_producer_2 201 prod-b $CB_JOB/prod-b $CB_SV/prod-b type1 type2 -ecs_api_edp_put_producer 201 prod-c $CB_JOB/prod-c $CB_SV/prod-c type1 testdata/ecs/ei-type-1.json type2 testdata/ecs/ei-type-2.json type3 testdata/ecs/ei-type-3.json + ecs_api_edp_put_producer_2 201 prod-c $CB_JOB/prod-c $CB_SV/prod-c type1 type2 type3 -ecs_api_edp_put_producer 201 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 testdata/ecs/ei-type-4.json type5 testdata/ecs/ei-type-5.json + ecs_api_edp_put_producer_2 201 prod-d $CB_JOB/prod-d $CB_SV/prod-d type4 type5 + +fi ecs_equal json:ei-producer/v1/eiproducers 4 @@ -261,35 +302,35 @@ do if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type1 job$i ENABLED else - ecs_api_a1_get_job_status 200 job$i ENABLED + ecs_api_a1_get_job_status 200 job$i ENABLED 120 fi fi if [ $(($i%5)) -eq 1 ]; then if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type2 job$i ENABLED else - ecs_api_a1_get_job_status 200 job$i ENABLED + ecs_api_a1_get_job_status 200 job$i ENABLED 120 fi fi if [ $(($i%5)) -eq 2 ]; then if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type3 job$i ENABLED else - ecs_api_a1_get_job_status 200 job$i ENABLED + ecs_api_a1_get_job_status 200 job$i ENABLED 120 fi fi if [ $(($i%5)) -eq 3 ]; then if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type4 job$i ENABLED else - ecs_api_a1_get_job_status 200 job$i ENABLED + ecs_api_a1_get_job_status 200 job$i ENABLED 120 fi fi if [ $(($i%5)) -eq 4 ]; then if [ -z "$FLAT_A1_EI" ]; then ecs_api_a1_get_job_status 200 type5 job$i ENABLED else - ecs_api_a1_get_job_status 200 job$i ENABLED + ecs_api_a1_get_job_status 200 job$i ENABLED 120 fi fi done @@ -381,4 +422,4 @@ store_logs END print_result -auto_clean_containers +auto_clean_environment diff --git a/test/auto-test/FTC300.sh b/test/auto-test/FTC300.sh index 39732825..723368e1 100755 --- a/test/auto-test/FTC300.sh +++ b/test/auto-test/FTC300.sh @@ -19,14 +19,26 @@ TC_ONELINE_DESCR="Resync 10000 policies using OSC and STD interface" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh +. ../common/consul_cbs_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh +. ../common/cr_api_functions.sh +. ../common/mr_api_functions.sh . ../common/ricsimulator_api_functions.sh #### TEST BEGIN #### @@ -37,6 +49,7 @@ generate_uuid TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC DMAAP_BATCH DMAAP_BATCH+SDNC" #Test agent and simulator protocol versions (others are http only) TESTED_PROTOCOLS="HTTP HTTPS" + for __httpx in $TESTED_PROTOCOLS ; do for interface in $TESTED_VARIANTS ; do @@ -73,7 +86,7 @@ for __httpx in $TESTED_PROTOCOLS ; do fi # Clean container and start all needed containers # - clean_containers + clean_environment start_ric_simulators ricsim_g1 4 OSC_2.1.0 @@ -87,7 +100,15 @@ for __httpx in $TESTED_PROTOCOLS ; do start_cr - start_consul_cbs + if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs + fi + + start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties + + start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml + + set_agent_debug if [[ $interface = *"SDNC"* ]]; then start_sdnc @@ -96,13 +117,11 @@ for __httpx in $TESTED_PROTOCOLS ; do prepare_consul_config NOSDNC ".consul_config.json" fi - consul_config_app ".consul_config.json" - - start_control_panel - - start_policy_agent - - set_agent_debug + if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" + else + consul_config_app ".consul_config.json" + fi api_get_status 200 @@ -122,13 +141,13 @@ for __httpx in $TESTED_PROTOCOLS ; do api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulator fi - api_put_service 201 "serv1" 3600 "$CR_PATH/1" + api_put_service 201 "serv1" 3600 "$CR_SERVICE_PATH/1" START_ID=2000 NUM_POLICIES=10000 # Must be at least 100 if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi @@ -201,4 +220,4 @@ done print_result -auto_clean_containers \ No newline at end of file +auto_clean_environment \ No newline at end of file diff --git a/test/auto-test/FTC310.sh b/test/auto-test/FTC310.sh index eec45420..dd79b33f 100755 --- a/test/auto-test/FTC310.sh +++ b/test/auto-test/FTC310.sh @@ -20,16 +20,21 @@ TC_ONELINE_DESCR="Resync of RIC via changes in the consul config or pushed config" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh . ../common/cr_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh #### TEST BEGIN #### @@ -43,7 +48,7 @@ for consul_conf in $TESTED_VARIANTS ; do generate_uuid # Clean container and start all needed containers # - clean_containers + clean_environment start_policy_agent @@ -51,7 +56,7 @@ for consul_conf in $TESTED_VARIANTS ; do # Create service to be able to receive events when rics becomes available # Must use rest towards the agent since dmaap is not configured yet - api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration" + api_put_service 201 "ric-registration" 0 "$CR_SERVICE_PATH/ric-registration" # Start one RIC of each type start_ric_simulators ricsim_g1 1 OSC_2.1.0 @@ -80,13 +85,13 @@ for consul_conf in $TESTED_VARIANTS ; do fi if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:rics 3 120 + api_equal json:rics 3 300 cr_equal received_callbacks 3 120 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1 else - api_equal json:rics 2 120 + api_equal json:rics 2 300 fi # Add an STD RIC and check @@ -148,4 +153,4 @@ done print_result -auto_clean_containers +auto_clean_environment diff --git a/test/auto-test/FTC350.sh b/test/auto-test/FTC350.sh index 0605944d..d30b3141 100755 --- a/test/auto-test/FTC350.sh +++ b/test/auto-test/FTC350.sh @@ -19,16 +19,27 @@ TC_ONELINE_DESCR="Change supported policy types and reconfigure rics" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh +. ../common/consul_cbs_functions.sh . ../common/ricsimulator_api_functions.sh . ../common/cr_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh #### TEST BEGIN #### @@ -52,7 +63,7 @@ for interface in $TESTED_VARIANTS ; do # Clean container and start all needed containers # - clean_containers + clean_environment #Start simulators and prepare two configs @@ -62,7 +73,9 @@ for interface in $TESTED_VARIANTS ; do start_mr - start_consul_cbs + if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs + fi # Create first config if [[ $interface = *"SDNC"* ]]; then @@ -81,7 +94,7 @@ for interface in $TESTED_VARIANTS ; do prepare_consul_config NOSDNC ".consul_config_all.json" fi - start_policy_agent + start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml set_agent_trace @@ -89,10 +102,14 @@ for interface in $TESTED_VARIANTS ; do # Create service to be able to receive events when rics becomes available # Must use rest towards the agent since dmaap is not configured yet - api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration" + api_put_service 201 "ric-registration" 0 "$CR_SERVICE_PATH/ric-registration" #Load first config - consul_config_app ".consul_config_initial.json" + if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config_initial.json" + else + consul_config_app ".consul_config_initial.json" + fi for ((i=1; i<=${NUM_RICS}; i++)) do @@ -100,7 +117,7 @@ for interface in $TESTED_VARIANTS ; do done # All sims running but 2 are not configured in consul - api_equal json:rics 8 120 + api_equal json:rics 8 300 if [ "$PMS_VERSION" == "V2" ]; then cr_equal received_callbacks?id=ric-registration 8 120 @@ -187,7 +204,11 @@ for interface in $TESTED_VARIANTS ; do fi #Load config with all rics - consul_config_app ".consul_config_all.json" + if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config_all.json" + else + consul_config_app ".consul_config_all.json" + fi api_equal json:rics 10 120 @@ -250,10 +271,10 @@ for interface in $TESTED_VARIANTS ; do api_equal json:policy_types 5 fi - api_put_service 201 "serv1" 3600 "$CR_PATH/serv1" + api_put_service 201 "serv1" 3600 "$CR_SERVICE_PATH/serv1" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi @@ -261,7 +282,11 @@ for interface in $TESTED_VARIANTS ; do sleep_wait 120 # Load config with reduced number of rics - consul_config_app ".consul_config_initial.json" + if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config_initial.json" + else + consul_config_app ".consul_config_initial.json" + fi api_equal json:rics 8 120 @@ -312,7 +337,11 @@ for interface in $TESTED_VARIANTS ; do api_get_policy_types 404 ricsim_g1_9 # Load config with all rics - consul_config_app ".consul_config_all.json" + if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config_all.json" + else + consul_config_app ".consul_config_all.json" + fi api_equal json:rics 10 120 @@ -442,4 +471,4 @@ done print_result -auto_clean_containers \ No newline at end of file +auto_clean_environment \ No newline at end of file diff --git a/test/auto-test/FTC800.sh b/test/auto-test/FTC800.sh index c90940c7..0be6be80 100755 --- a/test/auto-test/FTC800.sh +++ b/test/auto-test/FTC800.sh @@ -19,16 +19,26 @@ TC_ONELINE_DESCR="Create 10000 policies in sequence using http/https and Agent REST/DMAAP with/without SDNC controller" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh . ../common/cr_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh #### TEST BEGIN #### @@ -69,7 +79,7 @@ for __httpx in $TESTED_PROTOCOLS ; do # Policy instance start id START_ID=1 - clean_containers + clean_environment start_ric_simulators ricsim_g1 1 OSC_2.1.0 start_ric_simulators ricsim_g2 1 STD_1.1.3 @@ -81,6 +91,14 @@ for __httpx in $TESTED_PROTOCOLS ; do start_cr + start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties + + start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml + + set_agent_debug + + mr_equal requests_submitted 0 + if [[ $interface == "SDNC" ]]; then start_sdnc prepare_consul_config SDNC ".consul_config.json" @@ -88,17 +106,15 @@ for __httpx in $TESTED_PROTOCOLS ; do prepare_consul_config NOSDNC ".consul_config.json" fi - start_consul_cbs - - consul_config_app ".consul_config.json" - - start_control_panel - - start_policy_agent - - set_agent_debug + if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs + fi - mr_equal requests_submitted 0 + if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" + else + consul_config_app ".consul_config.json" + fi api_get_status 200 @@ -114,15 +130,15 @@ for __httpx in $TESTED_PROTOCOLS ; do if [ "$PMS_VERSION" == "V2" ]; then sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json - api_equal json:policy-types 3 120 #Wait for the agent to refresh types from the simulators + api_equal json:policy-types 3 300 #Wait for the agent to refresh types from the simulators else - api_equal json:policy_types 2 120 #Wait for the agent to refresh types from the simulators + api_equal json:policy_types 2 300 #Wait for the agent to refresh types from the simulators fi - api_put_service 201 "serv1" 3600 "$CR_PATH/1" + api_put_service 201 "serv1" 3600 "$CR_SERVICE_PATH/1" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi @@ -215,16 +231,16 @@ for __httpx in $TESTED_PROTOCOLS ; do fi if [ $interface == "SDNC" ]; then - sim_contains_str ricsim_g1_1 remote_hosts "a1-controller" - sim_contains_str ricsim_g2_1 remote_hosts "a1-controller" + sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME + sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME if [ "$PMS_VERSION" == "V2" ]; then - sim_contains_str ricsim_g3_1 remote_hosts "a1-controller" + sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME fi else - sim_contains_str ricsim_g1_1 remote_hosts "policy-agent" - sim_contains_str ricsim_g2_1 remote_hosts "policy-agent" + sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME + sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME if [ "$PMS_VERSION" == "V2" ]; then - sim_contains_str ricsim_g3_1 remote_hosts "policy-agent" + sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME fi fi @@ -241,4 +257,4 @@ done print_result -auto_clean_containers \ No newline at end of file +auto_clean_environment \ No newline at end of file diff --git a/test/auto-test/FTC810.sh b/test/auto-test/FTC810.sh index 7ac759cb..a92106ee 100755 --- a/test/auto-test/FTC810.sh +++ b/test/auto-test/FTC810.sh @@ -19,16 +19,26 @@ TC_ONELINE_DESCR="Repeatedly create and delete policies in each RICs for 24h (or configured number of days). Via agent REST/DMAAP/DMAAP_BATCH and SDNC using http or https" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh . ../common/cr_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh #### TEST BEGIN #### @@ -48,7 +58,7 @@ NUM_INSTANCES=5 DAYS=3 -clean_containers +clean_environment # use HTTP or HTTPS for all apis HTTPX=HTTPS @@ -77,16 +87,23 @@ start_mr start_cr -start_consul_cbs +start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties -prepare_consul_config SDNC ".consul_config.json" -consul_config_app ".consul_config.json" +start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml -start_sdnc +if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs +fi -start_control_panel +prepare_consul_config SDNC ".consul_config.json" -start_policy_agent +if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" +else + consul_config_app ".consul_config.json" +fi + +start_sdnc api_get_status 200 @@ -147,9 +164,9 @@ fi echo "Wait for the agent to refresh types from the simulator" if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy-types 3 120 + api_equal json:policy-types 3 300 else - api_equal json:policy_types 2 120 + api_equal json:policy_types 2 300 fi echo "Check the number of types in the agent for each ric is 1" @@ -164,7 +181,7 @@ do done echo "Register a service" -api_put_service 201 "serv1" 0 "$CR_PATH/1" +api_put_service 201 "serv1" 0 "$CR_SERVICE_PATH/1" TEST_DURATION=$((24*3600*$DAYS)) TEST_START=$SECONDS @@ -174,7 +191,7 @@ AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH" MR_MESSAGES=0 if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi @@ -380,11 +397,11 @@ while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do for ((i=1; i<=$NUM_RICS; i++)) do - sim_contains_str ricsim_g1_$i remote_hosts "a1-controller" - sim_contains_str ricsim_g2_$i remote_hosts "a1-controller" + sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME + sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME if [ "$PMS_VERSION" == "V2" ]; then - sim_contains_str ricsim_g3_$i remote_hosts "a1-controller" + sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME fi done @@ -401,4 +418,4 @@ store_logs END print_result -auto_clean_containers \ No newline at end of file +auto_clean_environment \ No newline at end of file diff --git a/test/auto-test/FTC850.sh b/test/auto-test/FTC850.sh index 3b65b10a..82e50f19 100755 --- a/test/auto-test/FTC850.sh +++ b/test/auto-test/FTC850.sh @@ -19,15 +19,25 @@ TC_ONELINE_DESCR="Create/delete policies in parallel over a number of rics using a number of child process" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh #### TEST BEGIN #### @@ -46,7 +56,7 @@ NUM_POLICIES_PER_RIC=500 generate_uuid if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi @@ -79,11 +89,19 @@ for __httpx in $TESTED_PROTOCOLS ; do fi # Clean container and start all needed containers # - clean_containers + clean_environment start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0 - start_consul_cbs + start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties + + start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml + + set_agent_debug + + if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs + fi if [[ $interface = *"SDNC"* ]]; then start_sdnc @@ -92,18 +110,16 @@ for __httpx in $TESTED_PROTOCOLS ; do prepare_consul_config NOSDNC ".consul_config.json" fi - consul_config_app ".consul_config.json" + if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" + else + consul_config_app ".consul_config.json" + fi start_mr # Not used, but removes error messages from the agent log start_cr - start_control_panel - - start_policy_agent - - set_agent_debug - api_get_status 200 for ((i=1; i<=$NUM_RICS; i++)) @@ -118,12 +134,12 @@ for __httpx in $TESTED_PROTOCOLS ; do done if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy-types 1 120 #Wait for the agent to refresh types from the simulator + api_equal json:policy-types 1 300 #Wait for the agent to refresh types from the simulator else - api_equal json:policy_types 1 120 #Wait for the agent to refresh types from the simulator + api_equal json:policy_types 1 300 #Wait for the agent to refresh types from the simulator fi - api_put_service 201 "serv1" 600 "$CR_PATH/1" + api_put_service 201 "serv1" 600 "$CR_SERVICE_PATH/1" echo "Check the number of types in the agent for each ric is 1" for ((i=1; i<=$NUM_RICS; i++)) @@ -167,9 +183,9 @@ for __httpx in $TESTED_PROTOCOLS ; do for ((i=1; i<=$NUM_RICS; i++)) do if [ $interface == "REST+SDNC" ]; then - sim_contains_str ricsim_g1_$i remote_hosts "a1-controller" + sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME else - sim_contains_str ricsim_g1_$i remote_hosts "policy-agent" + sim_contains_str ricsim_g1_$i remote_hosts $POLICY_AGENT_APP_NAME fi done @@ -189,4 +205,4 @@ done print_result -auto_clean_containers \ No newline at end of file +auto_clean_environment \ No newline at end of file diff --git a/test/auto-test/FTC900.sh b/test/auto-test/FTC900.sh index 356301e8..b3e4d29b 100755 --- a/test/auto-test/FTC900.sh +++ b/test/auto-test/FTC900.sh @@ -19,19 +19,29 @@ TC_ONELINE_DESCR="Preparation for test of the Control Panel and the Health Check app - populating a number of ric simulators with types and instances" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh #### TEST BEGIN #### -clean_containers +clean_environment OSC_NUM_RICS=6 STD_NUM_RICS=5 @@ -46,16 +56,23 @@ fi start_mr #Just to prevent errors in the agent log... -start_control_panel +start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties -start_consul_cbs +start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml -prepare_consul_config NOSDNC ".consul_config.json" -consul_config_app ".consul_config.json" +use_agent_rest_http -start_policy_agent +if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs +fi -use_agent_rest_http +prepare_consul_config NOSDNC ".consul_config.json" + +if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" +else + consul_config_app ".consul_config.json" +fi api_get_status 200 @@ -91,7 +108,7 @@ done #Check the number of schemas and the individual schemas in OSC if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy-types 4 120 + api_equal json:policy-types 4 300 for ((i=1; i<=$OSC_NUM_RICS; i++)) do @@ -106,7 +123,7 @@ if [ "$PMS_VERSION" == "V2" ]; then api_get_policy_type 200 20008 testdata/OSC/tsa-agent-modified.json done else - api_equal json:policy_types 4 120 + api_equal json:policy_types 4 300 for ((i=1; i<=$OSC_NUM_RICS; i++)) do @@ -150,10 +167,10 @@ fi # Create policies use_agent_rest_http -api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1" +api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_PATH/1" if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi diff --git a/test/auto-test/FTC_HELM-RECEPIE.sh b/test/auto-test/FTC_HELM-RECEPIE.sh new file mode 100755 index 00000000..a9f5e5ed --- /dev/null +++ b/test/auto-test/FTC_HELM-RECEPIE.sh @@ -0,0 +1,302 @@ +#!/usr/bin/env bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# + +TC_ONELINE_DESCR="Sanity test of Non-RT RIC Helm recepie - all components" + +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="" # Not used - KUBE only test script + +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES=" MR CR PRODSTUB" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES=" PA RICSIM CP ECS RC SDNC" + +#Supported test environment profiles +SUPPORTED_PROFILES="ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="KUBE" + +. ../common/testcase_common.sh $@ +. ../common/agent_api_functions.sh +. ../common/ricsimulator_api_functions.sh +. ../common/ecs_api_functions.sh +. ../common/prodstub_api_functions.sh +. ../common/cr_api_functions.sh +. ../common/rapp_catalogue_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh + +#### TEST BEGIN #### + +use_mr_http #MR only supports http? +use_cr_https +use_agent_rest_https +use_sdnc_https +use_simulator_https +use_ecs_rest_https +use_prod_stub_https +use_rapp_catalogue_http + +echo -e "$RED CHECK WHY RC HTTPS DOES NOT WORK $ERED" + +use_control_panel_https + +if [ "$PMS_VERSION" == "V1" ]; then + echo "PMS VERSION 2 (V2) is required" + exit 1 +fi + +clean_environment + +STD_NUM_RICS=2 +OSC_NUM_RICS=2 + +start_ric_simulators a1-sim-osc $STD_NUM_RICS OSC_2.1.0 +echo " RIC MAPPING a1-sim-osc-0 : ric1" +echo " RIC MAPPING a1-sim-osc-1 : ric2" + +start_ric_simulators a1-sim-std $STD_NUM_RICS STD_1.1.3 +echo " RIC MAPPING a1-sim-std-0 : ric3" +echo " RIC MAPPING a1-sim-std-1 : ric4" + +start_ric_simulators a1-sim-std2 $STD_NUM_RICS STD_2.0.0 +echo " RIC MAPPING a1-sim-std2-0 : ric5" +echo " RIC MAPPING a1-sim-std2-1 : ric6" + +start_mr + +start_control_panel + +start_sdnc + +start_policy_agent + +start_cr + +start_prod_stub + +start_ecs + +set_ecs_trace + +start_rapp_catalogue + +set_agent_trace + +#### Test RAPP Catalogue #### + +rapp_cat_api_get_services 200 EMPTY + +rapp_cat_api_put_service 201 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app" + +rapp_cat_api_get_services 200 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app" + +#Check the number of services +rc_equal json:services 1 + +api_get_status 200 + +#### Test Policy Management Service #### + +# Print the A1 version for STD 1.1.X +for ((i=0; i<$STD_NUM_RICS; i++)) +do + sim_print "a1-sim-std-"$i interface +done + +# Print the A1 version for STD 2.0.X +for ((i=0; i<$STD_NUM_RICS; i++)) +do + sim_print "a1-sim-std2-"$i interface +done + +# Print the A1 version for OSC 2.1.X +for ((i=0; i<$OSC_NUM_RICS; i++)) +do + sim_print "a1-sim-osc-"$i interface +done + + +# Load the polictypes in STD 2 +for ((i=0; i<$STD_NUM_RICS; i++)) +do + sim_put_policy_type 201 "a1-sim-std2-"$i STD_QOS_0_2_0 testdata/STD2/sim_qos.json + sim_put_policy_type 201 "a1-sim-std2-"$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json +done + +# Load the polictypes in OSC +for ((i=0; i<$OSC_NUM_RICS; i++)) +do + sim_put_policy_type 201 "a1-sim-osc-"$i 1 testdata/OSC/sim_1.json + sim_put_policy_type 201 "a1-sim-osc-"$i 2 testdata/OSC/sim_2.json +done + +# Check that all rics are synced in +api_equal json:rics 6 300 + +#Check the number of schemas and the individual schemas +api_equal json:policy-types 5 300 + +for ((i=0; i<$STD_NUM_RICS; i++)) +do + ricid=$((3+$i)) + api_equal json:policy-types?ric_id=ric$ricid 1 120 +done + +for ((i=0; i<$STD_NUM_RICS; i++)) +do + ricid=$((5+$i)) + api_equal json:policy-types?ric_id=ric$ricid 2 120 +done + +for ((i=0; i<$OSC_NUM_RICS; i++)) +do + ricid=$((1+$i)) + api_equal json:policy-types?ric_id=ric$ricid 2 120 +done + +#Check the schemas in STD 2 +for ((i=0; i<$OSC_NUM_RICS; i++)) +do + ricid=$((5+$i)) + api_get_policy_type 200 STD_QOS_0_2_0 testdata/STD2/qos-agent-modified.json + api_get_policy_type 200 STD_QOS2_0.1.0 testdata/STD2/qos2-agent-modified.json +done + +# Check the schemas in OSC +for ((i=0; i<$OSC_NUM_RICS; i++)) +do + api_get_policy_type 200 1 testdata/OSC/1-agent-modified.json + api_get_policy_type 200 2 testdata/OSC/2-agent-modified.json +done + +api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_PATH/ER-app" + +# Create policies in STD +for ((i=0; i<$STD_NUM_RICS; i++)) +do + ricid=$((3+$i)) + generate_uuid + api_put_policy 201 "Emergency-response-app" ric$ricid NOTYPE $((1100+$i)) NOTRANSIENT $CR_SERVICE_PATH/"std2" testdata/STD/pi1_template.json 1 + generate_uuid + api_put_policy 201 "Emergency-response-app" ric$ricid NOTYPE $((1200+$i)) NOTRANSIENT $CR_SERVICE_PATH/"std2" testdata/STD/pi1_template.json 1 +done + +#Create policies in STD 2 +for ((i=0; i<$STD_NUM_RICS; i++)) +do + ricid=$((5+$i)) + generate_uuid + api_put_policy 201 "Emergency-response-app" ric$ricid STD_QOS_0_2_0 $((2100+$i)) NOTRANSIENT $CR_SERVICE_PATH/"std2" testdata/STD2/pi_qos_template.json 1 + generate_uuid + api_put_policy 201 "Emergency-response-app" ric$ricid STD_QOS2_0.1.0 $((2200+$i)) NOTRANSIENT $CR_SERVICE_PATH/"std2" testdata/STD2/pi_qos2_template.json 1 +done + +# Create policies in OSC +for ((i=0; i<$OSC_NUM_RICS; i++)) +do + ricid=$((1+$i)) + generate_uuid + api_put_policy 201 "Emergency-response-app" ric$ricid 1 $((3100+$i)) NOTRANSIENT $CR_SERVICE_PATH/"osc" testdata/OSC/pi1_template.json 1 + generate_uuid + api_put_policy 201 "Emergency-response-app" ric$ricid 2 $((3200+$i)) NOTRANSIENT $CR_SERVICE_PATH/"osc" testdata/OSC/pi2_template.json 1 +done + + +# Check the number of policies in STD and STD2 +for ((i=0; i<$STD_NUM_RICS; i++)) +do + sim_equal "a1-sim-std-"$i num_instances 2 + sim_equal "a1-sim-std2-"$i num_instances 2 +done + +# Check the number of policies in OSC +for ((i=0; i<$STD_NUM_RICS; i++)) +do + sim_equal "a1-sim-osc-"$i num_instances 2 +done + +echo "ADD EVENT/STATUS CHECK" +echo "ADD MR CHECK" + +FLAT_A1_EI="1" + +ecs_api_admin_reset + +CB_JOB="$PROD_STUB_SERVICE_PATH$PROD_STUB_JOB_CALLBACK" +CB_SV="$PROD_STUB_SERVICE_PATH$PROD_STUB_SUPERVISION_CALLBACK" +TARGET1="$RIC_SIM_HTTPX://a1-sim-std2-0.a1-sim:$RIC_SIM_PORT/datadelivery" +TARGET2="$RIC_SIM_HTTPX://a1-sim-std2-1.a1-sim:$RIC_SIM_PORT/datadelivery" + +STATUS1="$CR_SERVICE_PATH/job1-status" +STATUS2="$CR_SERVICE_PATH/job2-status" + +prodstub_arm_producer 200 prod-a +prodstub_arm_type 200 prod-a type1 +prodstub_arm_job_create 200 prod-a job1 +prodstub_arm_job_create 200 prod-a job2 + + +### ecs status +ecs_api_service_status 200 + +## Setup prod-a +ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + +ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + +ecs_api_edp_get_producer_status 200 prod-a ENABLED + + +## Create a job for prod-a +## job1 - prod-a +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_put_job 201 type1 job1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json +else + ecs_api_a1_put_job 201 job1 type1 $TARGET1 ricsim_g3_1 $STATUS1 testdata/ecs/job-template.json +fi + +# Check the job data in the producer +prodstub_check_jobdata 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json + + +## Create a second job for prod-a +## job2 - prod-a +if [ -z "$FLAT_A1_EI" ]; then + ecs_api_a1_put_job 201 type1 job2 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json +else + ecs_api_a1_put_job 201 job2 type1 $TARGET2 ricsim_g3_2 $STATUS2 testdata/ecs/job-template.json +fi + +# Check the job data in the producer +prodstub_check_jobdata 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json + + +echo "ADD EVENT/STATUS CHECK" + +check_policy_agent_logs +check_ecs_logs +check_sdnc_logs + +#### TEST COMPLETE #### + +store_logs END + +print_result diff --git a/test/auto-test/PM_DEMO.sh b/test/auto-test/PM_DEMO.sh index c43ad3eb..0b704950 100755 --- a/test/auto-test/PM_DEMO.sh +++ b/test/auto-test/PM_DEMO.sh @@ -19,15 +19,27 @@ TC_ONELINE_DESCR="Preparation demo setup - populating a number of ric simulators with types and instances" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh . ../common/ricsimulator_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh +. ../common/cr_api_functions.sh +. ../common/consul_cbs_functions.sh #### TEST BEGIN #### @@ -40,12 +52,12 @@ use_sdnc_https use_simulator_https if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else notificationurl="" fi -clean_containers +clean_environment OSC_NUM_RICS=6 STD_NUM_RICS=5 @@ -60,18 +72,25 @@ fi start_mr #Just to prevent errors in the agent log... -start_control_panel +start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties start_sdnc -start_consul_cbs +start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml -prepare_consul_config SDNC ".consul_config.json" -consul_config_app ".consul_config.json" +set_agent_trace -start_policy_agent +if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs +fi -set_agent_trace +prepare_consul_config SDNC ".consul_config.json" + +if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" +else + consul_config_app ".consul_config.json" +fi api_get_status 200 @@ -108,7 +127,7 @@ done #Check the number of schemas and the individual schemas in OSC if [ "$PMS_VERSION" == "V2" ]; then - api_equal json:policy-types 3 120 + api_equal json:policy-types 3 300 for ((i=1; i<=$OSC_NUM_RICS; i++)) do @@ -122,7 +141,7 @@ if [ "$PMS_VERSION" == "V2" ]; then api_get_policy_type 200 20008 demo-testdata/OSC/tsa-agent-modified.json done else - api_equal json:policy_types 3 120 + api_equal json:policy_types 3 300 for ((i=1; i<=$OSC_NUM_RICS; i++)) do @@ -176,7 +195,7 @@ fi # Create policies use_agent_rest_http -api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1" +api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_PATH/1" # Create policies in OSC for ((i=1; i<=$OSC_NUM_RICS; i++)) diff --git a/test/auto-test/PM_EI_DEMO.sh b/test/auto-test/PM_EI_DEMO.sh index 2915b02c..324d892e 100755 --- a/test/auto-test/PM_EI_DEMO.sh +++ b/test/auto-test/PM_EI_DEMO.sh @@ -19,11 +19,18 @@ TC_ONELINE_DESCR="Preparation demo setup - policy management and enrichment information" -#App names to include in the test, space separated list -INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC ECS PRODSTUB RC" +#App names to include in the test when running docker, space separated list +DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC ECS PRODSTUB RC HTTPPROXY" -#SUPPORTED TEST ENV FILE -SUPPORTED_PROFILES="ONAP-MASTER ORAN-CHERRY" +#App names to include in the test when running kubernetes, space separated list +KUBE_INCLUDED_IMAGES=" MR CR PA RC PRODSTUB RICSIM CP ECS SDNC HTTPPROXY" +#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list +KUBE_PRESTARTED_IMAGES="" + +#Supported test environment profiles +SUPPORTED_PROFILES="ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" +#Supported run modes +SUPPORTED_RUNMODES="DOCKER KUBE" . ../common/testcase_common.sh $@ . ../common/agent_api_functions.sh @@ -32,6 +39,11 @@ SUPPORTED_PROFILES="ONAP-MASTER ORAN-CHERRY" . ../common/prodstub_api_functions.sh . ../common/cr_api_functions.sh . ../common/rapp_catalogue_api_functions.sh +. ../common/mr_api_functions.sh +. ../common/control_panel_api_functions.sh +. ../common/controller_api_functions.sh +. ../common/consul_cbs_functions.sh +. ../common/http_proxy_api_functions.sh #### TEST BEGIN #### @@ -47,13 +59,13 @@ use_prod_stub_https use_rapp_catalogue_http # https not yet supported if [ "$PMS_VERSION" == "V2" ]; then - notificationurl=$CR_PATH"/test" + notificationurl=$CR_SERVICE_PATH"/test" else echo "PMS VERSION 2 (V2) is required" exit 1 fi -clean_containers +clean_environment STD_NUM_RICS=2 @@ -61,24 +73,29 @@ start_ric_simulators $RIC_SIM_PREFIX"_g3" $STD_NUM_RICS STD_2.0.0 start_mr #Just to prevent errors in the agent log... -start_control_panel +start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties start_sdnc -start_consul_cbs +start_policy_agent PROXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml -prepare_consul_config SDNC ".consul_config.json" -consul_config_app ".consul_config.json" +if [ $RUNMODE == "DOCKER" ]; then + start_consul_cbs +fi -start_policy_agent +prepare_consul_config SDNC ".consul_config.json" -start_rapp_catalogue +if [ $RUNMODE == "KUBE" ]; then + agent_load_config ".consul_config.json" +else + consul_config_app ".consul_config.json" +fi start_cr start_prod_stub -start_ecs +start_ecs $SIM_GROUP/$ECS_COMPOSE_DIR/application.yaml start_rapp_catalogue @@ -86,7 +103,6 @@ set_agent_trace set_ecs_trace - rapp_cat_api_get_services 200 EMPTY rapp_cat_api_put_service 201 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app" @@ -123,9 +139,9 @@ do done #Check the number of types -api_equal json:policy-types 2 120 +api_equal json:policy-types 2 300 -api_put_service 201 "Emergency-response-app" 0 "$CR_PATH/1" +api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_PATH/1" # Create policies in STD for ((i=1; i<=$STD_NUM_RICS; i++)) @@ -143,33 +159,48 @@ do sim_equal $RIC_SIM_PREFIX"_g3_"$i num_instances 2 done - +# Print calling hosts STD 2.X +for ((i=1; i<=$STD_NUM_RICS; i++)) +do + sim_print $RIC_SIM_PREFIX"_g3_"$i remote_hosts +done FLAT_A1_EI="1" -CB_JOB="$PROD_STUB_HTTPX://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/job" -CB_SV="$PROD_STUB_HTTPX://$PROD_STUB_APP_NAME:$PROD_STUB_PORT/callbacks/supervision" -TARGET1="$RIC_SIM_HTTPX://ricsim_g3_1:$RIC_SIM_PORT/datadelivery" -TARGET2="$RIC_SIM_HTTPX://ricsim_g3_2:$RIC_SIM_PORT/datadelivery" +CB_JOB="$PROD_STUB_SERVICE_PATH$PROD_STUB_JOB_CALLBACK" +CB_SV="$PROD_STUB_SERVICE_PATH$PROD_STUB_SUPERVISION_CALLBACK" +RIC_G1_1=$RIC_SIM_PREFIX"_g3_1" +RIC_G1_2=$RIC_SIM_PREFIX"_g3_2" +if [ $RUNMODE == "KUBE" ]; then + RIC_G1_1=$(get_kube_sim_host $RIC_G1_1) + RIC_G1_2=$(get_kube_sim_host $RIC_G1_2) +fi +TARGET1="$RIC_SIM_HTTPX://$RIC_G1_1:$RIC_SIM_PORT/datadelivery" +TARGET2="$RIC_SIM_HTTPX://$RIC_G1_1:$RIC_SIM_PORT/datadelivery" -STATUS1="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job1-status" -STATUS2="$CR_HTTPX://$CR_APP_NAME:$CR_PORT/callbacks/job2-status" +STATUS1="$CR_SERVICE_PATH/callbacks/job1-status" +STATUS2="$CR_SERVICE_PATH/callbacks/job2-status" prodstub_arm_producer 200 prod-a prodstub_arm_type 200 prod-a type1 prodstub_arm_job_create 200 prod-a job1 prodstub_arm_job_create 200 prod-a job2 - ### ecs status ecs_api_service_status 200 +## Setup prod-a +if [ $ECS_VERSION == "V1-1" ]; then + ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json +else + ecs_api_edp_put_type_2 201 type1 testdata/ecs/ei-type-1.json -## Setup prod-a -ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + ecs_api_edp_put_producer_2 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 -ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json + ecs_api_edp_get_producer_2 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 +fi ecs_api_edp_get_producer_status 200 prod-a ENABLED @@ -197,9 +228,6 @@ fi # Check the job data in the producer prodstub_check_jobdata 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json - - - check_policy_agent_logs check_ecs_logs check_sdnc_logs diff --git a/test/auto-test/README.md b/test/auto-test/README.md index 82ff47b9..005ee0a4 100644 --- a/test/auto-test/README.md +++ b/test/auto-test/README.md @@ -15,7 +15,7 @@ The test scripts uses configuration from a single file, found in `../common/test ## How to run A test script, for example FTC1, is executed from the cmd line using the script filename and one or more parameters: - ./FTC1.sh remote --env-file ../common/test_env-oran-cherry + ./FTC1.sh remote --env-file ../common/test_env-oran-cherry.sh See the README.md in `../common/` for all details about available parameters and their meaning. diff --git a/test/common/.gitignore b/test/common/.gitignore new file mode 100644 index 00000000..bc68808f --- /dev/null +++ b/test/common/.gitignore @@ -0,0 +1 @@ +NO-CHECKIN diff --git a/test/common/README.md b/test/common/README.md index 21475c0e..b4754cd3 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -68,18 +68,22 @@ The script can be started with these arguments | arg list | |--| -| `local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix ] [ --env-file ] [--use-local-image []*]` | +| `remote|remote-remove --env-file [release] [auto-clean] [--stop-at-error] [--ricsim-prefix ] [--use-local-image +] [--use-snapshot-image +] [--use-staging-image +] [--use-release-image +]` | | parameter | description | |-|-| -| `local` | only locally built images (in local docker respository) will be used for the Non-RT RIC components. CBS, Consul, DB will still use remote nexus images | -| `remote` | only remote images from nexus will be used. Images pulled if not present in local docker repository | -| `remote-remove` | same as remote but all images are removed first so that fresh images are pulled when running | -| `auto-clean` | all containers will be automatically stopped and removed when the test case is complete. Requires the function 'auto_clean_containers' to be included last in the applicable auto-test script | -| `--stop-at-error` | intended for debugging and make the script stop at first 'FAIL' and save all logs with a prefix 'STOP_AT_ERROR' | -| `--ricsim-prefix ` | use another prefix for the ric simulator container name than the standard 'ricsim'. Note that the testscript has to read and use the env var `$RIC_SIM_PREFIX` instead of a hardcoded name of the ric(s). | -| `--env-file` | point to a file with environment variables (the previous default, test_env.sh, replaced with one env file for each branch in test/common) | -| `--use-local-image []*` | only applicable when running as 'remote' or 'remote-remove'. Mainly for debugging when a locally built image shall be used together with other remote images from nexus.Accepts a space separated list of PA, CP, RICSIM, SDNC, RC for Policy Agent, Control Panel, A1-controller, Ric simulator, RAPP Catalogue | +| `remote` | Use images from remote repositories. Can be overridden for individual images using the '--use_xxx' flags | +| `remote-remove` | Same as 'remote' but will also try to pull fresh images from remote repositories | +| `--env-file` | The script will use the supplied file to read environment variables from | +| `release` | If this flag is given the script will use release version of the images | +| `auto-clean` | If the function 'auto_clean_containers' is present in the end of the test script then all containers will be stopped and removed. If 'auto-clean' is not given then the function has no effect | +| `--stop-at-error` | The script will stop when the first failed test or configuration | +| `--ricsim-prefix ` | The a1 simulator will use the supplied string as container prefix instead of 'ricsim'. Note that the testscript has to read and use the env var `$RIC_SIM_PREFIX` instead of a hardcoded name of the ric(s). | +| `--use-local-image` | The script will use local images for the supplied apps, space separated list of app short names | +| `--use-snapshot-image` | The script will use images from the nexus snapshot repo for the supplied apps, space separated list of app short names | +| `--use-staging-image` | The script will use images from the nexus staging repo for the supplied apps, space separated list of app short names | +| `--use-release-image` | The script will use images from the nexus release repo for the supplied apps, space separated list of app short names | +| `help` | Print this info along with the test script description and the list of app short names supported | ## Function: print_result ## diff --git a/test/common/agent_api_functions.sh b/test/common/agent_api_functions.sh index fbd9fc49..1cd430eb 100644 --- a/test/common/agent_api_functions.sh +++ b/test/common/agent_api_functions.sh @@ -17,11 +17,283 @@ # ============LICENSE_END================================================= # -# This is a script that contains specific test functions for Policy Agent API +# This is a script that contains management and test functions for Policy Agent -### API functiond towards the Policy Agent -. ../common/api_curl.sh +## Access to Policy agent +# Host name may be changed if app started by kube +# Direct access from script +PA_HTTPX="http" +PA_HOST_NAME=$LOCALHOST_NAME +PA_PATH=$PA_HTTPX"://"$PA_HOST_NAME":"$POLICY_AGENT_EXTERNAL_PORT + +# PA_ADAPTER used for switch between REST and DMAAP +PA_ADAPTER_TYPE="REST" +PA_ADAPTER=$PA_PATH + +# Make curl retries towards the agent for http response codes set in this env var, space separated list of codes +AGENT_RETRY_CODES="" + +########################### +### Policy Agents functions +########################### + +# All calls to the agent will be directed to the agent REST interface from now on +# args: - +# (Function for test scripts) +use_agent_rest_http() { + echo -e $BOLD"Agent protocol setting"$EBOLD + echo -e " Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards the agent" + PA_HTTPX="http" + PA_PATH=$PA_HTTPX"://"$PA_HOST_NAME":"$POLICY_AGENT_EXTERNAL_PORT + + PA_ADAPTER_TYPE="REST" + PA_ADAPTER=$PA_PATH + echo "" +} + +# All calls to the agent will be directed to the agent REST interface from now on +# args: - +# (Function for test scripts) +use_agent_rest_https() { + echo -e $BOLD"Agent protocol setting"$EBOLD + echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards the agent" + PA_HTTPX="https" + PA_PATH=$PA_HTTPX"://"$PA_HOST_NAME":"$POLICY_AGENT_EXTERNAL_SECURE_PORT + + PA_ADAPTER_TYPE="REST" + PA_ADAPTER=$PA_PATH + echo "" +} + +# All calls to the agent will be directed to the agent dmaap interface over http from now on +# args: - +# (Function for test scripts) +use_agent_dmaap_http() { + echo -e $BOLD"Agent dmaap protocol setting"$EBOLD + echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards the agent" + PA_ADAPTER_TYPE="MR-HTTP" + echo "" +} + +# All calls to the agent will be directed to the agent dmaap interface over https from now on +# args: - +# (Function for test scripts) +use_agent_dmaap_https() { + echo -e $BOLD"Agent dmaap protocol setting"$EBOLD + echo -e " Using $BOLD https $EBOLD and $BOLD DMAAP $EBOLD towards the agent" + echo -e $YELLOW" Setting http instead of https - MR only uses http"$EYELLOW + PA_ADAPTER_TYPE="MR-HTTPS" + echo "" +} + +# Start the policy agent +# args: (kube only) PROXY|NOPROXY [ ] +# (Function for test scripts) +start_policy_agent() { + echo -e $BOLD"Starting $POLICY_AGENT_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + + # Check if app shall be fully managed by the test script + __check_included_image "PA" + retcode_i=$? + + # Check if app shall only be used by the testscipt + __check_prestarted_image "PA" + retcode_p=$? + + if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then + echo -e $RED"The $POLICY_AGENT_APP_NAME app is not included as managed nor prestarted in this test script"$ERED + echo -e $RED"The $POLICY_AGENT_APP_NAME will not be started"$ERED + exit + fi + if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then + echo -e $RED"The $POLICY_AGENT_APP_NAME app is included both as managed and prestarted in this test script"$ERED + echo -e $RED"The $POLICY_AGENT_APP_NAME will not be started"$ERED + exit + fi + + if [ $retcode_p -eq 0 ]; then + echo -e " Using existing $POLICY_AGENT_APP_NAME deployment and service" + echo " Setting $POLICY_AGENT_APP_NAME replicas=1" + __kube_scale deployment $POLICY_AGENT_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1 + fi + + if [ $retcode_i -eq 0 ]; then + + echo -e " Creating $POLICY_AGENT_APP_NAME app and expose service" + + #Check if nonrtric namespace exists, if not create it + __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE + + #Export all vars needed for service and deployment + export POLICY_AGENT_APP_NAME + export KUBE_NONRTRIC_NAMESPACE + export POLICY_AGENT_IMAGE + export POLICY_AGENT_INTERNAL_PORT + export POLICY_AGENT_INTERNAL_SECURE_PORT + export POLICY_AGENT_EXTERNAL_PORT + export POLICY_AGENT_EXTERNAL_SECURE_PORT + export POLICY_AGENT_CONFIG_MOUNT_PATH + export POLICY_AGENT_DATA_MOUNT_PATH + export POLICY_AGENT_CONFIG_CONFIGMAP_NAME=$POLICY_AGENT_APP_NAME"-config" + export POLICY_AGENT_DATA_CONFIGMAP_NAME=$POLICY_AGENT_APP_NAME"-data" + export POLICY_AGENT_PKG_NAME + if [ $1 == "PROXY" ]; then + AGENT_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT #Set if proxy is started + AGENT_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started + else + AGENT_HTTP_PROXY_CONFIG_PORT=0 + AGENT_HTTP_PROXY_CONFIG_HOST_NAME="" + fi + export AGENT_HTTP_PROXY_CONFIG_PORT + export AGENT_HTTP_PROXY_CONFIG_HOST_NAME + + + # Create config map for config + configfile=$PWD/tmp/$POLICY_AGENT_CONFIG_FILE + cp $2 $configfile + output_yaml=$PWD/tmp/pa_cfc.yaml + __kube_create_configmap $POLICY_AGENT_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest PA $configfile $output_yaml + + # Create config map for data + data_json=$PWD/tmp/$POLICY_AGENT_DATA_FILE + if [ $# -lt 3 ]; then + #create empty dummy file + echo "{}" > $data_json + else + cp $3 $data_json + fi + output_yaml=$PWD/tmp/pa_cfd.yaml + __kube_create_configmap $POLICY_AGENT_DATA_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest PA $data_json $output_yaml + + # Create service + input_yaml=$SIM_GROUP"/"$POLICY_AGENT_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/pa_svc.yaml + __kube_create_instance service $POLICY_AGENT_APP_NAME $input_yaml $output_yaml + + # Create app + input_yaml=$SIM_GROUP"/"$POLICY_AGENT_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/pa_app.yaml + __kube_create_instance app $POLICY_AGENT_APP_NAME $input_yaml $output_yaml + + fi + + echo " Retrieving host and ports for service..." + PA_HOST_NAME=$(__kube_get_service_host $POLICY_AGENT_APP_NAME $KUBE_NONRTRIC_NAMESPACE) + POLICY_AGENT_EXTERNAL_PORT=$(__kube_get_service_port $POLICY_AGENT_APP_NAME $KUBE_NONRTRIC_NAMESPACE "http") + POLICY_AGENT_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $POLICY_AGENT_APP_NAME $KUBE_NONRTRIC_NAMESPACE "https") + + echo " Host IP, http port, https port: $PA_HOST_NAME $POLICY_AGENT_EXTERNAL_PORT $POLICY_AGENT_EXTERNAL_SECURE_PORT" + + if [ $PA_HTTPX == "http" ]; then + PA_PATH=$PA_HTTPX"://"$PA_HOST_NAME":"$POLICY_AGENT_EXTERNAL_PORT + else + PA_PATH=$PA_HTTPX"://"$PA_HOST_NAME":"$POLICY_AGENT_EXTERNAL_SECURE_PORT + fi + __check_service_start $POLICY_AGENT_APP_NAME $PA_PATH$POLICY_AGENT_ALIVE_URL + + if [ $PA_ADAPTER_TYPE == "REST" ]; then + PA_ADAPTER=$PA_PATH + fi + else + __check_included_image 'PA' + if [ $? -eq 1 ]; then + echo -e $RED"The Policy Agent app is not included in this test script"$ERED + echo -e $RED"The Policy Agent will not be started"$ERED + exit + fi + + #Export all vars needed for docker-compose + export POLICY_AGENT_APP_NAME + export POLICY_AGENT_APP_NAME_ALIAS + export POLICY_AGENT_INTERNAL_PORT + export POLICY_AGENT_EXTERNAL_PORT + export POLICY_AGENT_INTERNAL_SECURE_PORT + export POLICY_AGENT_EXTERNAL_SECURE_PORT + export CONSUL_HOST + export CONSUL_INTERNAL_PORT + export CONFIG_BINDING_SERVICE + export POLICY_AGENT_CONFIG_KEY + export DOCKER_SIM_NWNAME + export POLICY_AGENT_HOST_MNT_DIR + export POLICY_AGENT_CONFIG_MOUNT_PATH + export POLICY_AGENT_CONFIG_FILE + export POLICY_AGENT_PKG_NAME + + if [ $1 == "PROXY" ]; then + AGENT_HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_CONFIG_PORT #Set if proxy is started + AGENT_HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_CONFIG_HOST_NAME #Set if proxy is started + else + AGENT_HTTP_PROXY_CONFIG_PORT=0 + AGENT_HTTP_PROXY_CONFIG_HOST_NAME="" + fi + export AGENT_HTTP_PROXY_CONFIG_PORT + export AGENT_HTTP_PROXY_CONFIG_HOST_NAME + + dest_file=$SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_HOST_MNT_DIR/application.yaml + + envsubst < $2 > $dest_file + + __start_container $POLICY_AGENT_COMPOSE_DIR NODOCKERARGS 1 $POLICY_AGENT_APP_NAME + + __check_service_start $POLICY_AGENT_APP_NAME $PA_PATH$POLICY_AGENT_ALIVE_URL + fi + echo "" + return 0 +} + +agent_load_config() { + echo -e $BOLD"Agent - load config from "$EBOLD$1 + data_json=$PWD/tmp/$POLICY_AGENT_DATA_FILE + cp $1 $data_json + output_yaml=$PWD/tmp/pa_cfd.yaml + __kube_create_configmap $POLICY_AGENT_APP_NAME"-data" $KUBE_NONRTRIC_NAMESPACE autotest PA $data_json $output_yaml +} + + +# Turn on debug level tracing in the agent +# args: - +# (Function for test scripts) +set_agent_debug() { + echo -e $BOLD"Setting agent debug logging"$EBOLD + curlString="$PA_PATH$POLICY_AGENT_ACTUATOR -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}" + result=$(__do_curl "$curlString") + if [ $? -ne 0 ]; then + __print_err "could not set debug mode" $@ + ((RES_CONF_FAIL++)) + return 1 + fi + echo "" + return 0 +} + +# Turn on trace level tracing in the agent +# args: - +# (Function for test scripts) +set_agent_trace() { + echo -e $BOLD"Setting agent trace logging"$EBOLD + curlString="$PA_PATH$POLICY_AGENT_ACTUATOR -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}" + result=$(__do_curl "$curlString") + if [ $? -ne 0 ]; then + __print_err "could not set trace mode" $@ + ((RES_CONF_FAIL++)) + return 1 + fi + echo "" + return 0 +} + +# Perform curl retries when making direct call to the agent for the specified http response codes +# Speace separated list of http response codes +# args: []* +use_agent_retries() { + echo -e $BOLD"Do curl retries to the agent REST inteface for these response codes:$@"$EBOLD + AGENT_RETRY_CODES=$@ + echo "" + return +} ######################################################### #### Test case functions A1 Policy management service @@ -36,9 +308,9 @@ api_equal() { if [ $# -eq 2 ] || [ $# -eq 3 ]; then if [[ $1 == "json:"* ]]; then if [ "$PMS_VERSION" == "V2" ]; then - __var_test "Policy Agent" $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT"/v2/" $1 "=" $2 $3 + __var_test "Policy Agent" $PA_PATH$PMS_API_PREFIX"/v2/" $1 "=" $2 $3 else - __var_test "Policy Agent" $LOCALHOST$POLICY_AGENT_EXTERNAL_PORT"/" $1 "=" $2 $3 + __var_test "Policy Agent" $PA_PATH"/" $1 "=" $2 $3 fi return 0 fi @@ -546,7 +818,8 @@ api_put_policy_parallel() { count=$1; shift; pids=$1; shift; - if [ $ADAPTER != $RESTBASE ] && [ $ADAPTER != $RESTBASE_SECURE ]; then + #if [ $PA_ADAPTER != $RESTBASE ] && [ $PA_ADAPTER != $RESTBASE_SECURE ]; then + if [ $__ADAPTER_TYPE != "REST" ]; then echo " Info - api_put_policy_parallel uses only the agent REST interface - create over dmaap in parallel is not supported" echo " Info - will execute over agent REST" fi @@ -570,7 +843,7 @@ api_put_policy_parallel() { fi fi - urlbase=${ADAPTER}${query} + urlbase=${PA_ADAPTER}${query} for ((i=1; i<=$pids; i++)) do @@ -746,7 +1019,8 @@ api_delete_policy_parallel() { count=$1; shift; pids=$1; shift; - if [ $ADAPTER != $RESTBASE ] && [ $ADAPTER != $RESTBASE_SECURE ]; then + #if [ $PA_ADAPTER != $RESTBASE ] && [ $PA_ADAPTER != $RESTBASE_SECURE ]; then + if [ $__ADAPTER_TYPE != "REST" ]; then echo " Info - api_delete_policy_parallel uses only the agent REST interface - create over dmaap in parallel is not supported" echo " Info - will execute over agent REST" fi @@ -757,7 +1031,7 @@ api_delete_policy_parallel() { query="/policy" fi - urlbase=${ADAPTER}${query} + urlbase=${PA_ADAPTER}${query} for ((i=1; i<=$pids; i++)) do diff --git a/test/common/api_curl.sh b/test/common/api_curl.sh index c7e5c908..1ea47dd6 100644 --- a/test/common/api_curl.sh +++ b/test/common/api_curl.sh @@ -19,41 +19,46 @@ # Generic function to query the agent/ECS via the REST or DMAAP interface. # Used by all other agent/ECS api test functions -# If operation prefix is '_BATCH' the the send and get response is split in two sequences, +# If operation sufffix is '_BATCH' the the send and get response is split in two sequences, # one for sending the requests and one for receiving the response # but only when using the DMAAP interface -# REST or DMAAP is controlled of the base url of $ADAPTER -# arg: (PA|ECS|CR|RC GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH []) | (PA|ECS RESPONSE ) +# REST or DMAAP is controlled of the base url of $XX_ADAPTER +# arg: (PA|ECS|CR|RC GET|PUT|POST|DELETE|GET_BATCH|PUT_BATCH|POST_BATCH|DELETE_BATCH | []) | (PA|ECS RESPONSE ) # (Not for test scripts) __do_curl_to_api() { TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S") echo " (${BASH_LINENO[0]}) - ${TIMESTAMP}: ${FUNCNAME[0]}" $@ >> $HTTPLOG paramError=0 - + input_url=$3 if [ $# -gt 0 ]; then if [ $1 == "PA" ]; then - __ADAPTER=$ADAPTER - __RESTBASE=$RESTBASE - __RESTBASE_SECURE=$RESTBASE_SECURE + __ADAPTER=$PA_ADAPTER + __ADAPTER_TYPE=$PA_ADAPTER_TYPE __RETRY_CODES=$AGENT_RETRY_CODES + if [ $PMS_VERSION != "V1" ]; then + input_url=$PMS_API_PREFIX$3 + fi elif [ $1 == "ECS" ]; then - __ADAPTER=$ECS_ADAPTER - __RESTBASE=$ECS_RESTBASE - __RESTBASE_SECURE=$ECS_RESTBASE_SECURE + __ADAPTER=$ECS_ADAPTER + __ADAPTER_TYPE=$ECS_ADAPTER_TYPE __RETRY_CODES=$ECS_RETRY_CODES elif [ $1 == "CR" ]; then - __ADAPTER=$CR_ADAPTER - __RESTBASE=$CR_RESTBASE - __RESTBASE_SECURE=$CR_RESTBASE_SECURE + __ADAPTER=$CR_ADAPTER + __ADAPTER_TYPE=$CR_ADAPTER_TYPE __RETRY_CODES="" elif [ $1 == "RC" ]; then - __ADAPTER=$RC_ADAPTER - __RESTBASE=$RC_RESTBASE - __RESTBASE_SECURE=$RC_RESTBASE_SECURE + __ADAPTER=$RC_ADAPTER + __ADAPTER_TYPE=$RC_ADAPTER_TYPE __RETRY_CODES="" else paramError=1 fi + if [ $__ADAPTER_TYPE == "MR-HTTP" ]; then + __ADAPTER=$MR_ADAPTER_HTTP + fi + if [ $__ADAPTER_TYPE == "MR-HTTPS" ]; then + __ADAPTER=$MR_ADAPTER_HTTPS + fi fi if [ $# -lt 3 ] || [ $# -gt 4 ]; then paramError=1 @@ -98,7 +103,8 @@ __do_curl_to_api() { if [ $# -ne 3 ]; then paramError=1 fi - if [ $__ADAPTER == $__RESTBASE ] || [ $__ADAPTER == $__RESTBASE_SECURE ]; then + #if [ $__ADAPTER == $__RESTBASE ] || [ $__ADAPTER == $__RESTBASE_SECURE ]; then + if [ $__ADAPTER_TYPE == "REST" ]; then paramError=1 fi else @@ -115,8 +121,9 @@ __do_curl_to_api() { return 1 fi - if [ $__ADAPTER == $__RESTBASE ] || [ $__ADAPTER == $__RESTBASE_SECURE ]; then - url=" "${__ADAPTER}${3} + #if [ $__ADAPTER == $__RESTBASE ] || [ $__ADAPTER == $__RESTBASE_SECURE ]; then + if [ $__ADAPTER_TYPE == "REST" ]; then + url=" "${__ADAPTER}${input_url} oper=" -X "$oper curlString="curl -k "${oper}${timeout}${httpcode}${accept}${content}${url}${file} echo " CMD: "$curlString >> $HTTPLOG @@ -156,7 +163,7 @@ __do_curl_to_api() { return 0 else if [ $oper != "RESPONSE" ]; then - requestUrl=$3 + requestUrl=$input_url if [ $2 == "PUT" ] && [ $# -eq 4 ]; then payload="$(cat $4 | tr -d '\n' | tr -d ' ' )" echo "payload: "$payload >> $HTTPLOG @@ -165,7 +172,7 @@ __do_curl_to_api() { echo " FILE: $(cat $4)" >> $HTTPLOG fi #urlencode the request url since it will be carried by send-request url - requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$3") + requestUrl=$(python3 -c "from __future__ import print_function; import urllib.parse, sys; print(urllib.parse.quote(sys.argv[1]))" "$input_url") url=" "${__ADAPTER}"/send-request?url="${requestUrl}"&operation="${oper} curlString="curl -k -X POST${timeout}${httpcode}${content}${url}${file}" echo " CMD: "$curlString >> $HTTPLOG diff --git a/test/common/clean_kube.sh b/test/common/clean_kube.sh new file mode 100755 index 00000000..ea17eeef --- /dev/null +++ b/test/common/clean_kube.sh @@ -0,0 +1,91 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2021 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= + +# Script to clean all resources from kubernetes having the label 'autotest', i.e started by autotest + +BOLD="\033[1m" +EBOLD="\033[0m" +RED="\033[31m\033[1m" +ERED="\033[0m" +GREEN="\033[32m\033[1m" +EGREEN="\033[0m" +YELLOW="\033[33m\033[1m" +EYELLOW="\033[0m" +SAMELINE="\033[0K\r" + +__kube_delete_all_resources() { + echo "Deleting all from namespace: "$1 + namespace=$1 + resources="deployments replicaset statefulset services pods configmaps pvc" + deleted_resourcetypes="" + for restype in $resources; do + result=$(kubectl get $restype -n $namespace -o jsonpath='{.items[?(@.metadata.labels.autotest)].metadata.name}') + if [ $? -eq 0 ] && [ ! -z "$result" ]; then + deleted_resourcetypes=$deleted_resourcetypes" "$restype + for resid in $result; do + if [ $restype == "replicaset" ] || [ $restype == "statefulset" ]; then + kubectl scale $restype $resid -n $namespace --replicas=0 1> /dev/null 2> /dev/null + T_START=$SECONDS + count=1 + while [ $count -ne 0 ]; do + count=$(kubectl get $restype $resid -n $namespace -o jsonpath='{.status.replicas}' 2> /dev/null) + echo -ne " Scaling $restype $resid from namespace $namespace with label autotest to 0,count=$count....$(($SECONDS-$T_START)) seconds"$SAMELINE + if [ $? -eq 0 ] && [ ! -z "$count" ]; then + sleep 0.5 + else + count=0 + fi + done + echo -e " Scaled $restype $resid from namespace $namespace with label $labelname=$labelid to 0,count=$count....$(($SECONDS-$T_START)) seconds$GREEN OK $EGREEN" + fi + echo -ne " Deleting $restype $resid from namespace $namespace with label autotest "$SAMELINE + kubectl delete $restype $resid -n $namespace 1> /dev/null 2> /dev/null + if [ $? -eq 0 ]; then + echo -e " Deleted $restype $resid from namespace $namespace with label autotest $GREEN OK $EGREEN" + else + echo -e " Deleted $restype $resid from namespace $namespace with label autotest $GREEN Does not exist - OK $EGREEN" + fi + #fi + done + fi + done + if [ ! -z "$deleted_resourcetypes" ]; then + for restype in $deleted_resources; do + echo -ne " Waiting for $restype in namespace $namespace with label autotest to be deleted..."$SAMELINE + T_START=$SECONDS + result="dummy" + while [ ! -z "$result" ]; do + sleep 0.5 + result=$(kubectl get $restype -n $namespace -o jsonpath='{.items[?(@.metadata.labels.autotest)].metadata.name}') + echo -ne " Waiting for $restype in namespace $namespace with label autotest to be deleted...$(($SECONDS-$T_START)) seconds "$SAMELINE + if [ -z "$result" ]; then + echo -e " Waiting for $restype in namespace $namespace with label autotest to be deleted...$(($SECONDS-$T_START)) seconds $GREEN OK $EGREEN" + elif [ $(($SECONDS-$T_START)) -gt 300 ]; then + echo -e " Waiting for $restype in namespace $namespace with label autotest to be deleted...$(($SECONDS-$T_START)) seconds $RED Failed $ERED" + result="" + fi + done + done + fi +} +echo "Will remove all kube resources marked with label 'autotest'" +__kube_delete_all_resources nonrtric +__kube_delete_all_resources nonrtric-ft +__kube_delete_all_resources onap + +echo "Done" \ No newline at end of file diff --git a/test/common/consul_cbs_functions.sh b/test/common/consul_cbs_functions.sh new file mode 100644 index 00000000..a3c08fa8 --- /dev/null +++ b/test/common/consul_cbs_functions.sh @@ -0,0 +1,219 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# + +# This is a script that contains container/service management functions and test functions for Consul/CBS + +CONSUL_PATH="http://$LOCALHOST:$CONSUL_EXTERNAL_PORT" + +#################### +### Consul functions +#################### + +# Function to load config from a file into consul for the Policy Agent +# arg: +# (Function for test scripts) +consul_config_app() { + + echo -e $BOLD"Configuring Consul"$EBOLD + + if [ $# -ne 1 ]; then + ((RES_CONF_FAIL++)) + __print_err "need one arg, " $@ + exit 1 + fi + + echo " Loading config for "$POLICY_AGENT_APP_NAME" from "$1 + + curlString="$LOCALHOST_HTTP:${CONSUL_EXTERNAL_PORT}/v1/kv/${POLICY_AGENT_CONFIG_KEY}?dc=dc1 -X PUT -H Accept:application/json -H Content-Type:application/json -H X-Requested-With:XMLHttpRequest --data-binary @"$1 + result=$(__do_curl "$curlString") + if [ $? -ne 0 ]; then + echo -e $RED" FAIL - json config could not be loaded to consul" $ERED + ((RES_CONF_FAIL++)) + return 1 + fi + body="$(__do_curl $LOCALHOST_HTTP:$CBS_EXTERNAL_PORT/service_component_all/$POLICY_AGENT_CONFIG_KEY)" + echo $body > "./tmp/.output"$1 + + if [ $? -ne 0 ]; then + echo -e $RED" FAIL - json config could not be loaded from consul/cbs, contents cannot be checked." $ERED + ((RES_CONF_FAIL++)) + return 1 + else + targetJson=$(< $1) + targetJson="{\"config\":"$targetJson"}" + echo "TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + if [ $res -ne 0 ]; then + echo -e $RED" FAIL - policy json config read from consul/cbs is not equal to the intended json config...." $ERED + ((RES_CONF_FAIL++)) + return 1 + else + echo -e $GREEN" Config loaded ok to consul"$EGREEN + fi + fi + + echo "" + +} + +# Function to perpare the consul configuration according to the current simulator configuration +# args: SDNC|NOSDNC +# (Function for test scripts) +prepare_consul_config() { + echo -e $BOLD"Prepare Consul config"$EBOLD + + echo " Writing consul config for "$POLICY_AGENT_APP_NAME" to file: "$2 + + if [ $# != 2 ]; then + ((RES_CONF_FAIL++)) + __print_err "need two args, SDNC|NOSDNC " $@ + exit 1 + fi + + if [ $1 == "SDNC" ]; then + echo -e " Config$BOLD including SDNC$EBOLD configuration" + elif [ $1 == "NOSDNC" ]; then + echo -e " Config$BOLD excluding SDNC$EBOLD configuration" + else + ((RES_CONF_FAIL++)) + __print_err "need two args, SDNC|NOSDNC " $@ + exit 1 + fi + + config_json="\n {" + if [ $1 == "SDNC" ]; then + config_json=$config_json"\n \"controller\": [" + config_json=$config_json"\n {" + config_json=$config_json"\n \"name\": \"$SDNC_APP_NAME\"," + config_json=$config_json"\n \"baseUrl\": \"$SDNC_SERVICE_PATH\"," + config_json=$config_json"\n \"userName\": \"$SDNC_USER\"," + config_json=$config_json"\n \"password\": \"$SDNC_PWD\"" + config_json=$config_json"\n }" + config_json=$config_json"\n ]," + fi + + config_json=$config_json"\n \"streams_publishes\": {" + config_json=$config_json"\n \"dmaap_publisher\": {" + config_json=$config_json"\n \"type\": \"message-router\"," + config_json=$config_json"\n \"dmaap_info\": {" + config_json=$config_json"\n \"topic_url\": \"$MR_SERVICE_PATH$MR_WRITE_URL\"" + config_json=$config_json"\n }" + config_json=$config_json"\n }" + config_json=$config_json"\n }," + config_json=$config_json"\n \"streams_subscribes\": {" + config_json=$config_json"\n \"dmaap_subscriber\": {" + config_json=$config_json"\n \"type\": \"message-router\"," + config_json=$config_json"\n \"dmaap_info\": {" + config_json=$config_json"\n \"topic_url\": \"$MR_SERVICE_PATH$MR_READ_URL\"" + config_json=$config_json"\n }" + config_json=$config_json"\n }" + config_json=$config_json"\n }," + + config_json=$config_json"\n \"ric\": [" + + if [ $RUNMODE == "KUBE" ]; then + result=$(kubectl get pods -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.items[?(@.metadata.labels.autotest=="RICSIM")].metadata.name}') + rics="" + ric_cntr=0 + if [ $? -eq 0 ] && [ ! -z "$result" ]; then + for im in $result; do + if [[ $im != *"-0" ]]; then + ric_subdomain=$(kubectl get pod $im -n $KUBE_NONRTRIC_NAMESPACE -o jsonpath='{.spec.subdomain}') + rics=$rics" "$im"."$ric_subdomain".nonrtric" + let ric_cntr=ric_cntr+1 + fi + done + fi + if [ $ric_cntr -eq 0 ]; then + echo $YELLOW"Warning: No rics found for the configuration"$EYELLOW + fi + else + rics=$(docker ps | grep $RIC_SIM_PREFIX | awk '{print $NF}') + + if [ $? -ne 0 ] || [ -z "$rics" ]; then + echo -e $RED" FAIL - the names of the running RIC Simulator cannot be retrieved." $ERED + ((RES_CONF_FAIL++)) + return 1 + fi + fi + cntr=0 + for ric in $rics; do + if [ $cntr -gt 0 ]; then + config_json=$config_json"\n ," + fi + config_json=$config_json"\n {" + if [ $RUNMODE == "KUBE" ]; then + ric_id=${ric%.*.*} #extract pod id from full hosthame + ric_id=$(echo "$ric_id" | tr '-' '_') + else + ric_id=$ric + fi + config_json=$config_json"\n \"name\": \"$ric_id\"," + config_json=$config_json"\n \"baseUrl\": \"$RIC_SIM_HTTPX://$ric:$RIC_SIM_PORT\"," + if [ $1 == "SDNC" ]; then + config_json=$config_json"\n \"controller\": \"$SDNC_APP_NAME\"," + fi + config_json=$config_json"\n \"managedElementIds\": [" + config_json=$config_json"\n \"me1_$ric_id\"," + config_json=$config_json"\n \"me2_$ric_id\"" + config_json=$config_json"\n ]" + config_json=$config_json"\n }" + let cntr=cntr+1 + done + + config_json=$config_json"\n ]" + config_json=$config_json"\n}" + + if [ $RUNMODE == "KUBE" ]; then + config_json="{\"config\":"$config_json"}" + fi + + printf "$config_json">$2 + + echo "" +} + +# Start Consul and CBS +# args: - +# (Function for test scripts) +start_consul_cbs() { + + echo -e $BOLD"Starting $CONSUL_DISPLAY_NAME and $CBS_DISPLAY_NAME"$EBOLD + __check_included_image 'CONSUL' + if [ $? -eq 1 ]; then + echo -e $RED"The Consul image has not been checked for this test run due to arg to the test script"$ERED + echo -e $RED"Consul will not be started"$ERED + exit + fi + export CONSUL_APP_NAME + export CONSUL_INTERNAL_PORT + export CONSUL_EXTERNAL_PORT + export CBS_APP_NAME + export CBS_INTERNAL_PORT + export CBS_EXTERNAL_PORT + export CONSUL_HOST + + __start_container $CONSUL_CBS_COMPOSE_DIR NODOCKERARGS 2 $CONSUL_APP_NAME $CBS_APP_NAME + + __check_service_start $CONSUL_APP_NAME "http://"$LOCALHOST_NAME":"$CONSUL_EXTERNAL_PORT$CONSUL_ALIVE_URL + __check_service_start $CBS_APP_NAME "http://"$LOCALHOST_NAME":"$CBS_EXTERNAL_PORT$CBS_ALIVE_URL + + echo "" +} + diff --git a/test/common/control_panel_api_functions.sh b/test/common/control_panel_api_functions.sh new file mode 100644 index 00000000..9f179a1f --- /dev/null +++ b/test/common/control_panel_api_functions.sh @@ -0,0 +1,172 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# + +# This is a script that contains container/service management function +# and test functions for Control Panel + +## Access to control panel +# Host name may be changed if app started by kube +# Direct access from script +CP_HTTPX="http" +CP_HOST_NAME=$LOCALHOST_NAME +CP_PATH=$CP_HTTPX"://"$CP_HOST_NAME":"$CONTROL_PANEL_EXTERNAL_PORT + +########################### +### Control Panel functions +########################### + +# Set http as the protocol to use for all communication to the Control Panel +# args: - +# (Function for test scripts) +use_control_panel_http() { + echo -e $BOLD"Control Panel, CP, protocol setting"$EBOLD + echo -e " Using $BOLD http $EBOLD towards CP" + CP_HTTPX="http" + CP_PATH=$CP_HTTPX"://"$CP_HOST_NAME":"$CONTROL_PANEL_EXTERNAL_PORT + echo "" +} + +# Set https as the protocol to use for all communication to the Control Panel +# args: - +# (Function for test scripts) +use_control_panel_https() { + echo -e $BOLD"Control Panel, CP, protocol setting"$EBOLD + echo -e " Using $BOLD https $EBOLD towards CP" + CP_HTTPX="https" + CP_PATH=$CP_HTTPX"://"$CP_HOST_NAME":"$CONTROL_PANEL_EXTERNAL_SECURE_PORT + echo "" +} + +# Start the Control Panel container +# args: - +# (Function for test scripts) +start_control_panel() { + + echo -e $BOLD"Starting $CONTROL_PANEL_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + + # Check if app shall be fully managed by the test script + __check_included_image "CP" + retcode_i=$? + + # Check if app shall only be used by the testscipt + __check_prestarted_image "CP" + retcode_p=$? + + if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then + echo -e $RED"The $CONTROL_PANEL_APP_NAME app is not included as managed nor prestarted in this test script"$ERED + echo -e $RED"The $CONTROL_PANEL_APP_NAME will not be started"$ERED + exit + fi + if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then + echo -e $RED"The $CONTROL_PANEL_APP_NAME app is included both as managed and prestarted in this test script"$ERED + echo -e $RED"The $CONTROL_PANEL_APP_NAME will not be started"$ERED + exit + fi + + # Check if app shall be used - not managed - by the test script + __check_prestarted_image "CP" + if [ $? -eq 0 ]; then + echo -e " Using existing $CONTROL_PANEL_APP_NAME deployment and service" + echo " Setting CP replicas=1" + __kube_scale deployment $CONTROL_PANEL_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1 + fi + + if [ $retcode_i -eq 0 ]; then + + echo -e " Creating $CP_APP_NAME app and expose service" + + #Export all vars needed for service and deployment + export CONTROL_PANEL_APP_NAME + export KUBE_NONRTRIC_NAMESPACE + export CONTROL_PANEL_IMAGE + export CONTROL_PANEL_INTERNAL_PORT + export CONTROL_PANEL_INTERNAL_SECURE_PORT + export CONTROL_PANEL_EXTERNAL_PORT + export CONTROL_PANEL_EXTERNAL_SECURE_PORT + export CONTROL_PANEL_CONFIG_MOUNT_PATH + export CONTROL_PANEL_CONFIG_FILE + export CP_CONFIG_CONFIGMAP_NAME=$CONTROL_PANEL_APP_NAME"-config" + + export POLICY_AGENT_EXTERNAL_SECURE_PORT + export ECS_EXTERNAL_SECURE_PORT + export POLICY_AGENT_DOMAIN_NAME=$POLICY_AGENT_APP_NAME.$KUBE_NONRTRIC_NAMESPACE + export ECS_DOMAIN_NAME=$ECS_APP_NAME.$KUBE_NONRTRIC_NAMESPACE + + #Check if nonrtric namespace exists, if not create it + __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE + + # Create config map for config + datafile=$PWD/tmp/$CONTROL_PANEL_CONFIG_FILE + #Add config to properties file + envsubst < $1 > $datafile + output_yaml=$PWD/tmp/cp_cfc.yaml + __kube_create_configmap $CP_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest CP $datafile $output_yaml + + # Create service + input_yaml=$SIM_GROUP"/"$CONTROL_PANEL_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/cp_svc.yaml + __kube_create_instance service $CONTROL_PANEL_APP_NAME $input_yaml $output_yaml + + # Create app + input_yaml=$SIM_GROUP"/"$CONTROL_PANEL_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/cp_app.yaml + __kube_create_instance app $CONTROL_PANEL_APP_NAME $input_yaml $output_yaml + + fi + + echo " Retrieving host and ports for service..." + CP_HOST_NAME=$(__kube_get_service_host $CONTROL_PANEL_APP_NAME $KUBE_NONRTRIC_NAMESPACE) + + CONTROL_PANEL_EXTERNAL_PORT=$(__kube_get_service_port $CONTROL_PANEL_APP_NAME $KUBE_NONRTRIC_NAMESPACE "http") + CONTROL_PANEL_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $CONTROL_PANEL_APP_NAME $KUBE_NONRTRIC_NAMESPACE "https") + + echo " Host IP, http port, https port: $CP_HOST_NAME $CONTROL_PANEL_EXTERNAL_PORT $CONTROL_PANEL_EXTERNAL_SECURE_PORT" + if [ $CP_HTTPX == "http" ]; then + CP_PATH=$CP_HTTPX"://"$CP_HOST_NAME":"$CONTROL_PANEL_EXTERNAL_PORT + else + CP_PATH=$CP_HTTPX"://"$CP_HOST_NAME":"$CONTROL_PANEL_EXTERNAL_SECURE_PORT + fi + + __check_service_start $CONTROL_PANEL_APP_NAME $CP_PATH$CONTROL_PANEL_ALIVE_URL + else + # Check if docker app shall be fully managed by the test script + __check_included_image 'CP' + if [ $? -eq 1 ]; then + echo -e $RED"The Control Panel app is not included in this test script"$ERED + echo -e $RED"The Control Panel will not be started"$ERED + exit + fi + + # Export needed vars for docker compose + export CONTROL_PANEL_APP_NAME + export CONTROL_PANEL_INTERNAL_PORT + export CONTROL_PANEL_EXTERNAL_PORT + export CONTROL_PANEL_INTERNAL_SECURE_PORT + export CONTROL_PANEL_EXTERNAL_SECURE_PORT + export DOCKER_SIM_NWNAME + + __start_container $CONTROL_PANEL_COMPOSE_DIR NODOCKERARGS 1 $CONTROL_PANEL_APP_NAME + + __check_service_start $CONTROL_PANEL_APP_NAME $CP_PATH$CONTROL_PANEL_ALIVE_URL + fi + echo "" +} + diff --git a/test/common/controller_api_functions.sh b/test/common/controller_api_functions.sh index 4d568d76..9e601751 100644 --- a/test/common/controller_api_functions.sh +++ b/test/common/controller_api_functions.sh @@ -17,7 +17,178 @@ # ============LICENSE_END================================================= # -# This is a script that contains specific test functions for A1 Controller API +# This is a script that contains container/service management functions and test functions for A1 Controller API + +SDNC_HTTPX="http" +SDNC_HOST_NAME=$LOCALHOST_NAME +SDNC_PATH=$SDNC_HTTPX"://"$SDNC_HOST_NAME":"$SDNC_EXTERNAL_PORT +SDNC_API_PATH=$SDNC_HTTPX"://"$SDNC_USER":"$SDNC_PWD"@"$SDNC_HOST_NAME":"$SDNC_EXTERNAL_PORT$SDNC_API_URL +#Docker/Kube internal path +if [ $RUNMODE == "KUBE" ]; then + SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME":"$SDNC_EXTERNAL_PORT + #presume correct + SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME"."$KUBE_NONRTRIC_NAMESPACE":"$SDNC_EXTERNAL_PORT + #test + #SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME"."$KUBE_NONRTRIC_NAMESPACE":"$SDNC_EXTERNAL_PORT +else + SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME":"$SDNC_INTERNAL_PORT +fi + +use_sdnc_http() { + echo -e $BOLD"SDNC NB protocol setting"$EBOLD + echo -e " Using $BOLD http $EBOLD towards SDNC" + SDNC_HTTPX="http" + SDNC_PATH=$SDNC_HTTPX"://"$SDNC_HOST_NAME":"$SDNC_EXTERNAL_PORT + SDNC_API_PATH=$SDNC_HTTPX"://"$SDNC_USER":"$SDNC_PWD"@"$SDNC_HOST_NAME":"$SDNC_EXTERNAL_PORT$SDNC_API_URL + if [ $RUNMODE == "KUBE" ]; then + #presume correct + SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME"."$KUBE_NONRTRIC_NAMESPACE":"$SDNC_EXTERNAL_PORT + #test + #SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME":"$SDNC_EXTERNAL_PORT + else + SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME":"$SDNC_INTERNAL_PORT + fi + echo "" +} + +use_sdnc_https() { + echo -e $BOLD"SDNC NB protocol setting"$EBOLD + echo -e " Using $BOLD https $EBOLD towards SDNC" + SDNC_HTTPX="https" + SDNC_PATH=$SDNC_HTTPX"://"$SDNC_HOST_NAME":"$SDNC_EXTERNAL_SECURE_PORT + SDNC_API_PATH=$SDNC_HTTPX"://"$SDNC_USER":"$SDNC_PWD"@"$SDNC_HOST_NAME":"$SDNC_EXTERNAL_SECURE_PORT$SDNC_API_URL + if [ $RUNMODE == "KUBE" ]; then + #presume correct + SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME"."$KUBE_NONRTRIC_NAMESPACE":"$SDNC_EXTERNAL_SECURE_PORT + #test + #SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME":"$SDNC_EXTERNAL_SECURE_PORT + else + SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME":"$SDNC_INTERNAL_SECURE_PORT + fi + echo "" +} + +################## +### SDNC functions +################## + +# Start the SDNC A1 Controller +# args: - +# (Function for test scripts) +start_sdnc() { + + echo -e $BOLD"Starting $SDNC_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + + # Check if app shall be fully managed by the test script + __check_included_image "SDNC" + retcode_i=$? + + # Check if app shall only be used by the testscipt + __check_prestarted_image "SDNC" + retcode_p=$? + + if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then + echo -e $RED"The $SDNC_APP_NAME app is not included as managed nor prestarted in this test script"$ERED + echo -e $RED"The $SDNC_APP_NAME will not be started"$ERED + exit + fi + if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then + echo -e $RED"The $SDNC_APP_NAME app is included both as managed and prestarted in this test script"$ERED + echo -e $RED"The $SDNC_APP_NAME will not be started"$ERED + exit + fi + + + if [ $retcode_p -eq 0 ]; then + echo -e " Using existing $SDNC_APP_NAME deployment and service" + echo " Setting SDNC replicas=1" + __kube_scale deployment $SDNC_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1 + fi + + # Check if app shall be fully managed by the test script + if [ $retcode_i -eq 0 ]; then + + echo -e " Creating $SDNC_APP_NAME app and expose service" + + #Check if nonrtric namespace exists, if not create it + __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE + + export KUBE_NONRTRIC_NAMESPACE + export SDNC_APP_NAME + export SDNC_A1_CONTROLLER_IMAGE + export SDNC_INTERNAL_PORT + export SDNC_EXTERNAL_PORT + export SDNC_INTERNAL_SECURE_PORT + export SDNC_EXTERNAL_SECURE_PORT + export SDNC_A1_TRUSTSTORE_PASSWORD + export SDNC_DB_APP_NAME + export SDNC_DB_IMAGE + + # Create service + input_yaml=$SIM_GROUP"/"$SDNC_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/sdnc_svc.yaml + __kube_create_instance service $SDNC_APP_NAME $input_yaml $output_yaml + + # Create app + input_yaml=$SIM_GROUP"/"$SDNC_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/sdnc_app.yaml + __kube_create_instance app $SDNC_APP_NAME $input_yaml $output_yaml + + fi + + echo " Retrieving host and ports for service..." + SDNC_HOST_NAME=$(__kube_get_service_host $SDNC_APP_NAME $KUBE_NONRTRIC_NAMESPACE) + SDNC_EXTERNAL_PORT=$(__kube_get_service_port $SDNC_APP_NAME $KUBE_NONRTRIC_NAMESPACE "http") + SDNC_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $SDNC_APP_NAME $KUBE_NONRTRIC_NAMESPACE "https") + + echo " Host IP, http port, https port: $SDNC_HOST_NAME $SDNC_EXTERNAL_PORT $SDNC_EXTERNAL_SECURE_PORT" + + if [ $SDNC_HTTPX == "http" ]; then + SDNC_PATH=$SDNC_HTTPX"://"$SDNC_HOST_NAME":"$SDNC_EXTERNAL_PORT + SDNC_API_PATH=$SDNC_HTTPX"://"$SDNC_USER":"$SDNC_PWD"@"$SDNC_HOST_NAME":"$SDNC_EXTERNAL_PORT$SDNC_API_URL + #presume correct + SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME"."$KUBE_NONRTRIC_NAMESPACE":"$SDNC_EXTERNAL_PORT + #test + #SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME":"$SDNC_EXTERNAL_PORT + else + SDNC_PATH=$SDNC_HTTPX"://"$SDNC_HOST_NAME":"$SDNC_EXTERNAL_SECURE_PORT + SDNC_API_PATH=$SDNC_HTTPX"://"$SDNC_USER":"$SDNC_PWD"@"$SDNC_HOST_NAME":"$SDNC_EXTERNAL_SECURE_PORT$SDNC_API_URL + #presume correct + SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME"."$KUBE_NONRTRIC_NAMESPACE":"$SDNC_EXTERNAL_SECURE_PORT + #test + #SDNC_SERVICE_PATH=$SDNC_HTTPX"://"$SDNC_APP_NAME":"$SDNC_EXTERNAL_SECURE_PORT + fi + + __check_service_start $SDNC_APP_NAME $SDNC_PATH$SDNC_ALIVE_URL + else + + __check_included_image 'SDNC' + if [ $? -eq 1 ]; then + echo -e $RED"The SDNC A1 Controller app is not included in this test script"$ERED + echo -e $RED"The Policy Agent will not be started"$ERED + exit + fi + + export SDNC_DB_APP_NAME + export SDNC_APP_NAME + export SDNC_INTERNAL_PORT + export SDNC_EXTERNAL_PORT + export SDNC_INTERNAL_SECURE_PORT + export SDNC_EXTERNAL_SECURE_PORT + export SDNC_A1_TRUSTSTORE_PASSWORD + export DOCKER_SIM_NWNAME + + __start_container $SDNC_COMPOSE_DIR NODOCKERARGS 1 $SDNC_APP_NAME + + __check_service_start $SDNC_APP_NAME $SDNC_PATH$SDNC_ALIVE_URL + fi + echo "" + return 0 +} + + # Generic function to query the RICs via the A1-controller API. # args: [] @@ -44,7 +215,7 @@ __do_curl_to_controller() { payload="./tmp/.sdnc.payload.json" echo "$json" > $payload echo " FILE ($payload) : $json" >> $HTTPLOG - curlString="curl -skw %{http_code} -X POST $SDNC_HTTPX://$SDNC_USER:$SDNC_PWD@localhost:$SDNC_LOCAL_PORT$SDNC_API_URL$1 -H accept:application/json -H Content-Type:application/json --data-binary @$payload" + curlString="curl -skw %{http_code} -X POST $SDNC_API_PATH$1 -H accept:application/json -H Content-Type:application/json --data-binary @$payload" echo " CMD: "$curlString >> $HTTPLOG res=$($curlString) retcode=$? @@ -77,12 +248,16 @@ __do_curl_to_controller() { controller_api_get_A1_policy_ids() { __log_test_start $@ + ric_id=$3 + if [ $RUNMODE == "KUBE" ]; then + ric_id=$(get_kube_sim_host $3) + fi paramError=1 if [ $# -gt 3 ] && [ $2 == "OSC" ]; then - url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/a1-p/policytypes/$4/policies" + url="$RIC_SIM_HTTPX://$ric_id:$RIC_SIM_PORT/a1-p/policytypes/$4/policies" paramError=0 elif [ $# -gt 2 ] && [ $2 == "STD" ]; then - url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/A1-P/v1/policies" + url="$RIC_SIM_HTTPX://$ric_id:$RIC_SIM_PORT/A1-P/v1/policies" paramError=0 fi @@ -139,9 +314,13 @@ controller_api_get_A1_policy_ids() { controller_api_get_A1_policy_type() { __log_test_start $@ + ric_id=$3 + if [ $RUNMODE == "KUBE" ]; then + ric_id=$(get_kube_sim_host $3) + fi paramError=1 if [ $# -gt 3 ] && [ $2 == "OSC" ]; then - url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/a1-p/policytypes/$4" + url="$RIC_SIM_HTTPX://$ric_id:$RIC_SIM_PORT/a1-p/policytypes/$4" paramError=0 fi @@ -189,12 +368,16 @@ controller_api_get_A1_policy_type() { controller_api_delete_A1_policy() { __log_test_start $@ + ric_id=$3 + if [ $RUNMODE == "KUBE" ]; then + ric_id=$(get_kube_sim_host $3) + fi paramError=1 if [ $# -eq 5 ] && [ $2 == "OSC" ]; then - url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/a1-p/policytypes/$4/policies/$UUID$5" + url="$RIC_SIM_HTTPX://$ric_id:$RIC_SIM_PORT/a1-p/policytypes/$4/policies/$UUID$5" paramError=0 elif [ $# -eq 4 ] && [ $2 == "STD" ]; then - url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/A1-P/v1/policies/$UUID$4" + url="$RIC_SIM_HTTPX://$ric_id:$RIC_SIM_PORT/A1-P/v1/policies/$UUID$4" paramError=0 fi @@ -227,14 +410,18 @@ controller_api_delete_A1_policy() { controller_api_put_A1_policy() { __log_test_start $@ + ric_id=$3 + if [ $RUNMODE == "KUBE" ]; then + ric_id=$(get_kube_sim_host $3) + fi paramError=1 if [ $# -eq 6 ] && [ $2 == "OSC" ]; then - url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/a1-p/policytypes/$4/policies/$UUID$5" + url="$RIC_SIM_HTTPX://$ric_id:$RIC_SIM_PORT/a1-p/policytypes/$4/policies/$UUID$5" body=$(sed 's/XXX/'${5}'/g' $6) paramError=0 elif [ $# -eq 5 ] && [ $2 == "STD" ]; then - url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/A1-P/v1/policies/$UUID$4" + url="$RIC_SIM_HTTPX://$ric_id:$RIC_SIM_PORT/A1-P/v1/policies/$UUID$4" body=$(sed 's/XXX/'${4}'/g' $5) paramError=0 fi @@ -269,10 +456,14 @@ controller_api_put_A1_policy() { controller_api_get_A1_policy_status() { __log_test_start $@ + ric_id=$3 + if [ $RUNMODE == "KUBE" ]; then + ric_id=$(get_kube_sim_host $3) + fi targetJson="" paramError=1 if [ $# -ge 5 ] && [ $2 == "OSC" ]; then - url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/a1-p/policytypes/$4/policies/$UUID$5/status" + url="$RIC_SIM_HTTPX://$ric_id:$RIC_SIM_PORT/a1-p/policytypes/$4/policies/$UUID$5/status" if [ $# -gt 5 ]; then targetJson="{\"instance_status\":\"$6\"" targetJson=$targetJson",\"has_been_deleted\":\"$7\"" @@ -280,7 +471,7 @@ controller_api_get_A1_policy_status() { fi paramError=0 elif [ $# -ge 4 ] && [ $2 == "STD" ]; then - url="$RIC_SIM_HTTPX://$3:$RIC_SIM_PORT/A1-P/v1/policies/$UUID$4/status" + url="$RIC_SIM_HTTPX://$ric_id:$RIC_SIM_PORT/A1-P/v1/policies/$UUID$4/status" if [ $# -gt 4 ]; then targetJson="{\"enforceStatus\":\"$5\"" if [ $# -eq 6 ]; then diff --git a/test/common/cr_api_functions.sh b/test/common/cr_api_functions.sh index e2b94913..bf490fc0 100644 --- a/test/common/cr_api_functions.sh +++ b/test/common/cr_api_functions.sh @@ -17,35 +17,180 @@ # ============LICENSE_END================================================= # -. ../common/api_curl.sh - -### Admin API functions for the Callback Reciver - - -# Excute a curl cmd towards a Callback Reciver admin interface and check the response code. -# args: -__execute_curl_to_cr() { - echo ${FUNCNAME[1]} "line: "${BASH_LINENO[1]} >> $HTTPLOG - echo " CMD: $2" >> $HTTPLOG - res="$($2)" - echo " RESP: $res" >> $HTTPLOG - retcode=$? - if [ $retcode -ne 0 ]; then - ((RES_CONF_FAIL++)) - echo " RETCODE: "$retcode - echo -e $RED" FAIL - fatal error when executing curl."$ERED - return 1 - fi - status=${res:${#res}-3} - if [ $status -eq $1 ]; then - echo -e $GREEN" OK"$EGREEN - return 0 - fi - echo -e $RED" FAIL - expected http response: "$1" but got http response: "$status $ERED - ((RES_CONF_FAIL++)) - return 1 +# This is a script that contains container/service managemnt functions test functions for the Callback Reciver + +## Access to Callback Receiver +# Host name may be changed if app started by kube +# Direct access from script +CR_HTTPX="http" +CR_HOST_NAME=$LOCALHOST_NAME +CR_PATH=$CR_HTTPX"://"$CR_HOST_NAME":"$CR_EXTERNAL_PORT +#Docker/Kube internal path +if [ $RUNMODE == "KUBE" ]; then + CR_SERVICE_PATH=$CR_HTTPX"://"$CR_APP_NAME"."$KUBE_SIM_NAMESPACE":"$CR_EXTERNAL_PORT$CR_APP_CALLBACK +else + CR_SERVICE_PATH=$CR_HTTPX"://"$CR_APP_NAME":"$CR_INTERNAL_PORT$CR_APP_CALLBACK +fi +# CR_ADAPTER used for switching between REST and DMAAP (only REST supported currently) +CR_ADAPTER_TYPE="REST" +CR_ADAPTER=$CR_PATH + +################ +### CR functions +################ + +# Set http as the protocol to use for all communication to the Callback Receiver +# args: - +# (Function for test scripts) +use_cr_http() { + echo -e $BOLD"CR protocol setting"$EBOLD + echo -e " Using $BOLD http $EBOLD towards CR" + + CR_HTTPX="http" + CR_PATH=$CR_HTTPX"://"$CR_HOST_NAME":"$CR_EXTERNAL_PORT + + #Docker/Kube internal path + if [ $RUNMODE == "KUBE" ]; then + CR_SERVICE_PATH=$CR_HTTPX"://"$CR_APP_NAME"."$KUBE_SIM_NAMESPACE":"$CR_EXTERNAL_PORT$CR_APP_CALLBACK + else + CR_SERVICE_PATH=$CR_HTTPX"://"$CR_APP_NAME":"$CR_INTERNAL_PORT$CR_APP_CALLBACK + fi + CR_ADAPTER_TYPE="REST" + CR_ADAPTER=$CR_PATH + echo "" +} + +# Set https as the protocol to use for all communication to the Callback Receiver +# args: - +# (Function for test scripts) +use_cr_https() { + echo -e $BOLD"CR protocol setting"$EBOLD + echo -e " Using $BOLD https $EBOLD towards CR" + + CR_HTTPX="https" + CR_PATH=$CR_HTTPX"://"$CR_HOST_NAME":"$CR_EXTERNAL_SECURE_PORT + + if [ $RUNMODE == "KUBE" ]; then + CR_SERVICE_PATH=$CR_HTTPX"://"$CR_APP_NAME"."$KUBE_SIM_NAMESPACE":"$CR_EXTERNAL_SECURE_PORT$CR_APP_CALLBACK + else + CR_SERVICE_PATH=$CR_HTTPX"://"$CR_APP_NAME":"$CR_INTERNAL_SECURE_PORT$CR_APP_CALLBACK + fi + + CR_ADAPTER_TYPE="REST" + CR_ADAPTER=$CR_PATH + echo "" +} + +# Start the Callback reciver in the simulator group +# args: - +# (Function for test scripts) +start_cr() { + + echo -e $BOLD"Starting $CR_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + + # Check if app shall be fully managed by the test script + __check_included_image "CR" + retcode_i=$? + + # Check if app shall only be used by the testscipt + __check_prestarted_image "CR" + retcode_p=$? + + if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then + echo -e $RED"The $CR_APP_NAME app is not included as managed nor prestarted in this test script"$ERED + echo -e $RED"The $CR_APP_NAME will not be started"$ERED + exit + fi + if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then + echo -e $RED"The $CR_APP_NAME app is included both as managed and prestarted in this test script"$ERED + echo -e $RED"The $CR_APP_NAME will not be started"$ERED + exit + fi + + # Check if app shall be used - not managed - by the test script + if [ $retcode_p -eq 0 ]; then + echo -e " Using existing $CR_APP_NAME deployment and service" + echo " Setting CR replicas=1" + __kube_scale deployment $CR_APP_NAME $KUBE_SIM_NAMESPACE 1 + fi + + if [ $retcode_i -eq 0 ]; then + echo -e " Creating $CR_APP_NAME deployment and service" + export CR_APP_NAME + export KUBE_SIM_NAMESPACE + export CR_IMAGE + export CR_INTERNAL_PORT + export CR_INTERNAL_SECURE_PORT + export CR_EXTERNAL_PORT + export CR_EXTERNAL_SECURE_PORT + + __kube_create_namespace $KUBE_SIM_NAMESPACE + + # Create service + input_yaml=$SIM_GROUP"/"$CR_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/cr_svc.yaml + __kube_create_instance service $CR_APP_NAME $input_yaml $output_yaml + + # Create app + input_yaml=$SIM_GROUP"/"$CR_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/cr_app.yaml + __kube_create_instance app $CR_APP_NAME $input_yaml $output_yaml + + fi + + echo " Retrieving host and ports for service..." + CR_HOST_NAME=$(__kube_get_service_host $CR_APP_NAME $KUBE_SIM_NAMESPACE) + + CR_EXTERNAL_PORT=$(__kube_get_service_port $CR_APP_NAME $KUBE_SIM_NAMESPACE "http") + CR_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $CR_APP_NAME $KUBE_SIM_NAMESPACE "https") + + echo " Host IP, http port, https port: $CR_HOST_NAME $CR_EXTERNAL_PORT $CR_EXTERNAL_SECURE_PORT" + if [ $CR_HTTPX == "http" ]; then + CR_PATH=$CR_HTTPX"://"$CR_HOST_NAME":"$CR_EXTERNAL_PORT + CR_SERVICE_PATH=$CR_HTTPX"://"$CR_APP_NAME"."$KUBE_SIM_NAMESPACE":"$CR_EXTERNAL_PORT$CR_APP_CALLBACK + else + CR_PATH=$CR_HTTPX"://"$CR_HOST_NAME":"$CR_EXTERNAL_SECURE_PORT + CR_SERVICE_PATH=$CR_HTTPX"://"$CR_APP_NAME"."$KUBE_SIM_NAMESPACE":"$CR_EXTERNAL_SECURE_PORT$CR_APP_CALLBACK + fi + if [ $CR_ADAPTER_TYPE == "REST" ]; then + CR_ADAPTER=$CR_PATH + fi + + __check_service_start $CR_APP_NAME $CR_PATH$CR_ALIVE_URL + + echo -ne " Service $CR_APP_NAME - reset "$SAMELINE + result=$(__do_curl $CR_APP_NAME $CR_PATH/reset) + if [ $? -ne 0 ]; then + echo -e " Service $CR_APP_NAME - reset $RED Failed $ERED - will continue" + else + echo -e " Service $CR_APP_NAME - reset $GREEN OK $EGREEN" + fi + else + # Check if docker app shall be fully managed by the test script + __check_included_image 'CR' + if [ $? -eq 1 ]; then + echo -e $RED"The Callback Receiver app is not included in this test script"$ERED + echo -e $RED"The Callback Receiver will not be started"$ERED + exit + fi + + export CR_APP_NAME + export CR_INTERNAL_PORT + export CR_EXTERNAL_PORT + export CR_INTERNAL_SECURE_PORT + export CR_EXTERNAL_SECURE_PORT + export DOCKER_SIM_NWNAME + + __start_container $CR_COMPOSE_DIR NODOCKERARGS 1 $CR_APP_NAME + + __check_service_start $CR_APP_NAME $CR_PATH$CR_ALIVE_URL + fi + echo "" } + # Tests if a variable value in the CR is equal to a target value and and optional timeout. # Arg: - This test set pass or fail depending on if the variable is # equal to the target or not. @@ -55,7 +200,7 @@ __execute_curl_to_cr() { # (Function for test scripts) cr_equal() { if [ $# -eq 2 ] || [ $# -eq 3 ]; then - __var_test "CR" "$LOCALHOST$CR_EXTERNAL_PORT/counter/" $1 "=" $2 $3 + __var_test "CR" "$CR_PATH/counter/" $1 "=" $2 $3 else __print_err "Wrong args to cr_equal, needs two or three args: [ timeout ]" $@ fi diff --git a/test/common/ecs_api_functions.sh b/test/common/ecs_api_functions.sh index 6c431734..ba451e6f 100644 --- a/test/common/ecs_api_functions.sh +++ b/test/common/ecs_api_functions.sh @@ -17,9 +17,275 @@ # ============LICENSE_END================================================= # -# This is a script that contains specific test functions for ECS NB/SB API +# This is a script that contains container/service management functions and test functions for ECS + +## Access to ECS +# Host name may be changed if app started by kube +# Direct access +ECS_HTTPX="http" +ECS_HOST_NAME=$LOCALHOST_NAME +ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_PORT + +# ECS_ADAPTER used for switch between REST and DMAAP (only REST supported currently) +ECS_ADAPTER_TYPE="REST" +ECS_ADAPTER=$ECS_PATH + +# Make curl retries towards ECS for http response codes set in this env var, space separated list of codes +ECS_RETRY_CODES="" + +########################### +### ECS functions +########################### + +# All calls to ECS will be directed to the ECS REST interface from now on +# args: - +# (Function for test scripts) +use_ecs_rest_http() { + echo -e $BOLD"ECS protocol setting"$EBOLD + echo -e " Using $BOLD http $EBOLD and $BOLD REST $EBOLD towards ECS" + ECS_HTTPX="http" + ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_PORT + + ECS_ADAPTER_TYPE="REST" + ECS_ADAPTER=$ECS_PATH + echo "" +} + +# All calls to ECS will be directed to the ECS REST interface from now on +# args: - +# (Function for test scripts) +use_ecs_rest_https() { + echo -e $BOLD"ECS protocol setting"$EBOLD + echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS" + ECS_HTTPX="https" + ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_SECURE_PORT + + ECS_ADAPTER_TYPE="REST" + ECS_ADAPTER=$ECS_PATH + echo "" +} + +# All calls to ECS will be directed to the ECS dmaap interface over http from now on +# args: - +# (Function for test scripts) +use_ecs_dmaap_http() { + echo -e $BOLD"ECS dmaap protocol setting"$EBOLD + echo -e $RED" - NOT SUPPORTED - "$ERED + echo -e " Using $BOLD http $EBOLD and $BOLD DMAAP $EBOLD towards ECS" + ECS_ADAPTER_TYPE="MR-HTTP" + echo "" +} + +# All calls to ECS will be directed to the ECS dmaap interface over https from now on +# args: - +# (Function for test scripts) +use_ecs_dmaap_https() { + echo -e $BOLD"RICSIM protocol setting"$EBOLD + echo -e $RED" - NOT SUPPORTED - "$ERED + echo -e " Using $BOLD https $EBOLD and $BOLD REST $EBOLD towards ECS" + ECS_ADAPTER_TYPE="MR-HTTPS" + echo "" +} + +# Start the ECS +# args: - +# (Function for test scripts) +start_ecs() { + + echo -e $BOLD"Starting $ECS_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + + # Check if app shall be fully managed by the test script + __check_included_image "ECS" + retcode_i=$? + + # Check if app shall only be used by the testscipt + __check_prestarted_image "ECS" + retcode_p=$? + + if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then + echo -e $RED"The $ECS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED + echo -e $RED"The $ECS_APP_NAME will not be started"$ERED + exit + fi + if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then + echo -e $RED"The $ECS_APP_NAME app is included both as managed and prestarted in this test script"$ERED + echo -e $RED"The $ECS_APP_NAME will not be started"$ERED + exit + fi + + + if [ $retcode_p -eq 0 ]; then + echo -e " Using existing $ECS_APP_NAME deployment and service" + echo " Setting ECS replicas=1" + __kube_scale deployment $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1 + fi + + # Check if app shall be fully managed by the test script + if [ $retcode_i -eq 0 ]; then + echo -e " Creating $ECS_APP_NAME app and expose service" + + #Check if nonrtric namespace exists, if not create it + __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE + + export ECS_APP_NAME + export KUBE_NONRTRIC_NAMESPACE + export ECS_IMAGE + export ECS_INTERNAL_PORT + export ECS_INTERNAL_SECURE_PORT + export ECS_EXTERNAL_PORT + export ECS_EXTERNAL_SECURE_PORT + export ECS_CONFIG_MOUNT_PATH + export ECS_CONFIG_CONFIGMAP_NAME=$ECS_APP_NAME"-config" + export ECS_DATA_CONFIGMAP_NAME=$ECS_APP_NAME"-data" + export ECS_CONTAINER_MNT_DIR + + # Create config map for config + datafile=$PWD/tmp/$ECS_CONFIG_FILE + cp $1 $datafile + output_yaml=$PWD/tmp/ecs_cfc.yaml + __kube_create_configmap $ECS_CONFIG_CONFIGMAP_NAME $KUBE_NONRTRIC_NAMESPACE autotest ECS $datafile $output_yaml + + # Create pvc + input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"pvc.yaml + output_yaml=$PWD/tmp/ecs_pvc.yaml + __kube_create_instance pvc $ECS_APP_NAME $input_yaml $output_yaml + + # Create service + input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/ecs_svc.yaml + __kube_create_instance service $ECS_APP_NAME $input_yaml $output_yaml + + # Create app + input_yaml=$SIM_GROUP"/"$ECS_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/ecs_app.yaml + __kube_create_instance app $ECS_APP_NAME $input_yaml $output_yaml + fi + + echo " Retrieving host and ports for service..." + ECS_HOST_NAME=$(__kube_get_service_host $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE) + ECS_EXTERNAL_PORT=$(__kube_get_service_port $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE "http") + ECS_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $ECS_APP_NAME $KUBE_NONRTRIC_NAMESPACE "https") + + echo " Host IP, http port, https port: $ECS_HOST_NAME $ECS_EXTERNAL_PORT $ECS_EXTERNAL_SECURE_PORT" + + if [ $ECS_HTTPX == "http" ]; then + ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_PORT + else + ECS_PATH=$ECS_HTTPX"://"$ECS_HOST_NAME":"$ECS_EXTERNAL_SECURE_PORT + fi + + __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL + + if [ $ECS_ADAPTER_TYPE == "REST" ]; then + ECS_ADAPTER=$ECS_PATH + fi + else + __check_included_image 'ECS' + if [ $? -eq 1 ]; then + echo -e $RED"The ECS app is not included in this test script"$ERED + echo -e $RED"ECS will not be started"$ERED + exit 1 + fi + + curdir=$PWD + cd $SIM_GROUP + cd ecs + cd $ECS_HOST_MNT_DIR + cd .. + if [ -d db ]; then + if [ "$(ls -A $DIR)" ]; then + echo -e $BOLD" Cleaning files in mounted dir: $PWD/db"$EBOLD + rm -rf db/* &> /dev/null + if [ $? -ne 0 ]; then + echo -e $RED" Cannot remove database files in: $PWD"$ERED + exit 1 + fi + fi + else + echo " No files in mounted dir or dir does not exists" + fi + cd $curdir + + export ECS_APP_NAME + export ECS_APP_NAME_ALIAS + export ECS_HOST_MNT_DIR + export ECS_CONTAINER_MNT_DIR + export ECS_INTERNAL_PORT + export ECS_EXTERNAL_PORT + export ECS_INTERNAL_SECURE_PORT + export ECS_EXTERNAL_SECURE_PORT + export DOCKER_SIM_NWNAME + + __start_container $ECS_COMPOSE_DIR NODOCKERARGS 1 $ECS_APP_NAME + + __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL + fi + echo "" + return 0 +} + +# Restart ECS +# args: - +# (Function for test scripts) +restart_ecs() { + echo -e $BOLD"Re-starting ECS"$EBOLD + docker restart $ECS_APP_NAME &> ./tmp/.dockererr + if [ $? -ne 0 ]; then + __print_err "Could not restart $ECS_APP_NAME" $@ + cat ./tmp/.dockererr + ((RES_CONF_FAIL++)) + return 1 + fi + + __check_service_start $ECS_APP_NAME $ECS_PATH$ECS_ALIVE_URL + echo "" + return 0 +} + +# Turn on debug level tracing in ECS +# args: - +# (Function for test scripts) +set_ecs_debug() { + echo -e $BOLD"Setting ecs debug logging"$EBOLD + curlString="$ECS_PATH$ECS_ACTUATOR -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"debug\"}" + result=$(__do_curl "$curlString") + if [ $? -ne 0 ]; then + __print_err "Could not set debug mode" $@ + ((RES_CONF_FAIL++)) + return 1 + fi + echo "" + return 0 +} + +# Turn on trace level tracing in ECS +# args: - +# (Function for test scripts) +set_ecs_trace() { + echo -e $BOLD"Setting ecs trace logging"$EBOLD + curlString="$ECS_PATH/actuator/loggers/org.oransc.enrichment -X POST -H Content-Type:application/json -d {\"configuredLevel\":\"trace\"}" + result=$(__do_curl "$curlString") + if [ $? -ne 0 ]; then + __print_err "Could not set trace mode" $@ + ((RES_CONF_FAIL++)) + return 1 + fi + echo "" + return 0 +} + +# Perform curl retries when making direct call to ECS for the specified http response codes +# Speace separated list of http response codes +# args: []* +use_agent_retries() { + echo -e $BOLD"Do curl retries to the ECS REST inteface for these response codes:$@"$EBOLD + ECS_AGENT_RETRY_CODES=$@ + echo "" + return 0 +} -. ../common/api_curl.sh # Tests if a variable value in the ECS is equal to a target value and and optional timeout. # Arg: - This test set pass or fail depending on if the variable is @@ -30,7 +296,7 @@ # (Function for test scripts) ecs_equal() { if [ $# -eq 2 ] || [ $# -eq 3 ]; then - __var_test ECS "$LOCALHOST$ECS_EXTERNAL_PORT/" $1 "=" $2 $3 + __var_test ECS "$ECS_PATH/" $1 "=" $2 $3 else __print_err "Wrong args to ecs_equal, needs two or three args: [ timeout ]" $@ fi @@ -207,7 +473,7 @@ ecs_api_a1_get_type_ids() { # API Test function: GET ​/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status # args: [] -# args (flat uri structure): [] +# args (flat uri structure): [ []] # (Function for test scripts) ecs_api_a1_get_job_status() { __log_test_start $@ @@ -240,31 +506,60 @@ ecs_api_a1_get_job_status() { fi else echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW - if [ $# -ne 2 ] && [ $# -ne 3 ]; then - __print_err " []" $@ + if [ $# -lt 2 ] && [ $# -gt 4 ]; then + __print_err " [ []]" $@ return 1 fi query="/A1-EI/v1/eijobs/$2/status" - res="$(__do_curl_to_api ECS GET $query)" - status=${res:${#res}-3} + start=$SECONDS + for (( ; ; )); do + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} - if [ $status -ne $1 ]; then - __log_test_fail_status_code $1 $status - return 1 - fi - if [ $# -eq 3 ]; then - body=${res:0:${#res}-3} - targetJson="{\"eiJobStatus\": \"$3\"}" - echo " TARGET JSON: $targetJson" >> $HTTPLOG - res=$(python3 ../common/compare_json.py "$targetJson" "$body") + if [ $# -eq 4 ]; then + duration=$((SECONDS-start)) + echo -ne " Response=${status} after ${duration} seconds, waiting for ${3} ${SAMELINE}" + if [ $duration -gt $4 ]; then + echo "" + duration=-1 #Last iteration + fi + else + duration=-1 #single test, no wait + fi - if [ $res -ne 0 ]; then - __log_test_fail_body - return 1 + if [ $status -ne $1 ]; then + if [ $duration -eq -1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi fi - fi + if [ $# -ge 3 ] && [ $status -eq $1 ]; then + body=${res:0:${#res}-3} + targetJson="{\"eiJobStatus\": \"$3\"}" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + if [ $duration -eq -1 ]; then + __log_test_fail_body + return 1 + fi + else + duration=-1 #Goto pass + fi + fi + if [ $duration -eq -1 ]; then + if [ $# -eq 4 ]; then + echo "" + fi + __log_test_pass + return 0 + else + sleep 1 + fi + done fi __log_test_pass @@ -552,7 +847,7 @@ ecs_api_edp_get_producer_status() { # API Test function: GET /ei-producer/v1/eiproducers -# args: [ EMPTY | +] +# args (v1_1): [ EMPTY | +] # (Function for test scripts) ecs_api_edp_get_producer_ids() { __log_test_start $@ @@ -598,8 +893,58 @@ ecs_api_edp_get_producer_ids() { return 0 } +# API Test function: GET /ei-producer/v1/eiproducers +# args (v1_2): [ ( NOTYPE | ) [ EMPTY | +] ] +# (Function for test scripts) +ecs_api_edp_get_producer_ids_2() { + __log_test_start $@ + + if [ $# -lt 1 ]; then + __print_err " [ ( NOTYPE | ) [ EMPTY | +] ]" $@ + return 1 + fi + + query="/ei-producer/v1/eiproducers" + if [ $# -gt 1 ] && [ $2 != "NOTYPE" ]; then + query=$query"?ei_type_id=$2" + fi + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + if [ $# -gt 2 ]; then + body=${res:0:${#res}-3} + targetJson="[" + + for pid in ${@:3} ; do + if [ "$targetJson" != "[" ]; then + targetJson=$targetJson"," + fi + if [ $pid != "EMPTY" ]; then + targetJson=$targetJson"\"$pid\"" + fi + done + + targetJson=$targetJson"]" + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + __log_test_fail_body + return 1 + fi + fi + + __log_test_pass + return 0 +} + # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId} -# args: [ (EMPTY | []+)] +# args: (v1_1) [ (EMPTY | []+)] # (Function for test scripts) ecs_api_edp_get_type() { __log_test_start $@ @@ -657,8 +1002,115 @@ ecs_api_edp_get_type() { return 0 } +# API Test function: GET /ei-producer/v1/eitypes/{eiTypeId} +# args: (v1_2) [ ] +# (Function for test scripts) +ecs_api_edp_get_type_2() { + __log_test_start $@ + + paramError=1 + if [ $# -eq 2 ]; then + paramError=0 + fi + if [ $# -eq 3 ]; then + paramError=0 + fi + if [ $paramError -ne 0 ]; then + __print_err " [ ]" $@ + return 1 + fi + + query="/ei-producer/v1/eitypes/$2" + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + if [ $# -eq 3 ]; then + body=${res:0:${#res}-3} + + if [ -f $3 ]; then + schema=$(cat $3) + else + __log_test_fail_general "Job template file "$3", does not exist" + return 1 + fi + + targetJson="{\"ei_job_data_schema\":$schema}" + + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + __log_test_fail_body + return 1 + fi + fi + __log_test_pass + return 0 +} + +# API Test function: PUT /ei-producer/v1/eitypes/{eiTypeId} +# args: (v1_2) +# (Function for test scripts) +ecs_api_edp_put_type_2() { + __log_test_start $@ + + if [ $# -ne 3 ]; then + __print_err " " $@ + return 1 + fi + + if [ ! -f $3 ]; then + __log_test_fail_general "Job schema file "$3", does not exist" + return 1 + fi + schema=$(cat $3) + input_json="{\"ei_job_data_schema\":$schema}" + file="./tmp/put_type.json" + echo $input_json > $file + + query="/ei-producer/v1/eitypes/$2" + res="$(__do_curl_to_api ECS PUT $query $file)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + __log_test_pass + return 0 +} + +# API Test function: DELETE /ei-producer/v1/eitypes/{eiTypeId} +# args: (v1_2) +# (Function for test scripts) +ecs_api_edp_delete_type_2() { + __log_test_start $@ + + if [ $# -ne 2 ]; then + __print_err " " $@ + return 1 + fi + + query="/ei-producer/v1/eitypes/$2" + res="$(__do_curl_to_api ECS DELETE $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + __log_test_pass + return 0 +} + # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId} -# args: [ (EMPTY | [ ]+) ] +# args: (v1_1) [ (EMPTY | [ ]+) ] # (Function for test scripts) ecs_api_edp_get_producer() { __log_test_start $@ @@ -726,6 +1178,67 @@ ecs_api_edp_get_producer() { return 0 } +# API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId} +# args (v1_2): [ (EMPTY | +) ] +# (Function for test scripts) +ecs_api_edp_get_producer_2() { + __log_test_start $@ + + #Possible arg count: 2, 5, 6, 7, 8 etc + paramError=1 + if [ $# -eq 2 ]; then + paramError=0 + fi + if [ $# -eq 5 ] && [ "$5" == "EMPTY" ]; then + paramError=0 + fi + if [ $# -ge 5 ]; then + paramError=0 + fi + + if [ $paramError -ne 0 ]; then + __print_err " [ (EMPTY | +) ]" $@ + return 1 + fi + + query="/ei-producer/v1/eiproducers/$2" + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + if [ $# -gt 2 ]; then + body=${res:0:${#res}-3} + targetJson="[" + if [ $# -gt 4 ] && [ "$5" != "EMPTY" ]; then + arr=(${@:5}) + for ((i=0; i<$(($#-4)); i=i+1)); do + if [ "$targetJson" != "[" ]; then + targetJson=$targetJson"," + fi + targetJson=$targetJson"\"${arr[$i]}\"" + done + fi + targetJson=$targetJson"]" + if [ $# -gt 4 ]; then + targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"}" + fi + echo " TARGET JSON: $targetJson" >> $HTTPLOG + res=$(python3 ../common/compare_json.py "$targetJson" "$body") + + if [ $res -ne 0 ]; then + __log_test_fail_body + return 1 + fi + fi + + __log_test_pass + return 0 +} + # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId} # args: # (Function for test scripts) @@ -751,7 +1264,7 @@ ecs_api_edp_delete_producer() { } # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId} -# args: NOTYPE|[ ]+ +# args: (v1_1) NOTYPE|[ ]+ # (Function for test scripts) ecs_api_edp_put_producer() { __log_test_start $@ @@ -805,6 +1318,55 @@ ecs_api_edp_put_producer() { return 0 } +# API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId} +# args: (v1_2) NOTYPE|[+] +# (Function for test scripts) +ecs_api_edp_put_producer_2() { + __log_test_start $@ + + #Valid number of parametrer 5,6,8,10, + paramError=1 + if [ $# -eq 5 ] && [ "$5" == "NOTYPE" ]; then + paramError=0 + elif [ $# -ge 5 ]; then + paramError=0 + fi + if [ $paramError -ne 0 ]; then + __print_err " NOTYPE|[+]" $@ + return 1 + fi + + inputJson="[" + if [ $# -gt 4 ] && [ "$5" != "NOTYPE" ]; then + arr=(${@:5}) + for ((i=0; i<$(($#-4)); i=i+1)); do + if [ "$inputJson" != "[" ]; then + inputJson=$inputJson"," + fi + inputJson=$inputJson"\""${arr[$i]}"\"" + done + fi + inputJson="\"supported_ei_types\":"$inputJson"]" + + inputJson=$inputJson",\"ei_job_callback_url\": \"$3\",\"ei_producer_supervision_callback_url\": \"$4\"" + + inputJson="{"$inputJson"}" + + file="./tmp/.p.json" + echo "$inputJson" > $file + query="/ei-producer/v1/eiproducers/$2" + res="$(__do_curl_to_api ECS PUT $query $file)" + status=${res:${#res}-3} + + if [ $status -ne $1 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + __log_test_pass + return 0 +} + # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs # args: (EMPTY | [ ]+) # (Function for test scripts) @@ -891,6 +1453,58 @@ ecs_api_service_status() { __log_test_fail_status_code $1 $status return 1 fi + __log_test_pass + return 0 +} + + +########################################## +#### Reset jobs #### +########################################## +# Function prefix: ecs_api_admin + +# Admin to remove all jobs +# args: +# (Function for test scripts) + +ecs_api_admin_reset() { + __log_test_start $@ + + if [ -z "$FLAT_A1_EI" ]; then + query="/A1-EI/v1/eitypes/$2/eijobs" + else + query="/A1-EI/v1/eijobs" + fi + res="$(__do_curl_to_api ECS GET $query)" + status=${res:${#res}-3} + + if [ $status -ne 200 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + + #Remove brackets and response code + body=${res:1:${#res}-4} + list=$(echo ${body//,/ }) + list=$(echo ${list//[/}) + list=$(echo ${list//]/}) + list=$(echo ${list//\"/}) + list=$list" " + for job in $list; do + if [ -z "$FLAT_A1_EI" ]; then + echo "Not supported for non-flat EI api" + else + query="/A1-EI/v1/eijobs/$job" + res="$(__do_curl_to_api ECS DELETE $query)" + status=${res:${#res}-3} + if [ $status -ne 204 ]; then + __log_test_fail_status_code $1 $status + return 1 + fi + echo " Deleted job: "$job + fi + done + __log_test_pass return 0 } \ No newline at end of file diff --git a/test/common/http_proxy_api_functions.sh b/test/common/http_proxy_api_functions.sh new file mode 100644 index 00000000..68df929f --- /dev/null +++ b/test/common/http_proxy_api_functions.sh @@ -0,0 +1,129 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# + +# This is a script that contains container/service managemnt functions for Http Proxy + +## Access to Http Proxy Receiver +# Host name may be changed if app started by kube +# Direct access from script +HTTP_PROXY_HTTPX="http" +HTTP_PROXY_HOST_NAME=$LOCALHOST_NAME +HTTP_PROXY_PATH=$HTTP_PROXY_HTTPX"://"$HTTP_PROXY_HOST_NAME":"$HTTP_PROXY_WEB_EXTERNAL_PORT + +######################### +### Http Proxy functions +######################### + +# Start the Http Proxy in the simulator group +# args: - +# (Function for test scripts) +start_http_proxy() { + + echo -e $BOLD"Starting $HTTP_PROXY_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + + # Check if app shall be fully managed by the test script + __check_included_image "HTTPPROXY" + retcode_i=$? + + # Check if app shall only be used by the testscipt + __check_prestarted_image "HTTPPROXY" + retcode_p=$? + + if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then + echo -e $RED"The $HTTP_PROXY_APP_NAME app is not included as managed nor prestarted in this test script"$ERED + echo -e $RED"The $HTTP_PROXY_APP_NAME will not be started"$ERED + exit + fi + if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then + echo -e $RED"The $HTTP_PROXY_APP_NAME app is included both as managed and prestarted in this test script"$ERED + echo -e $RED"The $HTTP_PROXY_APP_NAME will not be started"$ERED + exit + fi + + # Check if app shall be used - not managed - by the test script + if [ $retcode_p -eq 0 ]; then + echo -e " Using existing $HTTP_PROXY_APP_NAME deployment and service" + echo " Setting HTTPPROXY replicas=1" + __kube_scale deployment $HTTP_PROXY_APP_NAME $KUBE_SIM_NAMESPACE 1 + fi + + if [ $retcode_i -eq 0 ]; then + echo -e " Creating $HTTP_PROXY_APP_NAME deployment and service" + export HTTP_PROXY_APP_NAME + export HTTP_PROXY_WEB_EXTERNAL_PORT + export HTTP_PROXY_WEB_INTERNAL_PORT + export HTTP_PROXY_EXTERNAL_PORT + export HTTP_PROXY_INTERNAL_PORT + export KUBE_SIM_NAMESPACE + export HTTP_PROXY_IMAGE + + __kube_create_namespace $KUBE_SIM_NAMESPACE + + # Create service + input_yaml=$SIM_GROUP"/"$HTTP_PROXY_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/proxy_svc.yaml + __kube_create_instance service $HTTP_PROXY_APP_NAME $input_yaml $output_yaml + + # Create app + input_yaml=$SIM_GROUP"/"$HTTP_PROXY_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/proxy_app.yaml + __kube_create_instance app $HTTP_PROXY_APP_NAME $input_yaml $output_yaml + + fi + + echo " Retrieving host and ports for service..." + HTTP_PROXY_HOST_NAME=$(__kube_get_service_host $HTTP_PROXY_APP_NAME $KUBE_SIM_NAMESPACE) + HTTP_PROXY_WEB_EXTERNAL_PORT=$(__kube_get_service_port $HTTP_PROXY_APP_NAME $KUBE_SIM_NAMESPACE "web") + HTTP_PROXY_EXTERNAL_PORT=$(__kube_get_service_port $HTTP_PROXY_APP_NAME $KUBE_SIM_NAMESPACE "http") + + HTTP_PROXY_PATH=$HTTP_PROXY_HTTPX"://"$HTTP_PROXY_HOST_NAME":"$HTTP_PROXY_WEB_EXTERNAL_PORT + HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_EXTERNAL_PORT + HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_APP_NAME"."$KUBE_SIM_NAMESPACE + + echo " Host IP, http port: $HTTP_PROXY_HOST_NAME $HTTP_PROXY_WEB_EXTERNAL_PORT" + + __check_service_start $HTTP_PROXY_APP_NAME $HTTP_PROXY_PATH$HTTP_PROXY_ALIVE_URL + + else + # Check if docker app shall be fully managed by the test script + __check_included_image 'HTTPPROXY' + if [ $? -eq 1 ]; then + echo -e $RED"The Http Proxy app is not included in this test script"$ERED + echo -e $RED"The Http Proxy will not be started"$ERED + exit + fi + + export HTTP_PROXY_APP_NAME + export HTTP_PROXY_WEB_EXTERNAL_PORT + export HTTP_PROXY_WEB_INTERNAL_PORT + export DOCKER_SIM_NWNAME + + __start_container $HTTP_PROXY_COMPOSE_DIR NODOCKERARGS 1 $HTTP_PROXY_APP_NAME + + __check_service_start $HTTP_PROXY_APP_NAME $HTTP_PROXY_PATH$HTTP_PROXY_ALIVE_URL + + HTTP_PROXY_CONFIG_PORT=$HTTP_PROXY_INTERNAL_PORT + HTTP_PROXY_CONFIG_HOST_NAME=$HTTP_PROXY_APP_NAME + + fi + echo "" +} + diff --git a/test/common/mr_api_functions.sh b/test/common/mr_api_functions.sh new file mode 100644 index 00000000..54809b7b --- /dev/null +++ b/test/common/mr_api_functions.sh @@ -0,0 +1,511 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# + +# This is a script that contains container/service management function +# and test functions for Message Router - mr stub + +## Access to Message Router +# Host name may be changed if app started by kube +# Direct access from script +MR_HTTPX="http" +MR_STUB_HOST_NAME=$LOCALHOST_NAME +MR_DMAAP_HOST_NAME=$LOCALHOST_NAME +MR_STUB_PATH=$MR_HTTPX"://"$MR_STUB_HOST_NAME":"$MR_STUB_LOCALHOST_PORT +MR_DMAAP_PATH=$MR_HTTPX"://"$MR_DMAAP_HOST_NAME":"$MR_DMAAP_LOCALHOST_PORT +#Docker/Kube internal path +if [ $RUNMODE == "KUBE" ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_STUB_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXTERNAL_PORT + __check_included_image "DMAAPMR" + if [ $? -eq 0 ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXTERNAL_PORT + fi + __check_prestarted_image "DMAAPMR" + if [ $? -eq 0 ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXTERNAL_PORT + fi +else + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_STUB_APP_NAME":"$MR_INTERNAL_PORT + __check_included_image "DMAAPMR" + if [ $? -eq 0 ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME":"$MR_INTERNAL_PORT + fi +fi +MR_ADAPTER_HTTP="http://"$MR_STUB_HOST_NAME":"$MR_STUB_LOCALHOST_PORT +MR_ADAPTER_HTTPS="https://"$MR_STUB_HOST_NAME":"$MR_STUB_LOCALHOST_SECURE_PORT + + +##################### +### MR stub functions +##################### + +use_mr_http() { + echo -e $BOLD"MR protocol setting"$EBOLD + echo -e " Using $BOLD http $EBOLD towards MR" + MR_HTTPX="http" + MR_STUB_PATH=$MR_HTTPX"://"$MR_STUB_HOST_NAME":"$MR_STUB_LOCALHOST_PORT + MR_DMAAP_PATH=$MR_HTTPX"://"$MR_DMAAP_HOST_NAME":"$MR_DMAAP_LOCALHOST_PORT + #Docker/Kube internal path + if [ $RUNMODE == "KUBE" ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_STUB_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXTERNAL_PORT + __check_included_image "DMAAPMR" + if [ $? -eq 0 ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXTERNAL_PORT + fi + __check_prestarted_image "DMAAPMR" + if [ $? -eq 0 ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXTERNAL_PORT + fi + else + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_STUB_APP_NAME":"$MR_INTERNAL_PORT + __check_included_image "DMAAPMR" + if [ $? -eq 0 ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME":"$MR_INTERNAL_PORT + fi + fi + echo "" +} + +use_mr_https() { + echo -e $BOLD"MR protocol setting"$EBOLD + echo -e " Using $BOLD https $EBOLD towards MR" + MR_HTTPX="https" + MR_STUB_PATH=$MR_HTTPX"://"$MR_STUB_HOST_NAME":"$MR_STUB_LOCALHOST_SECURE_PORT + MR_DMAAP_PATH=$MR_HTTPX"://"$MR_DMAAP_HOST_NAME":"$MR_DMAAP_LOCALHOST_SECURE_PORT + #Docker/Kube internal path + if [ $RUNMODE == "KUBE" ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_STUB_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXTERNAL_SECURE_PORT + __check_included_image "DMAAPMR" + if [ $? -eq 0 ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXTERNAL_SECURE_PORT + fi + __check_prestarted_image "DMAAPMR" + if [ $? -eq 0 ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXTERNAL_SECURE_PORT + fi + else + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_STUB_APP_NAME":"$MR_INTERNAL_SECURE_PORT + __check_included_image "DMAAPMR" + if [ $? -eq 0 ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME":"$MR_INTERNAL_SECURE_PORT + fi + fi + echo "" +} + +# Create a dmaap mr topic +# args: +__create_topic() { + echo -ne " Creating read topic: $1"$SAMELINE + + json_topic="{\"topicName\":\"$1\",\"partitionCount\":\"2\", \"replicationCount\":\"3\", \"transactionEnabled\":\"false\",\"topicDescription\":\"$2\"}" + echo $json_topic > ./tmp/$1.json + + curlString="$MR_DMAAP_PATH/topics/create -X POST -H Content-Type:application/json -d@./tmp/$1.json" + topic_retries=5 + while [ $topic_retries -gt 0 ]; do + let topic_retries=topic_retries-1 + result=$(__do_curl "$curlString") + if [ $? -eq 0 ]; then + topic_retries=0 + echo -e " Creating read topic: $1 $GREEN OK $EGREEN" + fi + if [ $? -ne 0 ]; then + if [ $topic_retries -eq 0 ]; then + echo -e " Creating read topic: $1 $RED Failed $ERED" + ((RES_CONF_FAIL++)) + return 1 + else + sleep 1 + fi + fi + done + return 0 +} + +# Do a pipeclean of a topic - to overcome dmaap mr bug... +# args: +__dmaap_pipeclean() { + pipeclean_retries=50 + echo -ne " Doing dmaap-mr pipe cleaning on topic: $1"$SAMELINE + while [ $pipeclean_retries -gt 0 ]; do + echo "{\"pipeclean-$1\":$pipeclean_retries}" > ./tmp/pipeclean.json + let pipeclean_retries=pipeclean_retries-1 + curlString="$MR_DMAAP_PATH$2 -X POST -H Content-Type:application/json -d@./tmp/pipeclean.json" + result=$(__do_curl "$curlString") + if [ $? -ne 0 ]; then + sleep 1 + else + curlString="$MR_DMAAP_PATH$3" + result=$(__do_curl "$curlString") + if [ $? -eq 0 ]; then + if [ $result != "[]" ]; then + echo -e " Doing dmaap-mr pipe cleaning on topic: $1 $GREEN OK $EGREEN" + return 0 + + else + sleep 1 + fi + fi + fi + done + echo -e "Doing dmaap-mr pipe cleaning on topic: $1 $RED Failed $ERED" + return 1 +} + +# Start the Message Router stub interface in the simulator group +# args: - +# (Function for test scripts) +start_mr() { + + echo -e $BOLD"Starting $MR_DMAAP_DISPLAY_NAME and/or $MR_STUB_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + + # Table of possible combinations of included mr and included/prestarted dmaap-mr + # mr can never be prestarted + # mr can be used stand alone + # if dmaapmr is included/prestarted, then mr is needed as well as frontend + + # Inverted logic - 0 mean true, 1 means false + # mr prestarted 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 + # mr included 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 + # dmaap prestarted 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 + # dmaap included 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 + # ================================================== + # OK 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 + + __check_prestarted_image 'MR' + retcode_prestarted_mr=$? + __check_included_image 'MR' + retcode_included_mr=$? + + __check_prestarted_image 'DMAAPMR' + retcode_prestarted_dmaapmr=$? + __check_included_image 'DMAAPMR' + retcode_included_dmaapmr=$? + + paramerror=1 + + if [ $retcode_prestarted_mr -ne 0 ] && [ $retcode_included_mr -eq 0 ]; then + if [ $retcode_prestarted_dmaapmr -ne 0 ] && [ $retcode_included_dmaapmr -eq 0 ]; then + paramerror=0 + fi + fi + + if [ $retcode_prestarted_mr -ne 0 ] && [ $retcode_included_mr -eq 0 ]; then + if [ $retcode_prestarted_dmaapmr -eq 0 ] && [ $retcode_included_dmaapmr -ne 0 ]; then + paramerror=0 + fi + fi + + if [ $retcode_prestarted_mr -ne 0 ] && [ $retcode_included_mr -eq 0 ]; then + if [ $retcode_prestarted_dmaapmr -ne 0 ] && [ $retcode_included_dmaapmr -ne 0 ]; then + paramerror=0 + fi + fi + + if [ $paramerror -ne 0 ]; then + echo -e $RED"The Message Router apps 'MR' and/or 'DMAAPMR' are not included in this test script"$ERED + echo -e $RED"The Message Router will not be started"$ERED + echo -e $RED"Both MR and DAAMPMR - or - only MR - need to be included and/or prestarted" + exit + fi + + if [ $retcode_prestarted_dmaapmr -eq 0 ]; then + echo -e " Using existing $MR_DMAAP_APP_NAME deployment and service" + __kube_scale deployment $MR_DMAAP_APP_NAME $KUBE_ONAP_NAMESPACE 1 + fi + + if [ $retcode_included_dmaapmr -eq 0 ]; then + #export MR_DMAAP_APP_NAME + export MR_DMAAP_KUBE_APP_NAME=message-router + MR_DMAAP_APP_NAME=$MR_DMAAP_KUBE_APP_NAME + export KUBE_ONAP_NAMESPACE + export MR_EXTERNAL_PORT + export MR_INTERNAL_PORT + export MR_EXTERNAL_SECURE_PORT + export MR_INTERNAL_SECURE_PORT + export ONAP_DMAAPMR_IMAGE + + export MR_KAFKA_BWDS_NAME=akfak-bwds + export KUBE_ONAP_NAMESPACE + + export MR_ZOOKEEPER_APP_NAME + export ONAP_ZOOKEEPER_IMAGE + + #Check if onap namespace exists, if not create it + __kube_create_namespace $KUBE_ONAP_NAMESPACE + + # TODO - Fix domain name substitution in the prop file + # Create config maps - dmaapmr app + configfile=$PWD/tmp/MsgRtrApi.properties + cp $SIM_GROUP"/"$MR_DMAAP_COMPOSE_DIR"/"mnt/mr/KUBE-MsgRtrApi.properties $configfile + output_yaml=$PWD/tmp/dmaapmr_msgrtrapi_cfc.yaml + __kube_create_configmap dmaapmr-msgrtrapi.properties $KUBE_ONAP_NAMESPACE autotest DMAAPMR $configfile $output_yaml + + configfile=$PWD/tmp/logback.xml + cp $SIM_GROUP"/"$MR_DMAAP_COMPOSE_DIR"/"mnt/mr/logback.xml $configfile + output_yaml=$PWD/tmp/dmaapmr_logback_cfc.yaml + __kube_create_configmap dmaapmr-logback.xml $KUBE_ONAP_NAMESPACE autotest DMAAPMR $configfile $output_yaml + + configfile=$PWD/tmp/cadi.properties + cp $SIM_GROUP"/"$MR_DMAAP_COMPOSE_DIR"/"mnt/mr/cadi.properties $configfile + output_yaml=$PWD/tmp/dmaapmr_cadi_cfc.yaml + __kube_create_configmap dmaapmr-cadi.properties $KUBE_ONAP_NAMESPACE autotest DMAAPMR $configfile $output_yaml + + # Create config maps - kafka app + configfile=$PWD/tmp/zk_client_jaas.conf + cp $SIM_GROUP"/"$MR_DMAAP_COMPOSE_DIR"/"mnt/kafka/zk_client_jaas.conf $configfile + output_yaml=$PWD/tmp/dmaapmr_zk_client_cfc.yaml + __kube_create_configmap dmaapmr-zk-client-jaas.conf $KUBE_ONAP_NAMESPACE autotest DMAAPMR $configfile $output_yaml + + # Create config maps - zookeeper app + configfile=$PWD/tmp/zk_server_jaas.conf + cp $SIM_GROUP"/"$MR_DMAAP_COMPOSE_DIR"/"mnt/zk/zk_server_jaas.conf $configfile + output_yaml=$PWD/tmp/dmaapmr_zk_server_cfc.yaml + __kube_create_configmap dmaapmr-zk-server-jaas.conf $KUBE_ONAP_NAMESPACE autotest DMAAPMR $configfile $output_yaml + + # Create service + input_yaml=$SIM_GROUP"/"$MR_DMAAP_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/dmaapmr_svc.yaml + __kube_create_instance service $MR_DMAAP_APP_NAME $input_yaml $output_yaml + + # Create app + input_yaml=$SIM_GROUP"/"$MR_DMAAP_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/dmaapmr_app.yaml + __kube_create_instance app $MR_DMAAP_APP_NAME $input_yaml $output_yaml + + + echo " Retrieving host and ports for service..." + MR_DMAAP_HOST_NAME=$(__kube_get_service_host $MR_DMAAP_APP_NAME $KUBE_ONAP_NAMESPACE) + + MR_EXT_PORT=$(__kube_get_service_port $MR_DMAAP_APP_NAME $KUBE_ONAP_NAMESPACE "http") + MR_EXT_SECURE_PORT=$(__kube_get_service_port $MR_DMAAP_APP_NAME $KUBE_ONAP_NAMESPACE "https") + + echo " Host IP, http port, https port: $MR_DMAAP_APP_NAME $MR_EXT_PORT $MR_EXT_SECURE_PORT" + MR_SERVICE_PATH="" + if [ $MR_HTTPX == "http" ]; then + MR_DMAAP_PATH=$MR_HTTPX"://"$MR_DMAAP_HOST_NAME":"$MR_EXT_PORT + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXT_PORT + else + MR_DMAAP_PATH=$MR_HTTPX"://"$MR_DMAAP_HOST_NAME":"$MR_EXT_SECURE_PORT + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_DMAAP_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXT_SECURE_PORT + fi + + __check_service_start $MR_DMAAP_APP_NAME $MR_DMAAP_PATH$MR_DMAAP_ALIVE_URL + + fi + + if [ $retcode_included_mr -eq 0 ]; then + #exporting needed var for deployment + export MR_STUB_APP_NAME + export KUBE_ONAP_NAMESPACE + export MRSTUB_IMAGE + export MR_INTERNAL_PORT + export MR_INTERNAL_SECURE_PORT + export MR_EXTERNAL_PORT + export MR_EXTERNAL_SECURE_PORT + + if [ $retcode_prestarted_dmaapmr -eq 0 ] || [ $retcode_included_dmaapmr -eq 0 ]; then # Set topics for dmaap + export TOPIC_READ="http://$MR_DMAAP_APP_NAME.$KUBE_ONAP_NAMESPACE:$MR_INTERNAL_PORT/events/$MR_READ_TOPIC" + export TOPIC_WRITE="http://$MR_DMAAP_APP_NAME.$KUBE_ONAP_NAMESPACE:$MR_INTERNAL_PORT/events/$MR_WRITE_TOPIC/users/mr-stub?timeout=15000&limit=100" + else + export TOPIC_READ="" + export TOPIC_WRITE="" + fi + + #Check if onap namespace exists, if not create it + __kube_create_namespace $KUBE_ONAP_NAMESPACE + + # Create service + input_yaml=$SIM_GROUP"/"$MR_STUB_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/mr_svc.yaml + __kube_create_instance service $MR_STUB_APP_NAME $input_yaml $output_yaml + + # Create app + input_yaml=$SIM_GROUP"/"$MR_STUB_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/mr_app.yaml + __kube_create_instance app $MR_STUB_APP_NAME $input_yaml $output_yaml + + + fi + + + echo " Retrieving host and ports for service..." + MR_STUB_HOST_NAME=$(__kube_get_service_host $MR_STUB_APP_NAME $KUBE_ONAP_NAMESPACE) + + MR_EXT_PORT=$(__kube_get_service_port $MR_STUB_APP_NAME $KUBE_ONAP_NAMESPACE "http") + MR_EXT_SECURE_PORT=$(__kube_get_service_port $MR_STUB_APP_NAME $KUBE_ONAP_NAMESPACE "https") + + echo " Host IP, http port, https port: $MR_STUB_APP_NAME $MR_EXT_PORT $MR_EXT_SECURE_PORT" + if [ $MR_HTTPX == "http" ]; then + MR_STUB_PATH=$MR_HTTPX"://"$MR_STUB_HOST_NAME":"$MR_EXT_PORT + if [ -z "$MR_SERVICE_PATH" ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_STUB_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXT_PORT + fi + else + MR_STUB_PATH=$MR_HTTPX"://"$MR_STUB_HOST_NAME":"$MR_EXT_SECURE_PORT + if [ -z "$MR_SERVICE_PATH" ]; then + MR_SERVICE_PATH=$MR_HTTPX"://"$MR_STUB_APP_NAME"."$KUBE_ONAP_NAMESPACE":"$MR_EXT_SECURE_PORT + fi + fi + MR_ADAPTER_HTTP="http://"$MR_STUB_HOST_NAME":"$MR_EXT_PORT + MR_ADAPTER_HTTPS="https://"$MR_STUB_HOST_NAME":"$MR_EXT_SECURE_PORT + + __check_service_start $MR_STUB_APP_NAME $MR_STUB_PATH$MR_STUB_ALIVE_URL + + echo -ne " Service $MR_STUB_APP_NAME - reset "$SAMELINE + result=$(__do_curl $MR_STUB_APP_NAME $MR_STUB_PATH/reset) + if [ $? -ne 0 ]; then + echo -e " Service $MR_STUB_APP_NAME - reset $RED Failed $ERED - will continue" + else + echo -e " Service $MR_STUB_APP_NAME - reset $GREEN OK $EGREEN" + fi + + + else + + __check_included_image 'DMAAPMR' + retcode_dmaapmr=$? + __check_included_image 'MR' + retcode_mr=$? + + if [ $retcode_dmaapmr -ne 0 ] && [ $retcode_mr -ne 0 ]; then + echo -e $RED"The Message Router apps 'MR' and/or 'DMAAPMR' are not included in this test script"$ERED + echo -e $RED"The Message Router will not be started"$ERED + echo -e $RED"Both MR and DAAMPMR - or - only MR - need to be included" + exit + fi + + if [ $retcode_dmaapmr -eq 0 ] && [ $retcode_mr -ne 0 ]; then + echo -e $RED"The Message Router apps 'MR' and/or 'DMAAPMR' are not included in this test script"$ERED + echo -e $RED"The Message Router will not be started"$ERED + echo -e $RED"Both MR and DAAMPMR - or - only MR - need to be included" + exit + fi + + export TOPIC_READ="" + export TOPIC_WRITE="" + if [ $retcode_dmaapmr -eq 0 ]; then # Set topics for dmaap + export TOPIC_READ="http://$MR_DMAAP_APP_NAME:$MR_INTERNAL_PORT/events/$MR_READ_TOPIC" + export TOPIC_WRITE="http://$MR_DMAAP_APP_NAME:$MR_INTERNAL_PORT/events/$MR_WRITE_TOPIC/users/mr-stub?timeout=15000&limit=100" + fi + + export DOCKER_SIM_NWNAME + export ONAP_ZOOKEEPER_IMAGE + export MR_ZOOKEEPER_APP_NAME + export ONAP_KAFKA_IMAGE + export MR_KAFKA_APP_NAME + export ONAP_DMAAPMR_IMAGE + export MR_DMAAP_APP_NAME + export MR_DMAAP_LOCALHOST_PORT + export MR_INTERNAL_PORT + export MR_DMAAP_LOCALHOST_SECURE_PORT + export MR_INTERNAL_SECURE_PORT + + if [ $retcode_dmaapmr -eq 0 ]; then + __start_container $MR_DMAAP_COMPOSE_DIR NODOCKERARGS 1 $MR_DMAAP_APP_NAME + + __check_service_start $MR_DMAAP_APP_NAME $MR_DMAAP_PATH$MR_DMAAP_ALIVE_URL + + + __create_topic $MR_READ_TOPIC "Topic for reading policy messages" + + __create_topic $MR_WRITE_TOPIC "Topic for writing policy messages" + + __dmaap_pipeclean $MR_READ_TOPIC "/events/A1-POLICY-AGENT-READ" "/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=1000&limit=100" + + __dmaap_pipeclean $MR_WRITE_TOPIC "/events/A1-POLICY-AGENT-WRITE" "/events/A1-POLICY-AGENT-WRITE/users/mr-stub?timeout=1000&limit=100" + + echo " Current topics:" + curlString="$MR_DMAAP_PATH/topics" + result=$(__do_curl "$curlString") + echo $result | indent2 + fi + + export DOCKER_SIM_NWNAME + export MR_STUB_APP_NAME + export MRSTUB_IMAGE + export MR_INTERNAL_PORT + export MR_INTERNAL_SECURE_PORT + export MR_STUB_LOCALHOST_PORT + export MR_STUB_LOCALHOST_SECURE_PORT + export MR_STUB_CERT_MOUNT_DIR + + if [ $retcode_mr -eq 0 ]; then + __start_container $MR_STUB_COMPOSE_DIR NODOCKERARGS 1 $MR_STUB_APP_NAME + + __check_service_start $MR_STUB_APP_NAME $MR_STUB_PATH$MR_STUB_ALIVE_URL + fi + + fi + echo "" + return 0 +} + +### Generic test cases for varaible checking + +# Tests if a variable value in the MR stub is equal to a target value and and optional timeout. +# Arg: - This test set pass or fail depending on if the variable is +# equal to the target or not. +# Arg: - This test waits up to the timeout seconds +# before setting pass or fail depending on if the variable value becomes equal to the target +# value or not. +# (Function for test scripts) +mr_equal() { + if [ $# -eq 2 ] || [ $# -eq 3 ]; then + __var_test "MR" $MR_STUB_PATH/counter/ $1 "=" $2 $3 + else + ((RES_CONF_FAIL++)) + __print_err "Wrong args to mr_equal, needs two or three args: [ timeout ]" $@ + fi +} + +# Tests if a variable value in the MR stub is greater than a target value and and optional timeout. +# Arg: - This test set pass or fail depending on if the variable is +# greater than the target or not. +# Arg: - This test waits up to the timeout seconds +# before setting pass or fail depending on if the variable value becomes greater than the target +# value or not. +# (Function for test scripts) +mr_greater() { + if [ $# -eq 2 ] || [ $# -eq 3 ]; then + __var_test "MR" $MR_STUB_PATH/counter/ $1 ">" $2 $3 + else + ((RES_CONF_FAIL++)) + __print_err "Wrong args to mr_greater, needs two or three args: [ timeout ]" $@ + fi +} + +# Read a variable value from MR sim and send to stdout. Arg: +mr_read() { + echo "$(__do_curl $MR_STUB_PATH/counter/$1)" +} + +# Print a variable value from the MR stub. +# arg: +# (Function for test scripts) +mr_print() { + if [ $# != 1 ]; then + ((RES_CONF_FAIL++)) + __print_err "need one arg, " $@ + exit 1 + fi + echo -e $BOLD"INFO(${BASH_LINENO[0]}): mrstub, $1 = $(__do_curl $MR_STUB_PATH/counter/$1)"$EBOLD +} \ No newline at end of file diff --git a/test/common/prodstub_api_functions.sh b/test/common/prodstub_api_functions.sh index a27f3b4b..4dfe06b7 100644 --- a/test/common/prodstub_api_functions.sh +++ b/test/common/prodstub_api_functions.sh @@ -17,9 +17,169 @@ # ============LICENSE_END================================================= # +# This is a script that contains container/service management functions and test functions for Producer stub + +## Access to Prod stub sim +# Direct access +PROD_STUB_HTTPX="http" +PROD_STUB_HOST_NAME=$LOCALHOST_NAME +PROD_STUB_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_HOST_NAME":"$PROD_STUB_EXTERNAL_PORT + +#Docker/Kube internal path +if [ $RUNMODE == "KUBE" ]; then + PROD_STUB_SERVICE_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_APP_NAME"."$KUBE_SIM_NAMESPACE":"$PROD_STUB_EXTERNAL_PORT +else + PROD_STUB_SERVICE_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_APP_NAME":"$PROD_STUB_INTERNAL_PORT +fi + +# Set http as the protocol to use for all communication to the Producer stub +# args: - +# (Function for test scripts) +use_prod_stub_http() { + echo -e $BOLD"Producer stub protocol setting"$EBOLD + echo -e " Using $BOLD http $EBOLD towards Producer stub" + + PROD_STUB_HTTPX="http" + PROD_STUB_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_HOST_NAME":"$PROD_STUB_EXTERNAL_PORT + + if [ $RUNMODE == "KUBE" ]; then + PROD_STUB_SERVICE_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_APP_NAME"."$KUBE_SIM_NAMESPACE":"$PROD_STUB_EXTERNAL_PORT + else + PROD_STUB_SERVICE_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_APP_NAME":"$PROD_STUB_INTERNAL_PORT + fi + + echo "" +} + +# Set https as the protocol to use for all communication to the Producer stub +# args: - +# (Function for test scripts) +use_prod_stub_https() { + echo -e $BOLD"Producer stub protocol setting"$EBOLD + echo -e " Using $BOLD https $EBOLD towards Producer stub" + + PROD_STUB_HTTPX="https" + PROD_STUB_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_HOST_NAME":"$PROD_STUB_EXTERNAL_SECURE_PORT + + if [ $RUNMODE == "KUBE" ]; then + PROD_STUB_SERVICE_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_APP_NAME"."$KUBE_SIM_NAMESPACE":"$PROD_STUB_EXTERNAL_SECURE_PORT + else + PROD_STUB_SERVICE_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_APP_NAME":"$PROD_STUB_INTERNAL_SECURE_PORT + fi + echo "" +} ### Admin API functions producer stub +########################### +### Producer stub functions +########################### + +# Start the Producer stub in the simulator group +# args: - +# (Function for test scripts) +start_prod_stub() { + + echo -e $BOLD"Starting $PROD_STUB_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + + # Check if app shall be fully managed by the test script + __check_included_image "PRODSTUB" + retcode_i=$? + + # Check if app shall only be used by the testscipt + __check_prestarted_image "PRODSTUB" + retcode_p=$? + + if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then + echo -e $RED"The $ECS_APP_NAME app is not included as managed nor prestarted in this test script"$ERED + echo -e $RED"The $ECS_APP_NAME will not be started"$ERED + exit + fi + if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then + echo -e $RED"The $ECS_APP_NAME app is included both as managed and prestarted in this test script"$ERED + echo -e $RED"The $ECS_APP_NAME will not be started"$ERED + exit + fi + + if [ $retcode_p -eq 0 ]; then + echo -e " Using existing $PROD_STUB_APP_NAME deployment and service" + echo " Setting RC replicas=1" + __kube_scale deployment $PROD_STUB_APP_NAME $KUBE_SIM_NAMESPACE 1 + fi + + if [ $retcode_i -eq 0 ]; then + echo -e " Creating $PROD_STUB_APP_NAME deployment and service" + export PROD_STUB_APP_NAME + export KUBE_SIM_NAMESPACE + export PROD_STUB_IMAGE + export PROD_STUB_INTERNAL_PORT + export PROD_STUB_INTERNAL_SECURE_PORT + export PROD_STUB_EXTERNAL_PORT + export PROD_STUB_EXTERNAL_SECURE_PORT + + __kube_create_namespace $KUBE_SIM_NAMESPACE + + # Create service + input_yaml=$SIM_GROUP"/"$PROD_STUB_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/prodstub_svc.yaml + __kube_create_instance service $PROD_STUB_APP_NAME $input_yaml $output_yaml + + # Create app + input_yaml=$SIM_GROUP"/"$PROD_STUB_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/prodstub_app.yaml + __kube_create_instance app $PROD_STUB_APP_NAME $input_yaml $output_yaml + fi + + PROD_STUB_HOST_NAME=$(__kube_get_service_host $PROD_STUB_APP_NAME $KUBE_SIM_NAMESPACE) + + PROD_STUB_EXTERNAL_PORT=$(__kube_get_service_port $PROD_STUB_APP_NAME $KUBE_SIM_NAMESPACE "http") + PROD_STUB_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $PROD_STUB_APP_NAME $KUBE_SIM_NAMESPACE "https") + + echo " Host IP, http port, https port: $PROD_STUB_HOST_NAME $PROD_STUB_EXTERNAL_PORT $PROD_STUB_EXTERNAL_SECURE_PORT" + if [ $PROD_STUB_HTTPX == "http" ]; then + PROD_STUB_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_HOST_NAME":"$PROD_STUB_EXTERNAL_PORT + PROD_STUB_SERVICE_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_APP_NAME"."$KUBE_SIM_NAMESPACE":"$PROD_STUB_EXTERNAL_PORT + else + PROD_STUB_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_HOST_NAME":"$PROD_STUB_EXTERNAL_SECURE_PORT + PROD_STUB_SERVICE_PATH=$PROD_STUB_HTTPX"://"$PROD_STUB_APP_NAME"."$KUBE_SIM_NAMESPACE":"$PROD_STUB_EXTERNAL_SECURE_PORT + fi + + __check_service_start $PROD_STUB_APP_NAME $PROD_STUB_PATH$PROD_STUB_ALIVE_URL + + echo -ne " Service $PROD_STUB_APP_NAME - reset "$SAMELINE + result=$(__do_curl $PROD_STUB_PATH/reset) + if [ $? -ne 0 ]; then + echo -e " Service $PROD_STUB_APP_NAME - reset $RED Failed $ERED - will continue" + else + echo -e " Service $PROD_STUB_APP_NAME - reset $GREEN OK $EGREEN" + fi + else + + # Check if docker app shall be fully managed by the test script + __check_included_image 'PRODSTUB' + if [ $? -eq 1 ]; then + echo -e $RED"The Producer stub app is not included as managed in this test script"$ERED + echo -e $RED"The Producer stub will not be started"$ERED + exit + fi + + export PROD_STUB_APP_NAME + export PROD_STUB_APP_NAME_ALIAS + export PROD_STUB_INTERNAL_PORT + export PROD_STUB_EXTERNAL_PORT + export PROD_STUB_INTERNAL_SECURE_PORT + export PROD_STUB_EXTERNAL_SECURE_PORT + export DOCKER_SIM_NWNAME + + __start_container $PROD_STUB_COMPOSE_DIR NODOCKERARGS 1 $PROD_STUB_APP_NAME + + __check_service_start $PROD_STUB_APP_NAME $PROD_STUB_PATH$PROD_STUB_ALIVE_URL + fi + echo "" + return 0 +} # Excute a curl cmd towards the prodstub simulator and check the response code. # args: TEST|CONF [] @@ -75,7 +235,7 @@ prodstub_arm_producer() { return 1 fi - curlString="curl -X PUT -skw %{http_code} $PROD_STUB_LOCALHOST/arm/supervision/"$2 + curlString="curl -X PUT -skw %{http_code} $PROD_STUB_PATH/arm/supervision/"$2 if [ $# -eq 3 ]; then curlString=$curlString"?response="$3 fi @@ -94,7 +254,7 @@ prodstub_arm_job_create() { return 1 fi - curlString="curl -X PUT -skw %{http_code} $PROD_STUB_LOCALHOST/arm/create/$2/$3" + curlString="curl -X PUT -skw %{http_code} $PROD_STUB_PATH/arm/create/$2/$3" if [ $# -eq 4 ]; then curlString=$curlString"?response="$4 fi @@ -113,7 +273,7 @@ prodstub_arm_job_delete() { return 1 fi - curlString="curl -X PUT -skw %{http_code} $PROD_STUB_LOCALHOST/arm/delete/$2/$3" + curlString="curl -X PUT -skw %{http_code} $PROD_STUB_PATH/arm/delete/$2/$3" if [ $# -eq 4 ]; then curlString=$curlString"?response="$4 fi @@ -132,7 +292,7 @@ prodstub_arm_type() { return 1 fi - curlString="curl -X PUT -skw %{http_code} $PROD_STUB_LOCALHOST/arm/type/$2/$3" + curlString="curl -X PUT -skw %{http_code} $PROD_STUB_PATH/arm/type/$2/$3" __execute_curl_to_prodstub CONF $1 "$curlString" return $? @@ -148,7 +308,7 @@ prodstub_disarm_type() { return 1 fi - curlString="curl -X DELETE -skw %{http_code} $PROD_STUB_LOCALHOST/arm/type/$2/$3" + curlString="curl -X DELETE -skw %{http_code} $PROD_STUB_PATH/arm/type/$2/$3" __execute_curl_to_prodstub CONF $1 "$curlString" return $? @@ -174,7 +334,7 @@ prodstub_check_jobdata() { file="./tmp/.p.json" echo "$targetJson" > $file - curlString="curl -X GET -skw %{http_code} $PROD_STUB_LOCALHOST/jobdata/$2/$3" + curlString="curl -X GET -skw %{http_code} $PROD_STUB_PATH/jobdata/$2/$3" __execute_curl_to_prodstub TEST $1 "$curlString" $file return $? @@ -189,7 +349,7 @@ prodstub_delete_jobdata() { __print_err " " $@ return 1 fi - curlString="curl -X DELETE -skw %{http_code} $PROD_STUB_LOCALHOST/jobdata/$2/$3" + curlString="curl -X DELETE -skw %{http_code} $PROD_STUB_PATH/jobdata/$2/$3" __execute_curl_to_prodstub CONF $1 "$curlString" return $? @@ -204,7 +364,7 @@ prodstub_delete_jobdata() { # (Function for test scripts) prodstub_equal() { if [ $# -eq 2 ] || [ $# -eq 3 ]; then - __var_test "PRODSTUB" "$LOCALHOST$PROD_STUB_EXTERNAL_PORT/counter/" $1 "=" $2 $3 + __var_test "PRODSTUB" "$PROD_STUB_PATH/counter/" $1 "=" $2 $3 else __print_err "Wrong args to prodstub_equal, needs two or three args: [ timeout ]" $@ fi diff --git a/test/common/rapp_catalogue_api_functions.sh b/test/common/rapp_catalogue_api_functions.sh index dce28f3d..777b9d37 100644 --- a/test/common/rapp_catalogue_api_functions.sh +++ b/test/common/rapp_catalogue_api_functions.sh @@ -17,9 +17,149 @@ # ============LICENSE_END================================================= # -# This is a script that contains specific test functions for RAPP Catalogue API +# This is a script that contains container/service managemnt functions test functions for RAPP Catalogue API -. ../common/api_curl.sh +## Access to RAPP Catalogue +# Host name may be changed if app started by kube +# Direct access from script +RC_HTTPX="http" +RC_HOST_NAME=$LOCALHOST_NAME +RC_PATH=$RC_HTTPX"://"$RC_HOST_NAME":"$RAPP_CAT_EXTERNAL_PORT +# RC_ADAPTER used for switch between REST and DMAAP (only REST supported currently) +RC_ADAPTER_TYPE="REST" +RC_ADAPTER=$RC_PATH + + +########################### +### RAPP Catalogue +########################### + +# Set http as the protocol to use for all communication to the RAPP Catalogue +# args: - +# (Function for test scripts) +use_rapp_catalogue_http() { + echo -e $BOLD"RAPP Catalogue protocol setting"$EBOLD + echo -e " Using $BOLD http $EBOLD towards the RAPP Catalogue" + RC_HTTPX="http" + RC_PATH=$RC_HTTPX"://"$RC_HOST_NAME":"$RAPP_CAT_EXTERNAL_PORT + RC_ADAPTER_TYPE="REST" + RC_ADAPTER=$RC_PATH + echo "" +} + +# Set https as the protocol to use for all communication to the RAPP Catalogue +# args: - +# (Function for test scripts) +use_rapp_catalogue_https() { + echo -e $BOLD"RAPP Catalogue protocol setting"$EBOLD + echo -e " Using $BOLD https $EBOLD towards the RAPP Catalogue" + RC_HTTPX="https" + RC_PATH=$RC_HTTPX"://"$RC_HOST_NAME":"$RAPP_CAT_EXTERNAL_SECURE_PORT + RC_ADAPTER_TYPE="REST" + RC_ADAPTER=$RC_PATH + echo "" +} + +# Start the RAPP Catalogue container +# args: - +# (Function for test scripts) +start_rapp_catalogue() { + + echo -e $BOLD"Starting $RAPP_CAT_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + + # Check if app shall be fully managed by the test script + __check_included_image "RC" + retcode_i=$? + + # Check if app shall only be used by the testscipt + __check_prestarted_image "RC" + retcode_p=$? + + if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then + echo -e $RED"The $RAPP_CAT_APP_NAME app is not included as managed nor prestarted in this test script"$ERED + echo -e $RED"The $RAPP_CAT_APP_NAME will not be started"$ERED + exit + fi + if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then + echo -e $RED"The $RAPP_CAT_APP_NAME app is included both as managed and prestarted in this test script"$ERED + echo -e $RED"The $RAPP_CAT_APP_NAME will not be started"$ERED + exit + fi + + if [ $retcode_p -eq 0 ]; then + echo -e " Using existing $RAPP_CAT_APP_NAME deployment and service" + echo " Setting $RAPP_CAT_APP_NAME replicas=1" + __kube_scale deployment $RAPP_CAT_APP_NAME $KUBE_NONRTRIC_NAMESPACE 1 + fi + + if [ $retcode_i -eq 0 ]; then + + echo -e " Creating $RAPP_CAT_APP_NAME app and expose service" + + #Check if nonrtric namespace exists, if not create it + __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE + + export RAPP_CAT_APP_NAME + export KUBE_NONRTRIC_NAMESPACE + export RAPP_CAT_IMAGE + export RAPP_CAT_INTERNAL_PORT + export RAPP_CAT_INTERNAL_SECURE_PORT + export RAPP_CAT_EXTERNAL_PORT + export RAPP_CAT_EXTERNAL_SECURE_PORT + + #Create service + input_yaml=$SIM_GROUP"/"$RAPP_CAT_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/rac_svc.yaml + __kube_create_instance service $RAPP_CAT_APP_NAME $input_yaml $output_yaml + + #Create app + input_yaml=$SIM_GROUP"/"$RAPP_CAT_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/rac_app.yaml + __kube_create_instance app $RAPP_CAT_APP_NAME $input_yaml $output_yaml + fi + + echo " Retrieving host and ports for service..." + RC_HOST_NAME=$(__kube_get_service_host $RAPP_CAT_APP_NAME $KUBE_NONRTRIC_NAMESPACE) + + RAPP_CAT_EXTERNAL_PORT=$(__kube_get_service_port $RAPP_CAT_APP_NAME $KUBE_NONRTRIC_NAMESPACE "http") + RAPP_CAT_EXTERNAL_SECURE_PORT=$(__kube_get_service_port $RAPP_CAT_APP_NAME $KUBE_NONRTRIC_NAMESPACE "https") + + echo " Host IP, http port, https port: $RC_HOST_NAME $RAPP_CAT_EXTERNAL_PORT $RAPP_CAT_EXTERNAL_SECURE_PORT" + if [ $RC_HTTPX == "http" ]; then + RC_PATH=$RC_HTTPX"://"$RC_HOST_NAME":"$RAPP_CAT_EXTERNAL_PORT + else + RC_PATH=$RC_HTTPX"://"$RC_HOST_NAME":"$RAPP_CAT_EXTERNAL_SECURE_PORT + fi + + __check_service_start $RAPP_CAT_APP_NAME $RC_PATH$RAPP_CAT_ALIVE_URL + + # Update the curl adapter if set to rest, no change if type dmaap + if [ $RC_ADAPTER_TYPE == "REST" ]; then + RC_ADAPTER=$RC_PATH + fi + else + __check_included_image 'RC' + if [ $? -eq 1 ]; then + echo -e $RED"The RAPP Catalogue app is not included as managed in this test script"$ERED + echo -e $RED"The RAPP Catalogue will not be started"$ERED + exit + fi + + export RAPP_CAT_APP_NAME + export RAPP_CAT_INTERNAL_PORT + export RAPP_CAT_EXTERNAL_PORT + export RAPP_CAT_INTERNAL_SECURE_PORT + export RAPP_CAT_EXTERNAL_SECURE_PORT + export DOCKER_SIM_NWNAME + + __start_container $RAPP_CAT_COMPOSE_DIR NODOCKERARGS 1 $RAPP_CAT_APP_NAME + + __check_service_start $RAPP_CAT_APP_NAME $RC_PATH$RAPP_CAT_ALIVE_URL + fi + echo "" +} # Tests if a variable value in the RAPP Catalogue is equal to a target value and and optional timeout. # Arg: - This test set pass or fail depending on if the variable is @@ -30,7 +170,8 @@ # (Function for test scripts) rc_equal() { if [ $# -eq 2 ] || [ $# -eq 3 ]; then - __var_test RC "$LOCALHOST$RC_EXTERNAL_PORT/" $1 "=" $2 $3 + #__var_test RC "$LOCALHOST_HTTP:$RC_EXTERNAL_PORT/" $1 "=" $2 $3 + __var_test RC "$RC_PATH/" $1 "=" $2 $3 else __print_err "Wrong args to ecs_equal, needs two or three args: [ timeout ]" $@ fi diff --git a/test/common/ricsimulator_api_functions.sh b/test/common/ricsimulator_api_functions.sh index 2a68aa0e..bb057ce7 100644 --- a/test/common/ricsimulator_api_functions.sh +++ b/test/common/ricsimulator_api_functions.sh @@ -17,8 +17,211 @@ # ============LICENSE_END================================================= # +# This is a script that contains container/service management functions and test functions for RICSIM A1 simulators + +RIC_SIM_HTTPX="http" +RIC_SIM_HOST=$RIC_SIM_HTTPX"://"$LOCALHOST_NAME +RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT + + +#Vars for A1 interface version and container count +G1_A1_VERSION="" +G2_A1_VERSION="" +G3_A1_VERSION="" +G4_A1_VERSION="" +G5_A1_VERSION="" +G1_COUNT=0 +G2_COUNT=0 +G3_COUNT=0 +G4_COUNT=0 +G5_COUNT=0 + + +########################### +### RIC Simulator functions +########################### + +use_simulator_http() { + echo -e $BOLD"RICSIM protocol setting"$EBOLD + echo -e " Using $BOLD http $EBOLD towards the simulators" + RIC_SIM_HTTPX="http" + RIC_SIM_HOST=$RIC_SIM_HTTPX"://"$LOCALHOST_NAME + RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT + echo "" +} + +use_simulator_https() { + echo -e $BOLD"RICSIM protocol setting"$EBOLD + echo -e " Using $BOLD https $EBOLD towards the simulators" + RIC_SIM_HTTPX="https" + RIC_SIM_HOST=$RIC_SIM_HTTPX"://"$LOCALHOST_NAME + RIC_SIM_PORT=$RIC_SIM_INTERNAL_SECURE_PORT + echo "" +} + +# Start one group (ricsim_g1, ricsim_g2 .. ricsim_g5) with a number of RIC Simulators using a given A interface +# 'ricsim' may be set on command line to other prefix +# args: ricsim_g1|ricsim_g2|ricsim_g3|ricsim_g4|ricsim_g5 +# (Function for test scripts) +start_ric_simulators() { + + echo -e $BOLD"Starting $RIC_SIM_DISPLAY_NAME"$EBOLD + + if [ $RUNMODE == "KUBE" ]; then + + # Check if app shall be fully managed by the test script + __check_included_image "RICSIM" + retcode_i=$? + + # Check if app shall only be used by the testscipt + __check_prestarted_image "RICSIM" + retcode_p=$? + + if [ $retcode_i -ne 0 ] && [ $retcode_p -ne 0 ]; then + echo -e $RED"The $1 app is not included as managed nor prestarted in this test script"$ERED + echo -e $RED"The $1 will not be started"$ERED + exit + fi + if [ $retcode_i -eq 0 ] && [ $retcode_p -eq 0 ]; then + echo -e $RED"The $1 stub app is included both as managed and prestarted in this test script"$ERED + echo -e $RED"The $1 will not be started"$ERED + exit + fi + + if [ $retcode_p -eq 0 ]; then + echo -e " Using existing $1 statefulset and service" + echo " Using existing simulator deployment and service for statefulset $1" + echo " Setting $1 replicas=$2" + __kube_scale statefulset $1 $KUBE_NONRTRIC_NAMESPACE $2 + echo "" + return + fi + fi + + RIC1=$RIC_SIM_PREFIX"_g1" + RIC2=$RIC_SIM_PREFIX"_g2" + RIC3=$RIC_SIM_PREFIX"_g3" + RIC4=$RIC_SIM_PREFIX"_g4" + RIC5=$RIC_SIM_PREFIX"_g5" + + if [ $# != 3 ]; then + ((RES_CONF_FAIL++)) + __print_err "need three args, $RIC1|$RIC2|$RIC3|$RIC4|$RIC5 " $@ + exit 1 + fi + + echo " $2 simulators using basename: $1 on interface: $3" + #Set env var for simulator count and A1 interface vesion for the given group + if [ $1 == "$RIC1" ]; then + G1_COUNT=$2 + G1_A1_VERSION=$3 + elif [ $1 == "$RIC2" ]; then + G2_COUNT=$2 + G2_A1_VERSION=$3 + elif [ $1 == "$RIC3" ]; then + G3_COUNT=$2 + G3_A1_VERSION=$3 + elif [ $1 == "$RIC4" ]; then + G4_COUNT=$2 + G4_A1_VERSION=$3 + elif [ $1 == "$RIC5" ]; then + G5_COUNT=$2 + G5_A1_VERSION=$3 + else + ((RES_CONF_FAIL++)) + __print_err "need three args, $RIC1|$RIC2|$RIC3|$RIC4|$RIC5 " $@ + exit 1 + fi + + if [ $RUNMODE == "KUBE" ]; then + + if [ $retcode_i -eq 0 ]; then + + #export needed env var for statefulset + export RIC_SIM_SET_NAME=$(echo "$1" | tr '_' '-') #kube does not accept underscore in names + export KUBE_NONRTRIC_NAMESPACE + export RIC_SIM_IMAGE + #Adding 1 more instance, instance 0 is never used. This is done to keep test scripts compatible + # with docker that starts instance index on 1..... + export RIC_SIM_COUNT=$(($2+1)) + export A1_VERSION=$3 + export RIC_SIM_INTERNAL_PORT + export RIC_SIM_INTERNAL_SECURE_PORT + + echo -e " Creating $POLICY_AGENT_APP_NAME app and expose service" + + #Check if nonrtric namespace exists, if not create it + __kube_create_namespace $KUBE_NONRTRIC_NAMESPACE + + # Create service + input_yaml=$SIM_GROUP"/"$RIC_SIM_COMPOSE_DIR"/"svc.yaml + output_yaml=$PWD/tmp/ric_${1}_svc.yaml + __kube_create_instance service $RIC_SIM_SET_NAME $input_yaml $output_yaml + + # Create app + input_yaml=$SIM_GROUP"/"$RIC_SIM_COMPOSE_DIR"/"app.yaml + output_yaml=$PWD/tmp/pa_${1}_app.yaml + __kube_create_instance app $RIC_SIM_SET_NAME $input_yaml $output_yaml + + #Using only instance from index 1 to keep compatability with docker + for (( count=1; count<${RIC_SIM_COUNT}; count++ )); do + host=$(__find_sim_host $RIC_SIM_SET_NAME"-"$count) + __check_service_start $RIC_SIM_SET_NAME"-"$count $host"/" + done + fi + else + + __check_included_image 'RICSIM' + if [ $? -eq 1 ]; then + echo -e $RED"The Near-RT RIC Simulator app is not included as managed in this test script"$ERED + echo -e $RED"Near-RT RIC Simulator will not be started"$ERED + exit 1 + fi + + # Create .env file to compose project, all ric container will get this prefix + echo "COMPOSE_PROJECT_NAME="$RIC_SIM_PREFIX > $SIM_GROUP/$RIC_SIM_COMPOSE_DIR/.env + + export G1_A1_VERSION + export G2_A1_VERSION + export G3_A1_VERSION + export G4_A1_VERSION + export G5_A1_VERSION + export RIC_SIM_INTERNAL_PORT + export RIC_SIM_INTERNAL_SECURE_PORT + export RIC_SIM_CERT_MOUNT_DIR + export DOCKER_SIM_NWNAME + + docker_args="--scale g1=$G1_COUNT --scale g2=$G2_COUNT --scale g3=$G3_COUNT --scale g4=$G4_COUNT --scale g5=$G5_COUNT" + app_data="" + cntr=1 + while [ $cntr -le $2 ]; do + app=$1"_"$cntr + app_data="$app_data $app" + let cntr=cntr+1 + done + + __start_container $RIC_SIM_COMPOSE_DIR "$docker_args" $2 $app_data + + cntr=1 + while [ $cntr -le $2 ]; do + app=$1"_"$cntr + localport=0 + + while [ $localport -eq 0 ]; do + echo -ne " Waiting for container ${app} to publish its ports...${SAMELINE}" + localport=$(__find_sim_port $app) + sleep 0.5 + echo -ne " Waiting for container ${app} to publish its ports...retrying....${SAMELINE}" + done + echo -e " Waiting for container ${app} to publish its ports...retrying....$GREEN OK $EGREEN" + __check_service_start $app $RIC_SIM_HOST":"$localport$RIC_SIM_ALIVE_URL + let cntr=cntr+1 + done + fi + echo "" + return 0 +} -### Admin API functions for the RIC simulator # Excute a curl cmd towards a ricsimulator and check the response code. @@ -55,8 +258,8 @@ __execute_curl_to_sim() { sim_equal() { if [ $# -eq 3 ] || [ $# -eq 4 ]; then - port=$(__find_sim_port $1) - __var_test $1 "$RIC_SIM_LOCALHOST$port/counter/" $2 "=" $3 $4 + host=$(__find_sim_host $1) + __var_test $1 "$host/counter/" $2 "=" $3 $4 return 0 else __print_err "needs three or four args: [ timeout ]" @@ -73,8 +276,8 @@ sim_print() { __print_err "need two args, " $@ exit 1 fi - port=$(__find_sim_port $1) - echo -e $BOLD"INFO(${BASH_LINENO[0]}): $1, $2 = $(__do_curl $RIC_SIM_LOCALHOST$port/counter/$2)"$EBOLD + host=$(__find_sim_host $1) + echo -e $BOLD"INFO(${BASH_LINENO[0]}): $1, $2 = $(__do_curl $host/counter/$2)"$EBOLD } # Tests if a variable value in the RIC simulator contains the target string and and optional timeout @@ -87,8 +290,8 @@ sim_print() { sim_contains_str() { if [ $# -eq 3 ] || [ $# -eq 4 ]; then - port=$(__find_sim_port $1) - __var_test $1 "$RIC_SIM_LOCALHOST$port/counter/" $2 "contain_str" $3 $4 + host=$(__find_sim_host $1) + __var_test $1 "$host/counter/" $2 "contain_str" $3 $4 return 0 else __print_err "needs three or four args: [ timeout ]" @@ -105,8 +308,8 @@ sim_put_policy_type() { __print_err " " $@ return 1 fi - res=$(__find_sim_port $2) - curlString="curl -X PUT -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/policytype?id="$3" -H Content-Type:application/json --data-binary @"$4 + host=$(__find_sim_host $2) + curlString="curl -X PUT -skw %{http_code} "$host"/policytype?id="$3" -H Content-Type:application/json --data-binary @"$4 __execute_curl_to_sim $1 "$curlString" return $? } @@ -120,8 +323,8 @@ sim_delete_policy_type() { __print_err " " $@ return 1 fi - res=$(__find_sim_port $2) - curlString="curl -X DELETE -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/policytype?id="$3 + host=$(__find_sim_host $2) + curlString="curl -X DELETE -skw %{http_code} "$host"/policytype?id="$3 __execute_curl_to_sim $1 "$curlString" return $? } @@ -135,8 +338,8 @@ sim_post_delete_instances() { __print_err " " $@ return 1 fi - res=$(__find_sim_port $2) - curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/deleteinstances" + host=$(__find_sim_host $2) + curlString="curl -X POST -skw %{http_code} "$host"/deleteinstances" __execute_curl_to_sim $1 "$curlString" return $? } @@ -150,8 +353,8 @@ sim_post_delete_all() { __print_err " " $@ return 1 fi - res=$(__find_sim_port $2) - curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/deleteall" + host=$(__find_sim_host $2) + curlString="curl -X POST -skw %{http_code} "$host"/deleteall" __execute_curl_to_sim $1 "$curlString" return $? } @@ -165,8 +368,8 @@ sim_post_forcedresponse() { __print_err " " $@ return 1 fi - res=$(__find_sim_port $2) - curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST"$res"/forceresponse" + host=$(__find_sim_host $2) + curlString="curl -X POST -skw %{http_code} "$host"/forceresponse" if [ $# -eq 3 ]; then curlString=$curlString"?code="$3 fi @@ -183,8 +386,8 @@ sim_post_forcedelay() { __print_err " []" $@ return 1 fi - res=$(__find_sim_port $2) - curlString="curl -X POST -skw %{http_code} $RIC_SIM_LOCALHOST$res/forcedelay" + host=$(__find_sim_host $2) + curlString="curl -X POST -skw %{http_code} $host/forcedelay" if [ $# -eq 3 ]; then curlString=$curlString"?delay="$3 fi diff --git a/test/common/test_env-onap-guilin.sh b/test/common/test_env-onap-guilin.sh index 1dc2b363..e0e732c9 100644 --- a/test/common/test_env-onap-guilin.sh +++ b/test/common/test_env-onap-guilin.sh @@ -7,7 +7,7 @@ # 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 +# 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, @@ -18,134 +18,272 @@ # #Profile for ONAP guilin release TEST_ENV_PROFILE="ONAP-GUILIN" +FLAVOUR="ONAP" + +######################################## +## Nexus repo settings +######################################## + +# Nexus repos for developed images NEXUS_PROXY_REPO="nexus3.onap.org:10001/" +NEXUS_RELEASE_REPO="nexus3.onap.org:10002/" +NEXUS_SNAPSHOT_REPO="nexus3.onap.org:10003/" +NEXUS_STAGING_REPO=$NEXUS_SNAPSHOT_REPO #staging repo not used in ONAP, using snapshot -# Set up the image and tags for the test. Do not add the image tag to the image names. +# Nexus repos for images used by test (not developed by the project) +NEXUS_RELEASE_REPO_ORAN="nexus3.o-ran-sc.org:10002/" # Only for released ORAN images +NEXUS_RELEASE_REPO_ONAP=$NEXUS_RELEASE_REPO -# NOTE: A env var for each container is created by the test script. -# This var will point to the local or remote var depending on how -# the test script is started. The name format is _IMAGE, ie with 'LOCAL' or 'REMOTE'. +######################################## +# Set up of image and tags for the test. +######################################## -# Tag for guilin branch -# Remote Policy Agent image and tag -POLICY_AGENT_REMOTE_IMAGE="nexus3.onap.org:10003/onap/ccsdk-oran-a1policymanagementservice" -POLICY_AGENT_REMOTE_IMAGE_TAG="1.0.2-SNAPSHOT" +# NOTE: One environment variable containing the image name and tag is create by the test script +# for each image from the env variables below. +# The variable is created by removing the suffix "_BASE" from the base image variable name. +# Example: POLICY_AGENT_IMAGE_BASE -> POLICY_AGENT_IMAGE +# This var will point to the local or remote image depending on cmd line arguments. +# In addition, the repo and the image tag version are selected from the list of image tags based on the cmd line argurment. +# For images built by the script, only tag #1 shall be specified +# For project images, only tag #1, #2, #3 and #4 shall be specified +# For ORAN images (non project), only tag #5 shall be specified +# For ONAP images (non project), only tag #6 shall be specified +# For all other images, only tag #7 shall be specified +# 1 XXX_LOCAL: local images: : +# 2 XXX_REMOTE_SNAPSHOT: snapshot images: : +# 3 XXX_REMOTE: staging images: : +# 4 XXX_REMOTE_RELEASE: release images: : +# 5 XXX_REMOTE_RELEASE_ORAN: ORAN release images: : +# 6 XXX_REMOTE_RELEASE_ONAP: ONAP release images: : +# 7 XXX_PROXY: other images, not produced by the project: : -# Control Panel remote image and tag -CONTROL_PANEL_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel" -CONTROL_PANEL_REMOTE_IMAGE_TAG="2.0.0" +# Policy Agent image and tags +POLICY_AGENT_IMAGE_BASE="onap/ccsdk-oran-a1policymanagementservice" +POLICY_AGENT_IMAGE_TAG_LOCAL="1.0.2-SNAPSHOT" +POLICY_AGENT_IMAGE_TAG_REMOTE_SNAPSHOT="1.0.2-SNAPSHOT" +POLICY_AGENT_IMAGE_TAG_REMOTE="1.0.2-SNAPSHOT" #Will use snapshot repo +POLICY_AGENT_IMAGE_TAG_REMOTE_RELEASE="1.0.1" + # Tag for guilin branch # SDNC A1 Controller remote image and tag -SDNC_A1_CONTROLLER_REMOTE_IMAGE="nexus3.onap.org:10003/onap/sdnc-image" -SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG="2.0.2-STAGING-latest" +SDNC_A1_CONTROLLER_IMAGE_BASE="onap/sdnc-image" +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE_SNAPSHOT="2.0.5-STAGING-latest" +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE="2.0.5-STAGING-latest" +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE_RELEASE="2.0.4" #Will use snapshot repo #SDNC DB remote image and tag -SDNC_DB_REMOTE_IMAGE=$NEXUS_PROXY_REPO"mysql/mysql-server" -SDNC_DB_REMOTE_IMAGE_TAG="5.6" -#No local image for DB, remote image always used +#The DB is part of SDNC so handled in the same way as SDNC +SDNC_DB_IMAGE_BASE="mysql/mysql-server" +SDNC_DB_IMAGE_TAG_REMOTE_PROXY="5.6" + +# Control Panel image and tag - uses bronze release +CONTROL_PANEL_IMAGE_BASE="o-ran-sc/nonrtric-controlpanel" +CONTROL_PANEL_IMAGE_TAG_REMOTE_RELEASE_ORAN="2.0.0" -# Near RT RIC Simulator remote image and tag -RIC_SIM_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator" -RIC_SIM_REMOTE_IMAGE_TAG="2.0.0" + +# Near RT RIC Simulator image and tags - uses bronze release +RIC_SIM_IMAGE_BASE="o-ran-sc/a1-simulator" +RIC_SIM_IMAGE_TAG_REMOTE_RELEASE_ORAN="2.0.0" #Consul remote image and tag -CONSUL_REMOTE_IMAGE=$NEXUS_PROXY_REPO"consul" -CONSUL_REMOTE_IMAGE_TAG="1.7.2" +CONSUL_IMAGE_BASE="consul" +CONSUL_IMAGE_TAG_REMOTE_PROXY="1.7.2" #No local image for Consul, remote image always used #CBS remote image and tag -CBS_REMOTE_IMAGE="nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app" -CBS_REMOTE_IMAGE_TAG="2.3.0" +CBS_IMAGE_BASE="onap/org.onap.dcaegen2.platform.configbinding.app-app" +CBS_IMAGE_TAG_REMOTE_RELEASE_ONAP="2.3.0" #No local image for CBS, remote image always used #MR stub image and tag -MRSTUB_LOCAL_IMAGE="mrstub" -MRSTUB_LOCAL_IMAGE_TAG="latest" +MRSTUB_IMAGE_BASE="mrstub" +MRSTUB_IMAGE_TAG_LOCAL="latest" #No remote image for MR stub, local image always used + #Callback receiver image and tag -CR_LOCAL_IMAGE="callback-receiver" -CR_LOCAL_IMAGE_TAG="latest" +CR_IMAGE_BASE="callback-receiver" +CR_IMAGE_TAG_LOCAL="latest" #No remote image for CR, local image always used -# Common env var for auto-test. Vars used by docker-compose need to be exported -export DOCKER_SIM_NWNAME="nonrtric-docker-net" # Name of docker private network - -export POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent container external port (host -> container) -export POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) -export POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) -export POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) -export POLICY_AGENT_APIS="V1" # Supported northbound api versions - -export POLICY_AGENT_APP_NAME="policy-agent" # Name for Policy Agent container -POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container -export POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel - -export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container) -export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container) -export MR_EXTERNAL_SECURE_PORT=3906 # MR stub container external secure port (host -> container) -export MR_INTERNAL_SECURE_PORT=3906 # MR stub container internal secure port (container -> container) -export MR_APP_NAME="message-router" # Name for the MR -export MR_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100" # Path to read messages from MR -export MR_WRITE_URL="/events/A1-POLICY-AGENT-WRITE" # Path write messages to MR - -export CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container) -export CR_INTERNAL_PORT=8090 # Callback receiver container internal port (container -> container) -export CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container) -export CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container) -export CR_APP_NAME="callback-receiver" # Name for the Callback receiver - -export CONSUL_HOST="consul-server" # Host name of consul -export CONSUL_EXTERNAL_PORT=8500 # Consul container external port (host -> container) -export CONSUL_INTERNAL_PORT=8500 # Consul container internal port (container -> container) -export CONSUL_APP_NAME="polman-consul" # Name for consul container - -export CBS_APP_NAME="polman-cbs" # Name for CBS container -export CBS_EXTERNAL_PORT=10000 # CBS container external port (host -> container) -export CBS_INTERNAL_PORT=10000 # CBS container internal port (container -> container) -export CONFIG_BINDING_SERVICE="config-binding-service" # Host name of CBS - -export RIC_SIM_BASE="g" # Base name of the RIC Simulator container, shall be the group code - # Note, a prefix is added to each container name by the .env file in the 'ric' dir -RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir - # This prefix can be changed from the command line -export RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container). - # (external ports allocated by docker) -export RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container). - # (external ports allocated by docker) - -export SDNC_APP_NAME="a1-controller" # Name of the SNDC A1 Controller container -export SDNC_EXTERNAL_PORT=8282 # SNDC A1 Controller container external port (host -> container) -export SDNC_INTERNAL_PORT=8181 # SNDC A1 Controller container internal port (container -> container) -export SDNC_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container external securee port (host -> container) -export SDNC_INTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container internal secure port (container -> container) -export SDNC_DB_APP_NAME="sdnc-db" # Name of the SDNC DB container -export SDNC_A1_TRUSTSTORE_PASSWORD="a1adapter" # SDNC truststore password -SDNC_USER="admin" # SDNC username -SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD -SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API -SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check) -SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log - - -export CONTROL_PANEL_APP_NAME="control-panel" # Name of the Control Panel container -export CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container) -export CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container external port (host -> container) -CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container - -UUID="" # UUID used as prefix to the policy id to simulate a real UUID - # Testscript need to set the UUID to use other this empty prefix is used - -RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT # Base url to the Agent NB REST interface -RESTBASE_SECURE="https://localhost:"$POLICY_AGENT_EXTERNAL_SECURE_PORT # Base url to the secure Agent NB REST interface -DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http -DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https -ADAPTER=$RESTBASE # Adapter holds the address the agent R-APP interface (REST OR DMAAP) - # The values of this var is swiched between the two base url when needed +#Http proxy remote image and tag +HTTP_PROXY_IMAGE_BASE="mitmproxy/mitmproxy" +HTTP_PROXY_IMAGE_TAG_REMOTE_PROXY="6.0.2" +#No local image for SSDNC DB, remote image always used + + +#ONAP Zookeeper remote image and tag +ONAP_ZOOKEEPER_IMAGE_BASE="onap/dmaap/zookeeper" +ONAP_ZOOKEEPER_IMAGE_TAG_REMOTE_RELEASE_ONAP="6.0.3" +#No local image for ONAP Zookeeper, remote image always used + +#ONAP Kafka remote image and tag +ONAP_KAFKA_IMAGE_BASE="onap/dmaap/kafka111" +ONAP_KAFKA_IMAGE_TAG_REMOTE_RELEASE_ONAP="1.0.4" +#No local image for ONAP Kafka, remote image always used + +#ONAP DMAAP-MR remote image and tag +ONAP_DMAAPMR_IMAGE_BASE="onap/dmaap/dmaap-mr" +ONAP_DMAAPMR_IMAGE_TAG_REMOTE_RELEASE_ONAP="1.1.18" +#No local image for ONAP DMAAP-MR, remote image always used + +# List of app short names produced by the project +PROJECT_IMAGES_APP_NAMES="PA SDNC" + +# List of app short names which images pulled from ORAN +ORAN_IMAGES_APP_NAMES="CP RICSIM" + +# List of app short names which images pulled from ONAP +ONAP_IMAGES_APP_NAMES="" # Not used + +######################################## +# Detailed settings per app +######################################## + + +DOCKER_SIM_NWNAME="nonrtric-docker-net" # Name of docker private network + +KUBE_NONRTRIC_NAMESPACE="nonrtric" # Namespace for all nonrtric components +KUBE_SIM_NAMESPACE="nonrtric-ft" # Namespace for simulators (except MR and RICSIM) +KUBE_ONAP_NAMESPACE="onap" # Namespace for onap (only message router) + +POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent container external port (host -> container) +POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) +POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) +POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) +POLICY_AGENT_APIS="V1" # Supported northbound api versions +PMS_VERSION="V1" # Tested version of northbound API +PMS_API_PREFIX="" # api url prefix, only for V2 + +POLICY_AGENT_APP_NAME="policymanagementservice" # Name for Policy Agent container +POLICY_AGENT_DISPLAY_NAME="Policy Management Service" +POLICY_AGENT_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host +POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container +POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel +POLICY_AGENT_CONFIG_KEY="policy-agent" # Key for consul config +POLICY_AGENT_PKG_NAME="org.onap.ccsdk.oran.a1policymanagementservice" # Java base package name +POLICY_AGENT_ACTUATOR="/actuator/loggers/$POLICY_AGENT_PKG_NAME" # Url for trace/debug +POLICY_AGENT_ALIVE_URL="/status" # Base path for alive check +POLICY_AGENT_COMPOSE_DIR="policy_agent" # Dir in simulator_group for docker-compose +POLICY_AGENT_CONFIG_MOUNT_PATH="/opt/app/policy-agent/config" # Path in container for config file +POLICY_AGENT_DATA_MOUNT_PATH="/opt/app/policy-agent/data" # Path in container for data file +POLICY_AGENT_CONFIG_FILE="application.yaml" # Container config file name +POLICY_AGENT_DATA_FILE="application_configuration.json" # Container data file name + +MR_DMAAP_APP_NAME="dmaap-mr" # Name for the Dmaap MR +MR_STUB_APP_NAME="mr-stub" # Name of the MR stub +MR_DMAAP_DISPLAY_NAME="DMAAP Message Router" +MR_STUB_DISPLAY_NAME="Message Router stub" +MR_STUB_CERT_MOUNT_DIR="./cert" +MR_EXTERNAL_PORT=3904 # MR dmaap/stub container external port +MR_INTERNAL_PORT=3904 # MR dmaap/stub container internal port +MR_EXTERNAL_SECURE_PORT=3905 # MR dmaap/stub container external secure port +MR_INTERNAL_SECURE_PORT=3905 # MR dmaap/stub container internal secure port +MR_DMAAP_LOCALHOST_PORT=3904 # MR stub container external port (host -> container) +MR_STUB_LOCALHOST_PORT=3908 # MR stub container external port (host -> container) +MR_DMAAP_LOCALHOST_SECURE_PORT=3905 # MR stub container internal port (container -> container) +MR_STUB_LOCALHOST_SECURE_PORT=3909 # MR stub container external secure port (host -> container) +MR_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100" # Path to read messages from MR +MR_WRITE_URL="/events/A1-POLICY-AGENT-WRITE" # Path write messages to MR +MR_READ_TOPIC="A1-POLICY-AGENT-READ" # Read topic +MR_WRITE_TOPIC="A1-POLICY-AGENT-WRITE" # Write topic +MR_STUB_ALIVE_URL="/" # Base path for mr stub alive check +MR_DMAAP_ALIVE_URL="/topics" # Base path for dmaap-mr alive check +MR_DMAAP_COMPOSE_DIR="dmaapmr" # Dir in simulator_group for dmaap mr for - docker-compose +MR_STUB_COMPOSE_DIR="mrstub" # Dir in simulator_group for mr stub for - docker-compose +MR_KAFKA_APP_NAME="kafka" # Kafka app name +MR_ZOOKEEPER_APP_NAME="zookeeper" # Zookeeper app name + + +CR_APP_NAME="callback-receiver" # Name for the Callback receiver +CR_DISPLAY_NAME="Callback Reciever" +CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container) +CR_INTERNAL_PORT=8090 # Callback receiver container internal port (container -> container) +CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container) +CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container) +CR_APP_CALLBACK="/callbacks" # Url for callbacks +CR_ALIVE_URL="/" # Base path for alive check +CR_COMPOSE_DIR="cr" # Dir in simulator_group for docker-compose + +CONSUL_HOST="consul-server" # Host name of consul +CONSUL_DISPLAY_NAME="Consul" +CONSUL_EXTERNAL_PORT=8500 # Consul container external port (host -> container) +CONSUL_INTERNAL_PORT=8500 # Consul container internal port (container -> container) +CONSUL_APP_NAME="polman-consul" # Name for consul container +CONSUL_ALIVE_URL="/ui/dc1/kv" # Base path for alive check +CONSUL_CBS_COMPOSE_DIR="consul_cbs" # Dir in simulator group for docker compose + +CBS_APP_NAME="polman-cbs" # Name for CBS container +CBS_DISPLAY_NAME="Config Binding Service" +CBS_EXTERNAL_PORT=10000 # CBS container external port (host -> container) +CBS_INTERNAL_PORT=10000 # CBS container internal port (container -> container) +CONFIG_BINDING_SERVICE="config-binding-service" # Host name of CBS +CBS_ALIVE_URL="/healthcheck" # Base path for alive check + +RIC_SIM_DISPLAY_NAME="Near-RT RIC A1 Simulator" +RIC_SIM_BASE="g" # Base name of the RIC Simulator container, shall be the group code + # Note, a prefix is added to each container name by the .env file in the 'ric' dir +RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir + # This prefix can be changed from the command line +RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container). + # (external ports allocated by docker) +RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container). + # (external ports allocated by docker) +RIC_SIM_CERT_MOUNT_DIR="./cert" +RIC_SIM_COMPOSE_DIR="ric" # Dir in simulator group for docker compose +RIC_SIM_ALIVE_URL="/" + +SDNC_APP_NAME="a1controller" # Name of the SNDC A1 Controller container +SDNC_DISPLAY_NAME="SDNC A1 Controller" +SDNC_EXTERNAL_PORT=8282 # SNDC A1 Controller container external port (host -> container) +SDNC_INTERNAL_PORT=8181 # SNDC A1 Controller container internal port (container -> container) +SDNC_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container external securee port (host -> container) +SDNC_INTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container internal secure port (container -> container) +SDNC_DB_APP_NAME="sdncdb" # Name of the SDNC DB container +SDNC_A1_TRUSTSTORE_PASSWORD="a1adapter" # SDNC truststore password +SDNC_USER="admin" # SDNC username +SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD +SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API +SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check) +SDNC_COMPOSE_DIR="sdnc" # Dir in simulator_group for docker-compose +SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log + + +CONTROL_PANEL_APP_NAME="controlpanel" # Name of the Control Panel container +CONTROL_PANEL_DISPLAY_NAME="Non-RT RIC Control Panel" +CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container) +CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container internal port (container -> container) +CONTROL_PANEL_EXTERNAL_SECURE_PORT=8880 # Control Panel container external port (host -> container) +CONTROL_PANEL_INTERNAL_SECURE_PORT=8082 # Control Panel container internal port (container -> container) +CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container +CONTROL_PANEL_ALIVE_URL="/" # Base path for alive check +CONTROL_PANEL_COMPOSE_DIR="control_panel" # Dir in simulator_group for docker-compose +CONTROL_PANEL_CONFIG_MOUNT_PATH=/maven # Container internal path for config +CONTROL_PANEL_CONFIG_FILE=application.properties # Config file name + +HTTP_PROXY_APP_NAME="httpproxy" # Name of the Http Proxy container +HTTP_PROXY_DISPLAY_NAME="Http Proxy" +HTTP_PROXY_EXTERNAL_PORT=8780 # Http Proxy container external port (host -> container) +HTTP_PROXY_INTERNAL_PORT=8080 # Http Proxy container internal port (container -> container) +HTTP_PROXY_WEB_EXTERNAL_PORT=8781 # Http Proxy container external port (host -> container) +HTTP_PROXY_WEB_INTERNAL_PORT=8081 # Http Proxy container internal port (container -> container) +HTTP_PROXY_CONFIG_PORT=0 # Port number for proxy config, will be set if proxy is started +HTTP_PROXY_CONFIG_HOST_NAME="" # Proxy host, will be set if proxy is started +HTTP_PROXY_ALIVE_URL="/" # Base path for alive check +HTTP_PROXY_COMPOSE_DIR="httpproxy" # Dir in simulator_group for docker-compose + +######################################## +# Setting for common curl-base function +######################################## + + +UUID="" # UUID used as prefix to the policy id to simulate a real UUID + # Testscript need to set the UUID to use other this empty prefix is used + diff --git a/test/common/test_env-onap-honolulu.sh b/test/common/test_env-onap-honolulu.sh new file mode 100644 index 00000000..f3c5b519 --- /dev/null +++ b/test/common/test_env-onap-honolulu.sh @@ -0,0 +1,341 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# +#Profile for ONAP honolulu release +TEST_ENV_PROFILE="ONAP-HONOLULU" +FLAVOUR="ONAP" + +######################################## +## Nexus repo settings +######################################## + +# Nexus repos for developed images +NEXUS_PROXY_REPO="nexus3.onap.org:10001/" +NEXUS_RELEASE_REPO="nexus3.onap.org:10002/" +NEXUS_SNAPSHOT_REPO="nexus3.onap.org:10003/" +NEXUS_STAGING_REPO=$NEXUS_SNAPSHOT_REPO #staging repo not used in ONAP, using snapshot + +# Nexus repos for images used by test (not developed by the project) +NEXUS_RELEASE_REPO_ORAN="nexus3.o-ran-sc.org:10002/" # Only for released ORAN images +NEXUS_RELEASE_REPO_ONAP=$NEXUS_RELEASE_REPO + +######################################## +# Set up of image and tags for the test. +######################################## + +# NOTE: One environment variable containing the image name and tag is create by the test script +# for each image from the env variables below. +# The variable is created by removing the suffix "_BASE" from the base image variable name. +# Example: POLICY_AGENT_IMAGE_BASE -> POLICY_AGENT_IMAGE +# This var will point to the local or remote image depending on cmd line arguments. +# In addition, the repo and the image tag version are selected from the list of image tags based on the cmd line argurment. +# For images built by the script, only tag #1 shall be specified +# For project images, only tag #1, #2, #3 and #4 shall be specified +# For ORAN images (non project), only tag #5 shall be specified +# For ONAP images (non project), only tag #6 shall be specified +# For all other images, only tag #7 shall be specified +# 1 XXX_LOCAL: local images: : +# 2 XXX_REMOTE_SNAPSHOT: snapshot images: : +# 3 XXX_REMOTE: staging images: : +# 4 XXX_REMOTE_RELEASE: release images: : +# 5 XXX_REMOTE_RELEASE_ORAN: ORAN release images: : +# 6 XXX_REMOTE_RELEASE_ONAP: ONAP release images: : +# 7 XXX_PROXY: other images, not produced by the project: : + +# Policy Agent image and tags +POLICY_AGENT_IMAGE_BASE="onap/ccsdk-oran-a1policymanagementservice" +POLICY_AGENT_IMAGE_TAG_LOCAL="1.1.1-SNAPSHOT" +POLICY_AGENT_IMAGE_TAG_REMOTE_SNAPSHOT="1.1.1-SNAPSHOT" +POLICY_AGENT_IMAGE_TAG_REMOTE="1.1.1-STAGING-latest" #Will use snapshot repo +POLICY_AGENT_IMAGE_TAG_REMOTE_RELEASE="1.1.1" + + +# SDNC A1 Controller remote image and tag +SDNC_A1_CONTROLLER_IMAGE_BASE="onap/sdnc-image" +SDNC_A1_CONTROLLER_IMAGE_TAG_LOCAL="2.1.1-SNAPSHOT" ###CHECK THIS +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE_SNAPSHOT="2.1.1-STAGING-latest" +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE="2.1.1-STAGING-latest" #Will use snapshot repo +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE_RELEASE="2.1.1" + +#SDNC DB remote image and tag +#The DB is part of SDNC so handled in the same way as SDNC +SDNC_DB_IMAGE_BASE="mysql/mysql-server" +SDNC_DB_IMAGE_TAG_REMOTE_PROXY="5.6" + + +# ECS image and tag - uses cherry release +ECS_IMAGE_BASE="o-ran-sc/nonrtric-enrichment-coordinator-service" +ECS_IMAGE_TAG_REMOTE_RELEASE_ORAN="1.0.0" + + +# Control Panel image and tag - uses cherry release +CONTROL_PANEL_IMAGE_BASE="o-ran-sc/nonrtric-controlpanel" +CONTROL_PANEL_IMAGE_TAG_REMOTE_RELEASE_ORAN="2.1.0" + + +# RAPP Catalogue image and tags - uses cherry release +RAPP_CAT_IMAGE_BASE="o-ran-sc/nonrtric-r-app-catalogue" +RAPP_CAT_IMAGE_TAG_REMOTE_RELEASE_ORAN="1.0.0" + + +# Near RT RIC Simulator image and tags - uses cherry release +RIC_SIM_IMAGE_BASE="o-ran-sc/a1-simulator" +RIC_SIM_IMAGE_TAG_REMOTE_RELEASE_ORAN="2.1.0" + + +#Consul remote image and tag +CONSUL_IMAGE_BASE="consul" +CONSUL_IMAGE_TAG_REMOTE_PROXY="1.7.2" +#No local image for Consul, remote image always used + + +#CBS remote image and tag +CBS_IMAGE_BASE="onap/org.onap.dcaegen2.platform.configbinding.app-app" +CBS_IMAGE_TAG_REMOTE_RELEASE_ONAP="2.3.0" +#No local image for CBS, remote image always used + + +#MR stub image and tag +MRSTUB_IMAGE_BASE="mrstub" +MRSTUB_IMAGE_TAG_LOCAL="latest" +#No remote image for MR stub, local image always used + + +#Callback receiver image and tag +CR_IMAGE_BASE="callback-receiver" +CR_IMAGE_TAG_LOCAL="latest" +#No remote image for CR, local image always used + + +#Producer stub image and tag +PROD_STUB_IMAGE_BASE="producer-stub" +PROD_STUB_IMAGE_TAG_LOCAL="latest" +#No remote image for producer stub, local image always used + + +#Http proxy remote image and tag +HTTP_PROXY_IMAGE_BASE="mitmproxy/mitmproxy" +HTTP_PROXY_IMAGE_TAG_REMOTE_PROXY="6.0.2" +#No local image for SSDNC DB, remote image always used + +#ONAP Zookeeper remote image and tag +ONAP_ZOOKEEPER_IMAGE_BASE="onap/dmaap/zookeeper" +ONAP_ZOOKEEPER_IMAGE_TAG_REMOTE_RELEASE_ONAP="6.0.3" +#No local image for ONAP Zookeeper, remote image always used + +#ONAP Kafka remote image and tag +ONAP_KAFKA_IMAGE_BASE="onap/dmaap/kafka111" +ONAP_KAFKA_IMAGE_TAG_REMOTE_RELEASE_ONAP="1.0.4" +#No local image for ONAP Kafka, remote image always used + +#ONAP DMAAP-MR remote image and tag +ONAP_DMAAPMR_IMAGE_BASE="onap/dmaap/dmaap-mr" +ONAP_DMAAPMR_IMAGE_TAG_REMOTE_RELEASE_ONAP="1.1.18" +#No local image for ONAP DMAAP-MR, remote image always used + + +# List of app short names produced by the project +PROJECT_IMAGES_APP_NAMES="PA SDNC" + +# List of app short names which images pulled from ORAN +ORAN_IMAGES_APP_NAMES="CP ECS RICSIM RC" + +# List of app short names which images pulled from ONAP +ONAP_IMAGES_APP_NAMES="" # Not used + + +######################################## +# Detailed settings per app +######################################## + + +DOCKER_SIM_NWNAME="nonrtric-docker-net" # Name of docker private network + +KUBE_NONRTRIC_NAMESPACE="nonrtric" # Namespace for all nonrtric components +KUBE_SIM_NAMESPACE="nonrtric-ft" # Namespace for simulators (except MR and RICSIM) +KUBE_ONAP_NAMESPACE="onap" # Namespace for onap (only message router) + +POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent container external port (host -> container) +POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) +POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) +POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) +POLICY_AGENT_APIS="V1 V2" # Supported northbound api versions +PMS_VERSION="V2" # Tested version of northbound API +PMS_API_PREFIX="/a1-policy" # api url prefix, only for V2. Shall contain leading "/" + +POLICY_AGENT_APP_NAME="policymanagementservice" # Name for Policy Agent container +POLICY_AGENT_DISPLAY_NAME="Policy Management Service" +POLICY_AGENT_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host +POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container +POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel +POLICY_AGENT_CONFIG_KEY="policy-agent" # Key for consul config +POLICY_AGENT_PKG_NAME="org.onap.ccsdk.oran.a1policymanagementservice" # Java base package name +POLICY_AGENT_ACTUATOR="/actuator/loggers/$POLICY_AGENT_PKG_NAME" # Url for trace/debug +POLICY_AGENT_ALIVE_URL="$PMS_API_PREFIX/v2/status" # Base path for alive check +POLICY_AGENT_COMPOSE_DIR="policy_agent" # Dir in simulator_group for docker-compose +POLICY_AGENT_CONFIG_MOUNT_PATH="/opt/app/policy-agent/config" # Path in container for config file +POLICY_AGENT_DATA_MOUNT_PATH="/opt/app/policy-agent/data" # Path in container for data file +POLICY_AGENT_CONFIG_FILE="application.yaml" # Container config file name +POLICY_AGENT_DATA_FILE="application_configuration.json" # Container data file name + +ECS_APP_NAME="enrichmentservice" # Name for ECS container +ECS_DISPLAY_NAME="Enrichment Coordinator Service" # Display name for ECS container +ECS_EXTERNAL_PORT=8083 # ECS container external port (host -> container) +ECS_INTERNAL_PORT=8083 # ECS container internal port (container -> container) +ECS_EXTERNAL_SECURE_PORT=8434 # ECS container external secure port (host -> container) +ECS_INTERNAL_SECURE_PORT=8434 # ECS container internal secure port (container -> container) + +ECS_LOGPATH="/var/log/enrichment-coordinator-service/application.log" # Path the application log in the ECS container +ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel +ECS_HOST_MNT_DIR="./mnt/db" # Mounted dir, relative to compose file, on the host +ECS_CONTAINER_MNT_DIR="/var/enrichment-coordinator-service" # Mounted dir in the container +ECS_ACTUATOR="/actuator/loggers/org.oransc.enrichment" # Url for trace/debug +ECS_CERT_MOUNT_DIR="./cert" +ECS_ALIVE_URL="/status" # Base path for alive check +ECS_COMPOSE_DIR="ecs" # Dir in simulator_group for docker-compose +ECS_CONFIG_MOUNT_PATH=/opt/app/enrichment-coordinator-service/config # Internal container path for configuration +ECS_CONFIG_FILE=application.yaml # Config file name +ECS_VERSION="V1-1" # Version where the types are added in the producer registration + +MR_DMAAP_APP_NAME="dmaap-mr" # Name for the Dmaap MR +MR_STUB_APP_NAME="mr-stub" # Name of the MR stub +MR_DMAAP_DISPLAY_NAME="DMAAP Message Router" +MR_STUB_DISPLAY_NAME="Message Router stub" +MR_STUB_CERT_MOUNT_DIR="./cert" +MR_EXTERNAL_PORT=3904 # MR dmaap/stub container external port +MR_INTERNAL_PORT=3904 # MR dmaap/stub container internal port +MR_EXTERNAL_SECURE_PORT=3905 # MR dmaap/stub container external secure port +MR_INTERNAL_SECURE_PORT=3905 # MR dmaap/stub container internal secure port +MR_DMAAP_LOCALHOST_PORT=3904 # MR stub container external port (host -> container) +MR_STUB_LOCALHOST_PORT=3908 # MR stub container external port (host -> container) +MR_DMAAP_LOCALHOST_SECURE_PORT=3905 # MR stub container internal port (container -> container) +MR_STUB_LOCALHOST_SECURE_PORT=3909 # MR stub container external secure port (host -> container) +MR_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100" # Path to read messages from MR +MR_WRITE_URL="/events/A1-POLICY-AGENT-WRITE" # Path write messages to MR +MR_READ_TOPIC="A1-POLICY-AGENT-READ" # Read topic +MR_WRITE_TOPIC="A1-POLICY-AGENT-WRITE" # Write topic +MR_STUB_ALIVE_URL="/" # Base path for mr stub alive check +MR_DMAAP_ALIVE_URL="/topics" # Base path for dmaap-mr alive check +MR_DMAAP_COMPOSE_DIR="dmaapmr" # Dir in simulator_group for dmaap mr for - docker-compose +MR_STUB_COMPOSE_DIR="mrstub" # Dir in simulator_group for mr stub for - docker-compose +MR_KAFKA_APP_NAME="kafka" # Kafka app name +MR_ZOOKEEPER_APP_NAME="zookeeper" # Zookeeper app name + +CR_APP_NAME="callback-receiver" # Name for the Callback receiver +CR_DISPLAY_NAME="Callback Reciever" +CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container) +CR_INTERNAL_PORT=8090 # Callback receiver container internal port (container -> container) +CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container) +CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container) +CR_APP_NAME="callback-receiver" # Name for the Callback receiver +CR_APP_CALLBACK="/callbacks" # Url for callbacks +CR_ALIVE_URL="/" # Base path for alive check +CR_COMPOSE_DIR="cr" # Dir in simulator_group for docker-compose + +PROD_STUB_APP_NAME="producer-stub" # Name for the Producer stub +PROD_STUB_DISPLAY_NAME="Producer Stub" +PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container) +PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container) +PROD_STUB_EXTERNAL_SECURE_PORT=8093 # Producer stub container external secure port (host -> container) +PROD_STUB_INTERNAL_SECURE_PORT=8093 # Producer stub container internal secure port (container -> container) +PROD_STUB_JOB_CALLBACK="/callbacks/job" # Callback path for job create/update/delete +PROD_STUB_SUPERVISION_CALLBACK="/callbacks/supervision" # Callback path for producre supervision +PROD_STUB_ALIVE_URL="/" # Base path for alive check +PROD_STUB_COMPOSE_DIR="prodstub" # Dir in simulator_group for docker-compose + +CONSUL_HOST="consul-server" # Host name of consul +CONSUL_DISPLAY_NAME="Consul" +CONSUL_EXTERNAL_PORT=8500 # Consul container external port (host -> container) +CONSUL_INTERNAL_PORT=8500 # Consul container internal port (container -> container) +CONSUL_APP_NAME="polman-consul" # Name for consul container +CONSUL_ALIVE_URL="/ui/dc1/kv" # Base path for alive check +CONSUL_CBS_COMPOSE_DIR="consul_cbs" # Dir in simulator group for docker compose + +CBS_APP_NAME="polman-cbs" # Name for CBS container +CBS_DISPLAY_NAME="Config Binding Service" +CBS_EXTERNAL_PORT=10000 # CBS container external port (host -> container) +CBS_INTERNAL_PORT=10000 # CBS container internal port (container -> container) +CONFIG_BINDING_SERVICE="config-binding-service" # Host name of CBS +CBS_ALIVE_URL="/healthcheck" # Base path for alive check + +RIC_SIM_DISPLAY_NAME="Near-RT RIC A1 Simulator" +RIC_SIM_BASE="g" # Base name of the RIC Simulator container, shall be the group code + # Note, a prefix is added to each container name by the .env file in the 'ric' dir +RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir + # This prefix can be changed from the command line +RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container). + # (external ports allocated by docker) +RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container). + # (external ports allocated by docker) +RIC_SIM_CERT_MOUNT_DIR="./cert" +RIC_SIM_COMPOSE_DIR="ric" # Dir in simulator group for docker compose +RIC_SIM_ALIVE_URL="/" + +SDNC_APP_NAME="a1controller" # Name of the SNDC A1 Controller container +SDNC_DISPLAY_NAME="SDNC A1 Controller" +SDNC_EXTERNAL_PORT=8282 # SNDC A1 Controller container external port (host -> container) +SDNC_INTERNAL_PORT=8181 # SNDC A1 Controller container internal port (container -> container) +SDNC_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container external securee port (host -> container) +SDNC_INTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container internal secure port (container -> container) +SDNC_DB_APP_NAME="sdncdb" # Name of the SDNC DB container +SDNC_A1_TRUSTSTORE_PASSWORD="a1adapter" # SDNC truststore password +SDNC_USER="admin" # SDNC username +SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD +SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API +SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check) +SDNC_COMPOSE_DIR="sdnc" +SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log + +RAPP_CAT_APP_NAME="rappcatalogueservice" # Name for the RAPP Catalogue +RAPP_CAT_DISPLAY_NAME="RAPP Catalogue Service" +RAPP_CAT_EXTERNAL_PORT=8680 # RAPP Catalogue container external port (host -> container) +RAPP_CAT_INTERNAL_PORT=8080 # RAPP Catalogue container internal port (container -> container) +RAPP_CAT_EXTERNAL_SECURE_PORT=8633 # RAPP Catalogue container external secure port (host -> container) +RAPP_CAT_INTERNAL_SECURE_PORT=8433 # RAPP Catalogue container internal secure port (container -> container) +RAPP_CAT_ALIVE_URL="/services" # Base path for alive check +RAPP_CAT_COMPOSE_DIR="rapp_catalogue" # Dir in simulator_group for docker-compose + +CONTROL_PANEL_APP_NAME="controlpanel" # Name of the Control Panel container +CONTROL_PANEL_DISPLAY_NAME="Non-RT RIC Control Panel" +CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container) +CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container internal port (container -> container) +CONTROL_PANEL_EXTERNAL_SECURE_PORT=8880 # Control Panel container external port (host -> container) +CONTROL_PANEL_INTERNAL_SECURE_PORT=8082 # Control Panel container intternal port (container -> container) +CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container +CONTROL_PANEL_ALIVE_URL="/" # Base path for alive check +CONTROL_PANEL_COMPOSE_DIR="control_panel" # Dir in simulator_group for docker-compose +CONTROL_PANEL_CONFIG_MOUNT_PATH=/maven # Container internal path for config +CONTROL_PANEL_CONFIG_FILE=application.properties # Config file name + +HTTP_PROXY_APP_NAME="httpproxy" # Name of the Http Proxy container +HTTP_PROXY_DISPLAY_NAME="Http Proxy" +HTTP_PROXY_EXTERNAL_PORT=8780 # Http Proxy container external port (host -> container) +HTTP_PROXY_INTERNAL_PORT=8080 # Http Proxy container internal port (container -> container) +HTTP_PROXY_WEB_EXTERNAL_PORT=8781 # Http Proxy container external port (host -> container) +HTTP_PROXY_WEB_INTERNAL_PORT=8081 # Http Proxy container internal port (container -> container) +HTTP_PROXY_CONFIG_PORT=0 # Port number for proxy config, will be set if proxy is started +HTTP_PROXY_CONFIG_HOST_NAME="" # Proxy host, will be set if proxy is started +HTTP_PROXY_ALIVE_URL="/" # Base path for alive check +HTTP_PROXY_COMPOSE_DIR="httpproxy" # Dir in simulator_group for docker-compose + +######################################## +# Setting for common curl-base function +######################################## + +UUID="" # UUID used as prefix to the policy id to simulate a real UUID + # Testscript need to set the UUID to use other this empty prefix is used diff --git a/test/common/test_env-onap-master.sh b/test/common/test_env-onap-master.sh deleted file mode 100644 index 29647bd2..00000000 --- a/test/common/test_env-onap-master.sh +++ /dev/null @@ -1,201 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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. -# ============LICENSE_END================================================= -# -#Profile for ONAP master -TEST_ENV_PROFILE="ONAP-MASTER" -NEXUS_PROXY_REPO="nexus3.onap.org:10001/" - -# Set up the image and tags for the test. Do not add the image tag to the image names. - -# NOTE: A env var for each container is created by the test script. -# This var will point to the local or remote var depending on how -# the test script is started. The name format is _IMAGE, ie with 'LOCAL' or 'REMOTE'. - -# Local Policy Agent image and tag -POLICY_AGENT_LOCAL_IMAGE="onap/ccsdk-oran-a1policymanagementservice" -POLICY_AGENT_LOCAL_IMAGE_TAG="1.1.0-SNAPSHOT" -# Remote Policy Agent image and tag -POLICY_AGENT_REMOTE_IMAGE="nexus3.onap.org:10003/onap/ccsdk-oran-a1policymanagementservice" -POLICY_AGENT_REMOTE_IMAGE_TAG="1.1.0-SNAPSHOT" - -# Local ECS image and tag -ECS_LOCAL_IMAGE="o-ran-sc/nonrtric-enrichment-coordinator-service" -ECS_LOCAL_IMAGE_TAG="1.0.0-SNAPSHOT" -# Remote ECS image and tag -ECS_REMOTE_IMAGE="nexus3.o-ran-sc.org:10003/o-ran-sc/nonrtric-enrichment-coordinator-service" -ECS_REMOTE_IMAGE_TAG="1.0.0-SNAPSHOT" - -# Control Panel local image and tag -CONTROL_PANEL_LOCAL_IMAGE="o-ran-sc/nonrtric-controlpanel" -CONTROL_PANEL_LOCAL_IMAGE_TAG="2.0.0-SNAPSHOT" -# Control Panel remote image and tag -CONTROL_PANEL_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel" -CONTROL_PANEL_REMOTE_IMAGE_TAG="2.0.0" - - -# SDNC A1 Controller remote image and tag -SDNC_A1_CONTROLLER_REMOTE_IMAGE="nexus3.onap.org:10003/onap/sdnc-image" -SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG="2.1.0-STAGING-latest" - - -#SDNC DB remote image and tag -SDNC_DB_REMOTE_IMAGE=$NEXUS_PROXY_REPO"mysql/mysql-server" -SDNC_DB_REMOTE_IMAGE_TAG="5.6" -#No local image for DB, remote image always used - -# Near RT RIC Simulator local image and tag -RIC_SIM_LOCAL_IMAGE="o-ran-sc/a1-simulator" -RIC_SIM_LOCAL_IMAGE_TAG="latest" -# Near RT RIC Simulator remote image and tag -RIC_SIM_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator" -RIC_SIM_REMOTE_IMAGE_TAG="2.1.0" - - -#Consul remote image and tag -CONSUL_REMOTE_IMAGE=$NEXUS_PROXY_REPO"consul" -CONSUL_REMOTE_IMAGE_TAG="1.7.2" -#No local image for Consul, remote image always used - - -#CBS remote image and tag -CBS_REMOTE_IMAGE="nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app" -CBS_REMOTE_IMAGE_TAG="2.3.0" -#No local image for CBS, remote image always used - - -#MR stub image and tag -MRSTUB_LOCAL_IMAGE="mrstub" -MRSTUB_LOCAL_IMAGE_TAG="latest" -#No remote image for MR stub, local image always used - -#Callback receiver image and tag -CR_LOCAL_IMAGE="callback-receiver" -CR_LOCAL_IMAGE_TAG="latest" -#No remote image for CR, local image always used - -#Producer stub image and tag -PROD_STUB_LOCAL_IMAGE="producer-stub" -PROD_STUB_LOCAL_IMAGE_TAG="latest" -#No remote image for producer stub, local image always used - -# Common env var for auto-test. Vars used by docker-compose need to be exported -export DOCKER_SIM_NWNAME="nonrtric-docker-net" # Name of docker private network - -export POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent container external port (host -> container) -export POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) -export POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) -export POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) -export POLICY_AGENT_APIS="V1 V2" # Supported northbound api versions -export PMS_VERSION="V2" # Tested version of northbound API - -export POLICY_AGENT_APP_NAME="policy-agent" # Name for Policy Agent container -POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container -export POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel - -export ECS_EXTERNAL_PORT=8083 # ECS container external port (host -> container) -export ECS_INTERNAL_PORT=8083 # ECS container internal port (container -> container) -export ECS_EXTERNAL_SECURE_PORT=8434 # ECS container external secure port (host -> container) -export ECS_INTERNAL_SECURE_PORT=8434 # ECS container internal secure port (container -> container) - -export ECS_APP_NAME="ecs" # Name for ECS container -ECS_LOGPATH="/var/log/enrichment-coordinator-service/application.log" # Path the application log in the ECS container -export ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel -export ECS_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host -export ECS_CONTAINER_MNT_DIR="/var/enrichment-coordinator-service" # Mounted dir in the container - -export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container) -export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container) -export MR_EXTERNAL_SECURE_PORT=3906 # MR stub container external secure port (host -> container) -export MR_INTERNAL_SECURE_PORT=3906 # MR stub container internal secure port (container -> container) -export MR_APP_NAME="message-router" # Name for the MR -export MR_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100" # Path to read messages from MR -export MR_WRITE_URL="/events/A1-POLICY-AGENT-WRITE" # Path write messages to MR - -export CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container) -export CR_INTERNAL_PORT=8090 # Callback receiver container internal port (container -> container) -export CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container) -export CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container) -export CR_APP_NAME="callback-receiver" # Name for the Callback receiver -export CR_APP_CALLBACK="/callbacks" # Url for callbacks - -export PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container) -export PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container) -export PROD_STUB_EXTERNAL_SECURE_PORT=8093 # Producer stub container external secure port (host -> container) -export PROD_STUB_INTERNAL_SECURE_PORT=8093 # Producer stub container internal secure port (container -> container) -export PROD_STUB_APP_NAME="producer-stub" # Name for the Producer stub - -export CONSUL_HOST="consul-server" # Host name of consul -export CONSUL_EXTERNAL_PORT=8500 # Consul container external port (host -> container) -export CONSUL_INTERNAL_PORT=8500 # Consul container internal port (container -> container) -export CONSUL_APP_NAME="polman-consul" # Name for consul container - -export CBS_APP_NAME="polman-cbs" # Name for CBS container -export CBS_EXTERNAL_PORT=10000 # CBS container external port (host -> container) -export CBS_INTERNAL_PORT=10000 # CBS container internal port (container -> container) -export CONFIG_BINDING_SERVICE="config-binding-service" # Host name of CBS - -export RIC_SIM_BASE="g" # Base name of the RIC Simulator container, shall be the group code - # Note, a prefix is added to each container name by the .env file in the 'ric' dir -RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir - # This prefix can be changed from the command line -export RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container). - # (external ports allocated by docker) -export RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container). - # (external ports allocated by docker) - -export SDNC_APP_NAME="a1-controller" # Name of the SNDC A1 Controller container -export SDNC_EXTERNAL_PORT=8282 # SNDC A1 Controller container external port (host -> container) -export SDNC_INTERNAL_PORT=8181 # SNDC A1 Controller container internal port (container -> container) -export SDNC_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container external securee port (host -> container) -export SDNC_INTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container internal secure port (container -> container) -export SDNC_DB_APP_NAME="sdnc-db" # Name of the SDNC DB container -export SDNC_A1_TRUSTSTORE_PASSWORD="a1adapter" # SDNC truststore password -SDNC_USER="admin" # SDNC username -SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD -SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API -SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check) -SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log - - -export CONTROL_PANEL_APP_NAME="control-panel" # Name of the Control Panel container -export CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container) -export CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container external port (host -> container) -CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container - -UUID="" # UUID used as prefix to the policy id to simulate a real UUID - # Testscript need to set the UUID to use other this empty prefix is used - -RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT # Base url to the Agent NB REST interface -RESTBASE_SECURE="https://localhost:"$POLICY_AGENT_EXTERNAL_SECURE_PORT # Base url to the secure Agent NB REST interface -DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http -DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https -ADAPTER=$RESTBASE # Adapter holds the address the agent R-APP interface (REST OR DMAAP) - # The values of this var is swiched between the two base url when needed - # The values of this var is swiched between the four base url when needed - -ECS_RESTBASE="http://localhost:"$ECS_EXTERNAL_PORT # Base url to the ECS NB REST interface -ECS_RESTBASE_SECURE="https://localhost:"$ECS_EXTERNAL_SECURE_PORT # Base url to the secure ECS NB REST interface -ECS_DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http -ECS_DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https -ECS_ADAPTER=$ECS_RESTBASE # Adapter holds the address the ECS R-APP interface (REST OR DMAAP) - # The values of this var is swiched between the four base url when needed - -CR_RESTBASE="http://localhost:"$CR_EXTERNAL_PORT # Base url to the Callback receiver REST interface -CR_RESTBASE_SECURE="https://localhost:"$CR_EXTERNAL_SECURE_PORT # Base url to the secure Callback receiver REST interface -CR_ADAPTER=$CR_RESTBASE # Adapter holds the address the CR admin interface (REST only) - # The values of this var is swiched between the two base url when needed \ No newline at end of file diff --git a/test/common/test_env-oran-cherry.sh b/test/common/test_env-oran-cherry.sh index 4650768e..bc20aba7 100755 --- a/test/common/test_env-oran-cherry.sh +++ b/test/common/test_env-oran-cherry.sh @@ -18,205 +18,335 @@ # #Profile for ORAN Cherry TEST_ENV_PROFILE="ORAN-CHERRY" -NEXUS_PROXY_REPO="nexus3.onap.org:10001/" +FLAVOUR="ORAN" + +######################################## +## Nexus repo settings +######################################## + +# Nexus repos for developed images +NEXUS_PROXY_REPO="nexus3.o-ran-sc.org:10001/" +NEXUS_RELEASE_REPO="nexus3.o-ran-sc.org:10002/" +NEXUS_SNAPSHOT_REPO="nexus3.o-ran-sc.org:10003/" +NEXUS_STAGING_REPO="nexus3.o-ran-sc.org:10004/" + +# Nexus repos for images used by test (not developed by the project) +NEXUS_RELEASE_REPO_ONAP="nexus3.onap.org:10002/" # Only for released ONAP images +NEXUS_RELEASE_REPO_ORAN=$NEXUS_RELEASE_REPO + +######################################## +# Set up of image and tags for the test. +######################################## + +# NOTE: One environment variable containing the image name and tag is create by the test script +# for each image from the env variables below. +# The variable is created by removing the suffix "_BASE" from the base image variable name. +# Example: POLICY_AGENT_IMAGE_BASE -> POLICY_AGENT_IMAGE +# This var will point to the local or remote image depending on cmd line arguments. +# In addition, the repo and the image tag version are selected from the list of image tags based on the cmd line argurment. +# For images built by the script, only tag #1 shall be specified +# For project images, only tag #1, #2, #3 and #4 shall be specified +# For ORAN images (non project), only tag #5 shall be specified +# For ONAP images (non project), only tag #6 shall be specified +# For all other images, only tag #7 shall be specified +# 1 XXX_LOCAL: local images: : +# 2 XXX_REMOTE_SNAPSHOT: snapshot images: : +# 3 XXX_REMOTE: staging images: : +# 4 XXX_REMOTE_RELEASE: release images: : +# 5 XXX_REMOTE_RELEASE_ORAN: ORAN release images: : +# 6 XXX_REMOTE_RELEASE_ONAP: ONAP release images: : +# 7 XXX_PROXY: other images, not produced by the project: : + + +# Policy Agent base image and tags +POLICY_AGENT_IMAGE_BASE="o-ran-sc/nonrtric-policy-agent" +POLICY_AGENT_IMAGE_TAG_LOCAL="2.1.0-SNAPSHOT" +POLICY_AGENT_IMAGE_TAG_REMOTE_SNAPSHOT="2.1.0-SNAPSHOT" +POLICY_AGENT_IMAGE_TAG_REMOTE="2.1.0" +POLICY_AGENT_IMAGE_TAG_REMOTE_RELEASE="2.1.0" + +# ECS image and tags +ECS_IMAGE_BASE="o-ran-sc/nonrtric-enrichment-coordinator-service" +ECS_IMAGE_TAG_LOCAL="1.0.0-SNAPSHOT" +ECS_IMAGE_TAG_REMOTE_SNAPSHOT="1.0.0-SNAPSHOT" +ECS_IMAGE_TAG_REMOTE="1.0.0" +ECS_IMAGE_TAG_REMOTE_RELEASE="1.0.0" + + +# Control Panel image and tags +CONTROL_PANEL_IMAGE_BASE="o-ran-sc/nonrtric-controlpanel" +CONTROL_PANEL_IMAGE_TAG_LOCAL="2.1.0-SNAPSHOT" +CONTROL_PANEL_IMAGE_TAG_REMOTE_SNAPSHOT="2.1.0-SNAPSHOT" +CONTROL_PANEL_IMAGE_TAG_REMOTE="2.1.0" +CONTROL_PANEL_IMAGE_TAG_REMOTE_RELEASE="2.1.0" + + +# SDNC A1 Controller image and tags +SDNC_A1_CONTROLLER_IMAGE_BASE="o-ran-sc/nonrtric-a1-controller" +SDNC_A1_CONTROLLER_IMAGE_TAG_LOCAL="2.0.1-SNAPSHOT" +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE_SNAPSHOT="2.0.1-SNAPSHOT" +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE="2.0.1" +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE_RELEASE="2.0.1" -# Set up the image and tags for the test. Do not add the image tag to the image names. -# NOTE: A env var for each container is created by the test script. -# This var will point to the local or remote var depending on how -# the test script is started. The name format is _IMAGE, ie with 'LOCAL' or 'REMOTE'. - -# Local Policy Agent image and tag -POLICY_AGENT_LOCAL_IMAGE="o-ran-sc/nonrtric-policy-agent" -POLICY_AGENT_LOCAL_IMAGE_TAG="2.1.0-SNAPSHOT" -# Remote Policy Agent image and tag -POLICY_AGENT_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent" -POLICY_AGENT_REMOTE_IMAGE_TAG="2.1.0" - -# Local ECS image and tag -ECS_LOCAL_IMAGE="o-ran-sc/nonrtric-enrichment-coordinator-service" -ECS_LOCAL_IMAGE_TAG="1.0.0-SNAPSHOT" -# Remote ECS image and tag -ECS_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-enrichment-coordinator-service" -ECS_REMOTE_IMAGE_TAG="1.0.0" - -# Control Panel local image and tag -CONTROL_PANEL_LOCAL_IMAGE="o-ran-sc/nonrtric-controlpanel" -CONTROL_PANEL_LOCAL_IMAGE_TAG="2.0.0-SNAPSHOT" -# Control Panel remote image and tag -CONTROL_PANEL_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel" -CONTROL_PANEL_REMOTE_IMAGE_TAG="2.0.0" - - -# SDNC A1 Controller local image and tag -SDNC_A1_CONTROLLER_LOCAL_IMAGE="o-ran-sc/nonrtric-a1-controller" -SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG="2.1.0-SNAPSHOT" -# SDNC A1 Controller remote image and tag -SDNC_A1_CONTROLLER_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-a1-controller" -SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG="2.1.0" - - -# RAPP Catalogue local image and tag -RAPP_CAT_LOCAL_IMAGE="o-ran-sc/nonrtric-r-app-catalogue" -RAPP_CAT_LOCAL_IMAGE_TAG="1.0.0-SNAPSHOT" -# RAPP Catalogue remote image and tag -RAPP_CAT_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-r-app-catalogue" -RAPP_CAT_REMOTE_IMAGE_TAG="1.0.0" +#SDNC DB remote image and tag +SDNC_DB_IMAGE_BASE="mysql/mysql-server" +SDNC_DB_IMAGE_TAG_REMOTE_PROXY="5.6" +#No local image for SSDNC DB, remote image always used -#SDNC DB remote image and tag -SDNC_DB_REMOTE_IMAGE=$NEXUS_PROXY_REPO"mysql/mysql-server" -SDNC_DB_REMOTE_IMAGE_TAG="5.6" -#No local image for DB, remote image always used +# RAPP Catalogue image and tags +RAPP_CAT_IMAGE_BASE="o-ran-sc/nonrtric-r-app-catalogue" +RAPP_CAT_IMAGE_TAG_LOCAL="1.0.0-SNAPSHOT" +RAPP_CAT_IMAGE_TAG_REMOTE_SNAPSHOT="1.0.0-SNAPSHOT" +RAPP_CAT_IMAGE_TAG_REMOTE="1.0.0" +RAPP_CAT_IMAGE_TAG_REMOTE_RELEASE="1.0.0" -# Near RT RIC Simulator local image and tag -RIC_SIM_LOCAL_IMAGE="o-ran-sc/a1-simulator" -RIC_SIM_LOCAL_IMAGE_TAG="latest" -# Near RT RIC Simulator remote image and tag -RIC_SIM_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator" -RIC_SIM_REMOTE_IMAGE_TAG="2.1.0" +# Near RT RIC Simulator image and tags +RIC_SIM_IMAGE_BASE="o-ran-sc/a1-simulator" +RIC_SIM_IMAGE_TAG_LOCAL="latest" +RIC_SIM_IMAGE_TAG_REMOTE_SNAPSHOT="2.1.0-SNAPSHOT" +RIC_SIM_IMAGE_TAG_REMOTE="2.1.0" +RIC_SIM_IMAGE_TAG_REMOTE_RELEASE="2.1.0" #Consul remote image and tag -CONSUL_REMOTE_IMAGE=$NEXUS_PROXY_REPO"consul" -CONSUL_REMOTE_IMAGE_TAG="1.7.2" +CONSUL_IMAGE_BASE="consul" +CONSUL_IMAGE_TAG_REMOTE_PROXY="1.7.2" #No local image for Consul, remote image always used #CBS remote image and tag -CBS_REMOTE_IMAGE="nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app" -CBS_REMOTE_IMAGE_TAG="2.3.0" +CBS_IMAGE_BASE="onap/org.onap.dcaegen2.platform.configbinding.app-app" +CBS_IMAGE_TAG_REMOTE_RELEASE_ONAP="2.3.0" #No local image for CBS, remote image always used #MR stub image and tag -MRSTUB_LOCAL_IMAGE="mrstub" -MRSTUB_LOCAL_IMAGE_TAG="latest" +MRSTUB_IMAGE_BASE="mrstub" +MRSTUB_IMAGE_TAG_LOCAL="latest" #No remote image for MR stub, local image always used + #Callback receiver image and tag -CR_LOCAL_IMAGE="callback-receiver" -CR_LOCAL_IMAGE_TAG="latest" +CR_IMAGE_BASE="callback-receiver" +CR_IMAGE_TAG_LOCAL="latest" #No remote image for CR, local image always used + #Producer stub image and tag -PROD_STUB_LOCAL_IMAGE="producer-stub" -PROD_STUB_LOCAL_IMAGE_TAG="latest" +PROD_STUB_IMAGE_BASE="producer-stub" +PROD_STUB_IMAGE_TAG_LOCAL="latest" #No remote image for producer stub, local image always used -# Common env var for auto-test. Vars used by docker-compose need to be exported -export DOCKER_SIM_NWNAME="nonrtric-docker-net" # Name of docker private network - -export POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent container external port (host -> container) -export POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) -export POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) -export POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) -export POLICY_AGENT_APIS="V1 V2" # Supported northbound api versions -export PMS_VERSION="V2" # Tested version of northbound API - -export POLICY_AGENT_APP_NAME="policy-agent" # Name for Policy Agent container -POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container -export POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel - -export ECS_EXTERNAL_PORT=8083 # ECS container external port (host -> container) -export ECS_INTERNAL_PORT=8083 # ECS container internal port (container -> container) -export ECS_EXTERNAL_SECURE_PORT=8434 # ECS container external secure port (host -> container) -export ECS_INTERNAL_SECURE_PORT=8434 # ECS container internal secure port (container -> container) +#Http proxy remote image and tag +HTTP_PROXY_IMAGE_BASE="mitmproxy/mitmproxy" +HTTP_PROXY_IMAGE_TAG_REMOTE_PROXY="6.0.2" +#No local image for Http proxy, remote image always used + +#ONAP Zookeeper remote image and tag +ONAP_ZOOKEEPER_IMAGE_BASE="onap/dmaap/zookeeper" +ONAP_ZOOKEEPER_IMAGE_TAG_REMOTE_RELEASE_ONAP="6.0.3" +#No local image for ONAP Zookeeper, remote image always used + +#ONAP Kafka remote image and tag +ONAP_KAFKA_IMAGE_BASE="onap/dmaap/kafka111" +ONAP_KAFKA_IMAGE_TAG_REMOTE_RELEASE_ONAP="1.0.4" +#No local image for ONAP Kafka, remote image always used + +#ONAP DMAAP-MR remote image and tag +ONAP_DMAAPMR_IMAGE_BASE="onap/dmaap/dmaap-mr" +ONAP_DMAAPMR_IMAGE_TAG_REMOTE_RELEASE_ONAP="1.1.18" +#No local image for ONAP DMAAP-MR, remote image always used + +# List of app short names produced by the project +PROJECT_IMAGES_APP_NAMES="PA ECS CP SDNC RC RICSIM" + +# List of app short names which images pulled from ORAN +ORAN_IMAGES_APP_NAMES="" # Not used + +# List of app short names which images pulled from ONAP +ONAP_IMAGES_APP_NAMES="CBS DMAAPMR" + + +######################################## +# Detailed settings per app +######################################## + +DOCKER_SIM_NWNAME="nonrtric-docker-net" # Name of docker private network + +KUBE_NONRTRIC_NAMESPACE="nonrtric" # Namespace for all nonrtric components +KUBE_SIM_NAMESPACE="nonrtric-ft" # Namespace for simulators (except MR and RICSIM) +KUBE_ONAP_NAMESPACE="onap" # Namespace for onap (only message router) + +POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent container external port (host -> container) +POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) +POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) +POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) +POLICY_AGENT_APIS="V1 V2" # Supported northbound api versions +PMS_VERSION="V2" # Tested version of northbound API +PMS_API_PREFIX="" # api url prefix, only for V2 + +POLICY_AGENT_APP_NAME="policymanagementservice" # Name for Policy Agent container +POLICY_AGENT_DISPLAY_NAME="Policy Management Service" +POLICY_AGENT_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host +POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container +POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel +POLICY_AGENT_CONFIG_KEY="policy-agent" # Key for consul config +POLICY_AGENT_PKG_NAME="org.oransc.policyagent" # Java base package name +POLICY_AGENT_ACTUATOR="/actuator/loggers/$POLICY_AGENT_PKG_NAME" # Url for trace/debug +POLICY_AGENT_ALIVE_URL=$PMS_API_PREFIX"/v2/status" # Base path for alive check +POLICY_AGENT_COMPOSE_DIR="policy_agent" # Dir in simulator_group for docker-compose +POLICY_AGENT_CONFIG_MOUNT_PATH="/opt/app/policy-agent/config" # Path in container for config file +POLICY_AGENT_DATA_MOUNT_PATH="/opt/app/policy-agent/data" # Path in container for data file +POLICY_AGENT_CONFIG_FILE="application.yaml" # Container config file name +POLICY_AGENT_DATA_FILE="application_configuration.json" # Container data file name + +ECS_APP_NAME="enrichmentservice" # Name for ECS container +ECS_DISPLAY_NAME="Enrichment Coordinator Service" # Display name for ECS container +ECS_EXTERNAL_PORT=8083 # ECS container external port (host -> container) +ECS_INTERNAL_PORT=8083 # ECS container internal port (container -> container) +ECS_EXTERNAL_SECURE_PORT=8434 # ECS container external secure port (host -> container) +ECS_INTERNAL_SECURE_PORT=8434 # ECS container internal secure port (container -> container) -export ECS_APP_NAME="ecs" # Name for ECS container ECS_LOGPATH="/var/log/enrichment-coordinator-service/application.log" # Path the application log in the ECS container -export ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel -export ECS_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host -export ECS_CONTAINER_MNT_DIR="/var/enrichment-coordinator-service" # Mounted dir in the container - -export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container) -export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container) -export MR_EXTERNAL_SECURE_PORT=3906 # MR stub container external secure port (host -> container) -export MR_INTERNAL_SECURE_PORT=3906 # MR stub container internal secure port (container -> container) -export MR_APP_NAME="message-router" # Name for the MR -export MR_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100" # Path to read messages from MR -export MR_WRITE_URL="/events/A1-POLICY-AGENT-WRITE" # Path write messages to MR - -export CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container) -export CR_INTERNAL_PORT=8090 # Callback receiver container internal port (container -> container) -export CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container) -export CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container) -export CR_APP_NAME="callback-receiver" # Name for the Callback receiver -export CR_APP_CALLBACK="/callbacks" # Url for callbacks - -export PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container) -export PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container) -export PROD_STUB_EXTERNAL_SECURE_PORT=8093 # Producer stub container external secure port (host -> container) -export PROD_STUB_INTERNAL_SECURE_PORT=8093 # Producer stub container internal secure port (container -> container) -export PROD_STUB_APP_NAME="producer-stub" # Name for the Producer stub - -export CONSUL_HOST="consul-server" # Host name of consul -export CONSUL_EXTERNAL_PORT=8500 # Consul container external port (host -> container) -export CONSUL_INTERNAL_PORT=8500 # Consul container internal port (container -> container) -export CONSUL_APP_NAME="polman-consul" # Name for consul container - -export CBS_APP_NAME="polman-cbs" # Name for CBS container -export CBS_EXTERNAL_PORT=10000 # CBS container external port (host -> container) -export CBS_INTERNAL_PORT=10000 # CBS container internal port (container -> container) -export CONFIG_BINDING_SERVICE="config-binding-service" # Host name of CBS - -export RIC_SIM_BASE="g" # Base name of the RIC Simulator container, shall be the group code - # Note, a prefix is added to each container name by the .env file in the 'ric' dir -RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir - # This prefix can be changed from the command line -export RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container). - # (external ports allocated by docker) -export RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container). - # (external ports allocated by docker) - -export SDNC_APP_NAME="a1-controller" # Name of the SNDC A1 Controller container -export SDNC_EXTERNAL_PORT=8282 # SNDC A1 Controller container external port (host -> container) -export SDNC_INTERNAL_PORT=8181 # SNDC A1 Controller container internal port (container -> container) -export SDNC_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container external securee port (host -> container) -export SDNC_INTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container internal secure port (container -> container) -export SDNC_DB_APP_NAME="sdnc-db" # Name of the SDNC DB container -export SDNC_A1_TRUSTSTORE_PASSWORD="" # SDNC truststore password -SDNC_USER="admin" # SDNC username -SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD -SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API -SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check) -SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log - -export RAPP_CAT_EXTERNAL_PORT=8680 # RAPP Catalogue container external port (host -> container) -export RAPP_CAT_INTERNAL_PORT=8080 # RAPP Catalogue container internal port (container -> container) -export RAPP_CAT_EXTERNAL_SECURE_PORT=8633 # RAPP Catalogue container external secure port (host -> container) -export RAPP_CAT_INTERNAL_SECURE_PORT=8433 # RAPP Catalogue container internal secure port (container -> container) -export RAPP_CAT_APP_NAME="rapp-catalogue" # Name for the RAPP Catalogue - - -export CONTROL_PANEL_APP_NAME="control-panel" # Name of the Control Panel container -export CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container) -export CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container external port (host -> container) -CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container - -UUID="" # UUID used as prefix to the policy id to simulate a real UUID - # Testscript need to set the UUID otherwise this empty prefix is used - -RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT # Base url to the Agent NB REST interface -RESTBASE_SECURE="https://localhost:"$POLICY_AGENT_EXTERNAL_SECURE_PORT # Base url to the secure Agent NB REST interface -DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http -DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https -ADAPTER=$RESTBASE # Adapter holds the address the agent R-APP interface (REST OR DMAAP) - # The values of this var is swiched between the four base url when needed - -ECS_RESTBASE="http://localhost:"$ECS_EXTERNAL_PORT # Base url to the ECS NB REST interface -ECS_RESTBASE_SECURE="https://localhost:"$ECS_EXTERNAL_SECURE_PORT # Base url to the secure ECS NB REST interface -ECS_DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http -ECS_DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https -ECS_ADAPTER=$ECS_RESTBASE # Adapter holds the address the ECS R-APP interface (REST OR DMAAP) - # The values of this var is swiched between the four base url when needed - -CR_RESTBASE="http://localhost:"$CR_EXTERNAL_PORT # Base url to the Callback receiver REST interface -CR_RESTBASE_SECURE="https://localhost:"$CR_EXTERNAL_SECURE_PORT # Base url to the secure Callback receiver REST interface -CR_ADAPTER=$CR_RESTBASE # Adapter holds the address the CR admin interface (REST only) - # The values of this var is swiched between the two base url when needed - -RC_RESTBASE="http://localhost:"$RAPP_CAT_EXTERNAL_PORT # Base url to the RAPP Catalogue REST interface -RC_RESTBASE_SECURE="https://localhost:"$RAPP_CAT_EXTERNAL_SECURE_PORT # Base url to the secure RAPP Catalogue REST interface -RC_ADAPTER=$RC_RESTBASE # Adapter holds the address the RAPP Catalogue interface \ No newline at end of file +ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel +ECS_HOST_MNT_DIR="./mnt/db" # Mounted dir, relative to compose file, on the host +ECS_CONTAINER_MNT_DIR="/var/enrichment-coordinator-service" # Mounted dir in the container +ECS_ACTUATOR="/actuator/loggers/org.oransc.enrichment" # Url for trace/debug +ECS_CERT_MOUNT_DIR="./cert" +ECS_ALIVE_URL="/status" # Base path for alive check +ECS_COMPOSE_DIR="ecs" # Dir in simulator_group for docker-compose +ECS_CONFIG_MOUNT_PATH=/opt/app/enrichment-coordinator-service/config # Internal container path for configuration +ECS_CONFIG_FILE=application.yaml # Config file name +ECS_VERSION="V1-1" # Version where the types are added in the producer registration + +MR_DMAAP_APP_NAME="dmaap-mr" # Name for the Dmaap MR +MR_STUB_APP_NAME="mr-stub" # Name of the MR stub +MR_DMAAP_DISPLAY_NAME="DMAAP Message Router" +MR_STUB_DISPLAY_NAME="Message Router stub" +MR_STUB_CERT_MOUNT_DIR="./cert" +MR_EXTERNAL_PORT=3904 # MR dmaap/stub container external port +MR_INTERNAL_PORT=3904 # MR dmaap/stub container internal port +MR_EXTERNAL_SECURE_PORT=3905 # MR dmaap/stub container external secure port +MR_INTERNAL_SECURE_PORT=3905 # MR dmaap/stub container internal secure port +MR_DMAAP_LOCALHOST_PORT=3904 # MR stub container external port (host -> container) +MR_STUB_LOCALHOST_PORT=3908 # MR stub container external port (host -> container) +MR_DMAAP_LOCALHOST_SECURE_PORT=3905 # MR stub container internal port (container -> container) +MR_STUB_LOCALHOST_SECURE_PORT=3909 # MR stub container external secure port (host -> container) +MR_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100" # Path to read messages from MR +MR_WRITE_URL="/events/A1-POLICY-AGENT-WRITE" # Path write messages to MR +MR_READ_TOPIC="A1-POLICY-AGENT-READ" # Read topic +MR_WRITE_TOPIC="A1-POLICY-AGENT-WRITE" # Write topic +MR_STUB_ALIVE_URL="/" # Base path for mr stub alive check +MR_DMAAP_ALIVE_URL="/topics" # Base path for dmaap-mr alive check +MR_DMAAP_COMPOSE_DIR="dmaapmr" # Dir in simulator_group for dmaap mr for - docker-compose +MR_STUB_COMPOSE_DIR="mrstub" # Dir in simulator_group for mr stub for - docker-compose +MR_KAFKA_APP_NAME="kafka" # Kafka app name +MR_ZOOKEEPER_APP_NAME="zookeeper" # Zookeeper app name + + +CR_APP_NAME="callback-receiver" # Name for the Callback receiver +CR_DISPLAY_NAME="Callback Reciever" +CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container) +CR_INTERNAL_PORT=8090 # Callback receiver container internal port (container -> container) +CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container) +CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container) +CR_APP_CALLBACK="/callbacks" # Url for callbacks +CR_ALIVE_URL="/" # Base path for alive check +CR_COMPOSE_DIR="cr" # Dir in simulator_group for docker-compose + +PROD_STUB_APP_NAME="producer-stub" # Name for the Producer stub +PROD_STUB_DISPLAY_NAME="Producer Stub" +PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container) +PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container) +PROD_STUB_EXTERNAL_SECURE_PORT=8093 # Producer stub container external secure port (host -> container) +PROD_STUB_INTERNAL_SECURE_PORT=8093 # Producer stub container internal secure port (container -> container) +PROD_STUB_JOB_CALLBACK="/callbacks/job" # Callback path for job create/update/delete +PROD_STUB_SUPERVISION_CALLBACK="/callbacks/supervision" # Callback path for producre supervision +PROD_STUB_ALIVE_URL="/" # Base path for alive check +PROD_STUB_COMPOSE_DIR="prodstub" # Dir in simulator_group for docker-compose + +CONSUL_HOST="consul-server" # Host name of consul +CONSUL_DISPLAY_NAME="Consul" +CONSUL_EXTERNAL_PORT=8500 # Consul container external port (host -> container) +CONSUL_INTERNAL_PORT=8500 # Consul container internal port (container -> container) +CONSUL_APP_NAME="polman-consul" # Name for consul container +CONSUL_ALIVE_URL="/ui/dc1/kv" # Base path for alive check +CONSUL_CBS_COMPOSE_DIR="consul_cbs" # Dir in simulator group for docker compose + +CBS_APP_NAME="polman-cbs" # Name for CBS container +CBS_DISPLAY_NAME="Config Binding Service" +CBS_EXTERNAL_PORT=10000 # CBS container external port (host -> container) +CBS_INTERNAL_PORT=10000 # CBS container internal port (container -> container) +CONFIG_BINDING_SERVICE="config-binding-service" # Host name of CBS +CBS_ALIVE_URL="/healthcheck" # Base path for alive check + +RIC_SIM_DISPLAY_NAME="Near-RT RIC A1 Simulator" +RIC_SIM_BASE="g" # Base name of the RIC Simulator container, shall be the group code + # Note, a prefix is added to each container name by the .env file in the 'ric' dir +RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir + # This prefix can be changed from the command line +RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container). + # (external ports allocated by docker) +RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container). + # (external ports allocated by docker) +RIC_SIM_CERT_MOUNT_DIR="./cert" + +RIC_SIM_COMPOSE_DIR="ric" # Dir in simulator group for docker compose +RIC_SIM_ALIVE_URL="/" # Base path for alive check + +SDNC_APP_NAME="a1controller" # Name of the SNDC A1 Controller container +SDNC_DISPLAY_NAME="SDNC A1 Controller" +SDNC_EXTERNAL_PORT=8282 # SNDC A1 Controller container external port (host -> container) +SDNC_INTERNAL_PORT=8181 # SNDC A1 Controller container internal port (container -> container) +SDNC_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container external securee port (host -> container) +SDNC_INTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container internal secure port (container -> container) +SDNC_DB_APP_NAME="sdncdb" # Name of the SDNC DB container +SDNC_A1_TRUSTSTORE_PASSWORD="" # SDNC truststore password +SDNC_USER="admin" # SDNC username +SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD +SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API +SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check) +SDNC_COMPOSE_DIR="sdnc" # Dir in simulator_group for docker-compose +SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log + +RAPP_CAT_APP_NAME="rappcatalogueservice" # Name for the RAPP Catalogue +RAPP_CAT_DISPLAY_NAME="RAPP Catalogue Service" +RAPP_CAT_EXTERNAL_PORT=8680 # RAPP Catalogue container external port (host -> container) +RAPP_CAT_INTERNAL_PORT=8080 # RAPP Catalogue container internal port (container -> container) +RAPP_CAT_EXTERNAL_SECURE_PORT=8633 # RAPP Catalogue container external secure port (host -> container) +RAPP_CAT_INTERNAL_SECURE_PORT=8433 # RAPP Catalogue container internal secure port (container -> container) +RAPP_CAT_ALIVE_URL="/services" # Base path for alive check +RAPP_CAT_COMPOSE_DIR="rapp_catalogue" # Dir in simulator_group for docker-compose + +CONTROL_PANEL_APP_NAME="controlpanel" # Name of the Control Panel container +CONTROL_PANEL_DISPLAY_NAME="Non-RT RIC Control Panel" +CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container) +CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container internal port (container -> container) +CONTROL_PANEL_EXTERNAL_SECURE_PORT=8880 # Control Panel container external port (host -> container) +CONTROL_PANEL_INTERNAL_SECURE_PORT=8082 # Control Panel container internal port (container -> container) +CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container +CONTROL_PANEL_ALIVE_URL="/" # Base path for alive check +CONTROL_PANEL_COMPOSE_DIR="control_panel" # Dir in simulator_group for docker-compose +CONTROL_PANEL_CONFIG_MOUNT_PATH=/maven # Container internal path for config +CONTROL_PANEL_CONFIG_FILE=application.properties # Config file name + +HTTP_PROXY_APP_NAME="httpproxy" # Name of the Http Proxy container +HTTP_PROXY_DISPLAY_NAME="Http Proxy" +HTTP_PROXY_EXTERNAL_PORT=8780 # Http Proxy container external port (host -> container) +HTTP_PROXY_INTERNAL_PORT=8080 # Http Proxy container internal port (container -> container) +HTTP_PROXY_WEB_EXTERNAL_PORT=8781 # Http Proxy container external port (host -> container) +HTTP_PROXY_WEB_INTERNAL_PORT=8081 # Http Proxy container internal port (container -> container) +HTTP_PROXY_CONFIG_PORT=0 # Port number for proxy config, will be set if proxy is started +HTTP_PROXY_CONFIG_HOST_NAME="" # Proxy host, will be set if proxy is started +HTTP_PROXY_ALIVE_URL="/" # Base path for alive check +HTTP_PROXY_COMPOSE_DIR="httpproxy" # Dir in simulator_group for docker-compose + +######################################## +# Setting for common curl-base function +######################################## + +UUID="" # UUID used as prefix to the policy id to simulate a real UUID + # Testscript need to set the UUID otherwise this empty prefix is used diff --git a/test/common/test_env-oran-dawn.sh b/test/common/test_env-oran-dawn.sh new file mode 100755 index 00000000..8943ffdf --- /dev/null +++ b/test/common/test_env-oran-dawn.sh @@ -0,0 +1,359 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +# +#Profile for ORAN Cherry +TEST_ENV_PROFILE="ORAN-DAWN" +FLAVOUR="ORAN" + +######################################## +## Nexus repo settings +######################################## + +# Nexus repos for developed images +NEXUS_PROXY_REPO="nexus3.o-ran-sc.org:10001/" +NEXUS_RELEASE_REPO="nexus3.o-ran-sc.org:10002/" +NEXUS_SNAPSHOT_REPO="nexus3.o-ran-sc.org:10003/" +NEXUS_STAGING_REPO="nexus3.o-ran-sc.org:10004/" + +# Nexus repos for images used by test (not developed by the project) +NEXUS_RELEASE_REPO_ONAP="nexus3.onap.org:10002/" # Only for released ONAP images +NEXUS_RELEASE_REPO_ORAN=$NEXUS_RELEASE_REPO + +######################################## +# Set up of image and tags for the test. +######################################## + +# NOTE: One environment variable containing the image name and tag is create by the test script +# for each image from the env variables below. +# The variable is created by removing the suffix "_BASE" from the base image variable name. +# Example: POLICY_AGENT_IMAGE_BASE -> POLICY_AGENT_IMAGE +# This var will point to the local or remote image depending on cmd line arguments. +# In addition, the repo and the image tag version are selected from the list of image tags based on the cmd line argurment. +# For images built by the script, only tag #1 shall be specified +# For project images, only tag #1, #2, #3 and #4 shall be specified +# For ORAN images (non project), only tag #5 shall be specified +# For ONAP images (non project), only tag #6 shall be specified +# For all other images, only tag #7 shall be specified +# 1 XXX_LOCAL: local images: : +# 2 XXX_REMOTE_SNAPSHOT: snapshot images: : +# 3 XXX_REMOTE: staging images: : +# 4 XXX_REMOTE_RELEASE: release images: : +# 5 XXX_REMOTE_RELEASE_ORAN: ORAN release images: : +# 6 XXX_REMOTE_RELEASE_ONAP: ONAP release images: : +# 7 XXX_PROXY: other images, not produced by the project: : + + +# Policy Agent base image and tags +POLICY_AGENT_IMAGE_BASE="o-ran-sc/nonrtric-policy-agent" +POLICY_AGENT_IMAGE_TAG_LOCAL="2.2.0-SNAPSHOT" +POLICY_AGENT_IMAGE_TAG_REMOTE_SNAPSHOT="2.2.0-SNAPSHOT" +POLICY_AGENT_IMAGE_TAG_REMOTE="2.2.0" +POLICY_AGENT_IMAGE_TAG_REMOTE_RELEASE="2.2.0" + +# ECS image and tags +ECS_IMAGE_BASE="o-ran-sc/nonrtric-enrichment-coordinator-service" +ECS_IMAGE_TAG_LOCAL="1.1.0-SNAPSHOT" +ECS_IMAGE_TAG_REMOTE_SNAPSHOT="1.1.0-SNAPSHOT" +ECS_IMAGE_TAG_REMOTE="1.1.0" +ECS_IMAGE_TAG_REMOTE_RELEASE="1.1.0" + + +# Control Panel image and tags +CONTROL_PANEL_IMAGE_BASE="o-ran-sc/nonrtric-controlpanel" +CONTROL_PANEL_IMAGE_TAG_LOCAL="2.2.0-SNAPSHOT" +CONTROL_PANEL_IMAGE_TAG_REMOTE_SNAPSHOT="2.2.0-SNAPSHOT" +CONTROL_PANEL_IMAGE_TAG_REMOTE="2.2.0" +CONTROL_PANEL_IMAGE_TAG_REMOTE_RELEASE="2.2.0" + + +# SDNC A1 Controller image and tags - still using cherry version, no new version for dawn +SDNC_A1_CONTROLLER_IMAGE_BASE="o-ran-sc/nonrtric-a1-controller" +SDNC_A1_CONTROLLER_IMAGE_TAG_LOCAL="2.0.1-SNAPSHOT" +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE_SNAPSHOT="2.0.1-SNAPSHOT" +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE="2.0.1" +SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE_RELEASE="2.0.1" + +# SDNC A1 Controller image and tags - intended versions for dawn - not yet present +# SDNC_A1_CONTROLLER_IMAGE_BASE="o-ran-sc/nonrtric-a1-controller" +# SDNC_A1_CONTROLLER_IMAGE_TAG_LOCAL="2.1.0-SNAPSHOT" +# SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE_SNAPSHOT="2.1.0-SNAPSHOT" +# SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE="2.1.0" +# SDNC_A1_CONTROLLER_IMAGE_TAG_REMOTE_RELEASE="2.1.0" + + +#SDNC DB remote image and tag +SDNC_DB_IMAGE_BASE="mysql/mysql-server" +SDNC_DB_IMAGE_TAG_REMOTE_PROXY="5.6" +#No local image for SSDNC DB, remote image always used + + +# RAPP Catalogue image and tags +RAPP_CAT_IMAGE_BASE="o-ran-sc/nonrtric-r-app-catalogue" +RAPP_CAT_IMAGE_TAG_LOCAL="1.1.0-SNAPSHOT" +RAPP_CAT_IMAGE_TAG_REMOTE_SNAPSHOT="1.1.0-SNAPSHOT" +RAPP_CAT_IMAGE_TAG_REMOTE="1.1.0" +RAPP_CAT_IMAGE_TAG_REMOTE_RELEASE="1.1.0" + + +# Near RT RIC Simulator image and tags - same version as cherry +RIC_SIM_IMAGE_BASE="o-ran-sc/a1-simulator" +RIC_SIM_IMAGE_TAG_LOCAL="latest" +RIC_SIM_IMAGE_TAG_REMOTE_SNAPSHOT="2.1.0-SNAPSHOT" +RIC_SIM_IMAGE_TAG_REMOTE="2.1.0" +RIC_SIM_IMAGE_TAG_REMOTE_RELEASE="2.1.0" + + +#Consul remote image and tag +CONSUL_IMAGE_BASE="consul" +CONSUL_IMAGE_TAG_REMOTE_PROXY="1.7.2" +#No local image for Consul, remote image always used + + +#CBS remote image and tag +CBS_IMAGE_BASE="onap/org.onap.dcaegen2.platform.configbinding.app-app" +CBS_IMAGE_TAG_REMOTE_RELEASE_ONAP="2.3.0" +#No local image for CBS, remote image always used + + +#MR stub image and tag +MRSTUB_IMAGE_BASE="mrstub" +MRSTUB_IMAGE_TAG_LOCAL="latest" +#No remote image for MR stub, local image always used + + +#Callback receiver image and tag +CR_IMAGE_BASE="callback-receiver" +CR_IMAGE_TAG_LOCAL="latest" +#No remote image for CR, local image always used + + +#Producer stub image and tag +PROD_STUB_IMAGE_BASE="producer-stub" +PROD_STUB_IMAGE_TAG_LOCAL="latest" +#No remote image for producer stub, local image always used + +#Http proxy remote image and tag +HTTP_PROXY_IMAGE_BASE="mitmproxy/mitmproxy" +HTTP_PROXY_IMAGE_TAG_REMOTE_PROXY="6.0.2" +#No local image for SSDNC DB, remote image always used + +#ONAP Zookeeper remote image and tag +ONAP_ZOOKEEPER_IMAGE_BASE="onap/dmaap/zookeeper" +ONAP_ZOOKEEPER_IMAGE_TAG_REMOTE_RELEASE_ONAP="6.0.3" +#No local image for ONAP Zookeeper, remote image always used + +#ONAP Kafka remote image and tag +ONAP_KAFKA_IMAGE_BASE="onap/dmaap/kafka111" +ONAP_KAFKA_IMAGE_TAG_REMOTE_RELEASE_ONAP="1.0.4" +#No local image for ONAP Kafka, remote image always used + +#ONAP DMAAP-MR remote image and tag +ONAP_DMAAPMR_IMAGE_BASE="onap/dmaap/dmaap-mr" +ONAP_DMAAPMR_IMAGE_TAG_REMOTE_RELEASE_ONAP="1.1.18" +#No local image for ONAP DMAAP-MR, remote image always used + +# List of app short names produced by the project +PROJECT_IMAGES_APP_NAMES="PA ECS CP SDNC RC RICSIM" + +# List of app short names which images pulled from ORAN +ORAN_IMAGES_APP_NAMES="" # Not used + +# List of app short names which images pulled from ONAP +ONAP_IMAGES_APP_NAMES="CBS DMAAPMR" + + +######################################## +# Detailed settings per app +######################################## + +DOCKER_SIM_NWNAME="nonrtric-docker-net" # Name of docker private network + +KUBE_NONRTRIC_NAMESPACE="nonrtric" # Namespace for all nonrtric components +KUBE_SIM_NAMESPACE="nonrtric-ft" # Namespace for simulators (except MR and RICSIM) +KUBE_ONAP_NAMESPACE="onap" # Namespace for onap (only message router) + +POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent container external port (host -> container) +POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) +POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) +POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) +POLICY_AGENT_APIS="V1 V2" # Supported northbound api versions +PMS_VERSION="V2" # Tested version of northbound API +PMS_API_PREFIX="" # api url prefix, only for V2 + +POLICY_AGENT_APP_NAME="policymanagementservice" # Name for Policy Agent container +POLICY_AGENT_DISPLAY_NAME="Policy Management Service" +POLICY_AGENT_HOST_MNT_DIR="./mnt" # Mounted dir, relative to compose file, on the host +POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container +POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel +POLICY_AGENT_CONFIG_KEY="policy-agent" # Key for consul config +POLICY_AGENT_PKG_NAME="org.oransc.policyagent" # Java base package name +POLICY_AGENT_ACTUATOR="/actuator/loggers/$POLICY_AGENT_PKG_NAME" # Url for trace/debug +POLICY_AGENT_ALIVE_URL=$PMS_API_PREFIX"/v2/status" # Base path for alive check +POLICY_AGENT_COMPOSE_DIR="policy_agent" # Dir in simulator_group for docker-compose +POLICY_AGENT_CONFIG_MOUNT_PATH="/opt/app/policy-agent/config" # Path in container for config file +POLICY_AGENT_DATA_MOUNT_PATH="/opt/app/policy-agent/data" # Path in container for data file +POLICY_AGENT_CONFIG_FILE="application.yaml" # Container config file name +POLICY_AGENT_DATA_FILE="application_configuration.json" # Container data file name + +ECS_APP_NAME="enrichmentservice" # Name for ECS container +ECS_DISPLAY_NAME="Enrichment Coordinator Service" # Display name for ECS container +ECS_EXTERNAL_PORT=8083 # ECS container external port (host -> container) +ECS_INTERNAL_PORT=8083 # ECS container internal port (container -> container) +ECS_EXTERNAL_SECURE_PORT=8434 # ECS container external secure port (host -> container) +ECS_INTERNAL_SECURE_PORT=8434 # ECS container internal secure port (container -> container) + +ECS_LOGPATH="/var/log/enrichment-coordinator-service/application.log" # Path the application log in the ECS container +ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel +ECS_HOST_MNT_DIR="./mnt/db" # Mounted dir, relative to compose file, on the host +ECS_CONTAINER_MNT_DIR="/var/enrichment-coordinator-service" # Mounted dir in the container +ECS_ACTUATOR="/actuator/loggers/org.oransc.enrichment" # Url for trace/debug +ECS_CERT_MOUNT_DIR="./cert" +ECS_ALIVE_URL="/status" # Base path for alive check +ECS_COMPOSE_DIR="ecs" # Dir in simulator_group for docker-compose +ECS_CONFIG_MOUNT_PATH=/opt/app/enrichment-coordinator-service/config # Internal container path for configuration +ECS_CONFIG_FILE=application.yaml # Config file name +ECS_VERSION="V1-2" # Version where the types are decoupled from the producer registration + +MR_DMAAP_APP_NAME="dmaap-mr" # Name for the Dmaap MR +MR_STUB_APP_NAME="mr-stub" # Name of the MR stub +MR_DMAAP_DISPLAY_NAME="DMAAP Message Router" +MR_STUB_DISPLAY_NAME="Message Router stub" +MR_STUB_CERT_MOUNT_DIR="./cert" +MR_EXTERNAL_PORT=3904 # MR dmaap/stub container external port +MR_INTERNAL_PORT=3904 # MR dmaap/stub container internal port +MR_EXTERNAL_SECURE_PORT=3905 # MR dmaap/stub container external secure port +MR_INTERNAL_SECURE_PORT=3905 # MR dmaap/stub container internal secure port +MR_DMAAP_LOCALHOST_PORT=3904 # MR stub container external port (host -> container) +MR_STUB_LOCALHOST_PORT=3908 # MR stub container external port (host -> container) +MR_DMAAP_LOCALHOST_SECURE_PORT=3905 # MR stub container internal port (container -> container) +MR_STUB_LOCALHOST_SECURE_PORT=3909 # MR stub container external secure port (host -> container) +MR_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100" # Path to read messages from MR +MR_WRITE_URL="/events/A1-POLICY-AGENT-WRITE" # Path write messages to MR +MR_READ_TOPIC="A1-POLICY-AGENT-READ" # Read topic +MR_WRITE_TOPIC="A1-POLICY-AGENT-WRITE" # Write topic +MR_STUB_ALIVE_URL="/" # Base path for mr stub alive check +MR_DMAAP_ALIVE_URL="/topics" # Base path for dmaap-mr alive check +MR_DMAAP_COMPOSE_DIR="dmaapmr" # Dir in simulator_group for dmaap mr for - docker-compose +MR_STUB_COMPOSE_DIR="mrstub" # Dir in simulator_group for mr stub for - docker-compose +MR_KAFKA_APP_NAME="kafka" # Kafka app name +MR_ZOOKEEPER_APP_NAME="zookeeper" # Zookeeper app name + + +CR_APP_NAME="callback-receiver" # Name for the Callback receiver +CR_DISPLAY_NAME="RAPP Catalogue" +CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container) +CR_INTERNAL_PORT=8090 # Callback receiver container internal port (container -> container) +CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container) +CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container) +CR_APP_CALLBACK="/callbacks" # Url for callbacks +CR_ALIVE_URL="/" # Base path for alive check +CR_COMPOSE_DIR="cr" # Dir in simulator_group for docker-compose + +PROD_STUB_APP_NAME="producer-stub" # Name for the Producer stub +PROD_STUB_DISPLAY_NAME="Producer Stub" +PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container) +PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container) +PROD_STUB_EXTERNAL_SECURE_PORT=8093 # Producer stub container external secure port (host -> container) +PROD_STUB_INTERNAL_SECURE_PORT=8093 # Producer stub container internal secure port (container -> container) +PROD_STUB_JOB_CALLBACK="/callbacks/job" # Callback path for job create/update/delete +PROD_STUB_SUPERVISION_CALLBACK="/callbacks/supervision" # Callback path for producre supervision +PROD_STUB_ALIVE_URL="/" # Base path for alive check +PROD_STUB_COMPOSE_DIR="prodstub" # Dir in simulator_group for docker-compose + +CONSUL_HOST="consul-server" # Host name of consul +CONSUL_DISPLAY_NAME="Consul" +CONSUL_EXTERNAL_PORT=8500 # Consul container external port (host -> container) +CONSUL_INTERNAL_PORT=8500 # Consul container internal port (container -> container) +CONSUL_APP_NAME="polman-consul" # Name for consul container +CONSUL_ALIVE_URL="/ui/dc1/kv" # Base path for alive check +CONSUL_CBS_COMPOSE_DIR="consul_cbs" # Dir in simulator group for docker compose + +CBS_APP_NAME="polman-cbs" # Name for CBS container +CBS_DISPLAY_NAME="Config Binding Service" +CBS_EXTERNAL_PORT=10000 # CBS container external port (host -> container) +CBS_INTERNAL_PORT=10000 # CBS container internal port (container -> container) +CONFIG_BINDING_SERVICE="config-binding-service" # Host name of CBS +CBS_ALIVE_URL="/healthcheck" # Base path for alive check + +RIC_SIM_DISPLAY_NAME="Near-RT RIC A1 Simulator" +RIC_SIM_BASE="g" # Base name of the RIC Simulator container, shall be the group code + # Note, a prefix is added to each container name by the .env file in the 'ric' dir +RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir + # This prefix can be changed from the command line +RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container). + # (external ports allocated by docker) +RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container). + # (external ports allocated by docker) +RIC_SIM_CERT_MOUNT_DIR="./cert" + +RIC_SIM_COMPOSE_DIR="ric" # Dir in simulator group for docker compose +RIC_SIM_ALIVE_URL="/" # Base path for alive check + +SDNC_APP_NAME="a1controller" # Name of the SNDC A1 Controller container +SDNC_DISPLAY_NAME="SDNC A1 Controller" +SDNC_EXTERNAL_PORT=8282 # SNDC A1 Controller container external port (host -> container) +SDNC_INTERNAL_PORT=8181 # SNDC A1 Controller container internal port (container -> container) +SDNC_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container external securee port (host -> container) +SDNC_INTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container internal secure port (container -> container) +SDNC_DB_APP_NAME="sdncdb" # Name of the SDNC DB container +SDNC_A1_TRUSTSTORE_PASSWORD="" # SDNC truststore password +SDNC_USER="admin" # SDNC username +SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD +SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API +SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check) +SDNC_COMPOSE_DIR="sdnc" # Dir in simulator_group for docker-compose +SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log + +RAPP_CAT_APP_NAME="rappcatalogueservice" # Name for the RAPP Catalogue +RAPP_CAT_DISPLAY_NAME="RAPP Catalogue" +RAPP_CAT_EXTERNAL_PORT=8680 # RAPP Catalogue container external port (host -> container) +RAPP_CAT_INTERNAL_PORT=8080 # RAPP Catalogue container internal port (container -> container) +RAPP_CAT_EXTERNAL_SECURE_PORT=8633 # RAPP Catalogue container external secure port (host -> container) +RAPP_CAT_INTERNAL_SECURE_PORT=8433 # RAPP Catalogue container internal secure port (container -> container) +RAPP_CAT_ALIVE_URL="/services" # Base path for alive check +RAPP_CAT_COMPOSE_DIR="rapp_catalogue" # Dir in simulator_group for docker-compose + +CONTROL_PANEL_APP_NAME="controlpanel" # Name of the Control Panel container +CONTROL_PANEL_DISPLAY_NAME="Control Panel" +CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container) +CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container internal port (container -> container) +CONTROL_PANEL_EXTERNAL_SECURE_PORT=8880 # Control Panel container external port (host -> container) +CONTROL_PANEL_INTERNAL_SECURE_PORT=8082 # Control Panel container internal port (container -> container) +CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container +CONTROL_PANEL_ALIVE_URL="/" # Base path for alive check +CONTROL_PANEL_COMPOSE_DIR="control_panel" # Dir in simulator_group for docker-compose +CONTROL_PANEL_CONFIG_MOUNT_PATH=/maven # Container internal path for config +CONTROL_PANEL_CONFIG_FILE=application.properties # Config file name + +HTTP_PROXY_APP_NAME="httpproxy" # Name of the Http Proxy container +HTTP_PROXY_DISPLAY_NAME="Http Proxy" +HTTP_PROXY_EXTERNAL_PORT=8780 # Http Proxy container external port (host -> container) +HTTP_PROXY_INTERNAL_PORT=8080 # Http Proxy container internal port (container -> container) +HTTP_PROXY_WEB_EXTERNAL_PORT=8781 # Http Proxy container external port (host -> container) +HTTP_PROXY_WEB_INTERNAL_PORT=8081 # Http Proxy container internal port (container -> container) +HTTP_PROXY_CONFIG_PORT=0 # Port number for proxy config, will be set if proxy is started +HTTP_PROXY_CONFIG_HOST_NAME="" # Proxy host, will be set if proxy is started +HTTP_PROXY_ALIVE_URL="/" # Base path for alive check +HTTP_PROXY_COMPOSE_DIR="httpproxy" # Dir in simulator_group for docker-compose + +######################################## +# Setting for common curl-base function +######################################## + +UUID="" # UUID used as prefix to the policy id to simulate a real UUID + # Testscript need to set the UUID otherwise this empty prefix is used diff --git a/test/common/test_env.sh b/test/common/test_env.sh deleted file mode 100644 index a8e618fe..00000000 --- a/test/common/test_env.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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. -# ============LICENSE_END================================================= -# - -# Set up the image and tags for the test. Do not add the image tag to the image names. - -# NOTE: A env var for each container is created by the test script. -# This var will point to the local or remote var depending on how -# the test script is started. The name format is _IMAGE, ie with 'LOCAL' or 'REMOTE'. - -# Local Policy Agent image and tag -POLICY_AGENT_LOCAL_IMAGE="o-ran-sc/nonrtric-policy-agent" -POLICY_AGENT_LOCAL_IMAGE_TAG="2.2.0-SNAPSHOT" -# Remote Policy Agent image and tag -POLICY_AGENT_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent" -POLICY_AGENT_REMOTE_IMAGE_TAG="2.2.0" - -# Local ECS image and tag -ECS_LOCAL_IMAGE="o-ran-sc/nonrtric-enrichment-coordinator-service" -ECS_LOCAL_IMAGE_TAG="1.1.0-SNAPSHOT" -# Remote ECS image and tag -ECS_REMOTE_IMAGE="nexus3.o-ran-sc.org:10003/o-ran-sc/nonrtric-enrichment-coordinator-service" -ECS_REMOTE_IMAGE_TAG="1.1.0-SNAPSHOT" - -# Control Panel local image and tag -CONTROL_PANEL_LOCAL_IMAGE="o-ran-sc/nonrtric-controlpanel" -CONTROL_PANEL_LOCAL_IMAGE_TAG="2.2.0-SNAPSHOT" -# Control Panel remote image and tag -CONTROL_PANEL_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-controlpanel" -CONTROL_PANEL_REMOTE_IMAGE_TAG="2.2.0" - - -# SDNC A1 Controller local image and tag -SDNC_A1_CONTROLLER_LOCAL_IMAGE="o-ran-sc/nonrtric-a1-controller" -SDNC_A1_CONTROLLER_LOCAL_IMAGE_TAG="2.1.0-SNAPSHOT" -# SDNC A1 Controller remote image and tag -SDNC_A1_CONTROLLER_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-a1-controller" -SDNC_A1_CONTROLLER_REMOTE_IMAGE_TAG="2.1.0" - - -#SDNC DB remote image and tag -SDNC_DB_REMOTE_IMAGE="mysql/mysql-server" -SDNC_DB_REMOTE_IMAGE_TAG="5.6" -#No local image for DB, remote image always used - - -# Near RT RIC Simulator local image and tag -RIC_SIM_LOCAL_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator" -RIC_SIM_LOCAL_IMAGE_TAG="latest" -# Near RT RIC Simulator remote image and tag -RIC_SIM_REMOTE_IMAGE="nexus3.o-ran-sc.org:10004/o-ran-sc/a1-simulator" -RIC_SIM_REMOTE_IMAGE_TAG="2.0.0" - - -#Consul remote image and tag -CONSUL_REMOTE_IMAGE="consul" -CONSUL_REMOTE_IMAGE_TAG="1.7.2" -#No local image for Consul, remote image always used - - -#CBS remote image and tag -CBS_REMOTE_IMAGE="nexus3.onap.org:10001/onap/org.onap.dcaegen2.platform.configbinding.app-app" -CBS_REMOTE_IMAGE_TAG="2.3.0" -#No local image for CBS, remote image always used - - -#MR stub image and tag -MRSTUB_LOCAL_IMAGE="mrstub" -MRSTUB_LOCAL_IMAGE_TAG="latest" -#No remote image for MR stub, local image always used - -#Callback receiver image and tag -CR_LOCAL_IMAGE="callback-receiver" -CR_LOCAL_IMAGE_TAG="latest" -#No remote image for CR, local image always used - -#Producer stub image and tag -PROD_STUB_LOCAL_IMAGE="producer-stub" -PROD_STUB_LOCAL_IMAGE_TAG="latest" -#No remote image for producer stub, local image always used - -# Common env var for auto-test. Vars used by docker-compose need to be exported -export DOCKER_SIM_NWNAME="nonrtric-docker-net" # Name of docker private network - -export POLICY_AGENT_EXTERNAL_PORT=8081 # Policy Agent container external port (host -> container) -export POLICY_AGENT_INTERNAL_PORT=8081 # Policy Agent container internal port (container -> container) -export POLICY_AGENT_EXTERNAL_SECURE_PORT=8433 # Policy Agent container external secure port (host -> container) -export POLICY_AGENT_INTERNAL_SECURE_PORT=8433 # Policy Agent container internal secure port (container -> container) - -export POLICY_AGENT_APP_NAME="policy-agent" # Name for Policy Agent container -POLICY_AGENT_LOGPATH="/var/log/policy-agent/application.log" # Path the application log in the Policy Agent container -export POLICY_AGENT_APP_NAME_ALIAS="policy-agent-container" # Alias name, name used by the control panel - -export ECS_EXTERNAL_PORT=8083 # ECS container external port (host -> container) -export ECS_INTERNAL_PORT=8083 # ECS container internal port (container -> container) -export ECS_EXTERNAL_SECURE_PORT=8434 # ECS container external secure port (host -> container) -export ECS_INTERNAL_SECURE_PORT=8434 # ECS container internal secure port (container -> container) - -export ECS_APP_NAME="ecs" # Name for ECS container -ECS_LOGPATH="/var/log/enrichment-coordinator-service/application.log" # Path the application log in the ECS container -export ECS_APP_NAME_ALIAS="enrichment-service-container" # Alias name, name used by the control panel - -export MR_EXTERNAL_PORT=3905 # MR stub container external port (host -> container) -export MR_INTERNAL_PORT=3905 # MR stub container internal port (container -> container) -export MR_EXTERNAL_SECURE_PORT=3906 # MR stub container external secure port (host -> container) -export MR_INTERNAL_SECURE_PORT=3906 # MR stub container internal secure port (container -> container) -export MR_APP_NAME="message-router" # Name for the MR -export MR_READ_URL="/events/A1-POLICY-AGENT-READ/users/policy-agent?timeout=15000&limit=100" # Path to read messages from MR -export MR_WRITE_URL="/events/A1-POLICY-AGENT-WRITE" # Path write messages to MR - -export CR_EXTERNAL_PORT=8090 # Callback receiver container external port (host -> container) -export CR_INTERNAL_PORT=8090 # Callback receiver container internal port (container -> container) -export CR_EXTERNAL_SECURE_PORT=8091 # Callback receiver container external secure port (host -> container) -export CR_INTERNAL_SECURE_PORT=8091 # Callback receiver container internal secure port (container -> container) -export CR_APP_NAME="callback-receiver" # Name for the Callback receiver - -export PROD_STUB_EXTERNAL_PORT=8092 # Producer stub container external port (host -> container) -export PROD_STUB_INTERNAL_PORT=8092 # Producer stub container internal port (container -> container) -export PROD_STUB_EXTERNAL_SECURE_PORT=8093 # Producer stub container external secure port (host -> container) -export PROD_STUB_INTERNAL_SECURE_PORT=8093 # Producer stub container internal secure port (container -> container) -export PROD_STUB_APP_NAME="producer-stub" # Name for the Producer stub - -export CONSUL_HOST="consul-server" # Host name of consul -export CONSUL_EXTERNAL_PORT=8500 # Consul container external port (host -> container) -export CONSUL_INTERNAL_PORT=8500 # Consul container internal port (container -> container) -export CONSUL_APP_NAME="polman-consul" # Name for consul container - -export CBS_APP_NAME="polman-cbs" # Name for CBS container -export CBS_EXTERNAL_PORT=10000 # CBS container external port (host -> container) -export CBS_INTERNAL_PORT=10000 # CBS container internal port (container -> container) -export CONFIG_BINDING_SERVICE="config-binding-service" # Host name of CBS - -export RIC_SIM_BASE="g" # Base name of the RIC Simulator container, shall be the group code - # Note, a prefix is added to each container name by the .env file in the 'ric' dir -RIC_SIM_PREFIX="ricsim" # Prefix added to ric container name, added in the .env file in the 'ric' dir - # This prefix can be changed from the command line -export RIC_SIM_INTERNAL_PORT=8085 # RIC Simulator container internal port (container -> container). - # (external ports allocated by docker) -export RIC_SIM_INTERNAL_SECURE_PORT=8185 # RIC Simulator container internal secure port (container -> container). - # (external ports allocated by docker) - -export SDNC_APP_NAME="a1-controller" # Name of the SNDC A1 Controller container -export SDNC_EXTERNAL_PORT=8282 # SNDC A1 Controller container external port (host -> container) -export SDNC_INTERNAL_PORT=8181 # SNDC A1 Controller container internal port (container -> container) -export SDNC_EXTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container external securee port (host -> container) -export SDNC_INTERNAL_SECURE_PORT=8443 # SNDC A1 Controller container internal secure port (container -> container) -export SDNC_DB_APP_NAME="sdnc-db" # Name of the SDNC DB container -export SDNC_A1_TRUSTSTORE_PASSWORD="" # SDNC truststore password -SDNC_USER="admin" # SDNC username -SDNC_PWD="Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" # SNDC PWD -SDNC_API_URL="/restconf/operations/A1-ADAPTER-API:" # Base url path for SNDC API -SDNC_ALIVE_URL="/apidoc/explorer/" # Base url path for SNDC API docs (for alive check) -SDNC_KARAF_LOG="/opt/opendaylight/data/log/karaf.log" # Path to karaf log - -export CONTROL_PANEL_APP_NAME="control-panel" # Name of the Control Panel container -export CONTROL_PANEL_EXTERNAL_PORT=8080 # Control Panel container external port (host -> container) -export CONTROL_PANEL_INTERNAL_PORT=8080 # Control Panel container external port (host -> container) -CONTROL_PANEL_LOGPATH="/logs/nonrtric-controlpanel.log" # Path the application log in the Control Panel container - -UUID="" # UUID used as prefix to the policy id to simulate a real UUID - # Testscript need to set the UUID otherwise this empty prefix is used - -RESTBASE="http://localhost:"$POLICY_AGENT_EXTERNAL_PORT # Base url to the Agent NB REST interface -RESTBASE_SECURE="https://localhost:"$POLICY_AGENT_EXTERNAL_SECURE_PORT # Base url to the secure Agent NB REST interface -DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http -DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https -ADAPTER=$RESTBASE # Adapter holds the address the agent R-APP interface (REST OR DMAAP) - # The values of this var is swiched between the four base url when needed -ECS_RESTBASE="http://localhost:"$ECS_EXTERNAL_PORT # Base url to the ECS NB REST interface -ECS_RESTBASE_SECURE="https://localhost:"$ECS_EXTERNAL_SECURE_PORT # Base url to the secure ECS NB REST interface -ECS_DMAAPBASE="http://localhost:"$MR_EXTERNAL_PORT # Base url to the Dmaap adapter, http -ECS_DMAAPBASE_SECURE="https://localhost:"$MR_EXTERNAL_SECURE_PORT # Base url to the Dmaap adapter, https -ECS_ADAPTER=$ECS_RESTBASE # Adapter holds the address the ECS R-APP interface (REST OR DMAAP) - # The values of this var is swiched between the four base url when needed diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index f2783f39..aee3af5c 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -17,9 +17,46 @@ # ============LICENSE_END================================================= # -# This is a script that contains all the functions needed for auto test -# Arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix ] [ --env-file ] [--use-local-image []*] +# This is a script that contains all the common functions needed for auto test. +# Specific test function are defined in scripts XXXX_functions.sh +. ../common/api_curl.sh + +# List of short names for all supported apps, including simulators etc +APP_SHORT_NAMES="PA RICSIM SDNC CP ECS RC CBS CONSUL RC MR DMAAPMR CR PRODSTUB" + +__print_args() { + echo "Args: remote|remote-remove docker|kube --env-file [release] [auto-clean] [--stop-at-error] " + echo " [--ricsim-prefix ] [--use-local-image +] [--use-snapshot-image +]" + echo " [--use-staging-image +] [--use-release-image +]" +} + +if [ $# -eq 1 ] && [ "$1" == "help" ]; then + + if [ ! -z "$TC_ONELINE_DESCR" ]; then + echo "Test script description:" + echo $TC_ONELINE_DESCR + echo "" + fi + __print_args + echo "" + echo "remote - Use images from remote repositories. Can be overridden for individual images using the '--use_xxx' flags" + echo "remote-remove - Same as 'remote' but will also try to pull fresh images from remote repositories" + echo "docker - Test executed in docker environment" + echo "kube - Test executed in kubernetes environment - requires an already started kubernetes environment" + echo "--env-file - The script will use the supplied file to read environment variables from" + echo "release - If this flag is given the script will use release version of the images" + echo "auto-clean - If the function 'auto_clean_containers' is present in the end of the test script then all containers will be stopped and removed. If 'auto-clean' is not given then the function has no effect." + echo "--stop-at-error - The script will stop when the first failed test or configuration" + echo "--ricsim-prefix - The a1 simulator will use the supplied string as container prefix instead of 'ricsim'" + echo "--use-local-image - The script will use local images for the supplied apps, space separated list of app short names" + echo "--use-snapshot-image - The script will use images from the nexus snapshot repo for the supplied apps, space separated list of app short names" + echo "--use-staging-image - The script will use images from the nexus staging repo for the supplied apps, space separated list of app short names" + echo "--use-release-image - The script will use images from the nexus release repo for the supplied apps, space separated list of app short names" + echo "" + echo "List of app short names supported: "$APP_SHORT_NAMES + exit 0 +fi # Create a test case id, ATC (Auto Test Case), from the name of the test case script. # FTC1.sh -> ATC == FTC1 @@ -40,23 +77,6 @@ YELLOW="\033[33m\033[1m" EYELLOW="\033[0m" SAMELINE="\033[0K\r" -tmp=$(which python3) -if [ $? -ne 0 ] || [ -z tmp ]; then - echo -e $RED"python3 is required to run the test environment, pls install"$ERED - exit 1 -fi -tmp=$(which docker) -if [ $? -ne 0 ] || [ -z tmp ]; then - echo -e $RED"docker is required to run the test environment, pls install"$ERED - exit 1 -fi - -tmp=$(which docker-compose) -if [ $? -ne 0 ] || [ -z tmp ]; then - echo -e $RED"docker-compose is required to run the test environment, pls install"$ERED - exit 1 -fi - # Just resetting any previous echo formatting... echo -ne $EBOLD @@ -65,30 +85,37 @@ TEST_ENV_VAR_FILE="" echo "Test case started as: ${BASH_SOURCE[$i+1]} "$@ -#Localhost constant -LOCALHOST="http://localhost:" - -# Make curl retries towards ECS for http response codes set in this env var, space separated list of codes -ECS_RETRY_CODES="" - -# Make curl retries towards the agent for http response codes set in this env var, space separated list of codes -AGENT_RETRY_CODES="" - -# Var to contol if the agent runs in a container (normal = 0) or as application on the local machine ( = 1) -AGENT_STAND_ALONE=0 +#Localhost constants +LOCALHOST_NAME="localhost" +LOCALHOST_HTTP="http://localhost" +LOCALHOST_HTTPS="https://localhost" # Var to hold 'auto' in case containers shall be stopped when test case ends AUTO_CLEAN="" -# Var to hold the app names to use local image for when running 'remote' or 'remote-remove' +# Var to hold the app names to use local images for USE_LOCAL_IMAGES="" -# List of available apps to override with local image -AVAILABLE_LOCAL_IMAGES_OVERRIDE="PA ECS CP SDNC RICSIM RC" +# Var to hold the app names to use remote snapshot images for +USE_SNAPSHOT_IMAGES="" + +# Var to hold the app names to use remote staging images for +USE_STAGING_IMAGES="" + +# Var to hold the app names to use remote release images for +USE_RELEASE_IMAGES="" + +# List of available apps to override with local or remote staging/snapshot/release image +AVAILABLE_IMAGES_OVERRIDE="PA ECS CP SDNC RICSIM RC" # Use this var (STOP_AT_ERROR=1 in the test script) for debugging/trouble shooting to take all logs and exit at first FAIL test case STOP_AT_ERROR=0 +# The default value "DEV" indicate that development image tags (SNAPSHOT) and nexus repos (nexus port 10002) are used. +# The value "RELEASE" indicate that relase image tag and nexus repos (nexus port) are used +# Applies only to images defined in the test-env files with image names and tags defined as XXXX_RELEASE +IMAGE_CATEGORY="DEV" + # Function to indent cmd output with one space indent1() { sed 's/^/ /'; } @@ -124,7 +151,6 @@ fi HTTPLOG=$PWD"/.httplog_"$ATC".txt" echo "" > $HTTPLOG - # Create a log dir for the test case mkdir -p $TESTLOGS/$ATC @@ -159,7 +185,6 @@ RES_DEVIATION=0 DEVIATION_FILE=".tmp_deviations" rm $DEVIATION_FILE &> /dev/null - # Trap "command not found" and make the script fail trap_fnc() { @@ -265,19 +290,49 @@ echo "----------------------------------- Test case setup ------------ START_ARG=$1 paramerror=0 +paramerror_str="" if [ $# -lt 1 ]; then paramerror=1 fi if [ $paramerror -eq 0 ]; then - if [ "$1" != "remote" ] && [ "$1" != "remote-remove" ] && [ "$1" != "local" ]; then + if [ "$1" != "remote" ] && [ "$1" != "remote-remove" ]; then + paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="First arg shall be 'remote' or 'remote-remove'" + fi + else + shift; + fi +fi +if [ $paramerror -eq 0 ]; then + if [ "$1" != "docker" ] && [ "$1" != "kube" ]; then paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="Second arg shall be 'docker' or 'kube'" + fi else + if [ $1 == "docker" ]; then + RUNMODE="DOCKER" + echo "Setting RUNMODE=DOCKER" + fi + if [ $1 == "kube" ]; then + RUNMODE="KUBE" + echo "Setting RUNMODE=KUBE" + fi shift; fi fi foundparm=0 while [ $paramerror -eq 0 ] && [ $foundparm -eq 0 ]; do foundparm=1 + if [ $paramerror -eq 0 ]; then + if [ "$1" == "release" ]; then + IMAGE_CATEGORY="RELEASE" + echo "Option set - Release image tags used for applicable images " + shift; + foundparm=0 + fi + fi if [ $paramerror -eq 0 ]; then if [ "$1" == "auto-clean" ]; then AUTO_CLEAN="auto" @@ -297,9 +352,12 @@ while [ $paramerror -eq 0 ] && [ $foundparm -eq 0 ]; do if [ $paramerror -eq 0 ]; then if [ "$1" == "--ricsim-prefix" ]; then shift; - RIC_SIM_PREFIX=$1 + TMP_RIC_SIM_PREFIX=$1 #RIC_SIM_PREFIX need to be updated after sourcing of the env file if [ -z "$1" ]; then paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="No prefix found for flag: '--ricsim-prefix'" + fi else echo "Option set - Overriding RIC_SIM_PREFIX with: "$1 shift; @@ -313,6 +371,9 @@ while [ $paramerror -eq 0 ] && [ $foundparm -eq 0 ]; do TEST_ENV_VAR_FILE=$1 if [ -z "$1" ]; then paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="No env file found for flag: '--env-file'" + fi else echo "Option set - Reading test env from: "$1 shift; @@ -326,16 +387,97 @@ while [ $paramerror -eq 0 ] && [ $foundparm -eq 0 ]; do shift while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do USE_LOCAL_IMAGES=$USE_LOCAL_IMAGES" "$1 - if [[ "$AVAILABLE_LOCAL_IMAGES_OVERRIDE" != *"$1"* ]]; then + if [[ "$AVAILABLE_IMAGES_OVERRIDE" != *"$1"* ]]; then paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="App name $1 is not available for local override for flag: '--use-local-image'" + fi fi shift; done foundparm=0 if [ -z "$USE_LOCAL_IMAGES" ]; then paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="No app name found for flag: '--use-local-image'" + fi + else + echo "Option set - Overriding with local images for app(s):"$USE_LOCAL_IMAGES + fi + fi + fi + if [ $paramerror -eq 0 ]; then + if [ "$1" == "--use-snapshot-image" ]; then + USE_SNAPSHOT_IMAGES="" + shift + while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do + USE_SNAPSHOT_IMAGES=$USE_SNAPSHOT_IMAGES" "$1 + if [[ "$AVAILABLE_IMAGES_OVERRIDE" != *"$1"* ]]; then + paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="App name $1 is not available for snapshot override for flag: '--use-snapshot-image'" + fi + fi + shift; + done + foundparm=0 + if [ -z "$USE_SNAPSHOT_IMAGES" ]; then + paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="No app name found for flag: '--use-snapshot-image'" + fi + else + echo "Option set - Overriding with snapshot images for app(s):"$USE_SNAPSHOT_IMAGES + fi + fi + fi + if [ $paramerror -eq 0 ]; then + if [ "$1" == "--use-staging-image" ]; then + USE_STAGING_IMAGES="" + shift + while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do + USE_STAGING_IMAGES=$USE_STAGING_IMAGES" "$1 + if [[ "$AVAILABLE_IMAGES_OVERRIDE" != *"$1"* ]]; then + paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="App name $1 is not available for staging override for flag: '--use-staging-image'" + fi + fi + shift; + done + foundparm=0 + if [ -z "$USE_STAGING_IMAGES" ]; then + paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="No app name found for flag: '--use-staging-image'" + fi + else + echo "Option set - Overriding with staging images for app(s):"$USE_STAGING_IMAGES + fi + fi + fi + if [ $paramerror -eq 0 ]; then + if [ "$1" == "--use-release-image" ]; then + USE_RELEASE_IMAGES="" + shift + while [ $# -gt 0 ] && [[ "$1" != "--"* ]]; do + USE_RELEASE_IMAGES=$USE_RELEASE_IMAGES" "$1 + if [[ "$AVAILABLE_IMAGES_OVERRIDE" != *"$1"* ]]; then + paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="App name $1 is not available for release override for flag: '--use-release-image'" + fi + fi + shift; + done + foundparm=0 + if [ -z "$USE_RELEASE_IMAGES" ]; then + paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="No app name found for flag: '--use-release-image'" + fi else - echo "Option set - Override remote images for app(s):"$USE_LOCAL_IMAGES + echo "Option set - Overriding with release images for app(s):"$USE_RELEASE_IMAGES fi fi fi @@ -345,10 +487,14 @@ echo "" #Still params left? if [ $paramerror -eq 0 ] && [ $# -gt 0 ]; then paramerror=1 + if [ -z "$paramerror_str" ]; then + paramerror_str="Unknown parameter(s): "$@ + fi fi if [ $paramerror -eq 1 ]; then - echo -e $RED"Expected arg: local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix ] [ --env-file ] [--use-local-image []*]"$ERED + echo -e $RED"Incorrect arg list: "$paramerror_str$ERED + __print_args exit 1 fi @@ -358,12 +504,18 @@ if [ -f "$TEST_ENV_VAR_FILE" ]; then . $TEST_ENV_VAR_FILE if [ -z "$TEST_ENV_PROFILE" ] || [ -z "$SUPPORTED_PROFILES" ]; then - echo -e $YELLOW"This test case may no work with selected test env file. TEST_ENV_PROFILE is missing in test_env file or SUPPORTED_PROFILES is missing in test case file"$EYELLOW + echo -e $YELLOW"This test case may not work with selected test env file. TEST_ENV_PROFILE is missing in test_env file or SUPPORTED_PROFILES is missing in test case file"$EYELLOW else - if [[ "$SUPPORTED_PROFILES" == *"$TEST_ENV_PROFILE"* ]]; then - echo -e $GREEN"Test case support the selected test env file"$EGREEN - else + found_profile=0 + for prof in $SUPPORTED_PROFILES; do + if [ "$TEST_ENV_PROFILE" == "$prof" ]; then + echo -e $GREEN"Test case supports the selected test env file"$EGREEN + found_profile=1 + fi + done + if [ $found_profile -ne 1 ]; then echo -e $RED"Test case does not support the selected test env file"$ERED + echo "Profile: "$TEST_ENV_PROFILE" Supported profiles: "$SUPPORTED_PROFILES echo -e $RED"Exiting...."$ERED exit 1 fi @@ -376,45 +528,56 @@ else exit 1 fi -#Vars for A1 interface version and container count -G1_A1_VERSION="" -G2_A1_VERSION="" -G3_A1_VERSION="" -G4_A1_VERSION="" -G5_A1_VERSION="" -G1_COUNT=0 -G2_COUNT=0 -G3_COUNT=0 -G4_COUNT=0 -G5_COUNT=0 - -# Vars to switch between http and https. Extra curl flag needed for https -export RIC_SIM_HTTPX="http" -export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:" -export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT -export RIC_SIM_CERT_MOUNT_DIR="./cert" - -export MR_HTTPX="http" -export MR_PORT=$MR_INTERNAL_PORT -export MR_LOCAL_PORT=$MR_EXTERNAL_PORT #When agent is running outside the docker net - -export CR_HTTPX="http" -export CR_PORT=$CR_INTERNAL_PORT -export CR_LOCAL_PORT=$CR_EXTERNAL_PORT #When CR is running outside the docker net -export CR_PATH="$CR_HTTPX://$CR_APP_NAME:$CR_PORT$CR_APP_CALLBACK" - -export PROD_STUB_HTTPX="http" -export PROD_STUB_PORT=$PROD_STUB_INTERNAL_PORT -export PROD_STUB_LOCAL_PORT=$PROD_STUB_EXTERNAL_PORT #When Prodstub is running outside the docker net -export PROD_STUB_LOCALHOST=$PROD_STUB_HTTPX"://localhost:"$PROD_STUB_LOCAL_PORT - -export SDNC_HTTPX="http" -export SDNC_PORT=$SDNC_INTERNAL_PORT -export SDNC_LOCAL_PORT=$SDNC_EXTERNAL_PORT #When agent is running outside the docker net - -export RAPP_CAT_HTTPX="http" -export RAPP_CAT_PORT=$RAPP_CAT_INTERNAL_PORT -export RAPP_CAT_LOCAL_PORT=$RAPP_CAT_EXTERNAL_PORT #When Rapp catalogue is running outside the docker net +#This var need be preserved from the command line option, if set, when env var is sourced. +if [ ! -z "$TMP_RIC_SIM_PREFIX" ]; then + RIC_SIM_PREFIX=$TMP_RIC_SIM_PREFIX +fi + +if [ -z "$PROJECT_IMAGES_APP_NAMES" ]; then + echo -e $RED"Var PROJECT_IMAGES_APP_NAMES must be defined in: "$TEST_ENV_VAR_FILE $ERED + exit 1 +fi + +if [[ $SUPPORTED_RUNMODES != *"$RUNMODE"* ]]; then + echo -e $RED"This test script does not support RUNMODE $RUNMODE"$ERED + echo "Supported RUNMODEs: "$SUPPORTED_RUNMODES + exit 1 +fi + +# Choose list of included apps depending on run-mode +if [ $RUNMODE == "KUBE" ]; then + INCLUDED_IMAGES=$KUBE_INCLUDED_IMAGES +else + INCLUDED_IMAGES=$DOCKER_INCLUDED_IMAGES +fi + +# Check needed installed sw +tmp=$(which python3) +if [ $? -ne 0 ] || [ -z tmp ]; then + echo -e $RED"python3 is required to run the test environment, pls install"$ERED + exit 1 +fi +tmp=$(which docker) +if [ $? -ne 0 ] || [ -z tmp ]; then + echo -e $RED"docker is required to run the test environment, pls install"$ERED + exit 1 +fi + +tmp=$(which docker-compose) +if [ $? -ne 0 ] || [ -z tmp ]; then + if [ $RUNMODE == "DOCKER" ]; then + echo -e $RED"docker-compose is required to run the test environment, pls install"$ERED + exit 1 + fi +fi + +tmp=$(which kubectl) +if [ $? -ne 0 ] || [ -z tmp ]; then + if [ $RUNMODE == "KUBE" ]; then + echo -e $RED"kubectl is required to run the test environment in kubernetes mode, pls install"$ERED + exit 1 + fi +fi echo -e $BOLD"Checking configured image setting for this test case"$EBOLD @@ -422,13 +585,13 @@ echo -e $BOLD"Checking configured image setting for this test case"$EBOLD IMAGE_ERR=0 #Create a file with image info for later printing as a table image_list_file="./tmp/.image-list" -echo -e " Container\tImage\ttag" > $image_list_file +echo -e " Container\tImage\ttag\ttag-switch" > $image_list_file # Check if image env var is set and if so export the env var with image to use (used by docker compose files) -# arg: