-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest_export.bats
More file actions
114 lines (97 loc) · 3.18 KB
/
Copy pathtest_export.bats
File metadata and controls
114 lines (97 loc) · 3.18 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bats
export SYSTEM_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')"
export PROCFILE_BIN="build/$SYSTEM_NAME/procfile-util-amd64"
export TEST_FIXTURE="fixtures/export.Procfile"
setup_file() {
make prebuild $PROCFILE_BIN
}
teardown_file() {
make clean
}
setup() {
WORK_DIR="$(mktemp -d)"
}
teardown() {
rm -rf "$WORK_DIR"
}
@test "[export] systemd produces units accepted by systemd-analyze" {
run $PROCFILE_BIN export --procfile $TEST_FIXTURE --format systemd \
--location "$WORK_DIR" --app payments --formation web=2,worker=3
[ "$status" -eq 0 ]
for f in "$WORK_DIR"/etc/systemd/system/*.service "$WORK_DIR"/etc/systemd/system/*.target; do
run systemd-analyze verify "$f"
echo "file: $f"
echo "output: $output"
[ "$status" -eq 0 ]
[[ "$output" != *"Failed to parse"* ]]
[[ "$output" != *"marked executable"* ]]
done
}
@test "[export] systemd-user produces units accepted by systemd-analyze" {
run $PROCFILE_BIN export --procfile $TEST_FIXTURE --format systemd-user \
--location "$WORK_DIR" --app payments --formation web=2,worker=3
[ "$status" -eq 0 ]
for f in "$WORK_DIR"/home/*/.config/systemd/user/*.service; do
run systemd-analyze verify "$f"
echo "file: $f"
echo "output: $output"
[ "$status" -eq 0 ]
[[ "$output" != *"Failed to parse"* ]]
[[ "$output" != *"marked executable"* ]]
done
}
@test "[export] sysv init scripts pass shellcheck and bash -n" {
run $PROCFILE_BIN export --procfile $TEST_FIXTURE --format sysv \
--location "$WORK_DIR" --app payments --formation web=2,worker=3
[ "$status" -eq 0 ]
for f in "$WORK_DIR"/etc/init.d/*; do
run bash -n "$f"
echo "file: $f"
echo "output: $output"
[ "$status" -eq 0 ]
run shellcheck -S error "$f"
echo "output: $output"
[ "$status" -eq 0 ]
done
}
@test "[export] upstart conf files contain required stanzas" {
run $PROCFILE_BIN export --procfile $TEST_FIXTURE --format upstart \
--location "$WORK_DIR" --app payments --formation web=2,worker=3
[ "$status" -eq 0 ]
for f in "$WORK_DIR"/etc/init/*.conf; do
run grep -q '^start on' "$f"
echo "file: $f"
[ "$status" -eq 0 ]
done
}
@test "[export] runit run scripts pass shellcheck and bash -n" {
run $PROCFILE_BIN export --procfile $TEST_FIXTURE --format runit \
--location "$WORK_DIR" --app payments --formation web=2,worker=3
[ "$status" -eq 0 ]
for f in "$WORK_DIR"/service/*/run "$WORK_DIR"/service/*/log/run; do
run bash -n "$f"
echo "file: $f"
echo "output: $output"
[ "$status" -eq 0 ]
run shellcheck -S error "$f"
echo "output: $output"
[ "$status" -eq 0 ]
done
}
@test "[export] launchd plists are well-formed" {
run $PROCFILE_BIN export --procfile $TEST_FIXTURE --format launchd \
--location "$WORK_DIR" --app payments --formation web=2,worker=3
[ "$status" -eq 0 ]
for f in "$WORK_DIR"/Library/LaunchDaemons/*.plist; do
if command -v plutil >/dev/null 2>&1; then
run plutil -lint "$f"
elif command -v plistutil >/dev/null 2>&1; then
run plistutil -i "$f" -o /dev/null
else
run xmllint --noout "$f"
fi
echo "file: $f"
echo "output: $output"
[ "$status" -eq 0 ]
done
}