Skip to content

Commit af0e823

Browse files
committed
Update test run script
Signed-off-by: Victor Chang <[email protected]>
1 parent 6402da2 commit af0e823

File tree

6 files changed

+26
-193
lines changed

6 files changed

+26
-193
lines changed

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.400",
3+
"version": "6.0.110",
44
"rollForward": "latestFeature"
55
}
6-
}
6+
}

src/InformaticsGateway/Logging/Log.100.200.ScpService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public static partial class Log
5959
public static partial void NotifyAeChanged(this ILogger logger, int count, ChangedEventType eventType);
6060

6161
// SCP Service
62-
[LoggerMessage(EventId = 200, Level = LogLevel.Information, Message = "MONAI Deploy Informatics Gateway (SCP Service) {version} loading...")]
63-
public static partial void ScpServiceLoading(this ILogger logger, string version);
62+
[LoggerMessage(EventId = 200, Level = LogLevel.Information, Message = "Initializing SCP Service at port {port}...")]
63+
public static partial void ScpServiceLoading(this ILogger logger, int port);
6464

6565
[LoggerMessage(EventId = 201, Level = LogLevel.Critical, Message = "Failed to initialize SCP listener.")]
6666
public static partial void ScpListenerInitializationFailure(this ILogger logger);

src/InformaticsGateway/Services/Scp/ScpService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void Dispose()
7878

7979
public Task StartAsync(CancellationToken cancellationToken)
8080
{
81-
_logger.ScpServiceLoading(Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version);
81+
_logger.ScpServiceLoading(_configuration.Value.Dicom.Scp.Port);
8282

8383
try
8484
{

tests/Integration.Test/.env.dev

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/Integration.Test/docker-compose.yml

Lines changed: 0 additions & 123 deletions
This file was deleted.

tests/Integration.Test/run.sh

Lines changed: 21 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
export VSTEST_HOST_DEBUG=0
1919

2020
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"
2123
TEST_DIR="$SCRIPT_DIR/"
2224
LOG_DIR="${GITHUB_WORKSPACE:-$SCRIPT_DIR}"
23-
RUN_DIR="$SCRIPT_DIR/.run"
2425
BIN_DIR="$TEST_DIR/bin/Release/net6.0"
2526
CONFIG_DIR="$SCRIPT_DIR/configs"
2627
EXIT=false
2728
METRICSFILE="$LOG_DIR/metrics.log"
28-
LOADDEV=
2929
FEATURE=
3030
STREAMID=
3131
export STUDYJSON="study.json"
@@ -51,6 +51,7 @@ function check_status_code() {
5151
}
5252

5353
function env_setup() {
54+
[ -f $LOG_DIR/run.log ] && info "Deletig existing $LOG_DIR/run.log" && sudo rm $LOG_DIR/run.log
5455
[ -d $RUN_DIR ] && info "Removing $RUN_DIR..." && sudo rm -r $RUN_DIR
5556
mkdir -p $RUN_DIR
5657

@@ -70,13 +71,6 @@ function env_setup() {
7071
info "Filtering by feature=$FEATURE"
7172
shift 2
7273
;;
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-
;;
8074
--)
8175
shift;
8276
break
@@ -87,10 +81,12 @@ function env_setup() {
8781
esac
8882
done
8983

84+
pushd $DOCKER_COMPOSE_DIR
9085
if [[ $(docker compose ps -q | wc -l) -ne 0 ]]; then
9186
info "Stopping existing services..."
92-
docker compose $LOADDEV down
87+
docker compose down
9388
fi
89+
popd
9490

9591
if (dotnet tool list --global | grep livingdoc &>/dev/null); then
9692
info "Upgrading SpecFlow.Plus.LivingDoc.CLI..."
@@ -110,63 +106,26 @@ function build() {
110106
}
111107

112108
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
119114

120115
info "============================================="
121-
docker container ls --format 'table {{.Names}}\t{{.ID}}' | grep integrationtest
116+
docker container ls --format 'table {{.Names}}\t{{.ID}}' | grep igtest-
122117
info "============================================="
123118

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-
142119
sleep 1
143120
sudo chown -R $USER:$USER $RUN_DIR
144121
}
145122

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-
164123
function run_test() {
165124
pushd $TEST_DIR
166125
set +e
167126
info "Starting test runner..."
168127

169-
if [[ "$VSTEST_HOST_DEBUG" == 0 ]]; then
128+
if [[ "$VSTEST_HOST_DEBUG" == 0 ]]; then
170129
dotnet test -c Release $FEATURE 2>&1 | tee $LOG_DIR/run.log
171130
else
172131
dotnet test -c Debug $FEATURE 2>&1 | tee $LOG_DIR/run.log
@@ -189,31 +148,29 @@ function generate_reports() {
189148

190149
function save_logs() {
191150
[ -d $RUN_DIR ] && info "Clearning $RUN_DIR..." && sudo rm -r $RUN_DIR
151+
pushd $DOCKER_COMPOSE_DIR
192152
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
194155
}
195156

196157
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
202159
info "Stopping services..."
203-
docker compose $LOADDEV down --remove-orphans
160+
docker compose down --remove-orphans
161+
popd
204162
}
205163

206164
function main() {
207165
df -h
208166
env_setup "$@"
209167
build
210168
start_services
211-
stream_da_metrics
212169
run_test
213170
generate_reports
214171
df -h
215-
save_logs
216-
tear_down
172+
# save_logs
173+
# tear_down
217174
exit $EXITCODE
218175
}
219176

0 commit comments

Comments
 (0)