Skip to content

Commit e8856cc

Browse files
committed
gh-41 update ci to run integration test
Signed-off-by: Victor Chang <[email protected]>
1 parent cdc2984 commit e8856cc

File tree

11 files changed

+447
-17
lines changed

11 files changed

+447
-17
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
working-directory: ./src
129129

130130
- name: Run Unit Test
131-
run: dotnet test -c ${{ env.BUILD_CONFIG }} -v=minimal --results-directory "${{ env.TEST_RESULTS }}" --collect:"XPlat Code Coverage" --settings coverlet.runsettings ${{ env.SOLUTION }}
131+
run: dotnet test --filter FullyQualifiedName\!~Monai.Deploy.InformaticsGateway.Integration.Test -c ${{ env.BUILD_CONFIG }} -v=minimal --results-directory "${{ env.TEST_RESULTS }}" --collect:"XPlat Code Coverage" --settings coverlet.runsettings ${{ env.SOLUTION }}
132132
working-directory: ./src
133133

134134
- uses: codecov/codecov-action@v2
@@ -259,6 +259,26 @@ jobs:
259259
sarif_file: ${{ steps.anchore-scan.outputs.sarif }}
260260
token: ${{ secrets.GITHUB_TOKEN }}
261261

262+
- name: Integration Test
263+
env:
264+
TAG: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
265+
if: ${{ (matrix.os == 'ubuntu-latest') }}
266+
run: |
267+
pushd tests/Integration.Test
268+
./run.sh
269+
popd
270+
271+
- name: Upload Integration Test Results
272+
uses: actions/[email protected]
273+
with:
274+
name: integration
275+
path: |
276+
tests/Integration.Test/LivingDoc.html
277+
tests/Integration.Test/metrics.log
278+
tests/Integration.Test/services.log
279+
retention-days: 30
280+
281+
262282
docs:
263283
runs-on: ubuntu-latest
264284
needs: [calc-version]

tests/Integration.Test/.env.dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TAG=0.1.1

tests/Integration.Test/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.run
2+
LivingDoc.html
3+
service.log
4+
metrics.log

tests/Integration.Test/Drivers/Configurations.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public Configurations(ISpecFlowOutputHelper outputHelper)
3838
StudySpecs = LoadStudySpecs() ?? throw new NullReferenceException("study.json not found or empty.");
3939
_config = new ConfigurationBuilder()
4040
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
41+
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT")}.json", optional: true, reloadOnChange: true)
4142
.Build();
4243

4344
LoadConfiguration();
@@ -143,7 +144,13 @@ public class InformaticsGatewaySettings
143144
/// <summary>
144145
/// Gets the API endpoint of the Informatics Gateway.
145146
/// </summary>
146-
public Uri ApiEndpoint => new Uri($"http://{Host}:{ApiPort}");
147+
public string ApiEndpoint
148+
{
149+
get
150+
{
151+
return $"http://{Host}:{ApiPort}";
152+
}
153+
}
147154
}
148155

149156
/// <summary>

