Add Jenkisn file to cord-tester repo
Change-Id: I0140f397c75dc5eebb7ca8934ffa561217c47bea
diff --git a/Jenkinsfile-ecord-local b/Jenkinsfile-ecord-local
new file mode 100644
index 0000000..d1459f7
--- /dev/null
+++ b/Jenkinsfile-ecord-local
@@ -0,0 +1,113 @@
+// Copyright 2017-present Open Networking 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.
+
+pod_config = null
+deployment_config = null
+
+node ('master') {
+ stage ("Parse configuration file") {
+ sh returnStdout: true, script: 'rm -rf ${configRepoBaseDir}'
+ sh returnStdout: true, script: 'git clone -b ${branch} ${configRepoUrl}'
+ deployment_config = readYaml file: "${configRepoBaseDir}${configRepoFile}"
+ pod_config = readYaml file: "${configRepoBaseDir}${deployment_config.pod_config.file_name}"
+ }
+}
+
+node ("${deployment_config.dev_node.name}") {
+ stage('Prerequisites') {
+ runHeadNodeCmd("""
+ cd /opt/cord/test/cord-tester/src/test/setup
+ sudo ./prerequisites.sh --cord
+ """)
+ }
+ stage('Verify Collect Diag') {
+ timeout(10) {
+ try {
+ runHeadNodeCmd("""
+ rm -rf ~/diag-*
+ cd /opt/cord/build; make collect-diag
+ cd /opt/cord/test/cord-tester/src/test/diag/
+ rm -r Log/ || true
+ pybot -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T verifyCollectDiag.robot
+ """)
+ } catch(error) { currentBuild.result = 'FAILURE' }
+ }
+ }
+ stage('Sanity Test') {
+ timeout(10) {
+ try {
+ runHeadNodeCmd("""
+ cd /opt/cord/test/cord-tester/src/test/robot/
+ rm -r Log/ || true
+ """)
+ if (deployment_config.fabric_switches != null) {
+ runHeadNodeCmd("""
+ cd /opt/cord/test/cord-tester/src/test/robot/
+ pybot --exclude notready -v FABRIC:on -v PUBLIC_IFACE:${pod_config.external_iface} -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T SanityPhyPOD.robot
+ """)
+ }
+ else {
+ // Exclude fabric related tests
+ runHeadNodeCmd("""
+ cd /opt/cord/test/cord-tester/src/test/robot/
+ pybot --exclude notready --exclude fabric -v FABRIC:off -v PUBLIC_IFACE:${pod_config.external_iface} -v CORD_PROFILE:${pod_config.cord_profile} -d Log -T SanityPhyPOD.robot
+ """)
+ }
+ } catch(error) { currentBuild.result = 'FAILURE' }
+ }
+ }
+ stage('XOS API Tests') {
+ timeout(10) {
+ try {
+ runHeadNodeCmd("""
+ cd /opt/cord/test/cord-tester/src/test/cord-api/Properties/
+ sed -i s/^SERVER_IP\\ =\\ .*/SERVER_IP\\ =\\ \\'localhost\\'/ RestApiProperties.py
+ sed -i s/^SERVER_PORT\\ =\\ .*/SERVER_PORT\\ =\\ \\'9101\\'/ RestApiProperties.py
+ sed -i s/^PASSWD\\ =\\ .*/PASSWD\\ =\\ \\'\\\$(cat /opt/credentials/xosadmin@opencord.org)\\'/ RestApiProperties.py
+ """)
+ } catch(error) { currentBuild.result = 'FAILURE' }
+ }
+ }
+ stage('Publish') {
+ try {
+ sh """
+ if [ -d RobotLogs ]; then rm -r RobotLogs; fi; mkdir RobotLogs
+ scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/cord-api/Log/* ./RobotLogs || true
+ scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/robot/Log/* ./RobotLogs || true
+ scp -r ${deployment_config.head.user}@${deployment_config.head.ip}:/opt/cord/test/cord-tester/src/test/diag/Log/* ./RobotLogs || true
+ """
+ step([$class: 'RobotPublisher',
+ disableArchiveOutput: false,
+ logFileName: 'RobotLogs/log*.html',
+ otherFiles: '',
+ outputFileName: 'RobotLogs/output*.xml',
+ outputPath: '.',
+ passThreshold: 100,
+ reportFileName: 'RobotLogs/report*.html',
+ unstableThreshold: 0])
+ } catch(error) {}
+ }
+ step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${notificationEmail}", sendToIndividuals: false])
+}
+
+/**
+ * Runs a command on the head node.
+ *
+ * @param command the command to run
+ * @param sshArgs arguments for the ssh command
+ * @return the output of the command
+ */
+def runHeadNodeCmd(command, sshArgs="") {
+ return sh(returnStdout: true, script: "sshpass -p ${deployment_config.head.pass} ssh ${sshArgs} -oStrictHostKeyChecking=no -l ${deployment_config.head.user} ${deployment_config.head.ip} \"${command}\"")
+}