From 1f339f886d01c6d6ac5cfd6467850c61fee4f675 Mon Sep 17 00:00:00 2001 From: "adheli.tavares" Date: Fri, 17 Feb 2023 15:14:07 +0000 Subject: Restructure of csit files to be used both by docker and k8s config Issue-ID: POLICY-4125 Change-Id: Id63b3badb1b451b36e3226970dcafaa5a62d860f Signed-off-by: adheli.tavares --- csit/resources/scripts/get-cluster-info.sh | 112 +++++++++++++++++++++ csit/resources/scripts/node-templates.sh | 49 +++++++++ csit/resources/scripts/prepare-robot-env.sh | 54 ++++++++++ csit/resources/scripts/pylibs.txt | 26 +++++ csit/resources/scripts/run-test.sh | 45 +++++++++ csit/resources/scripts/setup-apex-pdp.sh | 33 ++++++ csit/resources/scripts/setup-api.sh | 34 +++++++ csit/resources/scripts/setup-clamp.sh | 31 ++++++ csit/resources/scripts/setup-distribution.sh | 43 ++++++++ .../resources/scripts/setup-drools-applications.sh | 39 +++++++ csit/resources/scripts/setup-drools-pdp.sh | 34 +++++++ csit/resources/scripts/setup-pap.sh | 36 +++++++ csit/resources/scripts/setup-xacml-pdp.sh | 35 +++++++ csit/resources/scripts/wait_for_rest.sh | 77 ++++++++++++++ 14 files changed, 648 insertions(+) create mode 100644 csit/resources/scripts/get-cluster-info.sh create mode 100755 csit/resources/scripts/node-templates.sh create mode 100755 csit/resources/scripts/prepare-robot-env.sh create mode 100644 csit/resources/scripts/pylibs.txt create mode 100755 csit/resources/scripts/run-test.sh create mode 100755 csit/resources/scripts/setup-apex-pdp.sh create mode 100755 csit/resources/scripts/setup-api.sh create mode 100755 csit/resources/scripts/setup-clamp.sh create mode 100755 csit/resources/scripts/setup-distribution.sh create mode 100755 csit/resources/scripts/setup-drools-applications.sh create mode 100755 csit/resources/scripts/setup-drools-pdp.sh create mode 100755 csit/resources/scripts/setup-pap.sh create mode 100755 csit/resources/scripts/setup-xacml-pdp.sh create mode 100755 csit/resources/scripts/wait_for_rest.sh (limited to 'csit/resources/scripts') diff --git a/csit/resources/scripts/get-cluster-info.sh b/csit/resources/scripts/get-cluster-info.sh new file mode 100644 index 00000000..efe0f517 --- /dev/null +++ b/csit/resources/scripts/get-cluster-info.sh @@ -0,0 +1,112 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2023 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +# This script will be used to gather cluster information +# for JMeter to work towards the installed cluster + +# EXPLICITLY ASSIGN PORTS FOR TESTING PURPOSES +export APEX_PORT=30001 +export API_PORT=30002 +export PAP_PORT=30003 +export XACML_PORT=30004 +export DROOLS_PORT=30005 +export DIST_PORT=30006 +export ACM_PORT=30007 +export POLICY_PARTICIPANT_PORT=30008 +export DMAAP_PORT=30904 + +# Retrieve pod names +function get_pod_names() { + export APEX_POD=$(get_pod_name apex) + export PAP_POD=$(get_pod_name pap) + export API_POD=$(get_pod_name api) + export DMAAP_POD=$(get_pod_name message-router) + export XACML_POD=$(get_pod_name xacml) + export DROOLS_POD=$(get_pod_name drools-pdp) + export DIST_POD=$(get_pod_name distribution) + export ACM_POD=$(get_pod_name acm-runtime) + export POLICY_PPNT_POD=$(get_pod_name policy-ppnt) +} + +# Retrieve service names +function get_svc_names() { + export APEX_SVC=$(get_svc_name policy-apex) + export PAP_SVC=$(get_svc_name policy-pap) + export API_SVC=$(get_svc_name policy-api) + export DMAAP_SVC=$(get_svc_name message-router) + export DROOLS_SVC=$(get_svc_name drools-pdp) + export XACML_SVC=$(get_svc_name xacml) + export DIST_SVC=$(get_svc_name distribution) + export ACM_SVC=$(get_svc_name acm-runtime) + export POLICY_PPNT_SVC=$(get_svc_name policy-ppnt) +} + +# Expose services in order to perform tests from JMeter +function expose_services() { + expose_service $APEX_SVC + expose_service $PAP_SVC + expose_service $API_SVC + expose_service $XACML_SVC + expose_service $DROOLS_SVC + expose_service $DIST_SVC + expose_service $ACM_SVC + export_service $POLICY_PPNT_SVC + + setup_message_router_svc + sleep 2 + patch_ports +} + +function get_pod_name() { + microk8s kubectl get pods --no-headers -o custom-columns=':metadata.name' | grep $1 +} + +function get_svc_name() { + microk8s kubectl get svc --no-headers -o custom-columns=':metadata.name' | grep $1 +} + +function expose_service() { + microk8s kubectl expose service $1 --name $1"-svc" --type NodePort --protocol TCP --port 6969 --target-port 6969 +} + +function patch_port() { + microk8s kubectl patch service "$1-svc" --namespace=default --type='json' --patch='[{"op": "replace", "path": "/spec/ports/0/nodePort", "value":'"$2"'}]' +} + +# Assign set port values +function patch_ports() { + patch_port "$APEX_SVC" $APEX_PORT + patch_port "$API_SVC" $API_PORT + patch_port "$PAP_SVC" $PAP_PORT + patch_port "$ACM_SVC" $ACM_PORT + patch_port "$POLICY_PPNT_SVC" $POLICY_PARTICIPANT_PORT + patch_port "$DIST_SVC" $DIST_PORT + patch_port "$DROOLS_SVC" $DROOLS_PORT + patch_port "$XACML_SVC" $XACML_PORT +} + +function setup_message_router_svc() { + microk8s kubectl expose service message-router --name message-router-svc --type NodePort --protocol TCP --port 3904 --target-port 3904 + microk8s kubectl patch service message-router-svc --namespace=default --type='json' --patch='[{"op": "replace", "path": "/spec/ports/0/nodePort", "value":'"$DMAAP_PORT"'}]' +} + +####MAIN### +get_pod_names +get_svc_names +expose_services diff --git a/csit/resources/scripts/node-templates.sh b/csit/resources/scripts/node-templates.sh new file mode 100755 index 00000000..4dc19d22 --- /dev/null +++ b/csit/resources/scripts/node-templates.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright 2023 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +if [ -z "${WORKSPACE}" ]; then + WORKSPACE=$(git rev-parse --show-toplevel) + export WORKSPACE +fi + +GERRIT_BRANCH=$(awk -F= '$1 == "defaultbranch" { print $2 }' \ + "${WORKSPACE}"/.gitreview) + +echo GERRIT_BRANCH="${GERRIT_BRANCH}" + +rm -rf "${WORKSPACE}"/models +mkdir "${WORKSPACE}"/models + +# download models examples +git clone -b "${GERRIT_BRANCH}" --single-branch https://github.com/onap/policy-models.git \ + "${WORKSPACE}"/models + +export DATA=${WORKSPACE}/models/models-examples/src/main/resources/policies + +export NODETEMPLATES=${WORKSPACE}/models/models-examples/src/main/resources/nodetemplates + +# create a couple of variations of the policy definitions +sed -e 's!Measurement_vGMUX!ADifferentValue!' \ + "${DATA}"/vCPE.policy.monitoring.input.tosca.json \ + >"${DATA}"/vCPE.policy.monitoring.input.tosca.v1_2.json + +sed -e 's!"version": "1.0.0"!"version": "2.0.0"!' \ + -e 's!"policy-version": 1!"policy-version": 2!' \ + "${DATA}"/vCPE.policy.monitoring.input.tosca.json \ + >"${DATA}"/vCPE.policy.monitoring.input.tosca.v2.json diff --git a/csit/resources/scripts/prepare-robot-env.sh b/csit/resources/scripts/prepare-robot-env.sh new file mode 100755 index 00000000..aeab5cd0 --- /dev/null +++ b/csit/resources/scripts/prepare-robot-env.sh @@ -0,0 +1,54 @@ +#!/bin/bash -x +# +# Copyright 2019 © Samsung Electronics Co., Ltd. +# Modification Copyright 2021 © AT&T Intellectual Property. +# Modification Copyright 2021-2023 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. +# +# This script installs common libraries required by CSIT tests +# + +if [ -z "$WORKSPACE" ]; then + WORKSPACE=$(git rev-parse --show-toplevel) + export WORKSPACE +fi + +ROBOT_VENV=$(mktemp -d) +echo "ROBOT_VENV=${ROBOT_VENV}" >> "${WORKSPACE}/env.properties" + +echo "Python version is: $(python3 --version)" + +python3 -m venv --clear "${ROBOT_VENV}" +source "${ROBOT_VENV}/bin/activate" > /dev/null + +set -exu + +python3 -m pip install -qq --upgrade pip setuptools +echo "Installing Python Requirements" +python3 -m pip install -qq -r "${SCRIPTS}"/pylibs.txt +python3 -m pip -qq freeze + +# install eteutils +mkdir -p "${ROBOT_VENV}"/src/onap +rm -rf "${ROBOT_VENV}"/src/onap/testsuite +python3 -m pip install -qq --upgrade --extra-index-url="https://nexus3.onap.org/repository/PyPi.staging/simple" 'robotframework-onap==0.5.1.*' --pre + +echo "Uninstall docker-py and reinstall docker." +python3 -m pip uninstall -y -qq docker-py +python3 -m pip uninstall -y -qq docker +python3 -m pip install -U -qq docker + +python3 -m pip -qq freeze + +sudo apt-get -y -qq install libxml2-utils diff --git a/csit/resources/scripts/pylibs.txt b/csit/resources/scripts/pylibs.txt new file mode 100644 index 00000000..a8d8c4e3 --- /dev/null +++ b/csit/resources/scripts/pylibs.txt @@ -0,0 +1,26 @@ +docker-py +ipaddr +netaddr +netifaces +pyhocon +requests +robotframework-httplibrary +robotframework-requests +robotframework-selenium2library +robotframework-sshlibrary +scapy +# Module jsonpath is needed by current AAA idmlite suite. +jsonpath-rw +# Modules for longevity framework robot library +elasticsearch +elasticsearch-dsl +# Module for pyangbind used by lispflowmapping project +pyangbind +# Module for iso8601 datetime format +isodate +# Module for TemplatedRequests.robot library +jmespath +# Module for backup-restore support library +jsonpatch +# odltools for extra debugging +odltools diff --git a/csit/resources/scripts/run-test.sh b/csit/resources/scripts/run-test.sh new file mode 100755 index 00000000..977bef75 --- /dev/null +++ b/csit/resources/scripts/run-test.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# ============LICENSE_START==================================================== +# Copyright (C) 2023 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END====================================================== + + +ROBOT_FILE=$1 +echo "Invoking the robot tests from: $1" + +export DEFAULT_PORT=6969 +export DATA=/opt/robotworkspace/models/models-examples/src/main/resources/policies +export NODETEMPLATES=/opt/robotworkspace/models/models-examples/src/main/resources/nodetemplates +export POLICY_RUNTIME_ACM_IP=policy-clamp-runtime-acm:${DEFAULT_PORT} +export POLICY_API_IP=policy-api:${DEFAULT_PORT} +export POLICY_PAP_IP=policy-pap:${DEFAULT_PORT} +export APEX_IP=policy-apex-pdp:${DEFAULT_PORT} +export DMAAP_IP=message-router:3904 +export SIMULATOR_IP=message-router +export PROMETHEUS_IP=prometheus:9090 + +export ROBOT_VARIABLES= +ROBOT_VARIABLES="-v DATA:$DATA -v NODETEMPLATES:$NODETEMPLATES -v POLICY_RUNTIME_ACM_IP:$POLICY_RUNTIME_ACM_IP -v POLICY_API_IP:$POLICY_API_IP +-v POLICY_PAP_IP:$POLICY_PAP_IP -v APEX_IP:$APEX_IP -v DMAAP_IP:$DMAAP_IP -v SIMULATOR_IP:$SIMULATOR_IP -v PROMETHEUS_IP:${PROMETHEUS_IP}" + +echo "Run Robot test" +echo ROBOT_VARIABLES="${ROBOT_VARIABLES}" +echo "Starting Robot test suites ..." +python3 -m robot.run -d /tmp/ $ROBOT_VARIABLES $1 +RESULT=$? +echo "RESULT: ${RESULT}" diff --git a/csit/resources/scripts/setup-apex-pdp.sh b/csit/resources/scripts/setup-apex-pdp.sh new file mode 100755 index 00000000..acebb284 --- /dev/null +++ b/csit/resources/scripts/setup-apex-pdp.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2018 Ericsson. All rights reserved. +# +# Modifications Copyright (c) 2019-2023 Nordix Foundation. +# Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. +# Modifications Copyright (C) 2021 Bell Canada. 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +source "${SCRIPTS}"/setup-pap.sh + +# wait for the app to start up +"${SCRIPTS}"/wait_for_rest.sh localhost "${APEX_PORT}" + +export DMAAP_IP="localhost:${DMAAP_PORT}" +export SUITES="apex-pdp-test.robot" + +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v APEX_IP:localhost:${APEX_PORT} -v DMAAP_IP:${DMAAP_IP} +-v APEX_EVENTS_IP:localhost:${APEX_EVENTS_PORT}" diff --git a/csit/resources/scripts/setup-api.sh b/csit/resources/scripts/setup-api.sh new file mode 100755 index 00000000..2a984643 --- /dev/null +++ b/csit/resources/scripts/setup-api.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright 2021-2023 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +source "${SCRIPTS}"/node-templates.sh + +source "${WORKSPACE}"/compose/start-compose.sh api --grafana + +sleep 10 +unset http_proxy https_proxy + +# wait for the app to start up +bash "${SCRIPTS}"/wait_for_rest.sh localhost ${API_PORT} + +export SUITES="api-test.robot" + +ROBOT_VARIABLES="-v POLICY_API_IP:localhost:${API_PORT} -v PROMETHEUS_IP:localhost:${PROMETHEUS_PORT} +-v DATA:${DATA} -v NODETEMPLATES:${NODETEMPLATES}" diff --git a/csit/resources/scripts/setup-clamp.sh b/csit/resources/scripts/setup-clamp.sh new file mode 100755 index 00000000..923b5218 --- /dev/null +++ b/csit/resources/scripts/setup-clamp.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2021-2023 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +source "${WORKSPACE}"/compose/start-compose.sh policy-clamp-runtime-acm + +sleep 10 +unset http_proxy https_proxy + +# wait for the app to start up +"${SCRIPTS}"/wait_for_rest.sh localhost "${ACM_PORT}" + +export SUITES="policy-clamp-test.robot" + +ROBOT_VARIABLES="-v POLICY_RUNTIME_ACM_IP:localhost:${ACM_PORT} +-v POLICY_API_IP:localhost:${POLICY_API_PORT}" diff --git a/csit/resources/scripts/setup-distribution.sh b/csit/resources/scripts/setup-distribution.sh new file mode 100755 index 00000000..3840d9d7 --- /dev/null +++ b/csit/resources/scripts/setup-distribution.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2018 Ericsson. All rights reserved. +# Modifications Copyright (c) 2019-2023 Nordix Foundation. +# Modifications Copyright (C) 2020-2021 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +# Remaking the csar file in case if the file got corrupted +DIST_TEMP_FOLDER=/tmp/distribution + +zip -F "${TEST_PLAN_DIR}"/data/csar/sample_csar_with_apex_policy.csar \ + --out "${TEST_PLAN_DIR}"/data/csar/csar_temp.csar + +# Remake temp directory +rm -rf "${DIST_TEMP_FOLDER}" +mkdir "${DIST_TEMP_FOLDER}" + +source "${WORKSPACE}"/compose/start-compose.sh distribution + +sleep 10 +unset http_proxy https_proxy + +# wait for the app to start up +"${SCRIPTS}"/wait_for_rest.sh localhost "${DIST_PORT}" + +export SUITES="distribution-test.robot" + +ROBOT_VARIABLES="-v APEX_EVENTS_IP:localhost:${APEX_EVENTS_PORT} +-v DISTRIBUTION_IP:localhost:${DIST_PORT} -v TEMP_FOLDER:${DIST_TEMP_FOLDER}" diff --git a/csit/resources/scripts/setup-drools-applications.sh b/csit/resources/scripts/setup-drools-applications.sh new file mode 100755 index 00000000..189fa6c9 --- /dev/null +++ b/csit/resources/scripts/setup-drools-applications.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# ===========LICENSE_START==================================================== +# Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright 2021-2023 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. +# ============LICENSE_END===================================================== +# + +source "${SCRIPTS}"/node-templates.sh + +source "${WORKSPACE}"/compose/start-compose.sh drools-apps + +sleep 10 +unset http_proxy https_proxy + +export DMAAP_IP="localhost:${DMAAP_PORT}" +export SUITES="drools-applications-test.robot" + +# wait for the app to start up +"${SCRIPTS}"/wait_for_rest.sh localhost ${DROOLS_APPS_PORT} + +# give enough time for the controllers to come up +sleep 15 + +ROBOT_VARIABLES="-v DATA:${DATA} -v DROOLS_IP:localhost:${DROOLS_APPS_PORT} +-v DROOLS_IP_2:localhost:${DROOLS_APPS_TELEMETRY_PORT} -v POLICY_API_IP:localhost:${API_PORT} +-v POLICY_PAP_IP:localhost:${PAP_PORT}" diff --git a/csit/resources/scripts/setup-drools-pdp.sh b/csit/resources/scripts/setup-drools-pdp.sh new file mode 100755 index 00000000..f6341908 --- /dev/null +++ b/csit/resources/scripts/setup-drools-pdp.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright 2017-2021 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright 2021-2023 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +source "${WORKSPACE}"/compose/start-compose.sh drools + +sleep 10 +unset http_proxy https_proxy + +export SUITES="drools-pdp-test.robot" + +# wait for the app to start up - looking for telemetry service on port ${DROOLS_PORT} forwarded from 9696 +"${SCRIPTS}"/wait_for_rest.sh localhost ${DROOLS_TELEMETRY_PORT} + +# give enough time for the controllers to come up +sleep 15 + +ROBOT_VARIABLES="${ROBOT_VARIABLES} -v POLICY_DROOLS_IP:localhost:${DROOLS_TELEMETRY_PORT}" diff --git a/csit/resources/scripts/setup-pap.sh b/csit/resources/scripts/setup-pap.sh new file mode 100755 index 00000000..741f0644 --- /dev/null +++ b/csit/resources/scripts/setup-pap.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2019-2022 Nordix Foundation. +# Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. +# Modifications Copyright (C) 2022-2023 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +source "${SCRIPTS}"/node-templates.sh + +source "${WORKSPACE}"/compose/start-compose.sh apex-pdp --grafana + +sleep 10 +unset http_proxy https_proxy + +# wait for the app to start up +bash "${SCRIPTS}"/wait_for_rest.sh localhost ${PAP_PORT} + +export SUITES="pap-test.robot +pap-slas.robot" + +ROBOT_VARIABLES="-v POLICY_PAP_IP:localhost:${PAP_PORT} -v POLICY_API_IP:localhost:${API_PORT} +-v PROMETHEUS_IP:localhost:${PROMETHEUS_PORT} -v DATA:${DATA} -v NODETEMPLATES:${NODETEMPLATES}" diff --git a/csit/resources/scripts/setup-xacml-pdp.sh b/csit/resources/scripts/setup-xacml-pdp.sh new file mode 100755 index 00000000..53c44cbd --- /dev/null +++ b/csit/resources/scripts/setup-xacml-pdp.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# ============LICENSE_START======================================================= +# Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright 2021-2023 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +source "${SCRIPTS}"/node-templates.sh + +source "${WORKSPACE}"/compose/start-compose.sh xacml-pdp + +sleep 10 +unset http_proxy https_proxy + +export DMAAP_IP="localhost:${DMAAP_PORT}" +export SUITES="xacml-pdp-test.robot" + +# wait for the app to start up +"${SCRIPTS}"/wait_for_rest.sh localhost "${XACML_PORT}" + +ROBOT_VARIABLES="-v DATA:${DATA} -v POLICY_PDPX_IP:localhost:${XACML_PORT} +-v POLICY_API_IP:localhost:${API_PORT} -v POLICY_PAP_IP:localhost:${PAP_PORT}" diff --git a/csit/resources/scripts/wait_for_rest.sh b/csit/resources/scripts/wait_for_rest.sh new file mode 100755 index 00000000..e400bbd4 --- /dev/null +++ b/csit/resources/scripts/wait_for_rest.sh @@ -0,0 +1,77 @@ +#!/bin/sh +# ============LICENSE_START==================================================== +# Copyright (C) 2023 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. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END====================================================== +usage() { + echo args: [-t timeout] [-c command] hostname1 port1 hostname2 port2 ... >&2 + exit 1 +} +tmout=300 +cmd= +while getopts c:t: opt +do + case "$opt" in + c) + cmd="$OPTARG" + ;; + t) + tmout="$OPTARG" + ;; + *) + usage + ;; + esac +done +nargs=$((OPTIND-1)) +shift "$nargs" +even_args=$(($#%2)) +if [ $# -lt 2 ] || [ "$even_args" -ne 0 ] +then + usage +fi +while [ $# -ge 2 ] +do + export host="$1" + export port="$2" + shift + shift + echo "Waiting for REST to come up on $host port $port..." + while [ "$tmout" -gt 0 ] + do + if command -v docker > /dev/null 2>&1 + then + docker ps --format "table {{ .Names }}\t{{ .Status }}" + fi + curl "http://$host:$port" > /dev/null 2>&1 + rc=$? + if [ $rc -eq 0 ] + then + break + else + tmout=$((tmout-5)) + sleep 5 + fi + done + if [ $rc -ne 0 ] + then + echo "$host port $port REST cannot be detected" + exit $rc + fi +done +$cmd +exit 0 + -- cgit 1.2.3-korg