-
Notifications
You must be signed in to change notification settings - Fork 0
/
doIt
executable file
·85 lines (75 loc) · 2.08 KB
/
doIt
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
#!/bin/bash
# This bash script builds, runs and tests podman images and containers for
# running go-searcher
removeContainer () {
if podman container exists go-searcher-test ; then
podman container rm go-searcher-test
fi
}
removeImage () {
removeContainer
if podman image exists go-searcher-test ; then
podman image rm go-searcher-test
fi
}
buildImage () {
rm -rf searcher/searcher
if ! podman image exists go-searcher-test ; then
podman build . --tag go-searcher-test
fi
}
runContainer () {
buildImage
rm -rf data/searcher.db
podman run -it \
--volume $(pwd)/config:/searcher/config \
--volume $(pwd)/files:/searcher/files \
--publish 127.0.0.1:9090:9090 \
--name go-searcher-test \
go-searcher-test -p 9090
}
testContainer () {
echo ""
echo "-------------------------------------------------------------------"
echo ""
echo "Should contain a 'search-result-link'"
echo ""
wget --post-data 'searchQueryStr=actively&searchQueryNum=10' -O - http://localhost:9090/ | grep Quantum
echo ""
echo "-------------------------------------------------------------------"
echo ""
echo "Should NOT contain a 'search-result-link'"
echo ""
wget --post-data 'searchQueryStr=notAWord&searchQueryNum=10' -O - http://localhost:9090/ | grep Quantum
echo ""
echo "-------------------------------------------------------------------"
echo ""
}
help () {
echo "usage: doIt <command>"
echo ""
echo "remove removes the go-searcher-test image"
echo "build builds the go-searcher-test image if it does not already exist"
echo "run runs a container using an existing go-searcher-test image"
echo "test runs and test a go-searcher-test based container"
}
if test $# -ne 1 ; then
echo "usage: doIt <command>"
exit 1
fi
if test $1 = "remove" ; then
removeImage
elif test $1 = "build" ; then
buildImage
elif test $1 = "run" ; then
runContainer
elif test $1 = "test" ; then
testContainer
elif test $1 = "help" ; then
help
else
echo "unrecognized command"
echo ""
help
exit 1
fi