Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/microsoft/fhir-server into …
Browse files Browse the repository at this point in the history
…114284_githubaction_ci1
  • Loading branch information
Nathan Lemma (Waferwire LLC) committed May 13, 2024
2 parents 2cafa5d + 5a98e34 commit e816d0e
Show file tree
Hide file tree
Showing 30 changed files with 5,473 additions and 84 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/validate-prs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Validate Pull Request

on:
pull_request:
pull_request_target:
branches:
- main
types:
Expand All @@ -11,8 +11,6 @@ on:
- reopened
- synchronize
- edited
- milestoned
- demilestoned

env:
LABELS: ${{ join( github.event.pull_request.labels.*.name, ' ' ) }}
Expand Down
42 changes: 37 additions & 5 deletions build/jobs/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ parameters:
- name: appServiceName
type: string
jobs:
- job: "integrationTests"

- job: "CosmosIntegrationTests"
pool:
name: '$(SharedLinuxPool)'
vmImage: '$(LinuxVmImage)'
Expand Down Expand Up @@ -34,22 +35,53 @@ jobs:
azureSubscription: $(ConnectedServiceName)
KeyVaultName: '${{ parameters.keyVaultName }}'

- task: DotNetCoreCLI@2
displayName: 'Run Cosmos Integration Tests'
inputs:
command: test
arguments: '"$(Agent.TempDirectory)/IntegrationTests/**/*${{ parameters.version }}.Tests.Integration*.dll" --filter DisplayName!~SqlServer -v normal'
workingDirectory: "$(System.ArtifactsDirectory)"
testRunTitle: '${{ parameters.version }} Integration'
env:
'CosmosDb:Host': $(CosmosDb--Host)
'CosmosDb:Key': $(CosmosDb--Key)

- job: "SqlIntegrationTests"
pool:
name: '$(SharedLinuxPool)'
vmImage: '$(LinuxVmImage)'
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
downloadPath: '$(System.ArtifactsDirectory)'
artifactName: 'IntegrationTests'

- task: ExtractFiles@1
displayName: 'Extract Integration Test Binaries'
inputs:
archiveFilePatterns: '$(System.ArtifactsDirectory)/IntegrationTests/Microsoft.Health.Fhir.${{ parameters.version }}.Tests.Integration.zip'
destinationFolder: '$(Agent.TempDirectory)/IntegrationTests/'

- task: UseDotNet@2
inputs:
useGlobalJson: true

- task: AzureKeyVault@1
displayName: 'Azure Key Vault: ${{ parameters.keyVaultName }}-sql'
inputs:
azureSubscription: $(ConnectedServiceName)
KeyVaultName: '${{ parameters.keyVaultName }}-sql'

- task: DotNetCoreCLI@2
displayName: 'Run Integration Tests'
displayName: 'Run Sql Integration Tests'
inputs:
command: test
arguments: '"$(Agent.TempDirectory)/IntegrationTests/**/*${{ parameters.version }}.Tests.Integration*.dll" --blame-hang-timeout 15m'
arguments: '"$(Agent.TempDirectory)/IntegrationTests/**/*${{ parameters.version }}.Tests.Integration*.dll" --filter DisplayName!~Cosmos -v normal'
workingDirectory: "$(System.ArtifactsDirectory)"
testRunTitle: '${{ parameters.version }} Integration'
env:
'CosmosDb:Host': $(CosmosDb--Host)
'CosmosDb:Key': $(CosmosDb--Key)
'SqlServer:ConnectionString': $(SqlServer--ConnectionString)

