Skip to content

Commit

Permalink
Start writing content length on file properties (#3268)
Browse files Browse the repository at this point in the history
* Start writing content length on file properties of an instance both on initial STOW as well as UPDATE

* fix name

* set default of 0 for backwards compat
  • Loading branch information
esmadau authored Dec 22, 2023
1 parent 68f0d02 commit c9d53cf
Show file tree
Hide file tree
Showing 28 changed files with 7,307 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ public async Task GivenGetStreamingFileAsyncFailureOnConditionNotMet_WhenCopying
FileProperties = new FileProperties
{
Path = "partition1/123.dcm",
ETag = "e456"
ETag = "e456",
ContentLength = 123
}
});
using var fileStream = new MemoryStream();
Expand Down Expand Up @@ -201,7 +202,8 @@ public async Task GivenGetStreamingFileAsyncFailureOnNoAccess_WhenCopyingFromIDP
FileProperties = new FileProperties
{
Path = "partition1/123.dcm",
ETag = "e456"
ETag = "e456",
ContentLength = 123
}
});
using var fileStream = new MemoryStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public class BlobFileStoreTests
private readonly FileProperties _defaultFileProperties = new FileProperties
{
Path = DefaultBlobName,
ETag = "45678"
ETag = "45678",
ContentLength = 123
};

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class DeleteServiceTests
private readonly FileProperties _defaultFileProperties = new FileProperties
{
Path = "partitionA/123.dcm",
ETag = "e45678"
ETag = "e45678",
ContentLength = 123
};

