-
Notifications
You must be signed in to change notification settings - Fork 191
Cosmos Indexing Integration #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7f0e4c3
Added initial work for cosmos indexing strategy
Richyl2 44835bd
Added settings updater and fixed all tests
Richyl2 453b2b8
Updated the build file to install the Cosmos emulator and updated the…
Richyl2 720095c
Updated build script and added more tests
Richyl2 70879af
Attempt to get tests running on windows
Richyl2 1be66b9
Updated build file
Richyl2 9e4373d
Updated build file
Richyl2 15685ed
Removed condition from build test
Richyl2 5afc1cc
Added steps to the test yml file
Richyl2 d0f569d
Updated the cosmos tests yml file to use the correct endpoint
Richyl2 3ccb0f1
Updated the test build script, added support for series and study que…
Richyl2 5f333c1
Fixed tests when running in parallel
Richyl2 3d9423e
Refactored PR based on comments and added Dicom Attribute for being a…
Richyl2 01dd8de
Fixed broken test and resolved more PR comments
Richyl2 1fb69cd
Added missing code comment change for the DICOM identifier validator
Richyl2 454ddeb
Updated the Regex so it is compiled
Richyl2 9baa990
Updated solution file to remove missing project
Richyl2 275fcc0
Refactored based on PR comments
Richyl2 a6cb0ee
Fixed typo in test build script file
Richyl2 a1fce50
Removed hard-coded paramter names from query strings and shortened un…
Richyl2 9f62bbf
Normalized document casing for Cosmos documents
Richyl2 1e712bb
Updated PR based on final comments
Richyl2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,53 @@ | ||
|
|
||
| steps: | ||
|
|
||
| # To run the tests we install NPM to run the 'azurite' emulator (https://github.com/Azure/Azurite). | ||
| # This allows us to test the blob storage providers without an Azure instance. | ||
| - task: NodeTool@0 | ||
| displayName: 'Use Node 8.x' | ||
| inputs: | ||
| versionSpec: 8.x | ||
| checkLatest: true | ||
|
|
||
| - script: npm install -g azurite@2.7.0 | ||
| displayName: 'Install Azurite v2.7.0' | ||
|
|
||
| # We start the Azurite as a separate process as the start call is blocking. | ||
| - script: azurite -s & | ||
| condition: and(succeeded(), eq( variables['Agent.OS'], 'Linux' )) | ||
| displayName: 'Start Azurite Storage Emulator (Linux)' | ||
|
|
||
| - script: start azurite -s | ||
| condition: and(succeeded(), eq( variables['Agent.OS'], 'Windows_NT' )) | ||
| displayName: 'Start Azurite Storage Emulator (Windows)' | ||
|
|
||
| # Currently the Cosmos DB Emulator only runs on Windows. Therefore all end to end testing | ||
| # is performed on windows. | ||
| - powershell: | | ||
| $cosmosemulator=[Environment]::GetEnvironmentVariable("ProgramFiles") + "\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" | ||
|
Richyl2 marked this conversation as resolved.
|
||
| & $cosmosemulator /noui | ||
| $location = 'https://localhost:8081/_explorer/index.html' | ||
| $statusCode = [int]0 | ||
| while ($statusCode -ne 200) | ||
| { | ||
| Try | ||
| { | ||
| $req = [system.Net.WebRequest]::Create($location) | ||
| $response = $req.GetResponse() | ||
| $statusCode = [int]$response.StatusCode | ||
| $location + " status code: " + $statusCode | ||
| $response.Close() | ||
| } Catch { | ||
| $PSItem.ToString() | ||
| } | ||
| } | ||
| displayName: 'Start Installed Cosmos Emulator' | ||
| condition: and(succeeded(), eq( variables['Agent.OS'], 'Windows_NT' )) | ||
|
|
||
| - task: DotNetCoreCLI@2 | ||
| displayName: 'Run all tests (Windows)' | ||
| condition: and(succeeded(), eq( variables['Agent.OS'], 'Windows_NT' )) | ||
| inputs: | ||
| command: test | ||
| projects: '**\*Tests*.csproj' | ||
| arguments: '--configuration $(buildConfiguration)' | ||
This file contains hidden or 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
72 changes: 72 additions & 0 deletions
72
...osoft.Health.Dicom.Core.UnitTests/Features/Persistence/DicomAttributeIdExtensionsTests.cs
This file contains hidden or 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,72 @@ | ||
| // ------------------------------------------------------------------------------------------------- | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
| // ------------------------------------------------------------------------------------------------- | ||
|
|
||
| using System; | ||
| using Dicom; | ||
| using Microsoft.Health.Dicom.Core.Features.Persistence; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.Health.Dicom.Core.UnitTests.Features.Persistence | ||
| { | ||
| public class DicomAttributeIdExtensionsTests | ||
| { | ||
| [Fact] | ||
| public void GivenDatasetAndInvalidParameters_WhenFetchedAttributeValues_ArgumentExceptionIsThrown() | ||
| { | ||
| var dicomDataset = new DicomDataset(); | ||
| Assert.Throws<ArgumentNullException>(() => dicomDataset.TryGetValues((DicomAttributeId)null, out object[] values)); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GivenDataset_WhenFetchingMissingAttribute_FalseIsReturned() | ||
| { | ||
| var dicomDataset = new DicomDataset(); | ||
| var result = dicomDataset.TryGetValues(new DicomAttributeId(DicomTag.PatientName), out object[] values); | ||
|
|
||
| Assert.False(result); | ||
| Assert.Null(values); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GivenDatasetWithSequence_WhenFetchingAttributeValues_IsReturnedCorrectly() | ||
| { | ||
| var sequence1 = new DicomSequence( | ||
| DicomTag.ReferencedPatientSequence, | ||
| new DicomDataset() { { DicomTag.PatientName, "Patient1" } }, | ||
| new DicomDataset() { { DicomTag.PatientName, "Patient2" } }, | ||
| new DicomDataset() { { DicomTag.PatientName, "Patient3" } }); | ||
|
|
||
| var fetchedValues1 = new DicomDataset() { sequence1 }.TryGetValues( | ||
| new DicomAttributeId(DicomTag.ReferencedPatientSequence, DicomTag.PatientName), | ||
| out object[] values1); | ||
| Assert.True(fetchedValues1); | ||
| Assert.Equal(3, values1.Length); | ||
| Assert.Contains("Patient1", values1); | ||
| Assert.Contains("Patient2", values1); | ||
| Assert.Contains("Patient3", values1); | ||
|
|
||
| var sequence2 = new DicomSequence( | ||
| DicomTag.ReferencedStudySequence, | ||
| new DicomDataset() { { DicomTag.StudyDate, new DateTime(2019, 6, 25) } }, | ||
| new DicomDataset() { { new DicomSequence(DicomTag.ReferencedStudySequence, new DicomDataset() { { DicomTag.StudyDate, new DateTime(2019, 6, 24) } }) } }, | ||
| new DicomDataset() { { DicomTag.StudyDate, new DateTime(2019, 6, 23) } }); | ||
|
|
||
| var fetchedValues2 = new DicomDataset() { sequence2 }.TryGetValues( | ||
| new DicomAttributeId(DicomTag.ReferencedStudySequence, DicomTag.StudyDate), | ||
| out object[] values2); | ||
| Assert.True(fetchedValues2); | ||
| Assert.Equal(2, values2.Length); | ||
| Assert.Contains(new DateTime(2019, 6, 25), values2); | ||
| Assert.Contains(new DateTime(2019, 6, 23), values2); | ||
|
|
||
| var fetchedValues3 = new DicomDataset() { sequence2 }.TryGetValues( | ||
| new DicomAttributeId(DicomTag.ReferencedStudySequence, DicomTag.ReferencedStudySequence, DicomTag.StudyDate), | ||
| out object[] values3); | ||
| Assert.True(fetchedValues3); | ||
| Assert.Single(values3); | ||
| Assert.Contains(new DateTime(2019, 6, 24), values3); | ||
| } | ||
| } | ||
| } |
67 changes: 67 additions & 0 deletions
67
src/Microsoft.Health.Dicom.Core.UnitTests/Features/Persistence/DicomAttributeIdTests.cs
This file contains hidden or 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,67 @@ | ||
| // ------------------------------------------------------------------------------------------------- | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
| // ------------------------------------------------------------------------------------------------- | ||
| using System; | ||
| using Dicom; | ||
| using Microsoft.Health.Dicom.Core.Features.Persistence; | ||
| using Newtonsoft.Json; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.Health.Dicom.Core.UnitTests.Features.Persistence | ||
| { | ||
| public class DicomAttributeIdTests | ||
| { | ||
| [Fact] | ||
| public void GivenDicomAttributeId_WhenConstructingWithInvalidParameters_ArgumentExceptionThrown() | ||
| { | ||
| Assert.Throws<ArgumentNullException>(() => new DicomAttributeId((DicomTag[])null)); | ||
| Assert.Throws<ArgumentException>(() => new DicomAttributeId(Array.Empty<DicomTag>())); | ||
| Assert.Throws<FormatException>(() => new DicomAttributeId(DicomTag.RightImageSequence)); | ||
| Assert.Throws<FormatException>(() => new DicomAttributeId(DicomTag.RightImageSequence, DicomTag.ROIContourSequence)); | ||
| Assert.Throws<FormatException>(() => new DicomAttributeId(DicomTag.StudyDate, DicomTag.RightLensSequence)); | ||
|
|
||
| Assert.Throws<ArgumentNullException>(() => new DicomAttributeId((string)null)); | ||
| Assert.Throws<ArgumentException>(() => new DicomAttributeId(string.Empty)); | ||
| Assert.Throws<FormatException>(() => new DicomAttributeId("0020000D.0020000D")); | ||
| Assert.Throws<FormatException>(() => new DicomAttributeId("INVALID")); | ||
| Assert.Throws<FormatException>(() => new DicomAttributeId("INVALID.INVALID")); | ||
|
|
||
| Assert.Throws<ArgumentOutOfRangeException>(() => new DicomAttributeId(DicomTag.StudyDate).GetDicomTag(-1)); | ||
| Assert.Throws<ArgumentOutOfRangeException>(() => new DicomAttributeId(DicomTag.StudyDate).GetDicomTag(1)); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GivenValidDicomAttributeId_WhenSerialized_IsDeserializedCorrectly() | ||
| { | ||
| SerializeAndDeserialize(new DicomAttributeId(DicomTag.StudyDate)); | ||
| SerializeAndDeserialize(new DicomAttributeId(DicomTag.RelatedSeriesSequence, DicomTag.RegistrationSequence, DicomTag.RegisteredLocalizerUnits)); | ||
| SerializeAndDeserialize(new DicomAttributeId(DicomTag.RegionPixelShiftSequence, DicomTag.NumberOfVerticalPixels)); | ||
| SerializeAndDeserialize(new DicomAttributeId("0020000D")); | ||
| SerializeAndDeserialize(new DicomAttributeId("00101002.00100020")); | ||
| SerializeAndDeserialize(new DicomAttributeId("00101002.00100024.00400032")); | ||
| SerializeAndDeserialize(new DicomAttributeId("StudyInstanceUID")); | ||
| SerializeAndDeserialize(new DicomAttributeId("OtherPatientIDsSequence.PatientID")); | ||
| SerializeAndDeserialize(new DicomAttributeId("OtherPatientIDsSequence.IssuerOfPatientIDQualifiersSequence.UniversalEntityID")); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void GivenValidDicomAttributeId_WhenCompared_IsComparedCorrectly() | ||
| { | ||
| Assert.Equal(new DicomAttributeId(DicomTag.StudyInstanceUID), new DicomAttributeId("StudyInstanceUID")); | ||
| Assert.Equal(new DicomAttributeId(DicomTag.OtherPatientIDsSequence, DicomTag.PatientID), new DicomAttributeId("OtherPatientIDsSequence.PatientID")); | ||
|
|
||
| Assert.Equal( | ||
| new DicomAttributeId(DicomTag.OtherPatientIDsSequence, DicomTag.IssuerOfPatientIDQualifiersSequence, DicomTag.UniversalEntityID), | ||
| new DicomAttributeId("OtherPatientIDsSequence.IssuerOfPatientIDQualifiersSequence.UniversalEntityID")); | ||
| } | ||
|
|
||
| private void SerializeAndDeserialize(DicomAttributeId dicomAttributeId) | ||
| { | ||
| var json = JsonConvert.SerializeObject(dicomAttributeId); | ||
| var deserialized = JsonConvert.DeserializeObject<DicomAttributeId>(json); | ||
|
|
||
| Assert.Equal(dicomAttributeId, deserialized); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.