From bf6e70d18914f4d6ac798c90a6918d3c47593b51 Mon Sep 17 00:00:00 2001 From: RehanRaza Date: Thu, 18 Feb 2021 15:00:12 +0100 Subject: [PATCH] Add script to populate enrichment data for E2E testing of nonrtric Change-Id: Ia248a317b045ef668a6149664e5f324526fa376e Issue-ID: NONRTRIC-445 Signed-off-by: RehanRaza --- nonrtric/RECIPE_EXAMPLE/example_recipe.yaml | 4 +- nonrtric/data/prepare_data.sh | 9 ++- .../data/run_in_k8s/populate_enrichment_data.sh | 82 ++++++++++++++++++++++ .../{populate_data.sh => populate_policy_data.sh} | 0 nonrtric/data/run_in_k8s/testdata/ECS/EiJob.json | 11 +++ .../data/run_in_k8s/testdata/ECS/EiProducer.json | 5 ++ nonrtric/data/run_in_k8s/testdata/ECS/EiType.json | 8 +++ nonrtric/helm/enrichmentservice/values.yaml | 4 +- 8 files changed, 116 insertions(+), 7 deletions(-) create mode 100755 nonrtric/data/run_in_k8s/populate_enrichment_data.sh rename nonrtric/data/run_in_k8s/{populate_data.sh => populate_policy_data.sh} (100%) create mode 100644 nonrtric/data/run_in_k8s/testdata/ECS/EiJob.json create mode 100644 nonrtric/data/run_in_k8s/testdata/ECS/EiProducer.json create mode 100644 nonrtric/data/run_in_k8s/testdata/ECS/EiType.json diff --git a/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml b/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml index fc81dfa0..73908b9d 100644 --- a/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml +++ b/nonrtric/RECIPE_EXAMPLE/example_recipe.yaml @@ -134,9 +134,9 @@ enrichmentservice: enrichmentservice: imagePullPolicy: IfNotPresent image: - registry: 'nexus3.o-ran-sc.org:10002/o-ran-sc' + registry: 'nexus3.o-ran-sc.org:10004/o-ran-sc' name: 'nonrtric-enrichment-coordinator-service' - tag: 1.0.0 + tag: 1.1.1 service: allowHttp: true httpName: http diff --git a/nonrtric/data/prepare_data.sh b/nonrtric/data/prepare_data.sh index e1b6a572..d605efb7 100755 --- a/nonrtric/data/prepare_data.sh +++ b/nonrtric/data/prepare_data.sh @@ -19,13 +19,16 @@ # This script is populating some data into nonrtric for demo/test purpose. # First this script copies data/ folder into one of the rics, in below case a1-sim-osc-0. -# Then from the ric, run populate_data.sh. -# populate_data.sh creats policy type/ service/ polocies. +# Then from the ric, run populate_policy_data.sh and populate_enrichment_data.sh. +# populate_policy_data.sh creates policy-types, service, and policies. +# populate_enrichment_data.sh creates EiProducer, EiType, and EiJob. # # Why we run the scripts in the ric, not from the host? # Because a1-simulators(ric) are deployed in statefulset, # they are not exposed to outside the k8s cluster. # And we must create policy type into the ric first. +# Similarly, the enrichmentservice is not exposed outside the k8s cluster, +# hence the commands for populating enrichment data need to be run from within the cluster. kubectl -n nonrtric cp run_in_k8s a1-sim-osc-0:/usr/src/app/ -kubectl -n nonrtric exec -it a1-sim-osc-0 -- bash -c 'cd run_in_k8s/ && ./populate_data.sh' \ No newline at end of file +kubectl -n nonrtric exec -it a1-sim-osc-0 -- bash -c 'cd run_in_k8s/ && ./populate_policy_data.sh && ./populate_enrichment_data.sh' \ No newline at end of file diff --git a/nonrtric/data/run_in_k8s/populate_enrichment_data.sh b/nonrtric/data/run_in_k8s/populate_enrichment_data.sh new file mode 100755 index 00000000..fe6a3f8f --- /dev/null +++ b/nonrtric/data/run_in_k8s/populate_enrichment_data.sh @@ -0,0 +1,82 @@ +#!/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================================================= +# + +# This script will generate some dummy enrichment data in the running system. +# It will create: +# one EiProducer in ECS +# one EiType in ECS +# one EiJob in ECS + +ecs_host="enrichmentservice" +ecs_port="9082" +httpx=http + +echo "ECS status:" +curl -skw " %{http_code}" $httpx://$ecs_host:$ecs_port/status +echo -e "\n" + +# Create EiType +echo "Create EiType:" +curl -X PUT -skw %{http_code} $httpx://$ecs_host:$ecs_port/ei-producer/v1/eitypes/type1 -H accept:application/json -H Content-Type:application/json --data-binary @testdata/ECS/EiType.json +echo -e "\n" + +# Get EiTypes +echo "Get EiTypes:" +curl -X GET -skw %{http_code} $httpx://$ecs_host:$ecs_port/ei-producer/v1/eitypes -H Content-Type:application/json +echo -e "\n" + +# Get Individual EiType +echo "Get Individual EiType:" +curl -X GET -skw %{http_code} $httpx://$ecs_host:$ecs_port/ei-producer/v1/eitypes/type1 -H Content-Type:application/json +echo -e "\n" + +# Create EiProducer +echo "Create EiProducer:" +curl -X PUT -skw %{http_code} $httpx://$ecs_host:$ecs_port/ei-producer/v1/eiproducers/1 -H Content-Type:application/json --data-binary @testdata/ECS/EiProducer.json +echo -e "\n" + +# Get EiProducers +echo "Get EiProducers:" +curl -X GET -skw %{http_code} $httpx://$ecs_host:$ecs_port/ei-producer/v1/eiproducers -H Content-Type:application/json +echo -e "\n" + +# Get Individual EiProducer +echo "Get Individual EiProducer:" +curl -X GET -skw %{http_code} $httpx://$ecs_host:$ecs_port/ei-producer/v1/eiproducers/1 -H Content-Type:application/json +echo -e "\n" + +# Get Individual EiProducer Status +echo "Get Individual EiProducer:" +curl -X GET -skw %{http_code} $httpx://$ecs_host:$ecs_port/ei-producer/v1/eiproducers/1/status -H Content-Type:application/json +echo -e "\n" + +# Create EiJob +echo "Create EiJob Of A Certain Type type1:" +curl -X PUT -skw %{http_code} $httpx://$ecs_host:$ecs_port/A1-EI/v1/eijobs/job1 -H Content-Type:application/json --data-binary @testdata/ECS/EiJob.json +echo -e "\n" + +# Get EiJobs +echo "Get EiJobs:" +curl -X GET -skw %{http_code} $httpx://$ecs_host:$ecs_port/A1-EI/v1/eijobs -H Content-Type:application/json +echo -e "\n" + +# Get Individual EiJob: +echo "Get Individual EiJob:" +curl -X GET -skw %{http_code} $httpx://$ecs_host:$ecs_port/A1-EI/v1/eijobs/job1 -H Content-Type:application/json +echo -e "\n" \ No newline at end of file diff --git a/nonrtric/data/run_in_k8s/populate_data.sh b/nonrtric/data/run_in_k8s/populate_policy_data.sh similarity index 100% rename from nonrtric/data/run_in_k8s/populate_data.sh rename to nonrtric/data/run_in_k8s/populate_policy_data.sh diff --git a/nonrtric/data/run_in_k8s/testdata/ECS/EiJob.json b/nonrtric/data/run_in_k8s/testdata/ECS/EiJob.json new file mode 100644 index 00000000..003c70f9 --- /dev/null +++ b/nonrtric/data/run_in_k8s/testdata/ECS/EiJob.json @@ -0,0 +1,11 @@ +{ + "eiTypeId": "type1", + "jobResultUri": "https://ricsim_g3_1:8185/datadelivery", + "jobOwner": "ricsim_g3_1", + "jobStatusNotificationUri": "http://producer:80/", + "jobDefinition": { + "jobparam1": "value1_job1", + "jobparam2": "value2_job1", + "jobparam3": "value3_job1" + } +} \ No newline at end of file diff --git a/nonrtric/data/run_in_k8s/testdata/ECS/EiProducer.json b/nonrtric/data/run_in_k8s/testdata/ECS/EiProducer.json new file mode 100644 index 00000000..01d8eb5a --- /dev/null +++ b/nonrtric/data/run_in_k8s/testdata/ECS/EiProducer.json @@ -0,0 +1,5 @@ +{ + "supported_ei_types":["type1"], + "ei_job_callback_url": "https://producer-stub:8093/callbacks/job/prod-a", + "ei_producer_supervision_callback_url": "https://producer-stub:8093/callbacks/supervision/prod-a" +} \ No newline at end of file diff --git a/nonrtric/data/run_in_k8s/testdata/ECS/EiType.json b/nonrtric/data/run_in_k8s/testdata/ECS/EiType.json new file mode 100644 index 00000000..073f0b4f --- /dev/null +++ b/nonrtric/data/run_in_k8s/testdata/ECS/EiType.json @@ -0,0 +1,8 @@ +{ + "ei_job_data_schema":{ + "$schema":"http://json-schema.org/draft-07/schema#", + "title":"STD_Type1_1.0.0", + "description":"EI-Type 1", + "type":"object" + } + } \ No newline at end of file diff --git a/nonrtric/helm/enrichmentservice/values.yaml b/nonrtric/helm/enrichmentservice/values.yaml index 7e1ed199..b8a504ab 100644 --- a/nonrtric/helm/enrichmentservice/values.yaml +++ b/nonrtric/helm/enrichmentservice/values.yaml @@ -21,9 +21,9 @@ enrichmentservice: imagePullPolicy: IfNotPresent image: - registry: 'nexus3.o-ran-sc.org:10002/o-ran-sc' + registry: 'nexus3.o-ran-sc.org:10004/o-ran-sc' name: 'nonrtric-enrichment-coordinator-service' - tag: 1.0.0 + tag: 1.1.1 service: allowHttp: true httpName: http -- 2.16.6