-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improved logging and added e2e tests (#7)
* feat: improved logging * test(e2e): added e2e tests * chore: formatted
- Loading branch information
Showing
11 changed files
with
507 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"config:recommended" | ||
] | ||
"extends": ["config:recommended"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"resourceType":"Patient","id":"pid.999","meta":{"source":"#p21"},"identifier":[{"use":"usual","type":{"coding":[{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"MR"}]},"system":"https://miracum.org/fhir/NamingSystem/identifier/PatientId","value":"pid.999"},{"use":"official","type":{"coding":[{"system":"http://fhir.de/CodeSystem/identifier-type-de-basis","code":"GKV"}]},"system":"http://fhir.de/NamingSystem/gkv/kvid-10","value":"5678","assigner":{"identifier":{"use":"official","system":"http://fhir.de/NamingSystem/arge-ik/iknr","value":"109905113"}}}],"name":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/data-absent-reason","valueCode":"unsupported"}]}],"gender":"unknown","birthDate":"1941-01-01","deceasedDateTime":"2018-08-05T21:28:00+02:00","address":[{"type":"physical","city":"Buschau","postalCode":"12365"}]} | ||
{"resourceType":"Patient","id":"pid-02cb8631-8342-4343-84d7-cd364e0ab101","identifier":[{"system":"http://example.com/fhir/id","value":"4ca676c2-e2d0-4726-b6dd-83eae57dcf50"}],"name":[{"family":"Wisozk","given":["Mariana"]}],"gender":"male","birthDate":"2005-12-08"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{"resourceType":"Patient","id":"pid.999","meta":{"source":"#p21"},"identifier":[{"use":"usual","type":{"coding":[{"system":"http://terminology.hl7.org/CodeSystem/v2-0203","code":"MR"}]},"system":"https://miracum.org/fhir/NamingSystem/identifier/PatientId","value":"pid.999"},{"use":"official","type":{"coding":[{"system":"http://fhir.de/CodeSystem/identifier-type-de-basis","code":"GKV"}]},"system":"http://fhir.de/NamingSystem/gkv/kvid-10","value":"5678","assigner":{"identifier":{"use":"official","system":"http://fhir.de/NamingSystem/arge-ik/iknr","value":"109905113"}}}],"name":[{"extension":[{"url":"http://hl7.org/fhir/StructureDefinition/data-absent-reason","valueCode":"unsupported"}]}],"gender":"unknown","birthDate":"1941-01-01","deceasedDateTime":"2018-08-05T21:28:00+02:00","address":[{"type":"physical","city":"Buschau","postalCode":"12365"}]} | ||
{"resourceType":"Patient","id":"new-id-123","identifier":[{"system":"http://example.com/fhir/id","value":"4ca676c2-e2d0-4726-b6dd-83eae57dcf50"}],"name":[{"family":"Wisozk","given":["Mariana"]}],"gender":"male","birthDate":"2005-12-08"} |
26 changes: 26 additions & 0 deletions
26
src/PathlingS3Import.Tests.E2E/PathlingS3Import.Tests.E2E.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0" /> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageReference Include="Hl7.Fhir.R4" Version="5.6.1" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" /> | ||
<PackageReference Include="Testcontainers" Version="3.7.0" /> | ||
<PackageReference Include="xunit" Version="2.5.3" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Xunit" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using DotNet.Testcontainers.Builders; | ||
using FluentAssertions; | ||
using Hl7.Fhir.Model; | ||
using Hl7.Fhir.Rest; | ||
using Xunit.Abstractions; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace PathlingS3Import.Tests.E2E; | ||
|
||
public class Tests(ITestOutputHelper output) | ||
{ | ||
private readonly ITestOutputHelper output = output; | ||
|
||
[Fact] | ||
public async Task StartImportTool_WithRunningPathlingServerAndMinio_ShouldCreateExpectedNumberOfResources() | ||
{ | ||
// this test requires the dev fixtures to be running on their default ports as well as | ||
// a PathlingS3Import image to exist. | ||
|
||
using var stdoutStream = new MemoryStream(); | ||
using var stderrStream = new MemoryStream(); | ||
using var consumer = Consume.RedirectStdoutAndStderrToStream(stdoutStream, stderrStream); | ||
|
||
var pathlingServerBaseUrl = "http://host.docker.internal:8082/fhir"; | ||
var resourceType = ResourceType.Patient; | ||
|
||
string[] args = | ||
[ | ||
"--s3-endpoint=http://host.docker.internal:9000", | ||
$"--pathling-server-base-url={pathlingServerBaseUrl}", | ||
"--s3-access-key=admin", | ||
"--s3-secret-key=miniopass", | ||
"--s3-bucket-name=fhir", | ||
"--s3-object-name-prefix=staging/", | ||
$"--import-resource-type={resourceType}", | ||
"--dry-run=false" | ||
]; | ||
|
||
var testImageTag = | ||
Environment.GetEnvironmentVariable("PATHLING_S3_IMPORT_IMAGE_TAG") ?? "test"; | ||
|
||
var testContainer = new ContainerBuilder() | ||
.WithImage($"ghcr.io/miracum/pathling-s3-import:{testImageTag}") | ||
.WithCommand(args) | ||
.WithOutputConsumer(consumer) | ||
.WithExtraHost("host.docker.internal", "host-gateway") | ||
.Build(); | ||
|
||
await testContainer.StartAsync(); | ||
|
||
var exitCode = await testContainer.GetExitCodeAsync(); | ||
|
||
output.WriteLine("Test container exited"); | ||
|
||
consumer.Stdout.Seek(0, SeekOrigin.Begin); | ||
using var stdoutReader = new StreamReader(consumer.Stdout); | ||
var stdout = stdoutReader.ReadToEnd(); | ||
output.WriteLine(stdout); | ||
|
||
exitCode.Should().Be(0); | ||
|
||
// use a different base URL since this test isn't run inside | ||
// a container. Slightly ugly. | ||
using var fhirClient = new FhirClient( | ||
"http://localhost:8082/fhir", | ||
settings: new() | ||
{ | ||
PreferredFormat = ResourceFormat.Json, | ||
Timeout = (int)TimeSpan.FromSeconds(60).TotalMilliseconds | ||
} | ||
); | ||
|
||
var response = await fhirClient.SearchAsync( | ||
resourceType.ToString(), | ||
summary: SummaryType.Count | ||
); | ||
|
||
response.Should().NotBeNull(); | ||
response!.Total.Should().Be(3); | ||
} | ||
} |
Oops, something went wrong.