tests/Integration.Test/Hooks/RabbitMqHooks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Monai.Deploy.InformaticsGateway.Integration.Test.Hooks
2323
public sealed class RabbitMqHooks
2424
{
2525
internal static readonly string ScenarioContextKey = "MESSAAGES";
26-
private readonly string QueueName = "TestQueue";
26+
private readonly string QueueName = "workflow-queue";
2727
private readonly ISpecFlowOutputHelper _outputHelper;
2828
private readonly Configurations _configuration;
2929
private readonly ScenarioContext _scenarioContext;

tests/Integration.Test/StepDefinitions/DicomDimseScpServicesStepDefinitions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public DicomDimseScpServicesStepDefinitions(
6767
_dicomScu = dicomScu ?? throw new ArgumentNullException(nameof(dicomScu));
6868
_informaticsGatewayClient = informaticsGatewayClient ?? throw new ArgumentNullException(nameof(informaticsGatewayClient));
6969
_rabbitMqHooks = rabbitMqHooks ?? throw new ArgumentNullException(nameof(rabbitMqHooks));
70-
_informaticsGatewayClient.ConfigureServiceUris(_configuration.InformaticsGatewayOptions.ApiEndpoint);
70+
_informaticsGatewayClient.ConfigureServiceUris(new Uri(_configuration.InformaticsGatewayOptions.ApiEndpoint));
7171
_dimseResponse = null;
7272
}
7373

@@ -252,7 +252,7 @@ public async Task ThenXXFilesUploadedToStorageService(int studyCount)
252252
var minioClient = new MinioClient(_configuration.StorageServiceOptions.Endpoint, _configuration.StorageServiceOptions.AccessKey, _configuration.StorageServiceOptions.AccessToken);
253253

254254
var dicomSizes = _scenarioContext[KeyDicomSizes] as Dictionary<string, long>;
255-
_rabbitMqHooks.MessageWaitHandle.Wait(MessageWaitTimeSpan);
255+
_rabbitMqHooks.MessageWaitHandle.Wait(MessageWaitTimeSpan).Should().BeTrue();
256256
var messages = _scenarioContext[RabbitMqHooks.ScenarioContextKey] as IList<Message>;
257257
messages.Should().NotBeNullOrEmpty();
258258

@@ -292,7 +292,7 @@ public void ThenWorkflowRequestSentToMessageBroker(int workflowCount)
292292
{
293293
Guard.Against.NegativeOrZero(workflowCount, nameof(workflowCount));
294294

295-
_rabbitMqHooks.MessageWaitHandle.Wait(MessageWaitTimeSpan);
295+
_rabbitMqHooks.MessageWaitHandle.Wait(MessageWaitTimeSpan).Should().BeTrue();
296296
var messages = _scenarioContext[RabbitMqHooks.ScenarioContextKey] as IList<Message>;
297297
var fileSpecs = _scenarioContext[KeyDicomFiles] as DicomInstanceGenerator.StudyGenerationSpecs;
298298

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
22
"TestRunnerSettings": {
3-
"HostIp": "192.168.50.155"
3+
"HostIp": "$HOST_IP"
44
},
55
"InformaticsGatewaySettings": {
6-
"temporaryDataStore": "~/.mig/data",
7-
"host": "192.168.50.209",
6+
"temporaryDataStore": "$DATA_PATH",
7+
"host": "$HOST_IP",
88
"dimsePort": 104,
99
"apiPort": 5000
1010
},
1111
"MessageBrokerSettings": {
12-
"endpoint": "192.168.50.155",
13-
"username": "mdig",
14-
"password": "helloworld",
15-
"virtualHost": "monaideploy",
12+
"endpoint": "$HOST_IP",
13+
"username": "rabbitmq",
14+
"password": "qmtibbar",
15+
"virtualHost": "/",
1616
"exchange": "monaideploy"
1717
},
1818
"StorageServiceSettings": {
19-
"host": "192.168.50.155",
19+
"host": "$HOST_IP",
2020
"port": 9000,
21-
"accessKey": "admin",
22-
"accessToken": "password",
23-
"storageServiceBucketName": "igbucket"
21+
"accessKey": "minioadmin",
22+
"accessToken": "minioadmin",
23+
"storageServiceBucketName": "monai"
2424
}
2525
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"ConnectionStrings": {
3+
"InformaticsGatewayDatabase": "Data Source=/database/mig.db"
4+
},
5+
"InformaticsGateway": {
6+
"dicom": {
7+
"scp": {
8+
"port": 104,
9+
"logDimseDatasets": false,
10+
"rejectUnknownSources": true
11+
},
12+
"scu": {
13+
"aeTitle": "MonaiSCU",
14+
"logDimseDatasets": false,
15+
"logDataPDUs": false
16+
}
17+
},
18+
"messaging": {
19+
"publisherSettings": {
20+
"endpoint": "rabbitmq",
21+
"username": "rabbitmq",
22+
"password": "qmtibbar",
23+
"virtualHost": "/",
24+
"exchange": "monaideploy"
25+
},
26+
"subscriberSettings": {
27+
"endpoint": "rabbitmq",
28+
"username": "rabbitmq",
29+
"password": "qmtibbar",
30+
"virtualHost": "/",
31+
"exchange": "monaideploy",
32+
"exportRequestQueue": "export_tasks"
33+
}
34+
},
35+
"storage": {
36+
"temporary": "/payloads",
37+
"storageServiceCredentials": {
38+
"endpoint": "minio:9000",
39+
"accessKey": "minioadmin",
40+
"accessToken": "minioadmin"
41+
},
42+
"securedConnection": false,
43+
"storageServiceBucketName": "monai"
44+
}
45+
},
46+
"Logging": {
47+
"LogLevel": {
48+
"Default": "Information",
49+
"Dicom": "Information",
50+
"System": "Warning",
51+
"Microsoft": "Warning",
52+
"Microsoft.EntityFrameworkCore": "Warning",
53+
"Microsoft.Hosting.Lifetime": "Warning",
54+
"Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker": "Error",
55+
"Monai": "Information"
56+
},
57+
"Console": {
58+
"FormatterName": "Simple",
59+
"FormatterOptions": {
60+
"ColorBehavior": "Disabled",
61+
"IncludeScopes": true,
62+
"SingleLine": false,
63+
"TimestampFormat": " HH:mm:ss ",
64+
"UseUtcTimestamp": true
65+
}
66+
},
67+
"File": {
68+
"BasePath": "logs",
69+
"FileEncodingName": "utf-8",
70+
"DateFormat": "yyyyMMdd",
71+
"CounterFormat": "000",
72+
"MaxFileSize": 10485760,
73+
"IncludeScopes": true,
74+
"MaxQueueSize": 100,
75+
"TextBuilderType": "Monai.Deploy.InformaticsGateway.Logging.FileLoggingTextFormatter, Monai.Deploy.InformaticsGateway",
76+
"Files": [
77+
{
78+
"Path": "MIG-<date>-<counter>.log"
79+
}
80+
]
81+
}
82+
},
83+
"Kestrel": {
84+
"EndPoints": {
85+
"Http": {
86+
"Url": "http://+:5000"
87+
}
88+
}
89+
},
90+
"AllowedHosts": "*",
91+
"Cli": {
92+
"Runner": "Docker",
93+
"HostDataStorageMount": "~/.mig/data",
94+
"HostDatabaseStorageMount": "~/.mig/database",
95+
"HostLogsStorageMount": "~/.mig/logs",
96+
"InformaticsGatewayServerEndpoint": "http://localhost:5000",
97+
"DockerImagePrefix": "ghcr.io/project-monai/monai-deploy-informatics-gateway"
98+
}
99+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"exchanges": [
3+
{
4+
"name": "monaideploy",
5+
"arguments": {},
6+
"auto_delete": false,
7+
"durable": true,
8+
"type": "topic",
9+
"vhost": "monaideploy"
10+
}
11+
],
12+
"users": [
13+
{
14+
"limits": {},
15+
"name": "rabbitmq",
16+
"password": "qmtibbar",
17+
"tags": [
18+
"administrator"
19+
]
20+
}
21+
],
22+
"vhosts": [
23+
{
24+
"name": "/"
25+
}
26+
],
27+
"permissions": [
28+
{
29+
"user": "rabbitmiq",
30+
"vhost": "/",
31+
"configure": ".*",
32+
"read": ".*",
33+
"write": ".*"
34+
}
35+
],
36+
"queues": [{
37+
"name": "workflow-queue",
38+
"vhost": "/",
39+
"durable": true,
40+
"auto_delete": false,
41+
"arguments": {
42+
"x-message-ttl": 3600000
43+
}
44+
}],
45+
"bindings": [{
46+
"source": "monaideploy",
47+
"vhost": "/",
48+
"destination": "workflow-queue",
49+
"destination_type": "queue",
50+
"routing_key": "md.workflow.request",
51+
"arguments": {}
52+
}]
53+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
version: "3.7"
2+
services:
3+
minio:
4+
image: "minio/minio:latest"
5+
command: server /data
6+
hostname: minio
7+
volumes:
8+
- ${PWD}/.run/minio/data:/data
9+
- ${PWD}/.run/minio/config:/root/.minio
10+
ports:
11+
- "9000:9000"
12+
environment:
13+
MINIO_ROOT_USER: minioadmin
14+
MINIO_ROOT_PASSWORD: minioadmin
15+
networks:
16+
- testrunner
17+
healthcheck:
18+
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
19+
interval: 30s
20+
timeout: 20s
21+
retries: 3
22+
23+
createbuckets:
24+
image: minio/mc
25+
environment:
26+
MINIO_ROOT_USER: minioadmin
27+
MINIO_ROOT_PASSWORD: minioadmin
28+
BUCKET_NAME: monai
29+
ENDPOINT: http://minio:9000
30+
depends_on:
31+
minio:
32+
condition: service_healthy
33+
networks:
34+
- testrunner
35+
entrypoint: >
36+
/bin/sh -c "
37+
until (/usr/bin/mc config host add myminio $$ENDPOINT $$MINIO_ROOT_USER $$MINIO_ROOT_PASSWORD) do echo '...waiting...' && sleep 1; done;
38+
/usr/bin/mc mb myminio/$$BUCKET_NAME;
39+
/usr/bin/mc policy set public myminio/$$BUCKET_NAME;
40+
/usr/bin/mc ls myminio;
41+
# exit 0
42+
"
43+
44+
rabbitmq:
45+
image: rabbitmq:latest
46+
hostname: rabbitmq
47+
ports:
48+
- 5672:5672
49+
- 15672:15672
50+
volumes:
51+
- ${PWD}/configs/rabbitmq.json:/etc/rabbitmq/definitions.json
52+
environment:
53+
RABBITMQ_DEFAULT_USER: rabbitmq
54+
RABBITMQ_DEFAULT_PASS: qmtibbar
55+
RABBITMQ_DEFAULT_VHOST: "/"
56+
networks:
57+
- testrunner
58+
healthcheck:
59+
test: rabbitmq-diagnostics -q ping
60+
interval: 30s
61+
timeout: 30s
62+
retries: 3
63+
64+
informatics-gateway:
65+
image: "ghcr.io/project-monai/monai-deploy-informatics-gateway:${TAG}"
66+
volumes:
67+
- ${PWD}/configs/informatics-gateway.json:/opt/monai/ig/appsettings.json
68+
- ${PWD}/.run/ig/payloads:/payloads
69+
- ${PWD}/.run/ig/database:/database
70+
ports:
71+
- "104:104"
72+
- "5000:5000"
73+
networks:
74+
- testrunner
75+
depends_on:
76+
minio:
77+
condition: service_healthy
78+
rabbitmq:
79+
condition: service_healthy
80+
links:
81+
- minio
82+
- rabbitmq
83+
84+
networks:
85+
testrunner:
86+
name: testrunner
87+
driver: bridge

0 commit comments

Comments
 (0)