public DeleteServiceTests()
Expand Down Expand Up @@ -546,7 +547,8 @@ private static List<InstanceMetadata> GeneratedDeletedInstanceList(int numberOfR
fileProperties = new FileProperties
{
Path = Guid.NewGuid() + ".dcm",
ETag = "e" + Guid.NewGuid()
ETag = "e" + Guid.NewGuid(),
ContentLength = 123
};
}
instanceProperties ??= new InstanceProperties() { FileProperties = fileProperties };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void GivenClientUsingForwardTelemetry_ExpectForwardLogFlagIsSetWithNoAddi
public void GivenClientUsingForwardTelemetryWithFileProperties_ExpectForwardLogFlagIsSetWithAdditionalProperties()
{
(TelemetryClient telemetryClient, var channel) = CreateTelemetryClientWithChannel();
var expectedProperties = new FileProperties { Path = "123.dcm", ETag = "e456" };
var expectedProperties = new FileProperties { Path = "123.dcm", ETag = "e456", ContentLength = 123 };
var expectedPartition = new Partition(1, "partitionOne");
telemetryClient.ForwardLogTrace("A message", expectedPartition, expectedProperties);

Expand All @@ -52,7 +52,7 @@ public void GivenClientUsingForwardTelemetryWithFileProperties_ExpectForwardLogF
public void GivenClientUsingForwardTelemetryWithFileProperties_ExpectForwardLogFlagIsSetWithAdditionalPropertiesWithoutPartition()
{
(TelemetryClient telemetryClient, var channel) = CreateTelemetryClientWithChannel();
var expectedProperties = new FileProperties { Path = "123.dcm", ETag = "e456" };
var expectedProperties = new FileProperties { Path = "123.dcm", ETag = "e456", ContentLength = 123 };

// because a default partition is being used, we don't log it in telemetry
var expectedPartition = Partition.Default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class RetrieveRenderedServiceTests
private readonly string _firstSeriesInstanceUid = TestUidGenerator.Generate();
private readonly string _sopInstanceUid = TestUidGenerator.Generate();
private static readonly CancellationToken DefaultCancellationToken = new CancellationTokenSource().Token;
private static readonly FileProperties DefaultFileProperties = new FileProperties() { Path = "default/path/0.dcm", ETag = "123" };
private static readonly FileProperties DefaultFileProperties = new FileProperties() { Path = "default/path/0.dcm", ETag = "123", ContentLength = 123 };
private readonly RetrieveMeter _retrieveMeter;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class RetrieveResourceServiceTests
private readonly IInstanceMetadataCache _instanceMetadataCache;
private readonly IFramesRangeCache _framesRangeCache;
private readonly RetrieveMeter _retrieveMeter;
private static readonly FileProperties DefaultFileProperties = new FileProperties() { Path = "default/path/0.dcm", ETag = "123" };
private static readonly FileProperties DefaultFileProperties = new FileProperties() { Path = "default/path/0.dcm", ETag = "123", ContentLength = 123 };

public RetrieveResourceServiceTests()
{
Expand Down Expand Up @@ -209,7 +209,7 @@ public async Task GivenInstancesWithOriginalVersion_WhenRetrieveRequestForStudyF
{
// Add multiple instances to validate that we return the requested instance and ignore the other(s).
int originalVersion = 5;
FileProperties fileProperties = new FileProperties { Path = "123.dcm" };
FileProperties fileProperties = new FileProperties { Path = "123.dcm", ETag = "e456", ContentLength = 123 };
List<InstanceMetadata> versionedInstanceIdentifiers = SetupInstanceIdentifiersList(
ResourceType.Instance,
instanceProperty: new InstanceProperties()
Expand Down Expand Up @@ -785,7 +785,7 @@ await _fileStore.GetFileFrameAsync(
Arg.Is<long>(x => x == instance.VersionedInstanceIdentifier.Version),
Partition.Default,
Arg.Any<FrameRange>(),
Arg.Is<FileProperties>(f => f.Path == DefaultFileProperties.Path && f.ETag == DefaultFileProperties.ETag),
Arg.Is<FileProperties>(f => f.Path == DefaultFileProperties.Path && f.ETag == DefaultFileProperties.ETag && f.ContentLength == DefaultFileProperties.ContentLength),
Arg.Any<CancellationToken>());
}

Expand Down Expand Up @@ -825,7 +825,7 @@ await _fileStore.GetFileFrameAsync(
Arg.Is<long>(x => x == instance.InstanceProperties.OriginalVersion.Value),
Partition.Default,
Arg.Any<FrameRange>(),
Arg.Is<FileProperties>(f => f.Path == DefaultFileProperties.Path && f.ETag == DefaultFileProperties.ETag),
Arg.Is<FileProperties>(f => f.Path == DefaultFileProperties.Path && f.ETag == DefaultFileProperties.ETag && f.ContentLength == DefaultFileProperties.ContentLength),
Arg.Any<CancellationToken>());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class StoreOrchestratorTests
private static readonly FileProperties DefaultFileProperties = new FileProperties
{
Path = "default/path/0.dcm",
ETag = "123"
ETag = "123",
ContentLength = 123
};

private static readonly CancellationToken DefaultCancellationToken = new CancellationTokenSource().Token;
Expand Down Expand Up @@ -217,7 +218,8 @@ private Task ValidateStatusUpdateAsync(IEnumerable<QueryTag> expectedTags, bool
expectedTags,
fileProperties: Arg.Is<FileProperties>(
p => p.Path == DefaultFileProperties.Path
&& p.ETag == DefaultFileProperties.ETag),
&& p.ETag == DefaultFileProperties.ETag
&& p.ContentLength == DefaultFileProperties.ContentLength),
allowExpiredTags: false,
hasFrameMetadata: hasFrameMetadata,
cancellationToken: DefaultCancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,23 @@ public class UpdateInstanceServiceTests
private readonly UpdateInstanceService _updateInstanceService;
private readonly IDicomRequestContextAccessor _dicomRequestContextAccessor;
private readonly UpdateConfiguration _config;
private static readonly FileProperties DefaultFileProperties = new FileProperties
private static readonly FileProperties DefaultFileProperties = new()
{
Path = "default/path/0.dcm",
ETag = "123"
ETag = "123",
ContentLength = 123
};
private static readonly FileProperties DefaultCopiedFileProperties = new FileProperties
private static readonly FileProperties DefaultCopiedFileProperties = new()
{
Path = "default/path/1.dcm",
ETag = "456"
ETag = "456",
ContentLength = 456
};
private static readonly FileProperties DefaultUpdatedFileProperties = new FileProperties
private static readonly FileProperties DefaultUpdatedFileProperties = new()
{
Path = "default/path/1.dcm",
ETag = "789"
ETag = "789",
ContentLength = 789
};
private static readonly InstanceMetadata DefaultInstanceMetadata = new InstanceMetadata(
new VersionedInstanceIdentifier(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public async Task GivenV4OrchestrationWithInput_WhenUpdatingInstancesWithExcepti
Partition.Default),
new InstanceProperties
{
FileProperties = new FileProperties { ETag = $"etag-{1}", Path = $"path-{1}" },
FileProperties = new FileProperties { ETag = $"etag-{1}", Path = $"path-{1}" , ContentLength = 123},
NewVersion = 3
}
),
Expand All @@ -585,7 +585,7 @@ public async Task GivenV4OrchestrationWithInput_WhenUpdatingInstancesWithExcepti
Partition.Default),
new InstanceProperties
{
FileProperties = new FileProperties { ETag = $"etag-{2}", Path = $"path-{2}" },
FileProperties = new FileProperties { ETag = $"etag-{2}", Path = $"path-{2}", ContentLength = 456},
NewVersion = 4
}
)
Expand Down Expand Up @@ -661,7 +661,7 @@ public async Task GivenV4OrchestrationWithInput_WhenUpdatingInstancesWithDataSto
Partition.Default),
new InstanceProperties
{
FileProperties = new FileProperties { ETag = $"etag-{1}", Path = $"path-{1}" },
FileProperties = new FileProperties { ETag = $"etag-{1}", Path = $"path-{1}", ContentLength = 123},
NewVersion = 3
}
),
Expand All @@ -674,7 +674,7 @@ public async Task GivenV4OrchestrationWithInput_WhenUpdatingInstancesWithDataSto
Partition.Default),
new InstanceProperties
{
FileProperties = new FileProperties { ETag = $"etag-{2}", Path = $"path-{2}" },
FileProperties = new FileProperties { ETag = $"etag-{2}", Path = $"path-{2}", ContentLength = 456},
NewVersion = 4
}
)
Expand Down
Loading

0 comments on commit c9d53cf

Please sign in to comment.