18
18
export VSTEST_HOST_DEBUG=0
19
19
20
20
export SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " > /dev/null && pwd) "
21
+ DOCKER_COMPOSE_DIR=" $SCRIPT_DIR /../../docker-compose"
22
+ RUN_DIR=" $DOCKER_COMPOSE_DIR /.run"
21
23
TEST_DIR=" $SCRIPT_DIR /"
22
24
LOG_DIR=" ${GITHUB_WORKSPACE:- $SCRIPT_DIR } "
23
- RUN_DIR=" $SCRIPT_DIR /.run"
24
25
BIN_DIR=" $TEST_DIR /bin/Release/net6.0"
25
26
CONFIG_DIR=" $SCRIPT_DIR /configs"
26
27
EXIT=false
27
28
METRICSFILE=" $LOG_DIR /metrics.log"
28
- LOADDEV=
29
29
FEATURE=
30
30
STREAMID=
31
31
export STUDYJSON=" study.json"
@@ -51,6 +51,7 @@ function check_status_code() {
51
51
}
52
52
53
53
function env_setup() {
54
+ [ -f $LOG_DIR /run.log ] && info " Deletig existing $LOG_DIR /run.log" && sudo rm $LOG_DIR /run.log
54
55
[ -d $RUN_DIR ] && info " Removing $RUN_DIR ..." && sudo rm -r $RUN_DIR
55
56
mkdir -p $RUN_DIR
56
57
@@ -70,13 +71,6 @@ function env_setup() {
70
71
info " Filtering by feature=$FEATURE "
71
72
shift 2
72
73
;;
73
- -d | --dev )
74
- info " Using .env.dev..."
75
- LOADDEV=" --env-file .env.dev"
76
- info " Using study.json.dev..."
77
- STUDYJSON=" study.json.dev"
78
- shift ;
79
- ;;
80
74
--)
81
75
shift ;
82
76
break
@@ -87,10 +81,12 @@ function env_setup() {
87
81
esac
88
82
done
89
83
84
+ pushd $DOCKER_COMPOSE_DIR
90
85
if [[ $( docker compose ps -q | wc -l) -ne 0 ]]; then
91
86
info " Stopping existing services..."
92
- docker compose $LOADDEV down
87
+ docker compose down
93
88
fi
89
+ popd
94
90
95
91
if (dotnet tool list --global | grep livingdoc & > /dev/null); then
96
92
info " Upgrading SpecFlow.Plus.LivingDoc.CLI..."
@@ -110,63 +106,26 @@ function build() {
110
106
}
111
107
112
108
function start_services() {
113
- info " Starting dependencies docker compose $LOADDEV up -d --force-recreate..."
114
- docker compose $LOADDEV up -d --force-recreate
115
-
116
- HOST_IP=$( docker network inspect testrunner | jq -r .[0].IPAM.Config[0].Gateway)
117
- info " Host IP = $HOST_IP "
118
- export HOST_IP
109
+ info " Starting dependencies docker compose up -d --force-recreate..."
110
+ pushd $DOCKER_COMPOSE_DIR
111
+ ./init.sh
112
+ docker compose -p igtest up -d --force-recreate
113
+ popd
119
114
120
115
info " ============================================="
121
- docker container ls --format ' table {{.Names}}\t{{.ID}}' | grep integrationtest
116
+ docker container ls --format ' table {{.Names}}\t{{.ID}}' | grep igtest-
122
117
info " ============================================="
123
118
124
- set +e
125
- COUNTER=0
126
- EXPECTEDSERVICE=8
127
- while true ; do
128
- info " Waiting for Informatics Gateway ($COUNTER )..."
129
- count=$( curl -s http://$HOST_IP :5000/health/status | jq | grep " running" | wc -l)
130
- info " $count services running..."
131
- if [ $count -eq $EXPECTEDSERVICE ]; then
132
- break
133
- fi
134
- if [ $COUNTER -gt 100 ]; then
135
- fatal " Timeout waiting for Informatics Gateway services to be ready ($COUNTER /$EXPECTEDSERVICE )."
136
- fi
137
- let COUNTER=COUNTER+1
138
- sleep 1s
139
- done
140
- set -e
141
-
142
119
sleep 1
143
120
sudo chown -R $USER :$USER $RUN_DIR
144
121
}
145
122
146
- function write_da_metrics() {
147
- docker container list
148
- CID=" $( docker container list | grep informatics-gateway | awk ' {{print $1}}' ) "
149
- info " Streaming Informatics Gateway perf logs from container $CID to $METRICSFILE "
150
-
151
- until $EXIT ; do
152
- DATA=$( docker stats $CID --no-stream --format " $( date +%s) ,{{.CPUPerc}},{{.MemUsage}},{{.NetIO}},{{.BlockIO}}" )
153
- echo $DATA >> $METRICSFILE
154
- sleep 1
155
- done
156
- }
157
-
158
- function stream_da_metrics() {
159
- [ -f $METRICSFILE ] && sudo rm $METRICSFILE
160
- write_da_metrics &
161
- STREAMID=$!
162
- }
163
-
164
123
function run_test() {
165
124
pushd $TEST_DIR
166
125
set +e
167
126
info " Starting test runner..."
168
127
169
- if [[ " $VSTEST_HOST_DEBUG " == 0 ]]; then
128
+ if [[ " $VSTEST_HOST_DEBUG " == 0 ]]; then
170
129
dotnet test -c Release $FEATURE 2>&1 | tee $LOG_DIR /run.log
171
130
else
172
131
dotnet test -c Debug $FEATURE 2>&1 | tee $LOG_DIR /run.log
@@ -189,31 +148,29 @@ function generate_reports() {
189
148
190
149
function save_logs() {
191
150
[ -d $RUN_DIR ] && info " Clearning $RUN_DIR ..." && sudo rm -r $RUN_DIR
151
+ pushd $DOCKER_COMPOSE_DIR
192
152
info " Saving service log..."
193
- docker compose $LOADDEV logs --no-color -t > " $LOG_DIR /services.log"
153
+ docker compose logs --no-color -t > " $LOG_DIR /services.log"
154
+ popd
194
155
}
195
156
196
157
function tear_down() {
197
- set +e
198
- info " Stop streaming metrics log..."
199
- kill $STREAMID > /dev/null 2>&1
200
- set -e
201
-
158
+ pushd $DOCKER_COMPOSE_DIR
202
159
info " Stopping services..."
203
- docker compose $LOADDEV down --remove-orphans
160
+ docker compose down --remove-orphans
161
+ popd
204
162
}
205
163
206
164
function main() {
207
165
df -h
208
166
env_setup " $@ "
209
167
build
210
168
start_services
211
- stream_da_metrics
212
169
run_test
213
170
generate_reports
214
171
df -h
215
- save_logs
216
- tear_down
172
+ # save_logs
173
+ # tear_down
217
174
exit $EXITCODE
218
175
}
219
176
0 commit comments