Add volume mount for storing k8s robot logs to the host 57/133257/2
authorrameshiyer27 <ramesh.murugan.iyer@est.tech>
Tue, 14 Feb 2023 17:52:49 +0000 (17:52 +0000)
committerrameshiyer27 <ramesh.murugan.iyer@est.tech>
Tue, 14 Feb 2023 18:06:20 +0000 (18:06 +0000)
Issue-ID: POLICY-4546
Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech>
Change-Id: I498aa9db39d6b04e685a893c9bca41c6bb108265

csit/run-k8s-csit.sh
helm/robot/templates/test-job.yaml
helm/robot/values.yaml
helm/run-test.sh

index e348ca8..22a67f9 100755 (executable)
@@ -36,6 +36,7 @@ POLICY_APEX_CONTAINER="policy-apex-pdp"
 
 export PROJECT=""
 export ROBOT_FILE=""
+export ROBOT_LOG_DIR=${PWD}/archives
 export READINESS_CONTAINERS=()
 
 function spin_microk8s_cluster () {
@@ -54,7 +55,7 @@ function spin_microk8s_cluster () {
         echo "Microk8s cluster installed successfully"
         sudo usermod -a -G microk8s $USER
         echo "Enabling DNS and helm3 plugins"
-        microk8s.enable dns helm3
+        microk8s.enable dns helm3 hostpath-storage
         echo "Creating configuration file for Microk8s"
         microk8s kubectl config view --raw > $HOME/.kube/config
         chmod 600 $HOME/.kube/config
@@ -93,7 +94,7 @@ function build_robot_image () {
         rm -rf tests/models/
         echo "---------------------------------------------"
         echo "Installing Robot framework pod for running CSIT"
-        microk8s helm install csit-robot robot --set robot=$ROBOT_FILE --set "readiness={${READINESS_CONTAINERS[*]}}";
+        microk8s helm install csit-robot robot --set robot=$ROBOT_FILE --set "readiness={${READINESS_CONTAINERS[*]}}" --set robotLogDir=$ROBOT_LOG_DIR;
         print_robot_log
     fi
 }
index 5d8a610..ed1669a 100644 (file)
@@ -49,4 +49,11 @@ spec:
             - name: ROBOT_FILE
               value: {{ .Values.robot }}
           command: [ "./run-test.sh", "$(ROBOT_FILE)" ]
-      restartPolicy: Never
\ No newline at end of file
+          volumeMounts:
+            - name: robot-csit-pv
+              mountPath: /tmp
+      restartPolicy: Never
+      volumes:
+        - name: robot-csit-pv
+          hostPath:
+            path: {{ .Values.robotLogDir }}
\ No newline at end of file
index 95df6fa..5baf8aa 100644 (file)
@@ -67,4 +67,4 @@ affinity: {}
 
 robot: ""
 readiness: []
-
+robotLogDir: ""
index bb073c3..d40bb58 100755 (executable)
@@ -38,6 +38,6 @@ ROBOT_VARIABLES="-v DATA:$DATA -v NODETEMPLATES:$NODETEMPLATES -v POLICY_RUNTIME
 echo "Run Robot test"
 echo ROBOT_VARIABLES="${ROBOT_VARIABLES}"
 echo "Starting Robot test suites ..."
-python3 -m robot.run $ROBOT_VARIABLES $1
+python3 -m robot.run -d /tmp/ $ROBOT_VARIABLES $1
 RESULT=$?
 echo "RESULT: ${RESULT}"