Skip to content

Commit b390ff4

Browse files
entrypoint: Add integration test.
1 parent b93e718 commit b390ff4

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

example/entrypoint.nomad

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
job "entrypoint" {
2+
datacenters = ["dc1"]
3+
4+
group "entrypoint-group" {
5+
task "entrypoint-task" {
6+
driver = "containerd-driver"
7+
8+
config {
9+
image = "ubuntu:16.04"
10+
entrypoint = ["/bin/echo"]
11+
args = ["container1", "container2"]
12+
}
13+
14+
resources {
15+
cpu = 500
16+
memory = 256
17+
}
18+
}
19+
}
20+
}

tests/008-test-entrypoint.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
source $SRCDIR/utils.sh
4+
5+
job_name=entrypoint
6+
7+
test_entrypoint_nomad_job() {
8+
pushd ~/go/src/github.com/Roblox/nomad-driver-containerd/example
9+
10+
echo "INFO: Starting nomad $job_name job using nomad-driver-containerd."
11+
nomad job run $job_name.nomad
12+
13+
# Even though $(nomad job status) reports job status as "running"
14+
# The actual container process might not be running yet.
15+
# We need to wait for actual container to start running before executing $(nomad alloc logs).
16+
echo "INFO: Wait for ${job_name} container to get into RUNNING state."
17+
is_container_active ${job_name} true
18+
19+
echo "INFO: Checking status of $job_name job."
20+
job_status=$(nomad job status -short $job_name|grep Status|awk '{split($0,a,"="); print a[2]}'|tr -d ' ')
21+
if [ "$job_status" != "running" ];then
22+
echo "ERROR: Error in getting ${job_name} job status."
23+
return 1
24+
fi
25+
26+
output=$(nomad logs -job ${job_name})
27+
for result in "container1" "container2" ; do
28+
echo -e "$output" |grep "$result" &>/dev/null
29+
if [ $? -ne 0 ];then
30+
echo "ERROR: $result not found in the output."
31+
return 1
32+
fi
33+
done
34+
35+
echo "INFO: purge nomad ${job_name} job."
36+
nomad job stop -purge ${job_name}
37+
popd
38+
}
39+
40+
test_entrypoint_nomad_job
File renamed without changes.

0 commit comments

Comments
 (0)