Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit ae3a477

Browse files
committed
Merge pull request #202 from gnawux/test_hostname
test case for hostname field in pod spec
2 parents 447eca2 + b93c1d6 commit ae3a477

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed

hack/lib/test.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ hyper::test::run_attached_pod() {
5151
hyper run --rm -a -p $1
5252
}
5353

54+
hyper::test::hostname() {
55+
hname=$(hyper::test::run_attached_pod ${HYPER_ROOT}/hack/pods/hostname.pod | tr -d '\r')
56+
echo "hostname is ${hname}, expected myname"
57+
[ "${hname}x" != "mynamex" ] && return 1
58+
59+
echo "check long hostname"
60+
hyper::test::run_attached_pod ${HYPER_ROOT}/hack/pods/hostname-err-long.pod && return 1
61+
echo "check invalid hostname"
62+
hyper::test::run_attached_pod ${HYPER_ROOT}/hack/pods/hostname-err-char.pod && return 1
63+
64+
return 0
65+
}
66+
5467
hyper::test::insert_file() {
5568
res=0
5669
count=5

hack/pods/hostname-err-char.pod

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"id": "host-name-tester",
3+
"hostname": "/myname",
4+
"containers" : [{
5+
"name": "file-tester",
6+
"image": "busybox:latest",
7+
"workdir": "/",
8+
"command": ["hostname"]
9+
}],
10+
"resource": {
11+
"vcpu": 1,
12+
"memory": 512
13+
},
14+
"volumes": [],
15+
"tty": true
16+
}

hack/pods/hostname-err-long.pod

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"id": "host-name-tester",
3+
"hostname": "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn",
4+
"containers" : [{
5+
"name": "file-tester",
6+
"image": "busybox:latest",
7+
"workdir": "/",
8+
"command": ["hostname"]
9+
}],
10+
"resource": {
11+
"vcpu": 1,
12+
"memory": 512
13+
},
14+
"volumes": [],
15+
"tty": true
16+
}

hack/pods/hostname.pod

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"id": "host-name-tester",
3+
"hostname": "myname",
4+
"containers" : [{
5+
"name": "file-tester",
6+
"image": "busybox:latest",
7+
"workdir": "/",
8+
"command": ["hostname"]
9+
}],
10+
"resource": {
11+
"vcpu": 1,
12+
"memory": 512
13+
},
14+
"volumes": [],
15+
"tty": true
16+
}

hack/test-cmd.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ __EOF__
156156

157157
hyper::test::exitcode
158158
hyper::test::exec
159+
hyper::test::hostname
159160
hyper::test::insert_file
160161
hyper::test::map_file
161162
hyper::test::with_volume

0 commit comments

Comments
 (0)