Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added backend/test.txt
Binary file not shown.
2 changes: 1 addition & 1 deletion devops-pipelines/backend/backend-pr-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ trigger: none
pr:
branches:
include:
- main
# - main
- development
paths:
include:
Expand Down
158 changes: 46 additions & 112 deletions devops-pipelines/backend/backend-pr-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,124 +4,58 @@ pr:
branches:
include:
- development
- main
paths:
include:
- backend/*

parameters:
- name: environment
displayName: "Target Environment"
type: string
default: "dev"
values:
- dev
- staging

variables:
- template: ../templates/variables/backend-deploy-vars.yml
parameters:
environment: "dev"
- template: ../templates/variables/fa-config-dev.yml
- group: lacc-automated-testing-dev
- name: buildConfiguration
value: "Release"
- name: dotNetVersion
value: "10.x"
- name: efVersion
value: "10.0.*"
- name: testResultsDirectory
value: "$(Agent.TempDirectory)/TestResults"
prTargetBranch: $[ variables['System.PullRequest.TargetBranch'] ]
buildReason: $[ variables['Build.Reason'] ]

pool: "LACC PreProd Pool"

jobs:
- job: Run_Integration_Tests
displayName: "Run Integration Test"
stages:
- stage: Test_for_Dev
condition: or(
eq(variables.prTargetBranch, 'development'),
and(
eq(variables.buildReason, 'Manual'),
${{ eq(parameters.environment, 'dev') }}
)
)
variables:
projectDir: "backend/CPS.ComplexCases.API.Integration.Tests"
Egress.Url: $(EgressOptionsUrl)
Egress.Username: $(EgressOptionsUsername)
Egress.Email: $(EgressEmail)
Egress.Password: $(EgressOptionsPassword)
Egress.WorkspaceId: $(EgressWorkspaceId)
Egress.WorkspaceName: $(EgressWorkspaceName)
Egress.TestDestinationPath: "integration-tests"
DDEI.BaseUrl: $[ replace( variables['DDEIOptionsBaseUrl'], '/api', '' ) ]
DDEI.AccessKey: $(DDEIOptionsAccessKey)
DDEI.Username: $(CmsUserName)
DDEI.Password: $(CmsUserPassword)
DDEI.TestCaseId: $(CmsTestCaseId)
DDEI.TestUrn: $(CmsTestUrn)
DDEI.TestOperationName: $(CmsTestOperationName)
DDEI.TestDefendantLastName: $(CmsTestDefendantLastName)
DDEI:TestCmsAreaCode: $(CmsTestCmsAreaCode)
Azure.TenantId: $(TenantId)
Azure.ClientId: $(CallingAppValidAudience)
Azure.ClientSecret: $(AadClientSecret)
Azure.UserScope: "api://$(CallingAppValidAudience)/user_impersonation"
Azure.TestUserEmail: $(AadUserName)
Azure.TestUserPassword: $(AadUserPassword)
NetApp.Url: $(NetAppOptionsUrl)
NetApp.ClusterUrl: $(NetAppOptionsClusterUrl)
NetApp.BucketName: $(NetAppOptionsBucketName)
NetApp.S3ServiceUuid: $(NetAppOptionsS3ServiceUuid)
NetApp.SessionDurationSeconds: $(NetAppOptionsSessionDurationSeconds)
NetApp.PepperVersion: $(NetAppOptionsPepperVersion)
NetApp.TestFolderPrefix: "integration-tests"
KeyVault.Url: "https://$(keyVaultName).vault.azure.net/"
ConnectionStrings.CaseManagementDatastoreConnection: $(DbConnectionString)
Postgres.AuthMode: "AAD"
Postgres.DbUserName: $(DbUserName)
steps:
- task: Bash@3
displayName: "Ensure Azure CLI"
inputs:
targetType: "inline"
script: |
echo "Checking if Azure CLI is installed..."

# Check if az command exists
if command -v az &> /dev/null; then
echo "Azure CLI is already installed"
az --version
exit 0
fi

echo "Azure CLI not found, installing..."
bash $(scripts_directory)/installAzureCli.sh

- task: UseDotNet@2
displayName: "Use .NET SDK"
inputs:
packageType: "sdk"
version: $(dotNetVersion)

- task: FileTransform@2
displayName: "Write App Settings to File"
inputs:
folderPath: "$(projectDir)"
enableXmlTransform: false
jsonTargetFiles: appsettings.template.json

- script: mv $(projectDir)/appsettings.template.json $(projectDir)/appsettings.json
displayName: "Rename Appsettings File"

- task: AzureCLI@2
displayName: "Run Integration Tests"
inputs:
azureSubscription: "Azure Pipeline: Large and Complex Cases - Pre-Prod"
scriptType: bash
scriptLocation: inlineScript
addSpnToEnvironment: true
workingDirectory: "$(Build.SourcesDirectory)"
inlineScript: |
dotnet test $(projectDir)/CPS.ComplexCases.API.Integration.Tests.csproj \
--configuration $(buildConfiguration) \
--collect:"XPlat Code Coverage;Format=cobertura" \
--settings backend/CodeCoverage.runsettings \
--logger "trx;LogFileName=integration-tests.trx" \
--results-directory $(testResultsDirectory)

- task: PublishTestResults@2
inputs:
testResultsFormat: "VSTest"
testResultsFiles: "$(testResultsDirectory)/integration-tests.trx"
condition: succeededOrFailed()

- task: PublishCodeCoverageResults@2
displayName: "Publish Code Coverage"
inputs:
summaryFileLocation: "$(Agent.TempDirectory)/**/coverage.cobertura.xml"
failIfCoverageEmpty: true
condition: succeededOrFailed()
- template: ../templates/variables/backend-deploy-vars.yml
parameters:
environment: "dev"
- template: ../templates/variables/fa-config-dev.yml
- group: lacc-automated-testing-dev
jobs:
- template: ../templates/backend-integration-test-job.yml

