[SDFAB-391] Create a new fabric-tna job and pipeline to run linerate tests

Change-Id: I7be6f3151a945385df9c77ba905eb22e0ffdfe79
diff --git a/jjb/pipeline/fabric-tna-hardware.groovy b/jjb/pipeline/fabric-tna-hardware.groovy
new file mode 100644
index 0000000..059687c
--- /dev/null
+++ b/jjb/pipeline/fabric-tna-hardware.groovy
@@ -0,0 +1,57 @@
+pipeline {
+    agent {
+        label "${params.BUILD_NODE}"
+    }
+    options {
+        timeout(time: 60, unit: 'MINUTES')
+    }
+    environment {
+        SWITCH_USER = "jenkins"
+        STRATUM_PORT = "${params.STRATUM_PORT}"
+        SWITCH_ADDR = "${params.SWITCH_IP}:${STRATUM_PORT}"
+        SWITCH_SSH = "${SWITCH_USER}@${params.SWITCH_IP}"
+        CHASSIS_CONFIG = "/home/jenkins/chassis_config.pb.txt"
+        TREX_DIR = "/srv/trex-core-2.85-scapy-2.4.5/scripts"
+    }
+
+    stages {
+        stage('Start Stratum') {
+            steps {
+                step([$class: 'WsCleanup'])
+                git branch: "${params.GIT_BRANCH}", credentialsId: 'github-onf-bot-ssh-key', url: "${params.GIT_URL}"
+                sshagent(credentials: ['menlo-pdp-32qs-jenkins']) {
+                    sh returnStdout: false, label: "Start Stratum on ${params.SWITCH_IP}", script: '''
+                        . ./.env
+                        ssh ${SWITCH_SSH} "docker stop stratum_bfrt && sudo pkill stratum" || true
+                        scp ./ptf/tests/linerate/chassis_config.pb.txt ${SWITCH_SSH}:/home/jenkins/
+                        ssh ${SWITCH_SSH} "DOCKER_IMAGE_TAGGED=$STRATUM_DOCKER_IMG SDE_VERSION=$SDE_VERSION CHASSIS_CONFIG=${CHASSIS_CONFIG} \
+                            ./start-stratum-container.sh -external_stratum_urls=0.0.0.0:${STRATUM_PORT}"
+                    '''
+                    sh "until nc -z ${params.SWITCH_IP} ${STRATUM_PORT}; do sleep 1; done"
+                }
+            }
+        }
+        stage('Run fabric-tna tests') {
+            options { retry(3) }
+            steps {
+                script {
+                    withDockerRegistry([url: "https://registry.opennetworking.org", credentialsId: "onf-registry-credentials"]) {
+                        sh returnStdout: false, label: "Build fabric-tna and run linerate tests", script: """
+                            PROFILE=${params.PROFILE} SWITCH_ADDR=${SWITCH_ADDR} bash .jenkins/linerate.sh
+                        """
+                    }
+                }
+            }
+        }
+    }
+    post {
+        always {
+            sshagent(credentials: ['menlo-pdp-32qs-jenkins']) {
+                sh returnStdout: false, label: "Stop Stratum", script: """
+                    ssh ${SWITCH_SSH} "docker stop stratum_bfrt && sudo pkill stratum" || true
+                """
+            }
+            archiveArtifacts(artifacts: 'logs/**/**', allowEmptyArchive: true, excludes: 'logs/**/int-traffic-trace-*.pcap')
+        }
+    }
+}