[VOL-3945] Added ONU Software Upgrade to periodic-software-upgrade pipeline

Change-Id: I34047b9d7f6a403ba58715b743346262b12fc2d3
diff --git a/jjb/pipeline/voltha/master/software-upgrades.groovy b/jjb/pipeline/voltha/master/software-upgrades.groovy
index 7802907..1735ba8 100644
--- a/jjb/pipeline/voltha/master/software-upgrades.groovy
+++ b/jjb/pipeline/voltha/master/software-upgrades.groovy
@@ -109,6 +109,10 @@
           export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v voltha_comps_under_test:\$VOLTHA_COMPS_UNDER_TEST -e PowerSwitch"
           export TARGET=voltha-comp-upgrade-test
         fi
+        if [[ ${name} == 'onu-software-upgrade' ]]; then
+          export ROBOT_MISC_ARGS="-d \$ROBOT_LOGS_DIR -v onu_image_name:${onuImageName.trim()} -v onu_image_url:${onuImageUrl.trim()} -v onu_image_version:${onuImageVersion.trim()} -v onu_image_crc:${onuImageCrc.trim()} -v onu_image_local_dir:${onuImageLocalDir.trim()} -e PowerSwitch"
+          export TARGET=onu-upgrade-test
+        fi
         export VOLTCONFIG=$HOME/.volt/config-minimal
         export KUBECONFIG=$HOME/.kube/kind-config-voltha-minimal
         # Run the specified tests
@@ -157,7 +161,7 @@
     label "${params.buildNode}"
   }
   options {
-    timeout(time: 30, unit: 'MINUTES')
+    timeout(time: 40, unit: 'MINUTES')
   }
   environment {
     PATH="$PATH:$WORKSPACE/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
@@ -174,10 +178,21 @@
         ])
       }
     }
+    stage('Cleanup') {
+      steps {
+        // remove port-forwarding
+        sh """
+          # remove orphaned port-forward from different namespaces
+          ps aux | grep port-forw | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9
+        """
+        helmTeardown(['infra', 'voltha'])
+      }
+    }
     stage('Run Test') {
       steps {
         test_software_upgrade("onos-app-upgrade")
         test_software_upgrade("voltha-component-upgrade")
+        test_software_upgrade("onu-software-upgrade")
       }
     }
   }
@@ -192,6 +207,7 @@
       sh '''
       gzip $WORKSPACE/onos-app-upgrade/onos-voltha-combined.log || true
       gzip $WORKSPACE/voltha-component-upgrade/onos-voltha-combined.log || true
+      gzip $WORKSPACE/onu-software-upgrade/onos-voltha-combined.log || true
       '''
       step([$class: 'RobotPublisher',
          disableArchiveOutput: false,
diff --git a/jjb/software-upgrades.yaml b/jjb/software-upgrades.yaml
index b887912..ccae596 100644
--- a/jjb/software-upgrades.yaml
+++ b/jjb/software-upgrades.yaml
@@ -30,6 +30,11 @@
           adapter-open-onu-image: 'voltha/voltha-openonu-adapter-go:1.2.6'
           rw-core-image: 'voltha/voltha-rw-core:2.6.3'
           ofagent-image: 'voltha/voltha-ofagent-go:1.5.2'
+          onu-image-name: 'software-image.img'
+          onu-image-url: 'http://bbsim0:50074/images'
+          onu-image-version: 'v1.0.0'
+          onu-image-crc: '0'
+          onu-image-local-dir: '/tmp'
           time-trigger: "H H/23 * * *"
 
 - job-template:
@@ -181,6 +186,31 @@
           default: '{ofagent-image}'
           description: 'Voltha Ofagent Component Image'
 
+      - string:
+          name: onuImageName
+          default: '{onu-image-name}'
+          description: 'Name of ONU Image to Upgrade'
+
+      - string:
+          name: onuImageUrl
+          default: '{onu-image-url}'
+          description: 'Url of ONU Image to Upgrade'
+
+      - string:
+          name: onuImageVersion
+          default: '{onu-image-version}'
+          description: 'Version of ONU Image to Upgrade'
+
+      - string:
+          name: onuImageCrc
+          default: '{onu-image-crc}'
+          description: 'CRC of ONU Image to Upgrade'
+
+      - string:
+          name: onuImageLocalDir
+          default: '{onu-image-local-dir}'
+          description: 'Local Dir of ONU Image to Upgrade'
+
     project-type: pipeline
     concurrent: true