- stage: Test_for_Staging
dependsOn: []
condition: or(
eq(variables.prTargetBranch, 'main'),
and(
eq(variables.buildReason, 'Manual'),
${{ eq(parameters.environment, 'staging') }}
)
)
variables:
- template: ../templates/variables/backend-deploy-vars.yml
parameters:
environment: "staging"
- template: ../templates/variables/fa-config-staging.yml
- group: lacc-automated-testing-staging
jobs:
- template: ../templates/backend-integration-test-job.yml
52 changes: 44 additions & 8 deletions devops-pipelines/cleanup-testfiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,51 @@ jobs:
displayName: "Install PowerShell"

- task: PowerShell@2
displayName: "Clear integration-tests Egress folder"
displayName: "Clear integration-tests Egress folders"
inputs:
filePath: "$(System.DefaultWorkingDirectory)/devops-pipelines/scripts/test-automation-cleanup/Clear-EgressFolder.ps1"
arguments: >
-BaseUrl $(EgressOptionsUrl)
-ServiceAccountAuth $(EgressServiceAccountAuth)
-WorkspaceId $(EgressWorkspaceId)
-FolderName "integration-tests"
-Force
targetType: "inline"
workingDirectory: "$(System.DefaultWorkingDirectory)/devops-pipelines/scripts/test-automation-cleanup"
script: |
$workspaceIds = @(
$env:devWorkspace
$env:stgWorkspace
)

$failedWorkspaces = @()

