| 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 ps | grep stratum | cut -d' ' -f1 | xargs docker stop; pkill stratum_bf" || 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-internal-registry"]) { |
| 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 ps | grep stratum | cut -d' ' -f1 | xargs docker stop; pkill stratum_bf" || true |
| """ |
| } |
| archiveArtifacts(artifacts: 'logs/**/**', allowEmptyArchive: true, excludes: 'logs/**/int-traffic-trace-*.pcap') |
| } |
| } |
| } |