Skip to content

Commit 7cca8ff

Browse files
authored
[mgmt] Add canary KVM tests for sonic-mgmt repo (sonic-net#108)
Signed-off-by: Danny Allen <[email protected]>
1 parent 91c5c67 commit 7cca8ff

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
pipeline {
2+
agent {
3+
node { label 'jenkins-kvmtest-workers' }
4+
}
5+
6+
options {
7+
buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '30'))
8+
}
9+
10+
triggers {
11+
pollSCM('@midnight')
12+
}
13+
14+
stages {
15+
stage('Prepare') {
16+
steps {
17+
dir('sonic-mgmt') {
18+
checkout([$class: 'GitSCM',
19+
branches: [[name: '*/master']],
20+
userRemoteConfigs: [[url: 'https://github.com/Azure/sonic-mgmt']]])
21+
}
22+
copyArtifacts(projectName: 'bldenv/docker-sonic-mgmt', filter: '**/docker-sonic-mgmt.gz', target: 'mgmt', flatten: true)
23+
copyArtifacts(projectName: 'vs/buildimage-vs-image', filter: '**/sonic-vs.img.gz', target: 'vsimage', flatten: true)
24+
}
25+
}
26+
27+
stage('Test') {
28+
steps {
29+
wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'xterm']) {
30+
lock(resource: "kvmtest_${env.NODE_NAME}") {
31+
withCredentials([sshUserPrivateKey(credentialsId: '2b6b6afe-4892-41d1-967c-d683e7773727', keyFileVariable: 'VM_USER_PRIVATE_KEY'), \
32+
usernamePassword(credentialsId: 'sonicdev-cr', usernameVariable: 'REGISTRY_USERNAME', passwordVariable: 'REGISTRY_PASSWD')]) {
33+
sh './scripts/mgmt/test.sh'
34+
}
35+
}
36+
}
37+
}
38+
39+
post {
40+
always {
41+
junit(allowEmptyResults: true, keepLongStdio: true, testResults: 'sonic-mgmt/tests/results/**/*.xml')
42+
archiveArtifacts(artifacts: 'sonic-mgmt/tests/results/**, sonic-mgmt/tests/logs/**')
43+
}
44+
}
45+
}
46+
}
47+
48+
post {
49+
cleanup {
50+
cleanWs(disableDeferredWipeout: false, deleteDirs: true, notFailBuild: true)
51+
}
52+
}
53+
}

scripts/mgmt/test.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash -xe
2+
3+
echo ${JOB_NAME##*/}.${BUILD_NUMBER}
4+
5+
docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWD sonicdev-microsoft.azurecr.io:443
6+
docker pull sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt:latest
7+
8+
cat $VM_USER_PRIVATE_KEY > pkey.txt
9+
10+
ls -l vsimage
11+
12+
mkdir -p $HOME/sonic-vm/images
13+
cp vsimage/sonic-vs.img.gz $HOME/sonic-vm/images/
14+
gzip -fd $HOME/sonic-vm/images/sonic-vs.img.gz
15+
16+
ls -l $HOME/sonic-vm/images
17+
18+
pushd sonic-mgmt/ansible
19+
sed -i s:use_own_value:johnar: veos.vtb
20+
echo abc > password.txt
21+
popd
22+
23+
docker run --rm=true -v $(pwd):/data -w /data -i sonicdev-microsoft.azurecr.io:443/docker-sonic-mgmt ./scripts/vs/buildimage-vs-image/runtest.sh

0 commit comments

Comments
 (0)