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

Fix end to end tests to work with .net 9 and new subscription #2371

Merged
merged 11 commits into from
Jan 24, 2025
Merged
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
33 changes: 26 additions & 7 deletions deploy/scripts/deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ Function New-Deployment() {
if ([string]::IsNullOrEmpty($script:gatewayVmSku)) {

# Get all vm skus available in the location and in the account
Write-Host "Determining VM sizes for Linux IoT Edge gateway simulations..."
$availableVms = Get-AzComputeResourceSku | Where-Object {
($_.ResourceType.Contains("virtualMachines")) -and `
($_.Locations -icontains $script:resourceGroupLocation) -and `
Expand Down Expand Up @@ -984,6 +985,7 @@ Write-Warning "Standard_D4s_v4 VM with Nested virtualization for IoT Edge Eflow
if ([string]::IsNullOrEmpty($script:opcPlcVmSku)) {

# We will use VM with at least 1 core and 2 GB of memory for hosting OPC PLC simulation containers.
Write-Host "Determining VM sizes for simulation containers..."
$simulationVmSizes = Get-AzVMSize $script:resourceGroupLocation `
| Where-Object { $availableVmNames -icontains $_.Name } `
| Where-Object {
Expand Down Expand Up @@ -1043,6 +1045,9 @@ Write-Warning "Standard_D4s_v4 VM with Nested virtualization for IoT Edge Eflow
Set-AzContext -Context $context
}
}
else {
Write-Host "Not registering AAD application!"
}
}
elseif (($script:aadConfig -is [string]) -and (Test-Path $script:aadConfig)) {
# read configuration from file
Expand Down Expand Up @@ -1076,26 +1081,40 @@ Write-Warning "Standard_D4s_v4 VM with Nested virtualization for IoT Edge Eflow
}

# Register current aad user to access keyvault
if (![string]::IsNullOrEmpty($script:aadConfig.UserPrincipalId)) {
$templateParameters.Add("userPrincipalId", $script:aadConfig.UserPrincipalId)
$userPrincipalId = $script:aadConfig.UserPrincipalId
if (![string]::IsNullOrWhiteSpace($userPrincipalId)) {
Write-Warning "Deployment will add access to keyvault for user $userPrincipalId..."
}
else {
$userPrincipalId = (Get-AzADUser -UserPrincipalName (Get-AzContext).Account.Id).Id

if (![string]::IsNullOrEmpty($userPrincipalId)) {
$templateParameters.Add("userPrincipalId", $userPrincipalId)
$ctx = Get-AzContext
if ($ctx.Account.Type -eq "User") {
$userPrincipalId = (Get-AzADUser -UserPrincipalName $ctx.Account.Id).Id
Write-Warning "Deployment will add access to keyvault for current user..."
}
else {
$userPrincipalId = (Get-AzADServicePrincipal -ApplicationId $ctx.Account.Id).Id
Write-Warning "Deployment will add access to keyvault for service principal id $userPrincipalId..."
}
}
if ([string]::IsNullOrWhiteSpace($userPrincipalId)) {
$userPrincipalId = $script:aadConfig.FallBackPrincipalId
if ([string]::IsNullOrWhiteSpace($userPrincipalId)) {
Write-Host "User principal could not be determined."
Write-Host "Access to deployed key vault must be configured manually..."
}
else {
$templateParameters.Add("userPrincipalId", $script:aadConfig.FallBackPrincipalId)
Write-Warning "Deployment will add access to keyvault for user $userPrincipalId (Fallback)..."
}
}
$templateParameters.Add("userPrincipalId", $userPrincipalId)

# Add IoTSuiteType tag. This tag will be applied for all resources.
$tags = @{"IoTSuiteType" = "AzureIndustrialIoT-$($script:type)-$($script:version)-PS1"}
$templateParameters.Add("tags", $tags)
$deploymentName = $script:version

# register providers
Write-Host "Registering providers..."
$script:requiredProviders | ForEach-Object {
Register-AzResourceProvider -ProviderNamespace $_
} | Out-Null
Expand Down
6 changes: 3 additions & 3 deletions tools/e2etesting/SetVariables.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ function Get-ContainerRegistrySecret
$KeyVaultName = $null
if ($registry -eq "industrialiot")
{
$KeyVaultName = "kv-release-pipeline"
$KeyVaultName = "kv-industrialiot"
}
if ($registry -eq "industrialiotdev")
{
$KeyVaultName = "kv-developer-pipeline"
$KeyVaultName = "kv-industrialiotdev"
}
if ($registry -eq "industrialiotprod")
{
# $KeyVaultName = "kv-release-pipeline" #todo
# $KeyVaultName = "kv-industrialiotprod" #todo
}
if ($KeyVaultName)
{
Expand Down
36 changes: 15 additions & 21 deletions tools/e2etesting/steps/deployplatform.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
steps:
- task: AzurePowerShell@5
displayName: 'Select Image to test'
inputs:
azureSubscription: '$(AzureSubscription)'
azurePowerShellVersion: 'latestVersion'
workingDirectory: '$(BasePath)'
scriptType: filePath
scriptPath: '$(BasePath)\tools\e2etesting\SetVariables.ps1'
scriptArguments: >
-BranchName "$(BranchName)"
-Region "$(Region)"
-ImageTag "$(PlatformVersion)"
-ContainerRegistryServer "$(ContainerRegistryServer)"

- task: UseDotNet@2
displayName: 'Install .NET Core SDK for building'
inputs:
packageType: sdk
version: 8.0.x
version: 9.0.x
includePreviewVersions: false
installationPath: $(Agent.ToolsDirectory)/dotnet

Expand All @@ -24,20 +38,6 @@ steps:
Write-Host "##vso[task.setvariable variable=ServicePrincipalAccessToken]$($accessToken.accessToken)"
Write-Host "##vso[task.setvariable variable=ServicePrincipalTenantId]$($env:tenantId)"

- task: AzurePowerShell@5
displayName: 'Select Image to test'
inputs:
azureSubscription: '$(AzureSubscription)'
azurePowerShellVersion: 'latestVersion'
workingDirectory: '$(BasePath)'
scriptType: filePath
scriptPath: '$(BasePath)\tools\e2etesting\SetVariables.ps1'
scriptArguments: >
-BranchName "$(BranchName)"
-Region "$(Region)"
-ImageTag "$(PlatformVersion)"
-ContainerRegistryServer "$(ContainerRegistryServer)"

- task: AzurePowerShell@5
displayName: "Run deployment script"
retryCountOnTaskFailure: 2
Expand Down Expand Up @@ -90,9 +90,3 @@ steps:
scriptPath: '$(BasePath)\tools\e2etesting\DetermineKeyVaultName.ps1'
scriptArguments: >
-ResourceGroupName '$(ResourceGroupName)'
- task: AzureKeyVault@1
displayName: 'Retrieve App identifier'
inputs:
azureSubscription: '$(AzureSubscription)'
KeyVaultName: '$(KeyVaultName)'
SecretsFilter: 'PCS-AUTH-CLIENT-APPID,PCS-AUTH-TENANT'
4 changes: 2 additions & 2 deletions tools/e2etesting/steps/runtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ steps:
-ResourceGroupName "$(ResourceGroupName)"
-ServicePrincipalName "$(ServicePrincipalId)"

- task: AzureKeyVault@1
- task: AzureKeyVault@2
displayName: 'Retrieve KeyVault secrets'
inputs:
azureSubscription: '$(AzureSubscription)'
KeyVaultName: '$(KeyVaultName)'
SecretsFilter: 'PCS-IOTHUB-CONNSTRING,plc-simulation-urls,plc-simulation-ips,iot-edge-vm-username,iot-edge-vm-publickey,iot-edge-vm-privatekey,iot-edge-device-id,iot-edge-device-dnsname,iothub-eventhub-connectionstring,PCS-SUBSCRIPTION-ID'
- task: AzureKeyVault@1
- task: AzureKeyVault@2
displayName: 'Retrieve KeyVault secrets for API tests'
condition: notIn( '${{ parameters.ModeValue }}', 'standalone', 'AE')
inputs:
Expand Down
Loading