Merge pull request #1 from microsoft/master

Pull from ms-master
This commit is contained in:
Erik P. Ernst 2019-11-27 13:47:43 +01:00 коммит произвёл GitHub
Родитель 179efc69f5 132c4b0448
Коммит 8249032b42
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 125 добавлений и 64 удалений

Просмотреть файл

@ -49,11 +49,11 @@ class ClientContext {
}
OpenSession() {
$Global:OpenClientContext = $this
$clientSessionParameters = New-Object ClientSessionParameters
$clientSessionParameters.CultureId = $this.culture
$clientSessionParameters.UICultureId = $this.culture
$clientSessionParameters.AdditionalSettings.Add("IncludeControlIdentifier", $true)
$this.events += @(Register-ObjectEvent -InputObject $this.clientSession -EventName MessageToShow -Action {
Write-Host -ForegroundColor Yellow "Message : $($EventArgs.Message)"
if ($this.debugMode) {
@ -74,55 +74,59 @@ class ClientContext {
})
$this.events += @(Register-ObjectEvent -InputObject $this.clientSession -EventName CommunicationError -Action {
Write-Host -ForegroundColor Red "CommunicationError : $($EventArgs.Exception.Message)"
if ($null -ne $EventArgs.Exception.InnerException) {
Write-Host -ForegroundColor Red "CommunicationError InnerException : $($EventArgs.Exception.InnerException)"
}
Write-Host -ForegroundColor Red "Current Interaction: $($this.currentInteraction.ToString())"
Write-Host -ForegroundColor Red "Time spend: $(([DateTime]::Now - $this.interactionStart).Seconds) seconds"
if ($this.debugMode) {
try {
$this.GetAllForms() | ForEach-Object {
$formInfo = $this.GetFormInfo($_)
if ($formInfo) {
Write-Host -ForegroundColor Yellow "Title: $($formInfo.title)"
Write-Host -ForegroundColor Yellow "Title: $($formInfo.identifier)"
$formInfo.controls | ConvertTo-Json -Depth 99 | Out-Host
Get-PSCallStack | Write-Host -ForegroundColor Red
if ($Global:OpenClientContext) {
Write-Host -ForegroundColor Red "Current Interaction: $($Global:OpenClientContext.currentInteraction.ToString())"
Write-Host -ForegroundColor Red "Time spend: $(([DateTime]::Now - $Global:OpenClientContext.interactionStart).Seconds) seconds"
if ($Global:OpenClientContext.debugMode) {
if ($null -ne $EventArgs.Exception.InnerException) {
Write-Host -ForegroundColor Red "CommunicationError InnerException : $($EventArgs.Exception.InnerException)"
}
try {
$Global:OpenClientContext.GetAllForms() | ForEach-Object {
$formInfo = $Global:OpenClientContext.GetFormInfo($_)
if ($formInfo) {
Write-Host -ForegroundColor Yellow "Title: $($formInfo.title)"
Write-Host -ForegroundColor Yellow "Title: $($formInfo.identifier)"
$formInfo.controls | ConvertTo-Json -Depth 99 | Out-Host
}
}
}
}
catch {
Write-Host "Exception when enumerating forms"
catch {
Write-Host "Exception when enumerating forms"
}
}
}
Remove-ClientSession
})
$this.events += @(Register-ObjectEvent -InputObject $this.clientSession -EventName UnhandledException -Action {
Write-Host -ForegroundColor Red "UnhandledException : $($EventArgs.Exception.Message)"
if ($null -ne $EventArgs.Exception.InnerException) {
Write-Host -ForegroundColor Red "UnhandledException InnerException : $($EventArgs.Exception.InnerException)"
}
Write-Host -ForegroundColor Red "Current Interaction: $($this.currentInteraction.ToString())"
Write-Host -ForegroundColor Red "Time spend: $(([DateTime]::Now - $this.interactionStart).Seconds) seconds"
if ($this.debugMode) {
try {
$this.GetAllForms() | ForEach-Object {
$formInfo = $this.GetFormInfo($_)
if ($formInfo) {
Write-Host -ForegroundColor Yellow "Title: $($formInfo.title)"
Write-Host -ForegroundColor Yellow "Title: $($formInfo.identifier)"
$formInfo.controls | ConvertTo-Json -Depth 99 | Out-Host
Get-PSCallStack | Write-Host -ForegroundColor Red
if ($Global:OpenClientContext) {
Write-Host -ForegroundColor Red "Current Interaction: $($Global:OpenClientContext.currentInteraction.ToString())"
Write-Host -ForegroundColor Red "Time spend: $(([DateTime]::Now - $Global:OpenClientContext.interactionStart).Seconds) seconds"
if ($Global:OpenClientContext.debugMode) {
if ($null -ne $EventArgs.Exception.InnerException) {
Write-Host -ForegroundColor Red "UnhandledException InnerException : $($EventArgs.Exception.InnerException)"
}
try {
$Global:OpenClientContext.GetAllForms() | ForEach-Object {
$formInfo = $Global:OpenClientContext.GetFormInfo($_)
if ($formInfo) {
Write-Host -ForegroundColor Yellow "Title: $($formInfo.title)"
Write-Host -ForegroundColor Yellow "Title: $($formInfo.identifier)"
$formInfo.controls | ConvertTo-Json -Depth 99 | Out-Host
}
}
}
}
catch {
Write-Host "Exception when enumerating forms"
catch {
Write-Host "Exception when enumerating forms"
}
}
}
Remove-ClientSession
})
$this.events += @(Register-ObjectEvent -InputObject $this.clientSession -EventName InvalidCredentialsError -Action {
Write-Host -ForegroundColor Red "InvalidCredentialsError"
Remove-ClientSession
Get-PSCallStack | Write-Host -ForegroundColor Red
})
$this.events += @(Register-ObjectEvent -InputObject $this.clientSession -EventName UriToShow -Action {
Write-Host -ForegroundColor Yellow "UriToShow : $($EventArgs.UriToShow)"
@ -158,6 +162,8 @@ class ClientContext {
#
Dispose() {
$Global:OpenClientContext = $null
$this.events | ForEach-Object { Unregister-Event $_.Name }
$this.events = @()
@ -175,13 +181,14 @@ class ClientContext {
$now = [DateTime]::Now
While ($this.clientSession.State -ne $state) {
Start-Sleep -Milliseconds 100
if ($this.clientSession.State -eq [ClientSessionState]::InError) {
$thisstate = $this.clientSession.State
if ($thisstate -eq [ClientSessionState]::InError) {
throw "ClientSession State is InError (Wait time $(([DateTime]::Now - $now).Seconds) seconds)"
}
if ($this.clientSession.State -eq [ClientSessionState]::TimedOut) {
if ($thisstate -eq [ClientSessionState]::TimedOut) {
throw "ClientSession State is TimedOut (Wait time $(([DateTime]::Now - $now).Seconds) seconds)"
}
if ($this.clientSession.State -eq [ClientSessionState]::Uninitialized) {
if ($thisstate -eq [ClientSessionState]::Uninitialized) {
$waited = ([DateTime]::Now - $now).Seconds
if ($waited -ge 10) {
throw "ClientSession State is Uninitialized (Wait time $waited seconds)"
@ -216,9 +223,14 @@ class ClientContext {
}
[ClientLogicalForm] OpenForm([int] $page) {
$interaction = New-Object OpenFormInteraction
$interaction.Page = $page
return $this.InvokeInteractionAndCatchForm($interaction)
try {
$interaction = New-Object OpenFormInteraction
$interaction.Page = $page
return $this.InvokeInteractionAndCatchForm($interaction)
}
catch {
return $null
}
}
CloseForm([ClientLogicalControl] $form) {

Просмотреть файл

@ -50,7 +50,8 @@ function Get-TestsFromNavContainer {
[int] $testPage,
[switch] $debugMode,
[switch] $ignoreGroups,
[switch] $usePublicWebBaseUrl
[switch] $usePublicWebBaseUrl,
[string] $useUrl
)
$navversion = Get-NavContainerNavversion -containerOrImageName $containerName
@ -60,7 +61,7 @@ function Get-TestsFromNavContainer {
$inspect = docker inspect $containerName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('traefik.enable').Count -gt 0) {
if ($inspect.config.Labels.'traefik.enable' -eq "true") {
$usePublicWebBaseUrl = $true
$usePublicWebBaseUrl = ($useUrl -eq "")
}
}
}
@ -72,6 +73,10 @@ function Get-TestsFromNavContainer {
$serverConfiguration = Get-NavContainerServerConfiguration -ContainerName $containerName
$clientServicesCredentialType = $serverConfiguration.ClientServicesCredentialType
if ($usePublicWebBaseUrl -and $useUrl -ne "") {
throw "You cannot specify usePublicWebBaseUrl and useUrl at the same time"
}
if ($serverConfiguration.PublicWebBaseUrl -eq "") {
throw "Container $containerName needs to include the WebClient in order to get tests (PublicWebBaseUrl is blank)"
}
@ -142,7 +147,7 @@ function Get-TestsFromNavContainer {
}
} -argumentList "01:00:00"
$result = Invoke-ScriptInNavContainer -containerName $containerName { Param([string] $tenant, [string] $companyName, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testCodeunit, [string] $PsTestFunctionsPath, [string] $ClientContextPath, $testPage, $version, $debugMode, $ignoreGroups, $usePublicWebBaseUrl, $extensionId, $disabledtests)
$result = Invoke-ScriptInNavContainer -containerName $containerName { Param([string] $tenant, [string] $companyName, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testCodeunit, [string] $PsTestFunctionsPath, [string] $ClientContextPath, $testPage, $version, $debugMode, $ignoreGroups, $usePublicWebBaseUrl, $useUrl, $extensionId, $disabledtests)
$newtonSoftDllPath = (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll").FullName
$clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll"
@ -151,12 +156,16 @@ function Get-TestsFromNavContainer {
$publicWebBaseUrl = $customConfig.SelectSingleNode("//appSettings/add[@key='PublicWebBaseUrl']").Value.TrimEnd('/')
$clientServicesCredentialType = $customConfig.SelectSingleNode("//appSettings/add[@key='ClientServicesCredentialType']").Value
$uri = [Uri]::new($publicWebBaseUrl)
if ($usePublicWebBaseUrl) {
if ($useUrl) {
$disableSslVerification = $false
$serviceUrl = "$($useUrl.TrimEnd('/'))/cs?tenant=$tenant"
}
elseif ($usePublicWebBaseUrl) {
$disableSslVerification = $false
$serviceUrl = "$publicWebBaseUrl/cs?tenant=$tenant"
}
else {
$uri = [Uri]::new($publicWebBaseUrl)
$disableSslVerification = ($Uri.Scheme -eq "https")
$serviceUrl = "$($Uri.Scheme)://localhost:$($Uri.Port)/$($Uri.PathAndQuery)/cs?tenant=$tenant"
}
@ -214,7 +223,7 @@ function Get-TestsFromNavContainer {
}
}
} -argumentList $tenant, $companyName, $credential, $accessToken, $testSuite, $testCodeunit, $PsTestFunctionsPath, $ClientContextPath, $testPage, $version, $debugMode, $ignoreGroups, $usePublicWebBaseUrl, $extensionId, $disabledtests
} -argumentList $tenant, $companyName, $credential, $accessToken, $testSuite, $testCodeunit, $PsTestFunctionsPath, $ClientContextPath, $testPage, $version, $debugMode, $ignoreGroups, $usePublicWebBaseUrl, $useUrl, $extensionId, $disabledtests
# When Invoke-ScriptInContainer is running as non-administrator - Write-Host (like license warnings) are send to the output
# If the output is an array - grab the last item.

Просмотреть файл

@ -50,7 +50,7 @@ function New-ClientContext {
throw "Unsupported authentication setting"
}
if ($clientContext) {
$clientContext.DebugMode = $debugMode
$clientContext.debugMode = $debugMode
}
return $clientContext
}
@ -151,7 +151,7 @@ function Get-Tests {
$form = $clientContext.OpenForm($testPage)
if (!($form)) {
throw "Cannot open page $testPage. You might need to import the test toolkit to the container and/or remove the folder $PSScriptRoot and retry."
throw "Cannot open page $testPage. You might need to import the test toolkit to the container and/or remove the folder $PSScriptRoot and retry. You might also have URL or Company name wrong."
}
$suiteControl = $clientContext.GetControlByName($form, "CurrentSuiteName")
@ -261,7 +261,7 @@ function Run-Tests {
$form = $clientContext.OpenForm($testPage)
if (!($form)) {
throw "Cannot open page $testPage. You might need to import the test toolkit to the container and/or remove the folder $PSScriptRoot and retry."
throw "Cannot open page $testPage. You might need to import the test toolkit to the container and/or remove the folder $PSScriptRoot and retry. You might also have URL or Company name wrong."
}
$suiteControl = $clientContext.GetControlByName($form, "CurrentSuiteName")

Просмотреть файл

@ -85,6 +85,7 @@ function Run-TestsInNavContainer {
[switch] $debugMode,
[switch] $restartContainerAndRetry,
[switch] $usePublicWebBaseUrl,
[string] $useUrl = "",
[switch] $connectFromHost
)
@ -95,7 +96,7 @@ function Run-TestsInNavContainer {
$inspect = docker inspect $containerName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('traefik.enable').Count -gt 0) {
if ($inspect.config.Labels.'traefik.enable' -eq "true") {
$usePublicWebBaseUrl = $true
$usePublicWebBaseUrl = ($useUrl -eq "")
$useTraefik = $true
}
}
@ -107,13 +108,19 @@ function Run-TestsInNavContainer {
$serverConfiguration = Get-NavContainerServerConfiguration -ContainerName $containerName
$clientServicesCredentialType = $serverConfiguration.ClientServicesCredentialType
if ($usePublicWebBaseUrl -and $useUrl -ne "") {
throw "You cannot specify usePublicWebBaseUrl and useUrl at the same time"
}
if ($serverConfiguration.PublicWebBaseUrl -eq "") {
throw "Container $containerName needs to include the WebClient in order to run tests (PublicWebBaseUrl is blank)"
}
if ([bool]($serverConfiguration.PSobject.Properties.name -match "EnableTaskScheduler")) {
if ($serverConfiguration.EnableTaskScheduler -eq "True") {
Write-Host -ForegroundColor Red "WARNING: TaskScheduler is running in the container. Please specify -EnableTaskScheduler:`$false when creating container."
if ($useUrl -eq "") {
if ([bool]($serverConfiguration.PSobject.Properties.name -match "EnableTaskScheduler")) {
if ($serverConfiguration.EnableTaskScheduler -eq "True") {
Write-Host -ForegroundColor Red "WARNING: TaskScheduler is running in the container. Please specify -EnableTaskScheduler:`$false when creating container."
}
}
}
@ -203,7 +210,12 @@ function Run-TestsInNavContainer {
} -argumentList $newtonSoftDllPath, $clientDllPath
$config = Get-NavContainerServerConfiguration -ContainerName $containerName
$publicWebBaseUrl = $config.PublicWebBaseUrl.TrimEnd('/')
if ($useUrl) {
$publicWebBaseUrl = $useUrl.TrimEnd('/')
}
else {
$publicWebBaseUrl = $config.PublicWebBaseUrl.TrimEnd('/')
}
$clientServicesCredentialType = $config.ClientServicesCredentialType
$serviceUrl = "$publicWebBaseUrl/cs?tenant=$tenant"
@ -221,7 +233,7 @@ function Run-TestsInNavContainer {
$clientContext = $null
try {
$clientContext = New-ClientContext -serviceUrl $serviceUrl -auth $clientServicesCredentialType -credential $credential -interactionTimeout $interactionTimeout -debugMode:$debugMode
$result = Run-Tests -clientContext $clientContext `
-TestSuite $testSuite `
-TestGroup $testGroup `
@ -259,7 +271,7 @@ function Run-TestsInNavContainer {
}
}
$result = Invoke-ScriptInNavContainer -containerName $containerName { Param([string] $tenant, [string] $companyName, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testGroup, [string] $testCodeunit, [string] $testFunction, [string] $PsTestFunctionsPath, [string] $ClientContextPath, [string] $XUnitResultFileName, [bool] $AppendToXUnitResultFile, [bool] $ReRun, [string] $AzureDevOps, [bool] $detailed, [timespan] $interactionTimeout, $testPage, $version, $debugMode, $usePublicWebBaseUrl, $extensionId, $disabledtests)
$result = Invoke-ScriptInNavContainer -containerName $containerName { Param([string] $tenant, [string] $companyName, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testGroup, [string] $testCodeunit, [string] $testFunction, [string] $PsTestFunctionsPath, [string] $ClientContextPath, [string] $XUnitResultFileName, [bool] $AppendToXUnitResultFile, [bool] $ReRun, [string] $AzureDevOps, [bool] $detailed, [timespan] $interactionTimeout, $testPage, $version, $debugMode, $usePublicWebBaseUrl, $useUrl, $extensionId, $disabledtests)
$newtonSoftDllPath = (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll").FullName
$clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll"
@ -268,12 +280,16 @@ function Run-TestsInNavContainer {
$publicWebBaseUrl = $customConfig.SelectSingleNode("//appSettings/add[@key='PublicWebBaseUrl']").Value.TrimEnd('/')
$clientServicesCredentialType = $customConfig.SelectSingleNode("//appSettings/add[@key='ClientServicesCredentialType']").Value
$uri = [Uri]::new($publicWebBaseUrl)
if ($usePublicWebBaseUrl) {
if ($useUrl) {
$disableSslVerification = $false
$serviceUrl = "$($useUrl.TrimEnd('/'))/cs?tenant=$tenant"
}
elseif ($usePublicWebBaseUrl) {
$disableSslVerification = $false
$serviceUrl = "$publicWebBaseUrl/cs?tenant=$tenant"
}
else {
$uri = [Uri]::new($publicWebBaseUrl)
$disableSslVerification = ($Uri.Scheme -eq "https")
$serviceUrl = "$($Uri.Scheme)://localhost:$($Uri.Port)/$($Uri.PathAndQuery)/cs?tenant=$tenant"
}
@ -338,7 +354,7 @@ function Run-TestsInNavContainer {
}
}
} -argumentList $tenant, $companyName, $credential, $accessToken, $testSuite, $testGroup, $testCodeunit, $testFunction, $PsTestFunctionsPath, $ClientContextPath, $containerXUnitResultFileName, $AppendToXUnitResultFile, $ReRun, $AzureDevOps, $detailed, $interactionTimeout, $testPage, $version, $debugMode, $usePublicWebBaseUrl, $extensionId, $disabledtests
} -argumentList $tenant, $companyName, $credential, $accessToken, $testSuite, $testGroup, $testCodeunit, $testFunction, $PsTestFunctionsPath, $ClientContextPath, $containerXUnitResultFileName, $AppendToXUnitResultFile, $ReRun, $AzureDevOps, $detailed, $interactionTimeout, $testPage, $version, $debugMode, $usePublicWebBaseUrl, $useUrl, $extensionId, $disabledtests
}
if ($result -is [array]) {
0..($result.Count-2) | % { Write-Host $result[$_] }

Просмотреть файл

@ -37,6 +37,19 @@ function Sort-AppFoldersByDependencies {
}
else {
$appJson = Get-Content -Path $appJsonFile | ConvertFrom-Json
# replace id with appid
if ($appJson.dependencies) {
$appJson.dependencies = $appJson.dependencies | % {
if ($_.psobject.Members | where-object membertype -like 'noteproperty' | Where-Object name -eq "id") {
New-Object psobject -Property ([ordered]@{ "appId" = $_.id; "publisher" = $_.publisher; "name" = $_.name; "version" = $_.version })
}
else {
$_
}
}
}
$folders += @{ "$($appJson.Id)" = $appFolder }
$apps += @($appJson)
}

Просмотреть файл

@ -66,7 +66,7 @@ function New-DesktopShortcut {
$Shortcut.IconLocation = $IconLocation
}
$Shortcut.save()
Move-Item -Path $tempfilename -Destination $filename
Move-Item -Path $tempfilename -Destination $filename -ErrorAction SilentlyContinue
if ($RunAsAdministrator) {
$bytes = [System.IO.File]::ReadAllBytes($filename)

Просмотреть файл

@ -98,6 +98,9 @@ function Import-TestToolkitToNavContainer {
if (!(Test-Path (Join-Path $serviceTierAddInsFolder "Mock Assemblies"))) {
new-item -itemtype symboliclink -path $serviceTierAddInsFolder -name "Mock Assemblies" -value $mockAssembliesPath | Out-Null
Set-NavServerInstance $serverInstance -restart
while (Get-NavTenant $serverInstance | Where-Object { $_.State -eq "Mounting" }) {
Start-Sleep -Seconds 1
}
}
$apps += "Microsoft_System Application Test Library.app", "Microsoft_Tests-TestLibraries.app" | % {
@(get-childitem -Path "C:\Applications\*.*" -recurse -filter $_)

Просмотреть файл

@ -1,3 +1,8 @@
0.6.4.20
Better error handling in Run-Tests and Get-Tests
Issue #755 Sort-AppFoldersByDependencies doesn't support "id" in dependencies
Wait for tenant ready when restarting service tier in Import-TestToolkitToNavContainer and Setup-NavContainerTestUsers
0.6.4.19
Issue 716 assignPremiumPlan shouldn't require databaseCredential when using in-container database
Support Windows Servercore 1909 generic image with useBestContainerOS

Просмотреть файл

@ -13,4 +13,4 @@ $credential = [PSCredential]::new("admin", (ConvertTo-SecureString -AsPlainText
. (Join-Path $PSScriptRoot '_CreateNavContainer.ps1')
. (Join-Path $PSScriptRoot '_CreateBcContainer.ps1')
. (Join-Path $PSScriptRoot "ObjectHandling.ps1")
. (Join-Path $PSScriptRoot "bacpac.ps1")

Просмотреть файл

@ -74,6 +74,9 @@ function Setup-NavContainerTestUsers {
if (!(Test-Path (Join-Path $serviceTierAddInsFolder "Mock Assemblies"))) {
new-item -itemtype symboliclink -path $serviceTierAddInsFolder -name "Mock Assemblies" -value $mockAssembliesPath | Out-Null
Set-NavServerInstance $serverInstance -restart
while (Get-NavTenant $serverInstance | Where-Object { $_.State -eq "Mounting" }) {
Start-Sleep -Seconds 1
}
}
get-childitem -Path "C:\Applications\*.*" -recurse -filter "Microsoft_System Application Test Library.app"
}

Просмотреть файл

@ -1 +1 @@
0.6.4.19
0.6.4.20