forked from RedHatInsights/insights-operator-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-postgres.sh
executable file
·54 lines (44 loc) · 1.12 KB
/
test-postgres.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
#!/usr/bin/env bash
go build
if [ $? -eq 0 ]
then
echo "Service build ok"
else
echo "Build failed"
exit 1
fi
go build -o rest-api-tests tests/rest_api_tests.go
if [ $? -eq 0 ]
then
echo "REST API tests build ok"
else
echo "Build failed"
exit 1
fi
echo "Creating test database"
rm -f test.db
./local_storage/drop_test_database_postgres.sh
./local_storage/create_test_database_postgres.sh
echo "Done"
echo "Starting service"
./insights-operator-controller --dbdriver=postgres --storage=postgres://postgres:postgres@localhost/test_db?sslmode=disable &
PID=$(echo $!)
if [ $? -eq 0 ]
then
echo "Service started, PID=$PID"
sleep 2
echo -e "------------------------------------------------------------------------------------------------"
./rest-api-tests
EXIT_VALUE=$?
echo -e "------------------------------------------------------------------------------------------------"
kill $PID
if [ $? -eq 0 ]
then
echo "Service killed, PID=$PID"
else
echo "Fatal, can not kill a service process"
fi
else
echo "Fatal, can not start service"
fi
exit $EXIT_VALUE