File tree Expand file tree Collapse file tree 8 files changed +48
-132
lines changed Expand file tree Collapse file tree 8 files changed +48
-132
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ source $SRCDIR /utils.sh
4+
35test_redis_nomad_job () {
46 pushd ~ /go/src/github.com/Roblox/nomad-driver-containerd/example
57
@@ -16,7 +18,7 @@ test_redis_nomad_job() {
1618 # The actual container process might not be running yet.
1719 # We need to wait for actual container to start running before trying exec.
1820 echo " INFO: Wait for redis container to get into RUNNING state, before trying exec."
19- is_redis_container_active
21+ is_container_active redis false
2022
2123 echo " INFO: Inspecting redis job."
2224 redis_status=$( nomad job inspect redis| jq -r ' .Job .Status' )
@@ -53,24 +55,4 @@ test_redis_nomad_job() {
5355 popd
5456}
5557
56- is_redis_container_active () {
57- i=" 0"
58- while test $i -lt 5
59- do
60- sudo CONTAINERD_NAMESPACE=nomad ctr task ls| grep -q RUNNING
61- if [ $? -eq 0 ]; then
62- echo " INFO: redis container is up and running"
63- break
64- fi
65- echo " INFO: redis container is down, sleep for 4 seconds."
66- sleep 4s
67- i=$[$i +1]
68- done
69-
70- if [ $i -ge 5 ]; then
71- echo " ERROR: redis container didn't come up. exit 1."
72- exit 1
73- fi
74- }
75-
7658test_redis_nomad_job
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ source $SRCDIR /utils.sh
4+
35test_signal_handler_nomad_job () {
46 pushd ~ /go/src/github.com/Roblox/nomad-driver-containerd/example
57
@@ -24,7 +26,7 @@ test_signal_handler_nomad_job() {
2426 # The actual container process might not be running yet.
2527 # We need to wait for actual container to start running before trying to send invalid signal.
2628 echo " INFO: Wait for signal container to get into RUNNING state, before trying to send invalid signal."
27- is_signal_container_active
29+ is_container_active signal false
2830
2931 echo " INFO: Test invalid signal."
3032 alloc_id=$( nomad job status signal| awk ' END{print}' | cut -d ' ' -f 1)
@@ -55,24 +57,4 @@ cleanup() {
5557 rm $tmpfile > /dev/null 2>&1
5658}
5759
58- is_signal_container_active () {
59- i=" 0"
60- while test $i -lt 5
61- do
62- sudo CONTAINERD_NAMESPACE=nomad ctr task ls| grep -q RUNNING
63- if [ $? -eq 0 ]; then
64- echo " INFO: signal container is up and running"
65- break
66- fi
67- echo " INFO: signal container is down, sleep for 4 seconds."
68- sleep 4s
69- i=$[$i +1]
70- done
71-
72- if [ $i -ge 5 ]; then
73- echo " ERROR: signal container didn't come up. exit 1."
74- exit 1
75- fi
76- }
77-
7860test_signal_handler_nomad_job
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ source $SRCDIR /utils.sh
4+
35# readonly_rootfs, cap_add and cap_drop flags are tested as part of this test.
46test_capabilities_nomad_job () {
57 pushd ~ /go/src/github.com/Roblox/nomad-driver-containerd/example
@@ -18,7 +20,7 @@ test_capabilities_nomad_job() {
1820 # The actual container process might not be running yet.
1921 # We need to wait for actual container to start running before trying exec.
2022 echo " INFO: Wait for capabilities container to get into RUNNING state, before trying exec."
21- is_capabilities_container_active
23+ is_container_active capabilities true
2224
2325 echo " INFO: Inspecting capabilities job."
2426 cap_status=$( nomad job inspect capabilities| jq -r ' .Job .Status' )
@@ -74,25 +76,4 @@ cleanup() {
7476 rm $tmpfile > /dev/null 2>&1
7577}
7678
77- is_capabilities_container_active () {
78- i=" 0"
79- while test $i -lt 5
80- do
81- sudo CONTAINERD_NAMESPACE=nomad ctr task ls| grep -q RUNNING
82- if [ $? -eq 0 ]; then
83- echo " INFO: capabilities container is up and running"
84- sleep 5s
85- break
86- fi
87- echo " INFO: capabilities container is down, sleep for 4 seconds."
88- sleep 4s
89- i=$[$i +1]
90- done
91-
92- if [ $i -ge 5 ]; then
93- echo " ERROR: capabilities container didn't come up. exit 1."
94- exit 1
95- fi
96- }
97-
9879test_capabilities_nomad_job
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ source $SRCDIR /utils.sh
4+
35# privileged mode, devices and mounts are tested as part of this test.
46test_privileged_nomad_job () {
57 pushd ~ /go/src/github.com/Roblox/nomad-driver-containerd/example
@@ -20,7 +22,7 @@ test_privileged_nomad_job() {
2022 # The actual container process might not be running yet.
2123 # We need to wait for actual container to start running before trying exec.
2224 echo " INFO: Wait for privileged container to get into RUNNING state, before trying exec."
23- is_privileged_container_active
25+ is_container_active privileged true
2426
2527 echo " INFO: Inspecting privileged job."
2628 job_status=$( nomad job inspect privileged| jq -r ' .Job .Status' )
@@ -73,25 +75,4 @@ setup_bind_source() {
7375 echo hello > /tmp/s1/bind.txt
7476}
7577
76- is_privileged_container_active () {
77- i=" 0"
78- while test $i -lt 5
79- do
80- sudo CONTAINERD_NAMESPACE=nomad ctr task ls| grep -q RUNNING
81- if [ $? -eq 0 ]; then
82- echo " INFO: privileged container is up and running"
83- sleep 5s
84- break
85- fi
86- echo " INFO: privileged container is down, sleep for 4 seconds."
87- sleep 4s
88- i=$[$i +1]
89- done
90-
91- if [ $i -ge 5 ]; then
92- echo " ERROR: privileged container didn't come up. exit 1."
93- exit 1
94- fi
95- }
96-
9778test_privileged_nomad_job
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ source $SRCDIR /utils.sh
4+
35job_name=volume_mount
46host_volume_path=/tmp/host_volume/s1
57
@@ -16,7 +18,7 @@ test_volume_mount_nomad_job() {
1618 # The actual container process might not be running yet.
1719 # We need to wait for actual container to start running before trying exec.
1820 echo " INFO: Wait for ${job_name} container to get into RUNNING state, before trying exec."
19- is_ ${job_name} _container_active
21+ is_container_active ${job_name} true
2022
2123 echo " INFO: Checking status of $job_name job."
2224 job_status=$( nomad job status -short $job_name | grep Status| awk ' {split($0,a,"="); print a[2]}' | tr -d ' ' )
@@ -71,25 +73,4 @@ setup_bind_source() {
7173 echo hello > ${host_volume_path} /bind.txt
7274}
7375
74- is_volume_mount_container_active () {
75- i=" 0"
76- while test $i -lt 5
77- do
78- sudo CONTAINERD_NAMESPACE=nomad ctr task ls| grep -q RUNNING
79- if [ $? -eq 0 ]; then
80- echo " INFO: ${job_name} container is up and running"
81- sleep 5s
82- break
83- fi
84- echo " INFO: ${job_name} container is down, sleep for 4 seconds."
85- sleep 4s
86- i=$[$i +1]
87- done
88-
89- if [ $i -ge 5 ]; then
90- echo " ERROR: ${job_name} container didn't come up. exit 1."
91- exit 1
92- fi
93- }
94-
9576test_volume_mount_nomad_job
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ source $SRCDIR /utils.sh
4+
35job_name=dns
46
57test_dns_nomad_job () {
@@ -12,7 +14,7 @@ test_dns_nomad_job() {
1214 # The actual container process might not be running yet.
1315 # We need to wait for actual container to start running before trying exec.
1416 echo " INFO: Wait for ${job_name} container to get into RUNNING state, before trying exec."
15- is_ ${job_name} _container_active
17+ is_container_active ${job_name} true
1618
1719 echo " INFO: Checking status of $job_name job."
1820 job_status=$( nomad job status -short $job_name | grep Status| awk ' {split($0,a,"="); print a[2]}' | tr -d ' ' )
@@ -58,25 +60,4 @@ test_dns_nomad_job() {
5860 popd
5961}
6062
61- is_dns_container_active () {
62- i=" 0"
63- while test $i -lt 5
64- do
65- sudo CONTAINERD_NAMESPACE=nomad ctr task ls| grep -q RUNNING
66- if [ $? -eq 0 ]; then
67- echo " INFO: ${job_name} container is up and running"
68- sleep 5s
69- break
70- fi
71- echo " INFO: ${job_name} container is down, sleep for 4 seconds."
72- sleep 4s
73- i=$[$i +1]
74- done
75-
76- if [ $i -ge 5 ]; then
77- echo " ERROR: ${job_name} container didn't come up. exit 1."
78- exit 1
79- fi
80- }
81-
8263test_dns_nomad_job
Original file line number Diff line number Diff line change 1212 export GOPATH=$HOME /go
1313fi
1414export GO_VERSION=1.14.3
15+ export SRCDIR=` dirname $0 `
16+ source $SRCDIR /utils.sh
1517
1618# Keeps track of overall pass/failure status of tests. Even if single test
1719# fails, PASS_STATUS will be set to 1 and returned to caller when all
@@ -47,11 +49,10 @@ run_test () {
4749}
4850
4951run_tests () {
50- local srcdir=` dirname $0 `
5152 if [ $# -gt 0 ]; then
5253 local files=$@
5354 else
54- local files=" $srcdir /[0-9][0-9][0-9]-test-*"
55+ local files=" $SRCDIR /[0-9][0-9][0-9]-test-*"
5556 fi
5657 for t in $files ; do
5758 run_test ./$t
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ is_container_active () {
4+ local job_name=$1
5+ local is_sleep=$2
6+
7+ i=" 0"
8+ while test $i -lt 5
9+ do
10+ sudo CONTAINERD_NAMESPACE=nomad ctr task ls| grep -q RUNNING
11+ if [ $? -eq 0 ]; then
12+ echo " INFO: ${job_name} container is up and running"
13+ if [ " $is_sleep " = true ]; then
14+ sleep 5s
15+ fi
16+ break
17+ fi
18+ echo " INFO: ${job_name} container is down, sleep for 4 seconds."
19+ sleep 4s
20+ i=$[$i +1]
21+ done
22+
23+ if [ $i -ge 5 ]; then
24+ echo " ERROR: ${job_name} container didn't come up. exit 1."
25+ exit 1
26+ fi
27+ }
You can’t perform that action at this time.
0 commit comments