From: Rohan Patel Date: Thu, 31 Oct 2019 20:19:21 +0000 (-0400) Subject: added oran ric test head X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=it%2Fotf.git;a=commitdiff_plain;h=3d33edd3ef5f8ee668efdf5db6dd670a7b217f23 added oran ric test head Change-Id: I7a365e056118cc7500bb18791f7e09ac332294ba Signed-off-by: Rohan Patel --- diff --git a/oran-ric-test-head/Dockerfile b/oran-ric-test-head/Dockerfile new file mode 100644 index 0000000..86f740d --- /dev/null +++ b/oran-ric-test-head/Dockerfile @@ -0,0 +1,13 @@ +FROM python:2.7 + +RUN python --version + +ADD pip-requirements.txt pip-requirements.txt +ADD ric-test-head.py ric-test-head.py +ADD config.json config.json + +RUN mkdir -p /otf/logs + +RUN python -m pip install -r pip-requirements.txt + +ENTRYPOINT ["python", "ric-test-head.py"] diff --git a/oran-ric-test-head/Jenkinsfile b/oran-ric-test-head/Jenkinsfile new file mode 100644 index 0000000..f5defc2 --- /dev/null +++ b/oran-ric-test-head/Jenkinsfile @@ -0,0 +1,141 @@ +#!/usr/bin/env groovy + + +properties([[$class: 'ParametersDefinitionProperty', parameterDefinitions: [ + [$class: 'hudson.model.StringParameterDefinition', name: 'PHASE', defaultValue: "BUILD"], + [$class: 'hudson.model.StringParameterDefinition', name: 'ENV', defaultValue: "dev"], + [$class: 'hudson.model.StringParameterDefinition', name: 'MECHID', defaultValue: "m13591_otf_dev"], + [$class: 'hudson.model.StringParameterDefinition', name: 'KUBE_CONFIG', defaultValue: "kubeConfig-dev"], + [$class: 'hudson.model.StringParameterDefinition', name: 'TILLER_NAMESPACE', defaultValue: "com-att-ecomp-otf-dev"] +]]]) + + +echo "Build branch: ${env.BRANCH_NAME}" + +node("docker"){ + stage 'Checkout' + checkout scm + PHASES=PHASE.tokenize( '_' ); + echo "PHASES : " + PHASES + + + ARTIFACT_ID="ric-test-head"; + VERSION="Camile.2.0"; + NAMESPACE="com.att.ecomp.otf" + DOCKER_REGISTRY="dockercentral.it.att.com:5100" + + if( ENV.equalsIgnoreCase("dev") ){ + IMAGE_NAME=DOCKER_REGISTRY + "/" + NAMESPACE + ".dev" + "/" + ARTIFACT_ID + ":" + VERSION + + } + if( ENV.equalsIgnoreCase("prod") || ENV.equalsIgnoreCase("prod-dr")){ + IMAGE_NAME=DOCKER_REGISTRY + "/" + NAMESPACE + ".prod" + "/" + ARTIFACT_ID + ":" + VERSION + + } + + if( ENV.equalsIgnoreCase("st") ){ + IMAGE_NAME=DOCKER_REGISTRY + "/" + NAMESPACE + ".st" + "/" + ARTIFACT_ID + ":" + VERSION + + } + + echo "Artifact: " + IMAGE_NAME + + withEnv(["PATH=${env.PATH}:${env.WORKSPACE}/linux-amd64", "HELM_HOME=${env.WORKSPACE}"]) { + + echo "PATH=${env.PATH}" + echo "HELM_HOME=${env.HELM_HOME}" + + if (PHASES.contains("BUILD")){ + + stage 'Publish Artifact' + + withCredentials([usernamePassword(credentialsId: MECHID, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + + echo "Artifact: " + IMAGE_NAME + + sh """ + docker login $DOCKER_REGISTRY --username $USERNAME --password $PASSWORD + docker build -t $IMAGE_NAME . + docker push $IMAGE_NAME + """ + } + + } + + if (PHASES.contains("DEPLOY") || PHASES.contains("UNDEPLOY")) { + + stage 'Init Helm' + + //check if helm exists if not install + if(fileExists('linux-amd64/helm')){ + sh """ + echo "helm is already installed" + """ + } + else{ + //download helm + sh """ + echo "installing helm" + wget https://storage.googleapis.com/kubernetes-helm/helm-v2.14.3-linux-amd64.tar.gz + tar -xf helm-v2.14.3-linux-amd64.tar.gz + rm helm-v2.14.3-linux-amd64.tar.gz + """ + } + + withCredentials([file(credentialsId: KUBE_CONFIG, variable: 'KUBECONFIG')]) { + + dir('helm'){ + //check if charts are valid, and then perform dry run, if successful then upgrade/install charts + + if (PHASES.contains("UNDEPLOY") ) { + stage 'Undeploy' + + sh """ + helm delete --tiller-namespace=$TILLER_NAMESPACE --purge $ARTIFACT_ID + """ + } + + //NOTE Double quotes are used below to access groovy variables like artifact_id and tiller_namespace + if (PHASES.contains("DEPLOY") ){ + stage 'Deploy' + withCredentials([usernamePassword(credentialsId: MECHID, usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + + sh """ + echo "Validate Yaml" + helm lint $ARTIFACT_ID + + echo "View Helm Templates" + helm template $ARTIFACT_ID --set appName=$ARTIFACT_ID \ + --set appName=$ARTIFACT_ID \ + --set version=$VERSION \ + --set env=$ENV \ + --set image=$IMAGE_NAME \ + --set namespace=$TILLER_NAMESPACE + + echo "Perform Dry Run Of Install" + helm upgrade --tiller-namespace=$TILLER_NAMESPACE --install --dry-run $ARTIFACT_ID $ARTIFACT_ID \ + --set appName=$ARTIFACT_ID \ + --set version=$VERSION \ + --set env=$ENV \ + --set image=$IMAGE_NAME \ + --set namespace=$TILLER_NAMESPACE + + + echo "Helm Install/Upgrade" + helm upgrade --tiller-namespace=$TILLER_NAMESPACE --install $ARTIFACT_ID $ARTIFACT_ID \ + --set appName=$ARTIFACT_ID \ + --set version=$VERSION \ + --set env=$ENV \ + --set image=$IMAGE_NAME \ + --set namespace=$TILLER_NAMESPACE + + """ + } + } + + } + } + } + + } +} diff --git a/oran-ric-test-head/LICENSE.txt b/oran-ric-test-head/LICENSE.txt new file mode 100644 index 0000000..aa73a11 --- /dev/null +++ b/oran-ric-test-head/LICENSE.txt @@ -0,0 +1,28 @@ +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the "Software License"); +you may not use this software except in compliance with the Software +License. You may obtain a copy of the Software License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the Software License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the Software License for the specific language governing permissions +and limitations under the Software License. + + + +Unless otherwise specified, all documentation contained herein is licensed +under the Creative Commons License, Attribution 4.0 Intl. (the +"Documentation License"); you may not use this documentation except in +compliance with the Documentation License. You may obtain a copy of the +Documentation License at + +https://creativecommons.org/licenses/by/4.0/ + +Unless required by applicable law or agreed to in writing, documentation +distributed under the Documentation License is distributed on an "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied. See the Documentation License for the specific language governing +permissions and limitations under the Documentation License. \ No newline at end of file diff --git a/oran-ric-test-head/config.json b/oran-ric-test-head/config.json new file mode 100644 index 0000000..95e4359 --- /dev/null +++ b/oran-ric-test-head/config.json @@ -0,0 +1,10 @@ +{ + "base_address": "http://localhost:3000", + "actions_path": { + "alive": "/appmgr/ric/v1/health/alive", + "ready": "/appmgr/ric/v1/health/ready", + "list": "/appmgr/ric/v1/xapps", + "deploy": "/appmgr/ric/v1/xapps", + "delete": "/appmgr/ric/v1/xapps/" + } +} \ No newline at end of file diff --git a/oran-ric-test-head/helm/ric-test-head/.helmignore b/oran-ric-test-head/helm/ric-test-head/.helmignore new file mode 100644 index 0000000..daebc7d --- /dev/null +++ b/oran-ric-test-head/helm/ric-test-head/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/oran-ric-test-head/helm/ric-test-head/Chart.yaml b/oran-ric-test-head/helm/ric-test-head/Chart.yaml new file mode 100644 index 0000000..f26e1ae --- /dev/null +++ b/oran-ric-test-head/helm/ric-test-head/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for the Ping Server Virtual Test Head +name: oran-ric-test-head +version: 0.0.1 diff --git a/oran-ric-test-head/helm/ric-test-head/templates/deployment.yaml b/oran-ric-test-head/helm/ric-test-head/templates/deployment.yaml new file mode 100644 index 0000000..4c38c37 --- /dev/null +++ b/oran-ric-test-head/helm/ric-test-head/templates/deployment.yaml @@ -0,0 +1,113 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Values.appName}} + namespace: {{.Values.namespace}} + labels: + app: {{ .Values.appName}} + version: {{.Values.version}} +spec: + revisionHistoryLimit: 1 + minReadySeconds: 10 + strategy: + # indicate which strategy we want for rolling update + type: RollingUpdate + rollingUpdate: + maxSurge: 0 + maxUnavailable: 1 + replicas: {{ .Values.replicas}} + selector: + matchLabels: + app: {{ .Values.appName}} + version: {{.Values.version}} + template: + metadata: + labels: + app: {{ .Values.appName}} + version: {{.Values.version}} + spec: + serviceAccount: default + volumes: + - name: {{ .Values.appName}}-cert-volume + secret: + secretName: {{.Values.sharedCert}} + optional: true + items: + - key: PEM_CERT + path: otf.pem + - key: PEM_KEY + path: privateKey.pem + {{ if or (eq .Values.env "st") (eq .Values.env "prod-dr")}} + {{else}} + - name: logging-pvc + persistentVolumeClaim: + {{if eq .Values.env "prod"}} + claimName: {{ .Values.pvc.prod | quote }} + {{ else }} + claimName: {{ .Values.pvc.dev | quote }} + {{ end }} + {{end}} + containers: + - name: {{ .Values.appName}} + image: {{ .Values.image}} + imagePullPolicy: Always + ports: + - name: http + containerPort: 5000 + nodePort: {{.Values.nodePort}} + protocol: TCP + {{ if eq .Values.env "st"}} + resources: + limits: + memory: "512Mi" + cpu: "500m" + requests: + memory: "256Mi" + cpu: "100m" + {{else}} + resources: + limits: + memory: "1Gi" + cpu: "1" + requests: + memory: "1Gi" + cpu: "1" + {{end}} + env: + - name: NAMESPACE + value: {{.Values.namespace}} + - name: APP_NAME + value: {{ .Values.appName}} + - name: APP_VERSION + value: {{.Values.version}} + volumeMounts: + - name: {{.Values.appName}}-cert-volume + mountPath: /opt/cert + {{ if or (eq .Values.env "st") (eq .Values.env "prod-dr")}} + {{else}} + - name: logging-pvc + mountPath: "/otf/logs" + {{end}} + livenessProbe: + httpGet: + path: {{.Values.health}} + port: http + scheme: HTTP + httpHeaders: + - name: X-Custom-Header + value: Alive + initialDelaySeconds: 30 + timeoutSeconds: 30 + periodSeconds: 30 + readinessProbe: + httpGet: + path: {{.Values.health}} + port: http + scheme: HTTP + httpHeaders: + - name: X-Custom-Header + value: Ready + initialDelaySeconds: 30 + timeoutSeconds: 30 + periodSeconds: 30 + restartPolicy: Always diff --git a/oran-ric-test-head/helm/ric-test-head/templates/service.yaml b/oran-ric-test-head/helm/ric-test-head/templates/service.yaml new file mode 100644 index 0000000..f3bcfab --- /dev/null +++ b/oran-ric-test-head/helm/ric-test-head/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.appName }} + namespace: {{ .Values.namespace}} + labels: + app: {{ .Values.appName }} + version: {{ .Values.version}} +spec: + type: NodePort + ports: + - name: http + port: 5000 + protocol: TCP + nodePort: {{ .Values.nodePort}} + selector: + app: {{ .Values.appName }} + version: {{ .Values.version}} diff --git a/oran-ric-test-head/helm/ric-test-head/values.yaml b/oran-ric-test-head/helm/ric-test-head/values.yaml new file mode 100644 index 0000000..6c5d067 --- /dev/null +++ b/oran-ric-test-head/helm/ric-test-head/values.yaml @@ -0,0 +1,12 @@ +appName: ric-test-head +env: dev +version: 0.0.1-SNAPSHOT +image: ric-test-head:0.0.1-SNAPSHOT +namespace: org-oran-otf +nodePort: 32323 +replicas: 1 +health : /otf/vth/oran/v1/health +sharedCert: otf-cert-secret-builder +pvc: + dev: org-oran-otf-dev-logs-pv + prod: org-oran-otf-prod-logs-pv diff --git a/oran-ric-test-head/mock_server/index.js b/oran-ric-test-head/mock_server/index.js new file mode 100644 index 0000000..255591a --- /dev/null +++ b/oran-ric-test-head/mock_server/index.js @@ -0,0 +1,31 @@ +const express = require('express') +const app = express() +const port = 3000 + +app.get('/', (req, res) => res.send('Hello World!')) + +app.get('/appmgr/ric/v1/health/ready',function(req,res){ + res.sendStatus(200) +}) + +app.get('/appmgr/ric/v1/health/alive',function(req,res){ + res.sendStatus(200) +}) + +app.get('/appmgr/ric/v1/xapps',function(req,res){ + res.status(200) + res.send([{"name":"admin-xapp","status":"deployed","version":"1.0","instances":null},{"name":"mcxapp","status":"deployed","version":"1.0","instances":[{"name":"mcxapp-649d7494-h5tjb","status":"running","ip":"service-ricxapp-mcxapp-rmr.ricxapp","port":4560,"txMessages":null,"rxMessages":["RIC_SUB_RESP","RIC_SUB_FAILURE","RIC_SUB_DEL_RESP","RIC_SUB_DEL_FAILURE","RIC_INDICATION"]}]},{"name":"ueec","status":"deployed","version":"1.0","instances":[{"name":"ueec-6675694b75-jtnz6","status":"running","ip":"service-ricxapp-ueec-rmr.ricxapp","port":4560,"txMessages":["RIC_SUB_REQ","RIC_SUB_DEL_REQ"],"rxMessages":["RIC_SUB_RESP","RIC_SUB_FAILURE","RIC_SUB_DEL_RESP","RIC_SUB_DEL_FAILURE","RIC_INDICATION"]}]}]) +}) + +app.post('/appmgr/ric/v1/xapps', function(req,res){ + res.statusMessage = 'Created' + res.status(201) + res.send({"result_output":{"name":"anr","status":"deployed","version":"1.0","instances":[{"name":"anr-7d4c47b4bb-jlslm","status":"running","ip":"service-ricxapp-anr-rmr.ricxapp","port":4560,"txMessages":null,"rxMessages":["RIC_SGNB_ADDITION_REQ","RIC_RRC_TRANSFER"]}]}}) +}) + +app.delete('/appmgr/ric/v1/xapps/:name',function(req,res){ + res.sendStatus(204) +}) + +app.listen(port, () => console.log(`Example app listening on port ${port}!`)) + diff --git a/oran-ric-test-head/mock_server/package.json b/oran-ric-test-head/mock_server/package.json new file mode 100644 index 0000000..f699513 --- /dev/null +++ b/oran-ric-test-head/mock_server/package.json @@ -0,0 +1,14 @@ +{ + "name": "mock_server", + "version": "1.0.0", + "description": "mock server for RIC", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "express": "^4.17.1" + } +} diff --git a/oran-ric-test-head/opt/cert/certInfo.txt b/oran-ric-test-head/opt/cert/certInfo.txt new file mode 100644 index 0000000..0799b0b --- /dev/null +++ b/oran-ric-test-head/opt/cert/certInfo.txt @@ -0,0 +1 @@ +add certs here. requires two pem files (Cert and key) diff --git a/oran-ric-test-head/pip-requirements.txt b/oran-ric-test-head/pip-requirements.txt new file mode 100644 index 0000000..4fbe8e7 --- /dev/null +++ b/oran-ric-test-head/pip-requirements.txt @@ -0,0 +1,6 @@ +flask +flask-cors +paramiko +FLASK +FLASK-CORS +requests diff --git a/oran-ric-test-head/ric-test-head.py b/oran-ric-test-head/ric-test-head.py new file mode 100644 index 0000000..f80d3d3 --- /dev/null +++ b/oran-ric-test-head/ric-test-head.py @@ -0,0 +1,117 @@ +# Copyright (c) 2019 AT&T Intellectual Property. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +import datetime +import json +import logging +from logging import FileHandler + +import requests +from flask import Flask, request, jsonify + +#redirect http to https +app = Flask(__name__) + + +# Prevents print statement every time an endpoint is triggered. +logging.getLogger("werkzeug").setLevel(logging.WARNING) + +def unix_time_millis(dt): + epoch = datetime.datetime.utcfromtimestamp(0) + return (dt - epoch).total_seconds() * 1000.0 + + +@app.route("/otf/vth/oran/v1/health", methods=['GET']) +def getHealth(): + return "UP" + +@app.route("/otf/vth/oran/ric/v1", methods =['POST']) +def executeRicRequest(): + + responseData = { + 'vthResponse': { + 'testDuration': '', + 'dateTimeUTC': datetime.datetime.now(), + 'abstractMessage': '', + 'resultData': {} + } + } + + startTime = unix_time_millis(datetime.datetime.now()) + + try: + if not request.is_json: + raise ValueError("request must be json") + + requestData = request.get_json() + + app.logger.info("Ric requestData:"+str(requestData)) + + action = requestData['action'].lower() + possibleActions = ['alive','ready','list', 'deploy','delete'] + responseData['vthResponse']['abstractMessage'] = 'Result from {}'.format(action) + + if action not in possibleActions: + raise KeyError("invalid action") + if (action == 'deploy' or action == 'delete') and 'name' not in requestData: + raise KeyError("must include name") + + with open('config.json') as configFile: + config = json.load(configFile) + + baseAddress= config['base_address'] + + if action == 'alive' or action == 'ready': + res = requests.get(baseAddress+config['actions_path'][action]) + responseData['vthResponse']['resultData']['statusCode'] = res.status_code + responseData['vthResponse']['resultData']['resultOutput'] = res.text + elif action == 'list': + res = requests.get(baseAddress+config['actions_path'][action]) + responseData['vthResponse']['resultData']['statusCode'] = res.status_code + responseData['vthResponse']['resultData']['resultOutput'] = res.json() + elif action == 'deploy': + payload = {'name': requestData['name']} + res = requests.post(baseAddress+config['actions_path'][action], data=payload) + responseData['vthResponse']['resultData']['statusCode'] = res.status_code + responseData['vthResponse']['resultData']['resultOutput'] = res.json() + elif action == 'delete': + path= baseAddress+config['actions_path'][action]+"{}".format(requestData['name']) + res = requests.delete(path) + responseData['vthResponse']['resultData']['resultOutput'] = res.text + responseData['vthResponse']['resultData']['statusCode'] = res.status_code + + except Exception as ex: + endTime = unix_time_millis(datetime.datetime.now()) + totalTime = endTime - startTime + responseData['vthResponse']['testDuration'] = totalTime + responseData['vthResponse']['abstractMessage'] = str(ex) + return jsonify(responseData) + + endTime = unix_time_millis(datetime.datetime.now()) + totalTime= endTime-startTime + + responseData['vthResponse']['testDuration'] = totalTime + + return jsonify(responseData),200 + +if __name__ == '__main__': + # logHandler = FileHandler('otf/logs/pingVTH.log', mode='a') + logHandler = FileHandler('ricVTH.log', mode='a') + logHandler.setLevel(logging.INFO) + app.logger.setLevel(logging.INFO) + app.logger.addHandler(logHandler) + # context = ('opt/cert/otf.pem', 'opt/cert/privateKey.pem') + # app.run(debug = False, host = '0.0.0.0', port = 5000, ssl_context = context) + app.run(debug = False, host = '0.0.0.0', port = 5000) diff --git a/oran-ric-test-head/workflows/Deploy_xAPP_Test.bpmn b/oran-ric-test-head/workflows/Deploy_xAPP_Test.bpmn new file mode 100644 index 0000000..bf2b3d9 --- /dev/null +++ b/oran-ric-test-head/workflows/Deploy_xAPP_Test.bpmn @@ -0,0 +1,463 @@ + + + + + SequenceFlow_0st7o3p + + + + + + ${ready} + + + + + + + + + + + + + ${deployed} + + + + ${validInput} + + + + ${!alreadyDeployed} + + + + + SequenceFlow_0j9397y + SequenceFlow_0e1kt1e + var System = java.lang.System + +var readyVthId = 'ready' +var testData = execution.getVariable("testData") +var vthInput = execution.getVariable("vthInput") +var ready = false; +var testResultMessage = "RIC VTH reported that xAppManager is not ready." + + + +try { + //get output from ready call + var testExecution = execution.getVariable('otf-execution-testExecution'); + var data = null; + testExecution.testHeadResults.forEach(function(item, index, array) { + if(item.bpmnVthTaskId == readyVthId ){ + data = item['testHeadResponse']['vthResponse']['resultData']['statusCode']; + } + }) + + if(data === 200){ + ready = true + testResultMessage = "RIC VTH reported that xAppManager is ready." + } + +} +catch(err) { + ready = false +} + +execution.setVariable("ready", ready); +execution.setVariable("testResultMessage", testResultMessage); + + + SequenceFlow_1chkfad + SequenceFlow_0nfij3v + SequenceFlow_0g7zkcv + SequenceFlow_0dscvt7 + SequenceFlow_1u9jrl1 + execution.setVariable("testResult", "FAILED") + + + SequenceFlow_08hkwrc + SequenceFlow_18bpwal + execution.setVariable("testResult", "SUCCESS") + + + SequenceFlow_07jnolr + SequenceFlow_08wazou + var System = java.lang.System + +var deploy = 'deploy' +var secondList = 'second_list' +var testData = execution.getVariable("testData") +var vthInput = execution.getVariable("vthInput") +var deployed = false; +var testResultMessage = "RIC VTH reported that xApp is not deployed." +var appName = testData['appName'] + + + +try { + //get output from deploy call + var testExecution = execution.getVariable('otf-execution-testExecution'); + data = null; + testExecution.testHeadResults.forEach(function(item, index, array) { + if(item.bpmnVthTaskId == deploy ){ + data = item['testHeadResponse']['vthResponse']['resultData']['statusCode']; + } + }) + + if(data === 201){ + testResultMessage = "RIC VTH reported that xAppManager deployment call succeeded." + + //get output from secondList call + var testExecution = execution.getVariable('otf-execution-testExecution'); + data = null; + testExecution.testHeadResults.forEach(function(item, index, array) { + if(item.bpmnVthTaskId == secondList ){ + data = item['testHeadResponse']['vthResponse']['resultData']['resultOutput']; + } + }) + + instance = null + data.forEach(function(item, index, array) { + if(item.name === appName){ + instance = item + testResultMessage = "RIC VTH reported that xApp is present." + } + }) + + if(instance !== null && instance.status === 'deployed'){ + deployed = true + testResultMessage = "RIC VTH reported that xApp is deployed." + testDetails = execution.getVariable("testDetails") + testDetails.put("instance", instance); + execution.setVariable("testDetails", testDetails) + } + else{ + deployed = false + testResultMessage = "RIC VTH reported that xApp was deployed, but xApp instance was either null or not deployed. See vth results for further information." + } + + } + +} +catch(err) { + deployed = false + testResultMessage = "Couldn't verify is xApp was deployed. Check Test Results" + err +} + +execution.setVariable("deployed", deployed); +execution.setVariable("testResultMessage", testResultMessage); + + + SequenceFlow_0st7o3p + SequenceFlow_18luk66 + var System = java.lang.System + +var deployVthId = 'deploy' +var testData = execution.getVariable("testData") +var vthInput = execution.getVariable("vthInput") +var validInput = false; +var testResultMessage = ""; + +try{ + + var appName = testData['appName']; + var waitDurationSec = testData['waitDurationSec']; + + if(typeof appName !== 'string' || appName.trim() === ''){ + System.out.println("appName is not a string, or empty string") + throw Error("appName is not a string, or empty string") + } + + if(typeof waitDurationSec !== 'number' || waitDurationSec < 0){ + System.out.println("not a number") + throw Error("waitDurationSec is not a number greater than 0") + } + + validInput = true + + vthInput[deployVthId].name = appName + var timer = "PT" + waitDurationSec + "S" + System.out.println("timer " + timer) + execution.setVariable("timer", timer) +} +catch(err){ + System.out.println(err) + validInput = false + testResultMessage = "Invalid input params. error: " + err; + execution.setVariable("testResult", "FAILED"); +} + +execution.setVariable("validInput", validInput) +execution.setVariable("testResultMessage", testResultMessage) + + + SequenceFlow_0s6ntyv + SequenceFlow_0i3et2n + var System = java.lang.System + +var firstList = 'first_list' +var testData = execution.getVariable("testData") +var vthInput = execution.getVariable("vthInput") +var alreadyDeployed = true; +var testResultMessage = "RIC VTH reported that xApp is already deployed." +var appName = testData['appName'] + + + +try { + //get output from firstList call + var testExecution = execution.getVariable('otf-execution-testExecution'); + var data = null; + testExecution.testHeadResults.forEach(function(item, index, array) { + if(item.bpmnVthTaskId == firstList ){ + data = item['testHeadResponse']['vthResponse']['resultData']['resultOutput']; + } + }) + + var instance = null + data.forEach(function(item, index, array) { + if(item.name === appName){ + instance = item + testResultMessage = "RIC VTH reported that xApp is already present." + } + }) + + if(instance === null){ + alreadyDeployed = false + testResultMessage = "RIC VTH reported that xApp is not present." + } + + +} +catch(err) { + alreadyDeployed = true + testResultMessage = "Couldn't verify is xApp was already deployed." +} + +execution.setVariable("alreadyDeployed", alreadyDeployed); +execution.setVariable("testResultMessage", testResultMessage); + + + SequenceFlow_0e1kt1e + SequenceFlow_0zxo4fr + SequenceFlow_1chkfad + + + SequenceFlow_08wazou + SequenceFlow_0nfij3v + SequenceFlow_08hkwrc + + + SequenceFlow_18luk66 + SequenceFlow_1y69zdb + SequenceFlow_0g7zkcv + + + SequenceFlow_0i3et2n + SequenceFlow_08v4jva + SequenceFlow_0dscvt7 + + + SequenceFlow_1oze54u + SequenceFlow_07rma3l + + ${timer} + + + + SequenceFlow_01cc25d + + + + SequenceFlow_1y69zdb + SequenceFlow_0j9397y + + + SequenceFlow_0zxo4fr + SequenceFlow_0s6ntyv + + + SequenceFlow_08v4jva + SequenceFlow_1oze54u + + + SequenceFlow_07rma3l + SequenceFlow_07jnolr + + + SequenceFlow_18bpwal + SequenceFlow_1u9jrl1 + SequenceFlow_01cc25d + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +