This commit is contained in:
Freddy Kristiansen 2019-09-06 12:09:09 +02:00
Родитель b0f19b713c
Коммит bd9870f04a
11 изменённых файлов: 107 добавлений и 17 удалений

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

@ -18,6 +18,8 @@
ID of the test page to use. Default for 15.x containers is 130455. Default for 14.x containers and earlier is 130409.
.Parameter debugMode
Include this switch to output debug information if getting the tests fails.
.Parameter ignoreGroups
Test Groups are not supported in 15.x - include this switch to ignore test groups in 14.x and earlier and have compatible resultsets from this function
.Example
Get-TestsFromNavContainer -contatinerName test -credential $credential
.Example
@ -38,7 +40,8 @@ function Get-TestsFromNavContainer {
[string] $testCodeunit = "*",
[Parameter(Mandatory=$false)]
[int] $testPage,
[switch] $debugMode
[switch] $debugMode,
[switch] $ignoreGroups
)
$navversion = Get-NavContainerNavversion -containerOrImageName $containerName
@ -96,7 +99,7 @@ function Get-TestsFromNavContainer {
}
}
Invoke-ScriptInNavContainer -containerName $containerName { Param([string] $tenant, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testCodeunit, [string] $PsTestFunctionsPath, [string] $ClientContextPath, $testPage, $version, $debugMode)
Invoke-ScriptInNavContainer -containerName $containerName { Param([string] $tenant, [pscredential] $credential, [string] $accessToken, [string] $testSuite, [string] $testCodeunit, [string] $PsTestFunctionsPath, [string] $ClientContextPath, $testPage, $version, $debugMode, $ignoreGroups)
$newtonSoftDllPath = (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Service\NewtonSoft.json.dll").FullName
$clientDllPath = "C:\Test Assemblies\Microsoft.Dynamics.Framework.UI.Client.dll"
@ -136,7 +139,7 @@ function Get-TestsFromNavContainer {
$clientContext = New-ClientContext -serviceUrl $serviceUrl -auth $clientServicesCredentialType -credential $credential -debugMode:$debugMode
Get-Tests -clientContext $clientContext -TestSuite $testSuite -TestCodeunit $testCodeunit -testPage $testPage
Get-Tests -clientContext $clientContext -TestSuite $testSuite -TestCodeunit $testCodeunit -testPage $testPage -ignoreGroups:$ignoreGroups
}
catch {
@ -152,7 +155,7 @@ function Get-TestsFromNavContainer {
Remove-ClientContext -clientContext $clientContext
}
} -argumentList $tenant, $credential, $accessToken, $testSuite, $testCodeunit, $PsTestFunctionsPath, $ClientContextPath, $testPage, $version, $debugMode | ConvertFrom-Json
} -argumentList $tenant, $credential, $accessToken, $testSuite, $testCodeunit, $PsTestFunctionsPath, $ClientContextPath, $testPage, $version, $debugMode, $ignoreGroups | ConvertFrom-Json
}
Set-Alias -Name Get-TestsFromBCContainer -Value Get-TestsFromNavContainer
Export-ModuleMember -Function Get-TestsFromNavContainer -Alias Get-TestsFromBCContainer

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

@ -85,7 +85,8 @@ function Get-Tests {
[ClientContext] $clientContext,
[int] $testPage = 130409,
[string] $testSuite = "DEFAULT",
[string] $testCodeunit = "*"
[string] $testCodeunit = "*",
[switch] $ignoreGroups
)
if ($testPage -eq 130455) {
@ -130,7 +131,7 @@ function Get-Tests {
#Write-Host "$linetype $name"
if ($name) {
if ($linetype -eq "0") {
if ($linetype -eq "0" -and !$ignoreGroups) {
$group = @{ "Group" = $name; "Codeunits" = @() }
$Tests += $group
@ -197,7 +198,7 @@ function Run-Tests {
$i = 0
if ([int]::TryParse($testCodeunit, [ref] $i) -and ($testCodeunit -eq $i)) {
$filterControl = $clientContext.GetControlByType($form, [ClientFilterLogicalControl])
if (([System.Management.Automation.PSTypeName]'Microsoft.Dynamics.Framework.UI.Client.Interactions.ExecuteFilterInteraction').Type) {
$filterInteraction = New-Object Microsoft.Dynamics.Framework.UI.Client.Interactions.ExecuteFilterInteraction -ArgumentList $filterControl
$filterInteraction.QuickFilterColumnId = $filterControl.QuickFilterColumns[0].Id

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

@ -30,7 +30,13 @@ function Backup-NavContainerDatabases {
}
elseif (!$bakFolder.Contains('\')) {
$navversion = Get-NavContainerNavversion -containerOrImageName $containerName
$bakFolder = Join-Path $containerHelperFolder "$($NavVersion)-bakFolders\$bakFolder"
if ((Invoke-ScriptInNavContainer -containerName $containerName -scriptblock { $env:IsBcSandbox }) -eq "Y") {
$folderPrefix = "sandbox"
}
else {
$folderPrefix = "onprem"
}
$bakFolder = Join-Path $containerHelperFolder "$folderPrefix-$NavVersion-bakFolders\$bakFolder"
}
$containerBakFolder = Get-NavContainerPath -containerName $containerName -path $bakFolder -throw

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

@ -54,7 +54,13 @@ function Restore-DatabasesInNavContainer {
}
elseif (!$bakFolder.Contains('\')) {
$navversion = Get-NavContainerNavversion -containerOrImageName $containerName
$bakFolder = Join-Path $containerHelperFolder "$($NavVersion)-bakFolders\$bakFolder"
if ((Invoke-ScriptInNavContainer -containerName $containerName -scriptblock { $env:IsBcSandbox }) -eq "Y") {
$folderPrefix = "sandbox"
}
else {
$folderPrefix = "onprem"
}
$bakFolder = Join-Path $containerHelperFolder "$folderPrefix-$NavVersion-bakFolders\$bakFolder"
}
$containerBakFolder = Get-NavContainerPath -containerName $containerName -path $bakFolder -throw
}

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

@ -0,0 +1,52 @@
<#
.Synopsis
Flush Caches used in ContainerHelper
.Description
Extract all files from a Container Image necessary to start a generic container with these files
.Parameter cache
Specify which cache you want to flush (default is all)
- calSourceCache is the C/AL Source Cache
- alSourceCache is the AL Source Cache
- filesCache is the files extracted from other images
- applicationCache are the test applications runtime cache (15.x containers)
- bakFolderCache are version specific backup sets
.Example
Flush-ContainerHelperCache -cache calSourceCache
#>
function Flush-ContainerHelperCache {
[CmdletBinding()]
Param (
[ValidateSet('all','calSourceCache','alSourceCache','applicationCache','bakFolderCache','filesCache')]
[string] $cache = 'all'
)
$folders = @()
if ($cache -eq 'all' -or $cache -eq 'calSourceCache') {
$folders += @("extensions\original-*-??","extensions\original-*-??-newsyntax")
}
if ($cache -eq 'all' -or $cache -eq 'filesCache') {
$folders += @("*-??-files")
}
if ($cache -eq 'all' -or $cache -eq 'alSourceCache') {
$folders += @("extensions\original-*-??-al")
}
if ($cache -eq 'all' -or $cache -eq 'applicationCache') {
$folders += @("extensions\applications-*-??","sandbox-applications-*-??","onprem-applications-*-??")
}
if ($cache -eq 'all' -or $cache -eq 'bakFolderCache') {
$folders += @("sandbox-*-bakfolders","onprem-*-bakfolders")
}
$folders | ForEach-Object {
$folder = Join-Path $hostHelperFolder $_
Get-Item $folder | ?{ $_.PSIsContainer } | ForEach-Object {
Write-Host "Removing Cache $($_.FullName)"
Remove-Item -Path $_.FullName -Recurse -Force
}
}
}
Export-ModuleMember -Function Flush-ContainerHelperCache

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

@ -342,6 +342,8 @@ function New-NavContainer {
$devCountry = ""
$navVersion = ""
$bcStyle = "onprem"
if ($imageName -eq "") {
if ("$dvdPath" -ne "") {
if ($useGenericImage) {
@ -530,9 +532,19 @@ function New-NavContainer {
}
if ($navVersion -eq "") {
$navversion = Get-NavContainerNavversion -containerOrImageName $imageName
$inspect = docker inspect $imageName | ConvertFrom-Json
if ($inspect.Config.Labels.psobject.Properties.Match('nav').Count -eq 0) {
throw "Container $containerOrImageName is not a NAV/BC container"
}
$navversion = "$($inspect.Config.Labels.version)-$($inspect.Config.Labels.country)"
if ($inspect.Config.Env | Where-Object { $_ -eq "IsBcSandbox=Y" }) {
$bcStyle = "sandbox"
}
}
Write-Host "Version: $navversion"
Write-Host "Style: $bcStyle"
$version = [System.Version]($navversion.split('-')[0])
$platformversion = Get-NavContainerPlatformversion -containerOrImageName $imageName -ErrorAction SilentlyContinue
if ($platformversion) {
@ -778,7 +790,7 @@ function New-NavContainer {
$restoreBakFolder = $false
if ($bakFolder) {
if (!$bakFolder.Contains('\')) {
$bakFolder = Join-Path $containerHelperFolder "$($NavVersion)-bakFolders\$bakFolder"
$bakFolder = Join-Path $containerHelperFolder "$bcStyle-$($NavVersion)-bakFolders\$bakFolder"
}
if (Test-Path (Join-Path $bakFolder "*.bak")) {
$restoreBakFolder = $true

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

@ -107,7 +107,7 @@ FunctionsToExport = 'Add-FontsToNavContainer', 'Backup-NavContainerDatabases', '
'Invoke-NavContainerApi', 'Invoke-NavContainerCodeunit',
'Invoke-ScriptInNavContainer', 'New-CompanyInNavContainer',
'New-DesktopShortcut', 'New-LetsEncryptCertificate',
'New-NavContainer', 'New-NavContainerNavUser',
'New-NavContainer', 'Flush-ContainerHelperCache', 'New-NavContainerNavUser',
'New-NavContainerTenant', 'New-NavContainerWindowsUser',
'Open-NavContainer', 'Publish-NavContainerApp',
'Publish-NewApplicationToNavContainer',

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

@ -88,6 +88,7 @@ Check-NavContainerHelperPermissions -Silent
. (Join-Path $PSScriptRoot "ContainerHandling\Get-BestNavContainerImageName.ps1")
. (Join-Path $PSScriptRoot "ContainerHandling\Invoke-ScriptInNavContainer.ps1")
. (Join-Path $PSScriptRoot "ContainerHandling\Setup-TraefikContainerForNavContainers.ps1")
. (Join-Path $PSScriptRoot "ContainerHandling\Flush-ContainerHelperCache.ps1")
# Object Handling functions
. (Join-Path $PSScriptRoot "ObjectHandling\Export-NavContainerObjects.ps1")

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

@ -83,7 +83,13 @@ function Import-TestToolkitToNavContainer {
}
if (!$doNotUseRuntimePackages) {
$applicationsPath = "C:\ProgramData\NavContainerHelper\Extensions\Applications-$navVersion"
if ($env:IsBcSandbox -eq "Y") {
$folderPrefix = "sandbox"
}
else {
$folderPrefix = "onprem"
}
$applicationsPath = "C:\ProgramData\NavContainerHelper\Extensions\$folderPrefix-Applications-$navVersion"
if (!(Test-Path $applicationsPath)) {
New-Item -Path $applicationsPath -ItemType Directory | Out-Null
}
@ -110,7 +116,7 @@ function Import-TestToolkitToNavContainer {
Sync-NavApp -ServerInstance $ServerInstance -Publisher $appPublisher -Name $appName -Version $appVersion -Tenant default -force -WarningAction Ignore
Install-NavApp -ServerInstance $ServerInstance -Publisher $appPublisher -Name $appName -Version $appVersion -Tenant default
if (!$doNotUseRuntimePackages -and !$useRuntimeApp) {
Get-NavAppRuntimePackage -ServerInstance $serverInstance -Publisher $appPublisher -Name $appName -version $appVersion -Path $runtimeAppFile
Get-NavAppRuntimePackage -ServerInstance $serverInstance -Publisher $appPublisher -Name $appName -version $appVersion -Path $runtimeAppFile -Tenant default
}
}
}

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

@ -1,13 +1,16 @@
0.6.3.5
0.6.4.0
Cleanup help for functions
Add more debugging info to Get-/Run-Tests when using -DebugMode
Add function Restore-DatabasesInBcContainer
New function Restore-DatabasesInBcContainer
Cannot find txt2al in latest 15.x container
Add parameter doNotUseRuntimePackages to New-BcContainer
Ignore empty runtime packages when caching runtime test apps
Add credential parameter to Create-AlProjectFolderFromBcContainer
Add support for relative bakfolders in Backup/Restore
Add parameter bakFolder to New-BcContainer to store and reuse database
Rename application runtime cache to sandbox-applications or onprem-applications based on style
Add parameter -ignoreGroups to Get-TestsFromBcContainer to allow compatible output with 15.x containers (where groups are not supported)
New function Flush-ContainerHelperCache to cleanup caches used by ContainerHelperCache
0.6.3.4
Bugfix #570: Get-NavContainerAppInfo can return one app multiple times

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

@ -1 +1 @@
0.6.3.5
0.6.4.0