2 # ============LICENSE_START=======================================================
3 # Copyright (C) 2023 Nordix Foundation. All rights reserved.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
20 # This script will be used to automatically trigger the S3P
21 # tests for policy components.
24 function start_kubernetes() {
25 bash run-k8s-csit.sh install
26 bash resources/scripts/get-cluster-info.sh
29 function install_jmeter() {
31 #NOTE: $TESTDIR is set by the component triggering this script
32 cd ${TESTDIR}/automate-performance
37 sudo apt install curl -y
40 sudo apt install -y default-jdk
43 curl -O https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.6.2.tgz
44 tar -xvf apache-jmeter-5.6.2.tgz
45 mv apache-jmeter-5.6.2 apache-jmeter
47 # Define your desired heap size values
48 echo 'export JVM_ARGS="-Xms2g -Xmx4g"' > apache-jmeter/bin/setenv.sh
49 echo 'export HEAP="-Xms1G -Xmx2G -XX:MaxMetaspaceSize=512m"' >> apache-jmeter/bin/setenv.sh
52 # Remove unnecessary files
53 rm -rf apache-jmeter/docs apache-jmeter/printable_docs
57 curl -O https://repo1.maven.org/maven2/kg/apc/cmdrunner/2.2.1/cmdrunner-2.2.1.jar
60 sudo cp -r ../../apache-jmeter /opt/
62 # Add JMeter Path Variable
63 export JMETER_HOME="/opt/apache-jmeter"
64 export PATH="$JMETER_HOME/bin:$PATH"
68 # TODO: Generate report
69 echo "Generating report..."
73 echo "Removing temp directories.."
75 rm -r ${TESTDIR}/automate-performance
77 echo "Removed directories"
79 echo "Tearing down kubernetes cluster..."
80 bash run-k8s-csit.sh uninstall
82 # DELETE created services
83 microk8s kubectl get svc | awk '/svc/{system("microk8s kubectl delete svc " $1)}'
91 echo "==========================="
92 echo "Starting K8s Environment"
93 echo "==========================="
96 echo "==========================="
97 echo "Installing JMeter"
98 echo "==========================="
101 # Run the JMX test plan
102 echo "==========================="
103 echo "Executing tests"
104 echo "==========================="
105 cd ${TESTDIR}/automate-performance || exit
106 nohup jmeter -n -t $2 -l s3pTestResults.jtl
108 # TODO: Generate report on on_exit()
110 elif [ $1 == "uninstall" ]
112 echo "Uninstalling environment and removing temp folders..."
115 echo "Invalid arguments provided. Usage: $0 [option..] {run | uninstall}"