Skip to content

Commit 44ba206

Browse files
authored
Merge pull request #231 from michelsciortino/ms-fixing-jenkins-tests
Fixing jenkinsfile for new k8s slaves
2 parents e8125a9 + 6d92042 commit 44ba206

31 files changed

Lines changed: 214 additions & 78 deletions

CI/JenkinsfileTestCleanInstance

Lines changed: 71 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ pipeline {
6868
environment {
6969
image_tag = "${env.GIT_COMMIT}"
7070
image_name = "polycube"
71+
container = "polycubed"
7172
registryCred = credentials('polycube-repo')
7273
notification_url = credentials('slack-notifications')
7374
github_token = credentials('github_status_update')
@@ -215,19 +216,27 @@ pipeline {
215216
script {
216217
docker.withRegistry("", 'polycube-repo') {
217218
sh """
218-
docker stop polycubed || true
219+
docker stop $container || true
219220
docker system prune --all --force
220-
# Launch the polycubed daemon and extract the polycubectl
221-
# /proc is mounted under /host/proc to have a complete visibility of the namespaces created outside of the container
222-
docker run -d --name polycubed --rm --privileged --pid=host --cap-add ALL --network host -v /proc:/host/proc -v /lib/modules:/lib/modules:ro -v /var/run/netns/:/var/run/netns:rw -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro polycubebot/${image_name}-default:${image_tag}
223-
mkdir bin
224-
docker cp polycubed:/usr/local/bin/polycubectl ./bin/
221+
set +e
222+
225223
# Overload environment variables in order to adapt the behavior of run_tests script
226-
export PATH=$PATH:${WORKSPACE}/bin
227-
export KILL_COMMAND="docker stop polycubed"
228-
export polycubed="docker run -d --name polycubed --rm --privileged --pid=host --cap-add ALL --network host -v /lib/modules:/lib/modules:ro -v /proc:/host/proc -v /var/run/netns/:/var/run/netns:rw -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro polycubebot/${image_name}-default:${image_tag}"
229-
# Killing polycube image if running
224+
export KILL_COMMAND="docker stop $container"
225+
226+
# /proc is mounted under /host/proc to have a complete visibility of the namespaces created outside of the container
227+
export polycubed="docker run -d --name $container --rm --privileged --pid=host --cap-add ALL --network host -v /proc:/host/proc -v /lib/modules:/lib/modules:ro -v /var/run/netns/:/var/run/netns:rw -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro polycubebot/${image_name}-default:${image_tag}"
228+
229+
# Launch the polycubed daemon
230+
\$polycubed /bin/sleep infinity
231+
232+
# Copy binaries, headers and libraries from docker to host fs
233+
sudo ./CI/extract_from_docker_image.sh $container
234+
230235
\$KILL_COMMAND
236+
237+
\$polycubed
238+
docker ps
239+
231240
cd tests/
232241
# For the moment, tests always returns 0 to enable junit generation
233242
./run-tests.sh || true
@@ -237,6 +246,10 @@ pipeline {
237246
pip install -r converter/requirements.txt
238247
export TEST_RESULTS=`ls -1 test_results_*`
239248
python3 converter/to_junit.py CleanInstance
249+
cd ..
250+
251+
# Cleaning slave
252+
sudo ./CI/clean_slave.sh
240253
"""
241254
}
242255
}
@@ -249,7 +262,7 @@ pipeline {
249262
}
250263
script {
251264
sh """
252-
docker stop polycubed || true
265+
docker stop $container || true
253266
docker system prune --all --force
254267
"""
255268
}
@@ -280,22 +293,38 @@ pipeline {
280293
script {
281294
docker.withRegistry("", 'polycube-repo') {
282295
sh """
283-
docker stop polycubed || true
296+
docker stop $container || true
284297
docker system prune --all --force
285298
set +e
286-
docker run -d --name polycubed --rm --privileged --pid=host --cap-add ALL --network host -v /proc:/host/proc -v /lib/modules:/lib/modules:ro -v /var/run/netns/:/var/run/netns:rw -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro polycubebot/${image_name}-default:${image_tag}
287-
mkdir bin
288-
docker cp polycubed:/usr/local/bin/polycubectl ./bin/
289-
export PATH=$PATH:${WORKSPACE}/bin
290-
export KILL_COMMAND="docker stop polycubed"
291-
export polycubed="docker run -d --name polycubed --rm --privileged --pid=host --cap-add ALL --network host -v /lib/modules:/lib/modules:ro -v /proc:/host/proc -v /var/run/netns/:/var/run/netns:rw -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro polycubebot/${image_name}-default:${image_tag}"
299+
300+
# Overload environment variables in order to adapt the behavior of run_tests script
301+
export KILL_COMMAND="docker stop $container"
302+
303+
# /proc is mounted under /host/proc to have a complete visibility of the namespaces created outside of the container
304+
export polycubed="docker run -d --name $container --rm --privileged --pid=host --cap-add ALL --network host -v /proc:/host/proc -v /lib/modules:/lib/modules:ro -v /var/run/netns/:/var/run/netns:rw -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro polycubebot/${image_name}-default:${image_tag}"
305+
306+
# Launch the polycubed daemon
307+
\$polycubed /bin/sleep infinity
308+
309+
# Copy binaries, headers and libraries from docker to host fs
310+
sudo ./CI/extract_from_docker_image.sh $container
311+
312+
\$KILL_COMMAND
313+
314+
\$polycubed
315+
316+
docker ps
292317
cd tests/ && ./run-tests.sh false || true
293318
export LC_ALL=C
294319
virtualenv venv -p python3
295320
. venv/bin/activate
296321
pip install -r converter/requirements.txt
297322
export TEST_RESULTS=`ls -1 test_results_*`
298323
python3 converter/to_junit.py SameInstance
324+
cd ..
325+
326+
# Cleaning slave
327+
sudo ./CI/clean_slave.sh
299328
"""
300329
}
301330
}
@@ -308,7 +337,7 @@ pipeline {
308337
archiveArtifacts artifacts: 'tests/test_results*'
309338
}
310339
sh """
311-
docker stop polycubed || true
340+
docker stop $container || true
312341
docker system prune --all --force
313342
"""
314343
}
@@ -339,22 +368,37 @@ pipeline {
339368
script {
340369
docker.withRegistry("", 'polycube-repo') {
341370
sh """
342-
docker stop polycubed || true
371+
docker stop $container || true
343372
docker system prune --all --force
344373
set +e
345-
docker run -d --name polycubed --rm --privileged --pid=host --cap-add ALL --network host -v /proc:/host/proc -v /lib/modules:/lib/modules:ro -v /var/run/netns/:/var/run/netns:rw -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro polycubebot/${image_name}-pcn-iptables:${image_tag}
346-
mkdir bin
347-
docker cp polycubed:/usr/local/bin/polycubectl ./bin/
348-
export PATH=$PATH:${WORKSPACE}/bin
349-
export KILL_COMMAND="docker stop polycubed"
350-
export polycubed="docker run -d --name polycubed --rm --privileged --pid=host --cap-add ALL --network host -v /lib/modules:/lib/modules:ro -v /proc:/host/proc -v /var/run/netns/:/var/run/netns:rw -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro polycubebot/${image_name}-pcn-iptables:${image_tag}"
374+
375+
# Overload environment variables in order to adapt the behavior of run_tests script
376+
export KILL_COMMAND="docker stop $container"
377+
378+
# /proc is mounted under /host/proc to have a complete visibility of the namespaces created outside of the container
379+
export polycubed="docker run -d --name $container --rm --privileged --pid=host --cap-add ALL --network host -v /proc:/host/proc -v /lib/modules:/lib/modules:ro -v /var/run/netns/:/var/run/netns:rw -v /usr/src:/usr/src:ro -v /etc/localtime:/etc/localtime:ro polycubebot/${image_name}-pcn-iptables:${image_tag}"
380+
381+
# Launch the polycubed daemon
382+
\$polycubed /bin/sleep infinity
383+
384+
# Copy binaries, headers and libraries from docker to host fs
385+
sudo ./CI/extract_from_docker_image.sh $container
386+
387+
\$KILL_COMMAND
388+
389+
\$polycubed
390+
351391
cd tests/ && ./run-tests-iptables.sh || true
352392
export LC_ALL=C
353393
virtualenv venv -p python3
354394
. venv/bin/activate
355395
pip install -r converter/requirements.txt
356396
export TEST_RESULTS=`ls -1 test_results_*`
357397
python3 converter/to_junit.py Iptables
398+
cd ..
399+
400+
# Cleaning slave
401+
sudo ./CI/clean_slave.sh
358402
"""
359403
}
360404
}
@@ -367,7 +411,7 @@ pipeline {
367411
}
368412
script {
369413
sh """
370-
docker stop polycubed || true
414+
docker stop $container || true
371415
docker system prune --all --force
372416
"""
373417
}

CI/clean_slave.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# Removing binaries
3+
echo "# Removing binaries"
4+
echo "removing /usr/local/bin/pcn*"
5+
sudo rm -rf /usr/local/bin/pcn*
6+
echo "removing /usr/local/bin/polycube*"
7+
sudo rm -rf /usr/local/bin/polycube*
8+
echo "removing /usr/local/share/polycube"
9+
sudo rm -rf /usr/local/share/polycube
10+
# Removing headers
11+
echo "# Removing headers"
12+
echo "removing /usr/include/polycube"
13+
sudo rm -rf /usr/include/polycube
14+
# Removing libraries
15+
echo "# Removing libraries"
16+
for lib in $(ls /usr/lib | grep "libp"); do
17+
echo "removing /usr/lib/$lib"
18+
sudo rm -rf /usr/lib/$lib
19+
done
20+
for lib in $(ls /usr/local/lib | grep "lib"); do
21+
echo "removing /usr/local/lib/$lib"
22+
sudo rm -rf /usr/local/lib/$lib
23+
done
24+
for lib in $(ls /usr/lib/x86_64-linux-gnu/ | grep -P "libyang|libnl"); do
25+
echo "removing /usr/lib/x86_64-linux-gnu/$lib"
26+
sudo rm -rf /usr/lib/x86_64-linux-gnu/$lib
27+
done
28+
for lib in $(ls /lib/x86_64-linux-gnu/ | grep -P "libnl"); do
29+
echo "removing /lib/x86_64-linux-gnu/$lib"
30+
sudo rm -rf /lib/x86_64-linux-gnu/$lib
31+
done
32+
sudo ldconfig

CI/extract_from_docker_image.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
container="polycubed"
3+
if ! test -z "$1"
4+
then
5+
container=$1
6+
fi
7+
# Checking if the container is up
8+
docker ps
9+
# Copying binaries
10+
echo "# Copying binaries"
11+
echo "container content in /usr/local/bin:"
12+
docker exec $container /bin/ls /usr/local/bin
13+
echo "Copying $container:/usr/local/bin to /usr/local"
14+
sudo docker cp -a $container:/usr/local/bin /usr/local
15+
echo "container content in /usr/local/share/polycube:"
16+
docker exec $container /bin/ls /usr/local/share/polycube
17+
echo "Copying $container:/usr/local/share/polycube to /usr/local/share"
18+
sudo docker cp -a $container:/usr/local/share/polycube /usr/local/share
19+
# Copying headers
20+
echo "# Copying headers"
21+
echo "container content in /usr/include/polycube:"
22+
docker exec $container /bin/ls /usr/include/polycube
23+
echo "Copying $container:/usr/include/polycube to /usr/include"
24+
sudo mkdir -p /usr/include/polycube
25+
sudo docker cp -a $container:/usr/include/polycube /usr/include
26+
# Copying libraries
27+
echo "# Copying libraries"
28+
echo "container content in /usr/lib:"
29+
docker exec $container /bin/ls /usr/lib | /bin/grep "libp"
30+
for lib in $(docker exec $container ls /usr/lib | grep "libp"); do
31+
echo "Copying $container:/usr/lib/$lib to /usr/lib/"
32+
sudo docker cp $container:/usr/lib/$lib /usr/lib/
33+
done
34+
echo "container content in /usr/local/lib:"
35+
docker exec $container /bin/ls /usr/local/lib | /bin/grep "lib"
36+
for lib in $(docker exec $container ls /usr/local/lib | grep "lib"); do
37+
echo "Copying $container:/usr/local/lib/$lib to /usr/local/lib"
38+
sudo docker cp $container:/usr/local/lib/$lib /usr/local/lib
39+
done
40+
echo "container content in /usr/lib/x86_64-linux-gnu:"
41+
docker exec $container /bin/ls /usr/lib/x86_64-linux-gnu | /bin/grep -P "libyang|libnl"
42+
for lib in $(docker exec $container ls /usr/lib/x86_64-linux-gnu/ | grep -P "libyang|libnl"); do
43+
echo "Copying $container:/usr/lib/x86_64-linux-gnu/$lib to /usr/lib/x86_64-linux-gnu"
44+
sudo docker cp $container:/usr/lib/x86_64-linux-gnu/$lib /usr/lib/x86_64-linux-gnu
45+
done
46+
echo "container content in /lib/x86_64-linux-gnu:"
47+
docker exec $container /bin/ls /lib/x86_64-linux-gnu | /bin/grep -P "libnl"
48+
for lib in $(docker exec $container ls /lib/x86_64-linux-gnu | grep -P "libnl"); do
49+
echo "Copying $container:/lib/x86_64-linux-gnu/$lib to /lib/x86_64-linux-gnu"
50+
sudo docker cp $container:/lib/x86_64-linux-gnu/$lib /lib/x86_64-linux-gnu
51+
done
52+
# Copying base yang models
53+
echo "# Copying base yang models"
54+
echo "container content in /usr/local/include/polycube:"
55+
docker exec $container /bin/ls /usr/local/include/polycube
56+
sudo mkdir -p /usr/local/include/polycube
57+
echo "Copying $container:/usr/local/include/polycube to /usr/local/include/"
58+
sudo docker cp -a $container:/usr/local/include/polycube /usr/local/include/
59+
sudo ldconfig

src/services/pcn-iptables/test/local_test_interfaces1.sh renamed to src/services/pcn-iptables/test/flaky_local_test_interfaces1.sh

File renamed without changes.

src/services/pcn-iptables/test/local_test20_iptables.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ trap iptablescleanup EXIT
1717
function test_tcp {
1818
sudo ip netns exec ns2 netcat -l -w 5 $1&
1919
sleep 2
20-
sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 $1
20+
sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 $1
2121
sleep 4
2222
}
2323

2424
function test_tcp_fail {
2525
sudo ip netns exec ns2 netcat -l -w 5 $1&
2626
sleep 2
27-
test_fail sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 $1
27+
test_fail sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 $1
2828
sleep 4
2929
}
3030

src/services/pcn-iptables/test/local_test6_iptables.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ trap iptablescleanup EXIT
1717
function test_tcp {
1818
sudo ip netns exec ns2 netcat -l -w 5 60123&
1919
sleep 2
20-
sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 60123
20+
sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 60123
2121
sleep 4
2222
}
2323

2424
function test_tcp_fail {
2525
sudo ip netns exec ns2 netcat -l -w 5 60123&
2626
sleep 2
27-
test_fail sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 60123
27+
test_fail sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 60123
2828
sleep 4
2929
}
3030

src/services/pcn-iptables/test/local_test7_iptables.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ trap iptablescleanup EXIT
1717
function test_tcp {
1818
sudo ip netns exec ns2 netcat -l -w 5 60123&
1919
sleep 2
20-
sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 60123
20+
sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 60123
2121
sleep 4
2222
}
2323

2424
function test_tcp_fail {
2525
sudo ip netns exec ns2 netcat -l -w 5 60123&
2626
sleep 2
27-
test_fail sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 60123
27+
test_fail sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 60123
2828
sleep 4
2929
}
3030

src/services/pcn-iptables/test/local_test8_iptables.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ trap iptablescleanup EXIT
1717
function test_tcp {
1818
sudo ip netns exec ns2 netcat -l -w 5 60123&
1919
sleep 2
20-
sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 60123
20+
sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 60123
2121
sleep 4
2222
}
2323

2424
function test_tcp_fail {
2525
sudo ip netns exec ns2 netcat -l -w 5 60123&
2626
sleep 2
27-
test_fail sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 60123
27+
test_fail sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 60123
2828
sleep 4
2929
}
3030

src/services/pcn-iptables/test/local_test9_iptables.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ trap iptablescleanup EXIT
1717
function test_tcp {
1818
sudo ip netns exec ns2 netcat -l -w 5 60123&
1919
sleep 2
20-
sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 60123
20+
sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 60123
2121
sleep 4
2222
}
2323

2424
function test_tcp_fail {
2525
sudo ip netns exec ns2 netcat -l -w 5 60123&
2626
sleep 2
27-
test_fail sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 60123
27+
test_fail sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 60123
2828
sleep 4
2929
}
3030

src/services/pcn-iptables/test/local_test_conntrack_tcp_1.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ trap iptablescleanup EXIT
1414
function test_tcp {
1515
sudo ip netns exec ns2 netcat -l -w 5 $1&
1616
sleep 2
17-
sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 $1
17+
sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 $1
1818
sleep 4
1919
}
2020

2121
function test_tcp_fail {
2222
sudo ip netns exec ns2 netcat -l -w 5 $1&
2323
sleep 2
24-
test_fail sudo ip netns exec ns1 netcat -w 2 -nvz 10.0.2.1 $1
24+
test_fail sudo ip netns exec ns1 netcat -w 5 -nvz 10.0.2.1 $1
2525
sleep 4
2626
}
2727

0 commit comments

Comments
 (0)