aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--csit/get-cluster-info.sh112
-rwxr-xr-xcsit/start-s3p-tests.sh121
2 files changed, 233 insertions, 0 deletions
diff --git a/csit/get-cluster-info.sh b/csit/get-cluster-info.sh
new file mode 100644
index 00000000..efe0f517
--- /dev/null
+++ b/csit/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/start-s3p-tests.sh b/csit/start-s3p-tests.sh
new file mode 100755
index 00000000..100f57c7
--- /dev/null
+++ b/csit/start-s3p-tests.sh
@@ -0,0 +1,121 @@
+#!/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 automatically trigger the S3P
+# tests for policy components.
+
+# Start Kubernetes
+function start_kubernetes() {
+ bash run-k8s-csit.sh install
+ bash get-cluster-info.sh
+}
+
+function install_jmeter() {
+
+ #NOTE: $TESTDIR is set by the component triggering this script
+ cd ${TESTDIR}/automate-performance
+
+ sudo apt-get update
+
+ # Install curl
+ sudo apt install curl -y
+
+ # Install JDK
+ sudo apt install -y default-jdk
+
+ # Install JMeter
+ curl -O https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.3.tgz
+ tar -xvf apache-jmeter-5.3.tgz
+
+ # Remove unnecessary files
+ rm -rf apache-jmeter-5.3/docs apache-jmeter-5.3/printable_docs
+
+ # Install CMD Runner
+ cd apache-jmeter-5.3/lib
+ curl -O https://repo1.maven.org/maven2/kg/apc/cmdrunner/2.2.1/cmdrunner-2.2.1.jar
+
+ # Install Plugin Manager
+ cd ext/
+ curl -O https://repo1.maven.org/maven2/kg/apc/jmeter-plugins-manager/1.6/jmeter-plugins-manager-1.6.jar
+
+ # Download Plugins
+ cd ..
+ java -jar cmdrunner-2.2.1.jar --tool org.jmeterplugins.repository.PluginManagerCMD install-all-except jpgc-hadoop,jpgc-oauth,ulp-jmeter-autocorrelator-plugin,ulp-jmeter-videostreaming-plugin,ulp-jmeter-gwt-plugin,tilln-iso8583
+
+ # Move JMeter to /opt
+ sudo cp -r ../../apache-jmeter-5.3 /opt/
+
+ # Add JMeter Path Variable
+ nano .profile
+ JMETER_HOME="/opt/apache-jmeter-5.3"
+ PATH="$JMETER_HOME/bin:$PATH"
+ source ~/.profile
+}
+
+function on_exit() {
+ # TODO: Generate report
+ echo "Generating report..."
+}
+
+function teardown() {
+ echo "Removing temp directories.."
+
+ rm -r ${TESTDIR}/automate-performance
+
+ echo "Removed directories"
+
+ echo "Tearing down kubernetes cluster..."
+ bash run-k8s-csit.sh uninstall
+
+ # DELETE created services
+ microk8s kubectl get svc | awk '/svc/{system("microk8s kubectl delete svc " $1)}'
+}
+
+#===MAIN===#
+
+if [ $1 == "run" ]
+then
+
+ echo "==========================="
+ echo "Starting K8s Environment"
+ echo "==========================="
+ start_kubernetes
+
+ echo "==========================="
+ echo "Installing JMeter"
+ echo "==========================="
+ install_jmeter
+
+ # Run the JMX test plan
+ echo "==========================="
+ echo "Executing tests"
+ echo "==========================="
+ cd ${TESTDIR}/automate-performance || exit
+ nohup apache-jmeter-5.3/bin/jmeter -n -t $2 -l s3pTestResults.jtl
+
+ # TODO: Generate report on on_exit()
+
+elif [ $1 == "uninstall" ]
+then
+ echo "Uninstalling environment and removing temp folders..."
+ teardown
+else
+ echo "Invalid arguments provided. Usage: $0 [option..] {run | uninstall}"
+fi
+