- job: 'cosmosE2eTests'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public async Task<UpsertOutcome> AppendResourceAsync(ResourceWrapperOperation re
{
if (!_resources.Any())
{
cancellationToken.ThrowIfCancellationRequested();
SetStatusSafe(BundleOrchestratorOperationStatus.WaitingForResources);
}

Expand Down Expand Up @@ -197,6 +198,7 @@ public async Task ReleaseResourceAsync(string reason, CancellationToken cancella
{
if (!_resources.Any())
{
cancellationToken.ThrowIfCancellationRequested();
SetStatusSafe(BundleOrchestratorOperationStatus.WaitingForResources);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,15 @@ private async Task ProcessAllResourcesInABundleAsRequestsAsync(Hl7.Fhir.Model.Bu
EntryComponent throttledEntryComponent = null;
foreach (HTTPVerb verb in _verbExecutionOrder)
{
throttledEntryComponent = await ExecuteRequestsWithSingleHttpVerbInSequenceAsync(
responseBundle: responseBundle,
httpVerb: verb,
throttledEntryComponent: throttledEntryComponent,
statistics: statistics,
cancellationToken: cancellationToken);
if (_requests[verb].Any())
{
throttledEntryComponent = await ExecuteRequestsWithSingleHttpVerbInSequenceAsync(
responseBundle: responseBundle,
httpVerb: verb,
throttledEntryComponent: throttledEntryComponent,
statistics: statistics,
cancellationToken: cancellationToken);
}
}
}
else if (processingLogic == BundleProcessingLogic.Parallel && _bundleType == BundleType.Batch)
Expand Down Expand Up @@ -607,6 +610,8 @@ private async Task<EntryComponent> ExecuteRequestsWithSingleHttpVerbInSequenceAs
{
HttpContext httpContext = resourceContext.Context.HttpContext;

// Ensure to pass original callers cancellation token to honor client request cancellations and httprequest timeouts
httpContext.RequestAborted = cancellationToken;
SetupContexts(resourceContext, httpContext);

Func<string> originalResourceIdProvider = _resourceIdProvider.Create;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ private async Task<EntryComponent> ExecuteRequestsInParallelAsync(
watch.Stop();
_logger.LogInformation("BundleHandler - '{HttpVerb}' Request #{RequestNumber} completed with status code '{StatusCode}' in {TotalElapsedMilliseconds}ms.", resourceExecutionContext.HttpVerb, resourceExecutionContext.Index, entry.Response.Status, watch.ElapsedMilliseconds);
}
catch (OperationCanceledException ex)
{
// If the exception raised is a OperationCanceledException, then either client cancelled the request or httprequest timed out
_logger.LogInformation(ex, "Bundle request timedout. Error: {ErrorMessage}", ex.Message);
}
catch (FhirTransactionFailedException ex)
{
_logger.LogError(ex, "BundleHandler - Failed transaction. Canceling Bundle Orchestrator Operation: {ErrorMessage}", ex.Message);
Expand Down Expand Up @@ -262,6 +267,9 @@ private static async Task<EntryComponent> HandleRequestAsync(
else
{
HttpContext httpContext = request.HttpContext;

// Ensure to pass original callers cancellation token to honor client request cancellations and httprequest timeouts
httpContext.RequestAborted = cancellationToken;
Func<string> originalResourceIdProvider = resourceIdProvider.Create;
if (!string.IsNullOrWhiteSpace(persistedId))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Azure;
using EnsureThat;
using MediatR;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Microsoft.Health.Core.Features.Audit;
Expand All @@ -22,6 +23,7 @@
using Microsoft.Health.Fhir.Core.Features.Operations;
using Microsoft.Health.Fhir.Core.Features.Operations.Import;
using Microsoft.Health.JobManagement;
using Microsoft.Health.SqlServer.Features.Storage;
using Newtonsoft.Json;

namespace Microsoft.Health.Fhir.SqlServer.Features.Operations.Import
Expand All @@ -31,6 +33,7 @@ public class ImportProcessingJob : IJob
{
private const string CancelledErrorMessage = "Import processing job is canceled.";
internal const string DefaultCallerAgent = "Microsoft.Health.Fhir.Server";
internal const string SurrogateIdsErrorMessage = "Unable to generate internal IDs. If the lastUpdated meta element is provided as input, reduce the number of resources with the same up to millisecond lastUpdated below 10,000.";

private readonly IMediator _mediator;
private readonly IQueueClient _queueClient;
Expand Down Expand Up @@ -152,6 +155,12 @@ public async Task<string> ExecuteAsync(JobInfo jobInfo, CancellationToken cancel
var error = new ImportJobErrorResult() { ErrorMessage = CancelledErrorMessage };
throw new JobExecutionException(canceledEx.Message, error, canceledEx);
}
catch (SqlException ex) when (ex.Number == SqlErrorCodes.Conflict)
{
_logger.LogJobInformation(ex, jobInfo, "Exceeded retries on conflicts. Most likely reason - too many input resources with the same last updated.");
var error = new ImportJobErrorResult() { ErrorMessage = SurrogateIdsErrorMessage, HttpStatusCode = HttpStatusCode.BadRequest, ErrorDetails = ex.ToString() };
throw new JobExecutionException(ex.Message, error, ex);
}
catch (Exception ex)
{
_logger.LogJobError(ex, jobInfo, "Critical error in import processing job.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
IF object_id('dbo.ReindexResource') IS NOT NULL DROP PROCEDURE dbo.ReindexResource -- Ths still exists on old accounts and prevents TVP drop
GO
IF object_id('dbo.BulkReindexResources') IS NOT NULL DROP PROCEDURE dbo.BulkReindexResources -- Ths still exists on old accounts and prevents TVP drop
GO
DECLARE @Names TABLE (Name varchar(100) PRIMARY KEY)
INSERT INTO @Names SELECT name FROM sys.objects WHERE type = 'p' AND name LIKE '%[0-9]' AND name NOT LIKE '%ResourceChanges%'
DECLARE @Name varchar(100)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Execute dbo.DeleteHistory 0,0,0
Loading

0 comments on commit e816d0e

Please sign in to comment.