-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e.sh
executable file
·89 lines (72 loc) · 2.43 KB
/
e2e.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
# this is just an ugly script to do some simple e2e test
# for locally running server/client
# TODO:
# add missing tests for
# - make request to endpoint without certificate
# - use invalid certificate
# - use multiple clients and verify that they only observe their own jobs
cargo build
target/debug/rcmd_server tls-certs &> /dev/null &
server_pid=$!
sleep 2
assert_eq() {
expected=$1
got=$2
if [[ "${expected}" == "${got}" ]]; then
echo Ok
else
echo "Fail, expected ${expected}, got ${got}"
fi
}
echo "TEST: create echo job"
output=$(target/debug/rcmd_client tls-certs localhost exec echo hi)
expected="0"
assert_eq "${expected}" "${output}"
echo "TEST: list jobs"
output=$(target/debug/rcmd_client tls-certs localhost list)
expected="0: echo hi"
assert_eq "${expected}" "${output}"
sleep 0.1
echo "TEST: status echo job"
output=$(target/debug/rcmd_client tls-certs localhost status 0)
expected="Completed { exit_code: 0 }"
assert_eq "${expected}" "${output}"
echo "TEST output echo job"
output=$(target/debug/rcmd_client tls-certs localhost output 0)
expected=$'___STDOUT___\nhi\n___STDERR___'
assert_eq "${expected}" "${output}"
echo "TEST delete echo job"
output=$(target/debug/rcmd_client tls-certs localhost delete 0)
expected="0 deleted"
assert_eq "${expected}" "${output}"
echo "TEST status deleted job"
output=$(target/debug/rcmd_client tls-certs localhost status 0)
expected="Job not found"
assert_eq "${expected}" "${output}"
echo "TEST output deleted job"
output=$(target/debug/rcmd_client tls-certs localhost output 0)
expected="Job not found"
assert_eq "${expected}" "${output}"
echo "TEST delete deleted job"
output=$(target/debug/rcmd_client tls-certs localhost delete 0)
expected="Job not found"
assert_eq "${expected}" "${output}"
echo "TEST: create sleep job"
output=$(target/debug/rcmd_client tls-certs localhost exec sleep 2)
expected="1"
assert_eq "${expected}" "${output}"
echo "TEST: status sleep job"
output=$(target/debug/rcmd_client tls-certs localhost status 1)
expected="Running"
assert_eq "${expected}" "${output}"
echo "TEST: create invalid job"
output=$(target/debug/rcmd_client tls-certs localhost exec aldjfiowed)
expected="2"
assert_eq "${expected}" "${output}"
echo "TEST: status invalid job"
output=$(target/debug/rcmd_client tls-certs localhost status 2)
expected="Error { msg: \"No such file or directory (os error 2)\" }"
assert_eq "${expected}" "${output}"
kill -2 $server_pid
wait $server_pid