foreach ($id in $workspaceIds) {
Write-Host "Attempting to clear the integration-tests folder in workspace $id..."

try {
& ./Clear-EgressFolder.ps1 `
-BaseUrl "$(EgressOptionsUrl)" `
-ServiceAccountAuth "$(EgressServiceAccountAuth)" `
-WorkspaceId "$Id" `
-FolderName "integration-tests" `
-Force
}
catch {
Write-Host "[ERROR] $_"
$failedWorkspaces += @{
workspaceId = $id
error = $_
}
}
}

if ($failedWorkspaces.Count -gt 0) {
Write-Host "The integration-tests folder failed to clear in one or more workspaces:"
foreach ($failed in $failedWorkspaces) {
Write-Host " - $($failed.workspaceId) : $($failed.error) "
}

throw "Egress cleanup failed for $($failedWorkspaces.Count) workspace(s)."
}

Write-Host "All integration-tests folders cleared successfully."
env:
devWorkspace: "$(EgressWorkspaceId)"
stgWorkspace: "$(EgressWorkspaceIdIntegrationMain)"

- task: PowerShell@2
displayName: "Clear ExistingCaseAutomation Egress folders"
Expand Down
103 changes: 103 additions & 0 deletions devops-pipelines/templates/backend-integration-test-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
jobs:
- job: Run_Integration_Tests
displayName: "Run Integration Test"
variables:
buildConfiguration: "Release"
dotNetVersion: "10.x"
testResultsDirectory: "$(Agent.TempDirectory)/TestResults"
projectDir: "backend/CPS.ComplexCases.API.Integration.Tests"
Egress.Url: $(EgressOptionsUrl)
Egress.Username: $(EgressOptionsUsername)
Egress.Email: $(EgressEmail)
Egress.Password: $(EgressOptionsPassword)
Egress.WorkspaceId: $(EgressWorkspaceId)
Egress.WorkspaceName: $(EgressWorkspaceName)
Egress.TestDestinationPath: "integration-tests"
DDEI.BaseUrl: $[ replace( variables['DDEIOptionsBaseUrl'], '/api', '' ) ]
DDEI.AccessKey: $(DDEIOptionsAccessKey)
DDEI.Username: $(CmsUserName)
DDEI.Password: $(CmsUserPassword)
DDEI.TestCaseId: $(CmsTestCaseId)
DDEI.TestUrn: $(CmsTestUrn)
DDEI.TestOperationName: $(CmsTestOperationName)
DDEI.TestDefendantLastName: $(CmsTestDefendantLastName)
DDEI:TestCmsAreaCode: $(CmsTestCmsAreaCode)
Azure.TenantId: $(TenantId)
Azure.ClientId: $(CallingAppValidAudience)
Azure.ClientSecret: $(AadClientSecret)
Azure.UserScope: "api://$(CallingAppValidAudience)/user_impersonation"
Azure.TestUserEmail: $(AadUserName)
Azure.TestUserPassword: $(AadUserPassword)
NetApp.Url: $(NetAppOptionsUrl)
NetApp.ClusterUrl: $(NetAppOptionsClusterUrl)
NetApp.BucketName: $(NetAppOptionsBucketName)
NetApp.S3ServiceUuid: $(NetAppOptionsS3ServiceUuid)
NetApp.SessionDurationSeconds: $(NetAppOptionsSessionDurationSeconds)
NetApp.PepperVersion: $(NetAppOptionsPepperVersion)
NetApp.TestFolderPrefix: "integration-tests"
KeyVault.Url: "https://$(keyVaultName).vault.azure.net/"
ConnectionStrings.CaseManagementDatastoreConnection: $(DbConnectionString)
Postgres.AuthMode: "AAD"
Postgres.DbUserName: $(DbUserName)
steps:
- task: Bash@3
displayName: "Ensure Azure CLI"
inputs:
targetType: "inline"
script: |
echo "Checking if Azure CLI is installed..."

# Check if az command exists
if command -v az &> /dev/null; then
echo "Azure CLI is already installed"
az --version
exit 0
fi

echo "Azure CLI not found, installing..."
bash $(scripts_directory)/installAzureCli.sh

- task: UseDotNet@2
displayName: "Use .NET SDK"
inputs:
packageType: "sdk"
version: $(dotNetVersion)

- task: FileTransform@2
displayName: "Write App Settings to File"
inputs:
folderPath: "$(projectDir)"
enableXmlTransform: false
jsonTargetFiles: appsettings.template.json

- script: mv $(projectDir)/appsettings.template.json $(projectDir)/appsettings.json
displayName: "Rename Appsettings File"

- task: AzureCLI@2
displayName: "Run Integration Tests"
inputs:
azureSubscription: "Azure Pipeline: Large and Complex Cases - Pre-Prod"
scriptType: bash
scriptLocation: inlineScript
addSpnToEnvironment: true
workingDirectory: "$(Build.SourcesDirectory)"
inlineScript: |
dotnet test $(projectDir)/CPS.ComplexCases.API.Integration.Tests.csproj \
--configuration $(buildConfiguration) \
--collect:"XPlat Code Coverage;Format=cobertura" \
--settings backend/CodeCoverage.runsettings \
--logger "trx;LogFileName=integration-tests.trx" \
--results-directory $(testResultsDirectory)

- task: PublishTestResults@2
inputs:
testResultsFormat: "VSTest"
testResultsFiles: "$(testResultsDirectory)/integration-tests.trx"
condition: succeededOrFailed()

- task: PublishCodeCoverageResults@2
displayName: "Publish Code Coverage"
inputs:
summaryFileLocation: "$(Agent.TempDirectory)/**/coverage.cobertura.xml"
failIfCoverageEmpty: true
condition: succeededOrFailed()
Loading