Skip to content
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

chore: run tests on linux and windows #233

Merged
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4270f1e
chore: run tests on linux and windows
stijnmoreels Nov 12, 2021
d646628
pr-fix: update with correct multiple var group
stijnmoreels Nov 12, 2021
4ed17dd
pr-fix: update with correct array def
stijnmoreels Nov 12, 2021
a8baaf7
pr-fix: update with correct array def
stijnmoreels Nov 12, 2021
3ea8097
pr-fix: update with correct array def
stijnmoreels Nov 12, 2021
08be2ff
pr-fix: update with correct array def
stijnmoreels Nov 12, 2021
2803275
pr-fix: update with strategy in job
stijnmoreels Nov 12, 2021
7df3faf
pr-fix: update with strategy in job
stijnmoreels Nov 12, 2021
9082d53
pr-fix: update with allow glober installing ps modules
stijnmoreels Nov 12, 2021
ac638cc
pr-fix: update w correct vm image on build
stijnmoreels Nov 12, 2021
006ef62
pr-temp: check windows latest
stijnmoreels Nov 12, 2021
2e63200
pr-fix: don't use variable in strategy.matrix variable definition
stijnmoreels Nov 12, 2021
e16636e
pr-fix: update with `-AllowClobber` on installing dependent ps modules
stijnmoreels Nov 15, 2021
2801544
pr-fix: update with cross-platform support
stijnmoreels Nov 18, 2021
71158a5
Merge branch 'chore/run-linux-and-windows' of https://github.com/stij…
stijnmoreels Nov 18, 2021
4d90a0a
pr-fix: add integration account maps to integration test project
stijnmoreels Nov 18, 2021
0d845bc
Merge branch 'master' into chore/run-linux-and-windows
stijnmoreels Nov 18, 2021
7a00d05
pr-fix: add sql files to integration test project and prepare for win…
stijnmoreels Nov 18, 2021
9af3b63
pr-prop: runtime variable declaration
stijnmoreels Nov 18, 2021
9da7e8c
pr-fix: update release pipeline with runtime vars
stijnmoreels Nov 18, 2021
fb24a47
pr-sug: remove try/catch for warming up sql connection
stijnmoreels Nov 18, 2021
6969553
pr-fix: update with correct sql statement
stijnmoreels Nov 18, 2021
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
15 changes: 11 additions & 4 deletions build/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ stages:
jobs:
- job: Compile
pool:
vmImage: '$(Vm.Image)'
vmImage: '$(Vm.Linux.Image)'
steps:
- task: qetza.replacetokens.replacetokens-task.replacetokens@3
displayName: 'Replace package version tokens'
Expand Down Expand Up @@ -75,7 +75,7 @@ stages:
- job: RunUnitTests
displayName: 'Run unit tests'
pool:
vmImage: '$(Vm.Image)'
vmImage: '$(Vm.Linux.Image)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
Expand All @@ -93,8 +93,15 @@ stages:
jobs:
- job: RunIntegrationTests
displayName: 'Run integration tests'
strategy:
maxParallel: 1
matrix:
linux:
imageName: ${{ variables['Vm.Linux.Image']}}
windows:
imageName: ${{ variables['Vm.Windows.Image']}}
pool:
vmImage: '$(Vm.Image)'
vmImage: '$(imageName)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
Expand All @@ -115,7 +122,7 @@ stages:
- job: PushToMyGet
displayName: 'Push to MyGet'
pool:
vmImage: 'windows-2019'
vmImage: '$(Vm.Linux.Image)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
Expand Down
15 changes: 11 additions & 4 deletions build/psgallery-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ stages:
jobs:
- job: Compile
pool:
vmImage: '$(Vm.Image)'
vmImage: '$(Vm.Linux.Image)'
steps:
- task: qetza.replacetokens.replacetokens-task.replacetokens@3
displayName: 'Replace package version tokens'
Expand Down Expand Up @@ -79,7 +79,7 @@ stages:
- job: RunUnitTests
displayName: 'Run unit tests'
pool:
vmImage: '$(Vm.Image)'
vmImage: '$(Vm.Linux.Image)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
Expand All @@ -97,8 +97,15 @@ stages:
jobs:
- job: RunIntegrationTests
displayName: 'Run integration tests'
strategy:
maxParallel: 1
matrix:
linux:
imageName: ${{ variables['Vm.Linux.Image']}}
windows:
imageName: ${{ variables['Vm.Windows.Image']}}
pool:
vmImage: '$(Vm.Image)'
vmImage: '$(imageName)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
Expand All @@ -119,7 +126,7 @@ stages:
- job: PushToNuGet
displayName: 'Push to PowerShell Gallery'
pool:
vmImage: '$(Vm.Image)'
vmImage: '$(Vm.Linux.Image)'
variables:
${{ if ne(variables['Prerelease'], 'none') }}:
Package.Version: "${{ parameters['Package.Version'] }}${{ parameters['Prerelease'] }}"
Expand Down
4 changes: 2 additions & 2 deletions build/templates/run-pester-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ steps:
$content.RequiredModules |
where { $_.ModuleName -ne $null -and $_.ModuleName -notlike 'Arcus.Scripting.*' -and $_.ModuleVersion -ne "#{Package.Version}#" } |
% { Write-Host "Install $($_.ModuleName) module $($_.ModuleVersion)"
Install-Module $_.ModuleName -MaximumVersion $_.ModuleVersion -Force -SkipPublisherCheck } }
Install-Module -Name Az -Force -SkipPublisherCheck -MaximumVersion 5.6.0
Install-Module $_.ModuleName -MaximumVersion $_.ModuleVersion -AllowClobber -Force -SkipPublisherCheck } }
Install-Module -Name Az -Force -AllowClobber -SkipPublisherCheck -MaximumVersion 5.6.0
Install-Module -Name AzTable -Force -SkipPublisherCheck -MaximumVersion 2.1.0
Write-Host "Done installing, start importing modules"
displayName: 'Install Pester test framework and Az required modules'
Expand Down
3 changes: 2 additions & 1 deletion build/variables/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
variables:
DotNet.Sdk.Version: '2.2.105'
Project: 'Arcus.Scripting'
Vm.Image: 'ubuntu-latest'
Vm.Linux.Image: 'ubuntu-latest'
Vm.Windows.Image: 'windows-latest'
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ Write-Verbose "Creating Azure Key Vault secret from file..."
$secretValue = $null
if ($Base64) {
Write-Verbose "Use BASE64 format as secret format"
$content = Get-Content $filePath -AsByteStream -Raw
$contentBase64 = [System.Convert]::ToBase64String($content)
$content = Get-Content $filePath -Raw
$bytes = [System.Text.Encoding]::UTF8.GetBytes($content)
$contentBase64 = [System.Convert]::ToBase64String($bytes)
$secretValue = ConvertTo-SecureString -String $contentBase64 -Force -AsPlainText
} else {
$rawContent = Get-Content $FilePath -Raw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,18 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = "unexisting-integration-account"
$schemaFilePath = "$PSScriptRoot\Files\IntegrationAccount\Schemas\NestedSchema.xsd"
$schemaFilePath = "$PSScriptRoot\Files\IntegrationAccount\Schemas\NestedSchema.xsd"
$schema = Get-ChildItem($schemaFilePath) -File

# Act
{
Set-AzIntegrationAccountSchemas -ResourceGroupName $resourceGroupName -Name $integrationAccountName -SchemaFilePath $schema.FullName -ErrorAction Stop
} | Should -Throw

# Assert
Assert-VerifiableMock
Assert-MockCalled Set-AzKeyVaultSecret -Times 0
{ Set-AzIntegrationAccountSchemas -ResourceGroupName $resourceGroupName -Name $integrationAccountName -SchemaFilePath $schema.FullName -ErrorAction Stop } |
Should -Throw
}
It "Create a single schema in an Integration Account" {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$schemaFilePath = "$PSScriptRoot\Files\IntegrationAccount\Schemas\NestedSchema.xsd"
$schemaFilePath = "$PSScriptRoot\Files\IntegrationAccount\Schemas\NestedSchema.xsd"
$schema = Get-ChildItem($schemaFilePath) -File
$expectedSchemaName = $schema.Name
$executionDateTime = (Get-Date).ToUniversalTime()
Expand All @@ -56,7 +51,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$schemaFilePath = "$PSScriptRoot\Files\IntegrationAccount\Schemas\NestedSchema.xsd"
$schemaFilePath = "$PSScriptRoot\Files\IntegrationAccount\Schemas\NestedSchema.xsd"
$schema = Get-ChildItem($schemaFilePath) -File
$expectedSchemaName = $schema.Name
$executionDateTime = (Get-Date).ToUniversalTime()
Expand All @@ -82,7 +77,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$schemaFilePath = "$PSScriptRoot\Files\IntegrationAccount\Schemas\NestedSchema.xsd"
$schemaFilePath = "$PSScriptRoot\Files\IntegrationAccount\Schemas\NestedSchema.xsd"
$schema = Get-ChildItem($schemaFilePath) -File
$expectedSchemaName = $schema.BaseName
$executionDateTime = (Get-Date).ToUniversalTime()
Expand All @@ -105,7 +100,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$schemaFilePath = "$PSScriptRoot\Files\IntegrationAccount\Schemas\NestedSchema.xsd"
$schemaFilePath = "$PSScriptRoot\Files\IntegrationAccount\Schemas\NestedSchema.xsd"
$schema = Get-ChildItem($schemaFilePath) -File
$artifactsPrefix = "dev-"
$expectedSchemaName = $artifactsPrefix + $schema.BaseName
Expand All @@ -129,7 +124,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$schemasFolder = "$PSScriptRoot\Files\IntegrationAccount\Schemas"
$schemasFolder = "$PSScriptRoot\Files\IntegrationAccount\Schemas"
$executionDateTime = (Get-Date).ToUniversalTime()

try {
Expand Down Expand Up @@ -158,7 +153,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$schemasFolder = "$PSScriptRoot\Files\IntegrationAccount\Schemas"
$schemasFolder = "$PSScriptRoot\Files\IntegrationAccount\Schemas"
$executionDateTime = (Get-Date).ToUniversalTime()

try {
Expand Down Expand Up @@ -187,7 +182,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$schemasFolder = "$PSScriptRoot\Files\IntegrationAccount\Schemas"
$schemasFolder = "$PSScriptRoot\Files\IntegrationAccount\Schemas"
$artifactsPrefix = "dev-"
$executionDateTime = (Get-Date).ToUniversalTime()

Expand Down Expand Up @@ -219,23 +214,18 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = "unexisting-integration-account"
$mapFilePath = "$PSScriptRoot\Files\IntegrationAccount\Maps\BankTransfer_CSV-to-BankTransfer_Canonical.xslt"
$mapFilePath = "$PSScriptRoot\Files\IntegrationAccount\Maps\BankTransfer_CSV-to-BankTransfer_Canonical.xslt"
$map = Get-ChildItem($mapFilePath) -File

# Act
{
Set-AzIntegrationAccountMaps -ResourceGroupName $resourceGroupName -Name $integrationAccountName -MapFilePath $map.FullName -ErrorAction Stop
} | Should -Throw

# Assert
Assert-VerifiableMock
Assert-MockCalled Set-AzKeyVaultSecret -Times 0
{ Set-AzIntegrationAccountMaps -ResourceGroupName $resourceGroupName -Name $integrationAccountName -MapFilePath $map.FullName -ErrorAction Stop} |
Should -Throw
}
It "Create a single map in an Integration Account" {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$mapFilePath = "$PSScriptRoot\Files\IntegrationAccount\Maps\BankTransfer_CSV-to-BankTransfer_Canonical.xslt"
$mapFilePath = "$PSScriptRoot\Files\IntegrationAccount\Maps\BankTransfer_CSV-to-BankTransfer_Canonical.xslt"
$map = Get-ChildItem($mapFilePath) -File
$expectedMapName = $map.Name
$executionDateTime = (Get-Date).ToUniversalTime()
Expand All @@ -258,7 +248,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$mapFilePath = "$PSScriptRoot\Files\IntegrationAccount\Maps\BankTransfer_CSV-to-BankTransfer_Canonical.xslt"
$mapFilePath = "$PSScriptRoot\Files\IntegrationAccount\Maps\BankTransfer_CSV-to-BankTransfer_Canonical.xslt"
$map = Get-ChildItem($mapFilePath) -File
$expectedMapName = $map.Name
$executionDateTime = (Get-Date).ToUniversalTime()
Expand All @@ -284,7 +274,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$mapFilePath = "$PSScriptRoot\Files\IntegrationAccount\Maps\BankTransfer_CSV-to-BankTransfer_Canonical.xslt"
$mapFilePath = "$PSScriptRoot\Files\IntegrationAccount\Maps\BankTransfer_CSV-to-BankTransfer_Canonical.xslt"
$map = Get-ChildItem($mapFilePath) -File
$expectedMapName = $map.BaseName
$executionDateTime = (Get-Date).ToUniversalTime()
Expand All @@ -307,7 +297,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$mapFilePath = "$PSScriptRoot\Files\IntegrationAccount\Maps\BankTransfer_CSV-to-BankTransfer_Canonical.xslt"
$mapFilePath = "$PSScriptRoot\Files\IntegrationAccount\Maps\BankTransfer_CSV-to-BankTransfer_Canonical.xslt"
$map = Get-ChildItem($mapFilePath) -File
$artifactsPrefix = "dev-"
$expectedMapName = $artifactsPrefix + $map.BaseName
Expand All @@ -331,7 +321,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$mapsFolder = "$PSScriptRoot\Files\IntegrationAccount\Maps"
$mapsFolder = "$PSScriptRoot\Files\IntegrationAccount\Maps"
$executionDateTime = (Get-Date).ToUniversalTime()

try {
Expand Down Expand Up @@ -360,7 +350,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$mapsFolder = "$PSScriptRoot\Files\IntegrationAccount\Maps"
$mapsFolder = "$PSScriptRoot\Files\IntegrationAccount\Maps"
$executionDateTime = (Get-Date).ToUniversalTime()

try {
Expand Down Expand Up @@ -389,7 +379,7 @@ InModuleScope Arcus.Scripting.IntegrationAccount {
# Arrange
$resourceGroupName = $config.Arcus.ResourceGroupName
$integrationAccountName = $config.Arcus.IntegrationAccount.Name
$mapsFolder = "$PSScriptRoot\Files\IntegrationAccount\Maps"
$mapsFolder = "$PSScriptRoot\Files\IntegrationAccount\Maps"
$artifactsPrefix = "dev-"
$executionDateTime = (Get-Date).ToUniversalTime()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,19 @@ InModuleScope Arcus.Scripting.KeyVault {
}
}
It "Set secret as BASE64 in Key Vault" {
$contents = [System.Guid]::NewGuid().ToString()
$file = New-Item -Path "test-base64-file.txt" -ItemType File -Value $contents
# Arrange
$expected = [System.Guid]::NewGuid().ToString()
$file = New-Item -Path "test-base64-file.txt" -ItemType File -Value $expected
$secretName = "Arcus-Scripting-KeyVault-MySecret-$([System.Guid]::NewGuid())"
try {
# Arrange
$secretName = "Arcus-Scripting-KeyVault-MySecret-$([System.Guid]::NewGuid())"

# Act
Set-AzKeyVaultSecretAsBase64FromFile -KeyVaultName $config.Arcus.KeyVault.VaultName -SecretName $secretName -FilePath $file.FullName

# Assert
$actual = Get-AzKeyVaultSecret -VaultName $config.Arcus.KeyVault.VaultName -Name $secretName -AsPlainText
[System.Convert]::FromBase64String($actual) |
% { [System.Text.Encoding]::UTF8.GetString($_) } |
Should -Be $contents.ToCharArray()
Should -Be $expected.ToCharArray()
} finally {
Remove-Item -Path $file.FullName
Remove-AzKeyVaultSecret -VaultName $config.Arcus.KeyVault.VaultName -Name $secretName -PassThru -Force
Expand Down Expand Up @@ -71,14 +70,13 @@ InModuleScope Arcus.Scripting.KeyVault {
}
It "Set secret as BASE64 in Key Vault with expiration date" {
# Arrange
$contents = [System.Guid]::NewGuid().ToString()
$file = New-Item -Path "test-file.txt" -ItemType File -Value $contents
$expected = [System.Guid]::NewGuid().ToString()
$file = New-Item -Path "test-base64-file.txt" -ItemType File -Value $expected
$secretName = "Arcus-Scripting-KeyVault-MySecret-$([System.Guid]::NewGuid())"
$expirationDate = (Get-Date).AddDays(7).ToUniversalTime()
$expirationDate = $expirationDate.AddTicks(-$expirationDate.Ticks)

try
{
try {
# Act
Set-AzKeyVaultSecretAsBase64FromFile -KeyVaultName $config.Arcus.KeyVault.VaultName -SecretName $secretName -Expires $expirationDate -FilePath $file.FullName

Expand All @@ -88,7 +86,7 @@ InModuleScope Arcus.Scripting.KeyVault {
$actual = Get-AzKeyVaultSecret -VaultName $config.Arcus.KeyVault.VaultName -Name $secretName -AsPlainText
[System.Convert]::FromBase64String($actual) |
% { [System.Text.Encoding]::UTF8.GetString($_) } |
Should -Be $contents.ToCharArray()
Should -Be $expected.ToCharArray()

} finally {
Remove-Item -Path $file.FullName
Expand Down
Loading