|
| 1 | +parameters: |
| 2 | +- name: version |
| 3 | + type: string |
| 4 | + |
| 5 | +steps: |
| 6 | + - checkout: self |
| 7 | + fetchDepth: 1 |
| 8 | + fetchTags: false |
| 9 | + |
| 10 | + - task: UseDotNet@2 |
| 11 | + inputs: |
| 12 | + useGlobalJson: true |
| 13 | + |
| 14 | + - task: DockerCompose@0 |
| 15 | + displayName: 'Start CosmosDB Emulator and Azurite containers' |
| 16 | + inputs: |
| 17 | + action: 'Run services' |
| 18 | + dockerComposeFile: '$(Build.SourcesDirectory)/build/docker-compose.test.yml' |
| 19 | + projectName: 'fhir-server-test-${{ lower(parameters.version) }}-cosmos' |
| 20 | + dockerComposeCommand: 'up -d cosmos azurite' |
| 21 | + detached: true |
| 22 | + |
| 23 | + - script: | |
| 24 | + echo "Waiting for Cosmos DB Emulator to be ready..." |
| 25 | + timeout=240 |
| 26 | + elapsed=0 |
| 27 | + until docker exec fhir-test-cosmos curl -k https://localhost:8081/_explorer/emulator.pem > /dev/null 2>&1 || [ $elapsed -ge $timeout ]; do |
| 28 | + echo "Waiting for Cosmos DB Emulator... ($elapsed seconds)" |
| 29 | + sleep 10 |
| 30 | + elapsed=$((elapsed + 10)) |
| 31 | + done |
| 32 | + echo "Cosmos DB Emulator is ready" |
| 33 | + displayName: 'Verify Cosmos DB Emulator connectivity' |
| 34 | +
|
| 35 | + - script: | |
| 36 | + echo "Exporting and trusting CosmosDB Emulator SSL certificate..." |
| 37 | + # Extract certificate from the emulator |
| 38 | + curl -k https://localhost:8081/_explorer/emulator.pem > ~/emulatorcert.crt |
| 39 | +
|
| 40 | + # Install to system certificate store |
| 41 | + sudo cp ~/emulatorcert.crt /usr/local/share/ca-certificates/ |
| 42 | + sudo update-ca-certificates |
| 43 | +
|
| 44 | + echo "CosmosDB Emulator certificate trusted" |
| 45 | + displayName: 'Trust CosmosDB Emulator SSL certificate' |
| 46 | +
|
| 47 | + - script: | |
| 48 | + echo "Waiting for Azurite to be ready..." |
| 49 | + timeout=60 |
| 50 | + elapsed=0 |
| 51 | + until curl -f http://localhost:10000/devstoreaccount1?restype=account > /dev/null 2>&1 || [ $elapsed -ge $timeout ]; do |
| 52 | + echo "Waiting for Azurite... ($elapsed seconds)" |
| 53 | + sleep 5 |
| 54 | + elapsed=$((elapsed + 5)) |
| 55 | + done |
| 56 | + echo "Azurite is ready" |
| 57 | + displayName: 'Verify Azurite connectivity' |
| 58 | +
|
| 59 | + - task: DotNetCoreCLI@2 |
| 60 | + displayName: 'Build ${{ parameters.version }} integration test project' |
| 61 | + inputs: |
| 62 | + command: build |
| 63 | + projects: 'test/**/*${{ parameters.version }}.Tests.Integration.csproj' |
| 64 | + arguments: '--configuration $(buildConfiguration) -f $(defaultBuildFramework)' |
| 65 | + |
| 66 | + - task: DotNetCoreCLI@2 |
| 67 | + displayName: 'Run ${{ parameters.version }} CosmosDB Integration Tests' |
| 68 | + inputs: |
| 69 | + command: test |
| 70 | + projects: 'test/**/*${{ parameters.version }}.Tests.Integration.csproj' |
| 71 | + arguments: '--filter DisplayName!~SqlServer --configuration $(buildConfiguration) --collect "XPlat Code Coverage" -s "$(build.sourcesDirectory)/CodeCoverage.runsettings" -v normal --no-build -f $(defaultBuildFramework)' |
| 72 | + testRunTitle: '${{ parameters.version }} Docker CosmosDB Integration Tests' |
| 73 | + publishTestResults: true |
| 74 | + env: |
| 75 | + 'CosmosDb__Host': 'https://localhost:8081' |
| 76 | + 'CosmosDb__Key': 'C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==' |
| 77 | + 'CosmosDb__DatabaseId': 'FhirTests' |
| 78 | + 'TestExportStoreUri': 'http://127.0.0.1:10000/devstoreaccount1' |
| 79 | + 'TestIntegrationStoreUri': 'http://127.0.0.1:10000/devstoreaccount1' |
| 80 | + |
| 81 | + - task: DotNetCoreCLI@2 |
| 82 | + displayName: 'Build ${{ parameters.version }} E2E test project' |
| 83 | + inputs: |
| 84 | + command: build |
| 85 | + projects: 'test/**/*${{ parameters.version }}.Tests.E2E.csproj' |
| 86 | + arguments: '--configuration $(buildConfiguration) -f $(defaultBuildFramework)' |
| 87 | + |
| 88 | + - task: DotNetCoreCLI@2 |
| 89 | + displayName: 'Run ${{ parameters.version }} CosmosDB E2E Tests (In-Proc)' |
| 90 | + inputs: |
| 91 | + command: test |
| 92 | + projects: 'test/**/*${{ parameters.version }}.Tests.E2E.csproj' |
| 93 | + arguments: '--filter FullyQualifiedName~CosmosDb --configuration $(buildConfiguration) --collect "XPlat Code Coverage" -s "$(build.sourcesDirectory)/CodeCoverage.runsettings" -v normal --no-build -f $(defaultBuildFramework)' |
| 94 | + testRunTitle: '${{ parameters.version }} Docker CosmosDB E2E Tests' |
| 95 | + publishTestResults: true |
| 96 | + env: |
| 97 | + 'CosmosDb__Host': 'https://localhost:8081' |
| 98 | + 'CosmosDb__Key': 'C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==' |
| 99 | + 'CosmosDb__DatabaseId': 'FhirTests' |
| 100 | + 'TestExportStoreUri': 'http://127.0.0.1:10000/devstoreaccount1' |
| 101 | + 'TestIntegrationStoreUri': 'http://127.0.0.1:10000/devstoreaccount1' |
| 102 | + |
| 103 | + - task: reportgenerator@5 |
| 104 | + displayName: 'Aggregate ${{ parameters.version }} CosmosDB test coverage' |
| 105 | + condition: succeededOrFailed() |
| 106 | + inputs: |
| 107 | + reports: '$(Agent.TempDirectory)/*/coverage.cobertura.xml' |
| 108 | + reporttypes: 'Cobertura' |
| 109 | + targetdir: '$(Agent.TempDirectory)/coverage' |
| 110 | + |
| 111 | + - task: PublishBuildArtifacts@1 |
| 112 | + displayName: 'Publish ${{ parameters.version }} CosmosDB test coverage' |
| 113 | + condition: succeededOrFailed() |
| 114 | + inputs: |
| 115 | + pathToPublish: '$(Agent.TempDirectory)/coverage' |
| 116 | + artifactName: 'Coverage_Docker_CosmosDB_${{ parameters.version }}' |
| 117 | + artifactType: 'container' |
| 118 | + |
| 119 | + - task: PublishCodeCoverageResults@1 |
| 120 | + displayName: 'Publish ${{ parameters.version }} CosmosDB code coverage results' |
| 121 | + condition: always() |
| 122 | + inputs: |
| 123 | + codeCoverageTool: 'Cobertura' |
| 124 | + summaryFileLocation: '$(Agent.TempDirectory)/coverage/Cobertura.xml' |
| 125 | + reportDirectory: '$(Agent.TempDirectory)/coverage' |
| 126 | + |
| 127 | + - task: DockerCompose@0 |
| 128 | + displayName: 'Stop and remove containers' |
| 129 | + condition: always() |
| 130 | + inputs: |
| 131 | + action: 'Run a Docker Compose command' |
| 132 | + dockerComposeFile: '$(Build.SourcesDirectory)/build/docker-compose.test.yml' |
| 133 | + projectName: 'fhir-server-test-${{ lower(parameters.version) }}-cosmos' |
| 134 | + dockerComposeCommand: 'down -v' |
0 commit comments