microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
381 stars 243 forks source link

Error Get-TestsFromNavContainer NavContainerHelper > 0.6.4.27 #878

Closed pmatsconsulting closed 4 years ago

pmatsconsulting commented 4 years ago

I have updated NavContainerHelper in version 0.6.4.30. Now, when I run Get-TestsFromNavContainer I got this error :

The property 'Tests' cannot be found on this object. Verify that the property exists and can be set. at Get-Tests, C:\ProgramData\NavContainerHelper\Extensions\CAGCO150-Dev\PsTestTool-4\PsTestFunctions.ps1: line 218 at , : line 51

Was working with NavContainerHelper in version 0.6.4.27.

freddydk commented 4 years ago

If you uninstall and install 0.6.4.27 - is it then still working?

Or are you using a different image as well? Could you provide a repro script?

freddydk commented 4 years ago

When I run this script:

$credential = New-Object pscredential 'admin', (ConvertTo-SecureString -String 'P@ssword1' -AsPlainText -Force)
New-NavContainer `
    -accept_eula `
    -imageName mcr.microsoft.com/businesscentral/sandbox:us `
    -containerName test `
    -auth UserPassword `
    -Credential $credential `
    -updateHosts -licenseFile 'C:\temp\build.flf'
Import-TestToolkitToBCContainer test -credential $credential
# Open client and import tests
Get-TestsFromBCContainer test -credential $credential

Then I get

Tests                                                                                                                                                                                            Name                          
-----                                                                                                                                                                                            ----                          
{WarmupInvoicePosting}                                                                                                                                                                           Sys. Warmup Scenarios         
{T001_SecondSubscriberCannotSubscribeOfficially, T002_FirstUnofficialSubscriberGetsSkipped, T003_FirstOfficialSecondUnofficialSubscriber, T004_TestOfficialSubscribers...}                       Error Message Handling        
{T001_PostingDateIsInNotAllowedPeriodInGLSetup, T002_PostingDateIsInNotAllowedPeriodInUserSetup, T900_PreviewWithOneLoggedAndOneDirectError, T940_BatchPostingWithOneLoggedAndOneDirectError...} Sales Document Posting Errors 
{T001_PostingDateIsInNotAllowedPeriodInGLSetup, T002_PostingDateIsInNotAllowedPeriodInUserSetup, T900_PreviewWithOneLoggedAndOneDirectError, T940_BatchPostingWithOneLoggedAndOneDirectError...} Purch. Document Posting Errors

I need more info about which container, isolation, authentication etc. etc. etc.

I will close this.

Please provide script which was used to create the container and repro the error including the full output of these script if I am to investigate further.

pmatsconsulting commented 4 years ago

For the container : isolation is Process authentication is UserPassword

The error occurs for the 2nd command when I run at least 2 times the Get-TestsFormNavContainer and for the first App, no test codeunit in the App :

$Parameters = @{} if ($User -ne "") { $Parameters += @{"credential" = (New-Object System.Management.Automation.PSCredential ($User, (ConvertTo-SecureString $Password -AsPlainText -Force)))}}

$Tests = Get-TestsFromNavContainer @Parameters -containerName $ContainerName -ignoreGroups -testSuite $TestSuite -extensionId $AppId1

$Tests = Get-TestsFromNavContainer @Parameters -containerName $ContainerName -ignoreGroups -testSuite $TestSuite -extensionId $AppId2

With $AppId1, no test codeunit in the App

Error occurs at the 2nd command : The property 'Tests' cannot be found on this object. Verify that the property exists and can be set. at Get-Tests, C:\ProgramData\NavContainerHelper\Extensions\CAGCO150-Dev\PsTestTool-4\PsTestFunctions.ps1: line 219 at , : line 51

If I run at least 2 times for App with test codeunits, no error occurs

freddydk commented 4 years ago

I am sorry, but this isn't enough information still. You need to provide repro steps, scripts AND output - I will spend hours and hours trying to repro this without knowing which app, which image version which platform etc etc.

pmatsconsulting commented 4 years ago

Repro steps :

Use NavContainerHelper version higher than 0.6.4.27

Create container with following commands (replace $LicenseFile and $ContainerName with adapted values) :

$LicenseFile = "D365BC-V15-DEV-License.flf"
$ContainerName = "BC150" 
$ContainerImageName = "mcr.microsoft.com/businesscentral/onprem:1910-cu2-fr" 
$Auth = "UserPassword" # Authentification NavUserPassword
$User = "sa" 
$Password = "sa" 

$Credential = (New-Object System.Management.Automation.PSCredential ($User, (ConvertTo-SecureString $Password -AsPlainText -Force))) 
$Parameters = @{
    "Accept_Eula" = $true
    "Accept_Outdated" = $true
}
if ($LicenseFile -ne "") { $Parameters += @{"licensefile" = "$LicenseFile"  } }
$IncludeCSide = $false
$EnableSymbolLoading = $false
$DoNotUseRuntimePackages = $true
$DoNotExportObjectsToText = $true
$IncludeTestToolkit  = $true
$IncludeTestLibrariesOnly = $true
$MemoryLimit = "8G"

New-NavContainer @parameters `
    -doNotCheckHealth `
    -containerName $ContainerName `
    -imageName $ContainerImageName `
    -auth $Auth `
    -Credential $Credential `
    -updateHosts `
    -includeCSide:$IncludeCSide `
    -memoryLimit $MemoryLimit `
    -doNotExportObjectsToText:$DoNotExportObjectsToText `
    -enableSymbolLoading:$EnableSymbolLoading `
    -includeTestToolkit:$IncludeTestToolkit `
        -includeTestLibrariesOnly:$IncludeTestLibrariesOnly `
        -doNotUseRuntimePackages:$DoNotUseRuntimePackages `
    -isolation process -useBestContainerOS -includeAL

Create one App with no test codeunit. Publish, Sync, Install in the container. Create one App with at least one test codeunit. Publish, Sync, Install in the container.

Run the folowing commands (replace $AppId1 value with id of the first App created with no test condeunit, replace $AppId2 value with id of the second App created with at least one test condeunit ) :

$Parameters = @{}
if ($User -ne "") { $Parameters += @{"credential" = (New-Object System.Management.Automation.PSCredential ($User, (ConvertTo-SecureString $Password -AsPlainText -Force)))}}

$Tests = Get-TestsFromNavContainer @parameters -containerName $ContainerName -ignoreGroups -testSuite $TestSuite -extensionId $AppId1

$Tests = Get-TestsFromNavContainer @parameters -containerName $ContainerName -ignoreGroups -testSuite $TestSuite -extensionId $AppId2

Output :

The property 'Tests' cannot be found on this object. Verify that the property exists and can be set.
at Get-Tests, C:\ProgramData\NavContainerHelper\Extensions\BC150\PsTestTool-4\PsTestFunctions.ps1: line 219
at <ScriptBlock>, <No file>: line 51
The property 'Tests' cannot be found on this object. Verify that the property exists and can be set.
Au caractère C:\Program Files\WindowsPowerShell\Modules\navcontainerhelper\0.6.4.30\ContainerHandling\Invoke-ScriptInNavContainer.ps1:37 : 13
+             Invoke-Command -Session $session -ScriptBlock $scriptbloc ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation : (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

Container creation output :

NavContainerHelper is version 0.6.4.30
NavContainerHelper is running as administrator
Host is Microsoft Windows 10 Entreprise - 1903
Docker Client Version is 19.03.5
Docker Server Version is 19.03.5
Using image mcr.microsoft.com/businesscentral/onprem:1910-cu2-fr-ltsc2019
Disabling Health Check (always report healthy)
Removing C:\ProgramData\NavContainerHelper\Extensions\BC150
Creating Container BC150
Version: 15.2.39040.0-fr
Style: onprem
Platform: 15.0.38951.0
Generic Tag: 0.0.9.97
Container OS Version: 10.0.17763.914 (ltsc2019)
Host OS Version: 10.0.18362.592 (1903)
A better Generic Container OS exists for your host (1903)
Using generic image mcr.microsoft.com/dynamicsnav:generic-1903
Generic Container OS Version: 10.0.18362.592 (1903)
Generic Tag of better generic: 0.0.9.99
Using locale fr-FR
Using process isolation
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Using license file D:\Sources\DevOps\Tfvc\Workspaces\3LI Industrialisation environnements\Main\Deployment\DeploymentWorkstation\DeploymentWorkstation\Template\Configs\3LI-DE
V-D365 V15-DemoAndDev-3LI Std LS Peb Perm-ISVRights-20191217.flf
Files in C:\ProgramData\NavContainerHelper\Extensions\BC150\my:
- AdditionalOutput.ps1
- license.flf
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container BC150 from image mcr.microsoft.com/dynamicsnav:generic-1903
4aebdce00c6ebf401085d9882ffa22748804cc9d743b93c0bdea75fb7f086d08
Waiting for container BC150 to be ready
Installing Business Central
Installing Url Rewrite
Installing OpenXML
Installing DotNetCore
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
Copying Web Client Files
Copying Client Files
Copying ModernDev Files
Copying PowerShell Scripts
Copying Test Assemblies
Copying Applications
Copying ReportBuilder
Changing Database Server Collation to French_100_CI_AS
SQL Server 2017 transmits information about your installation experience, as well as other usage and performance data, to Microsoft to help improve the product. To learn mor
e about SQL Server 2017 data processing and privacy controls, please see the Privacy Statement.
Copying Cronus database
Modifying Business Central Service Tier Config File for Docker
Creating Business Central Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Starting Business Central Service Tier
Installation took 322 seconds
Installation complete
Initializing...
Setting host.docker.internal to  in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to  in container hosts file (copy from host hosts file)
Setting host.docker.internal to 192.168.1.32 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.1.32 in container hosts file (copy from host hosts file)
Setting kubernetes.docker.internal to 127.0.0.1 in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to 172.22.224.1 in container hosts file
Starting Container
Hostname is BC150
PublicDnsName is BC150
Using NavUserPassword Authentication
Creating Self Signed Certificate
Self Signed Certificate Thumbprint ED12981CDFB1A39963E9CF795E1D03100E067BC9
Modifying Service Tier Config File with Instance Specific Settings
Restarting Service Tier
Registering event sources
Creating DotNetCore Web Server Instance
Using license file 'c:\run\my\license.flf'
Import License
Creating http download site
Setting SA Password and enabling SA
Creating sa as SQL User and add to sysadmin
Creating SUPER user
Container IP Address: 172.22.226.22
Container Hostname  : BC150
Container Dns Name  : BC150
Web Client          : http://BC150/BC/
Dev. Server         : http://BC150
Dev. ServerInstance : BC
Setting BC150 to 172.22.226.22 in host hosts file

Files:
http://BC150:8080/al-4.0.206840.vsix

Initialization took 45 seconds
Ready for connections!
Reading CustomSettings.config from BC150
Creating Desktop Shortcuts for BC150
Copy from container BC150 (C:\Applications\TestFramework\TestLibraries\Any\Microsoft_Any.app) to C:\ProgramData\NavContainerHelper\Extensions\BC150\_Microsoft_Any.app
Publishing C:\ProgramData\NavContainerHelper\Extensions\BC150\_Microsoft_Any.app
Synchronizing Any on tenant default
Installing Any on tenant default
App successfully published
Copy from container BC150 (C:\Applications\TestFramework\TestLibraries\Assert\Microsoft_Library Assert.app) to C:\ProgramData\NavContainerHelper\Extensions\BC150\_Microsoft_
Library Assert.app
Publishing C:\ProgramData\NavContainerHelper\Extensions\BC150\_Microsoft_Library Assert.app
Synchronizing Library Assert on tenant default
Installing Library Assert on tenant default
App successfully published
Copy from container BC150 (C:\Applications\TestFramework\TestRunner\Microsoft_Test Runner.app) to C:\ProgramData\NavContainerHelper\Extensions\BC150\_Microsoft_Test Runner.a
pp
Publishing C:\ProgramData\NavContainerHelper\Extensions\BC150\_Microsoft_Test Runner.app
Synchronizing Test Runner on tenant default
Installing Test Runner on tenant default
App successfully published
Copy from container BC150 (C:\Applications\System Application\Test\Microsoft_System Application Test Library.app) to C:\ProgramData\NavContainerHelper\Extensions\BC150\_Micr
osoft_System Application Test Library.app
Publishing C:\ProgramData\NavContainerHelper\Extensions\BC150\_Microsoft_System Application Test Library.app
Synchronizing System Application Test Library on tenant default
Installing System Application Test Library on tenant default
App successfully published
Copy from container BC150 (C:\Applications\BaseApp\Test\Microsoft_Tests-TestLibraries.app) to C:\ProgramData\NavContainerHelper\Extensions\BC150\_Microsoft_Tests-TestLibrari
es.app
Publishing C:\ProgramData\NavContainerHelper\Extensions\BC150\_Microsoft_Tests-TestLibraries.app
Synchronizing Tests-TestLibraries on tenant default
Installing Tests-TestLibraries on tenant default
App successfully published
TestToolkit successfully imported
Creating .net Assembly Reference Folder for VS Code
Copying DLLs from C:\Windows\assembly to assemblyProbingPath
Copying DLLs from C:\Program Files\Microsoft Dynamics NAV\150\Service to assemblyProbingPath
Copying DLLs from C:\Program Files (x86)\Microsoft Dynamics NAV\150\RoleTailored Client to assemblyProbingPath
Copying DLLs from C:\Test Assemblies\Mock Assemblies to assemblyProbingPath
Copying DLLs from C:\Program Files (x86)\Open XML SDK to assemblyProbingPath
Container BC150 successfully created
freddydk commented 4 years ago

You still didn't provide the output of the container creation, and you need to mark the script above as code (in the toolbar) - then I can actually see the code formatted correctly.

I really really really want to help - but there has been no change to anything in the test runner since 0.6.4.27 - so I really have a hard time believing that this is caused by containerhelper changes.

This means that I probably won't be able to repro this unless I have exactly what you have.

Reading the text again, you are trying to get tests from an app without test codeunits - now that might be that that is an error. But that would not have anything to do with the version of containerhelper. If you comment out the line getting tests from app1 (which doesn't contain any tests) does it work then?

pmatsconsulting commented 4 years ago

As explained before the error didn't occur on the first line, but on the second one. If I run just the second one, no error, if i run 2 times the second one, no error. I will format the script

freddydk commented 4 years ago

So, if you run the first line using F8 in ISE - it works = empty result. Then you run the second line using F8 in ISE - it fails. If you run the first line twice - it works. If you run the second line twice - it works.

And you have tried to uninstall navcontainerhelper and install navcontainerhelper 0.6.4.27 - and see that it actually works there? BTW - I also asked for the output of the scripts - cannot do much without that.

pmatsconsulting commented 4 years ago

I formated the scripts and provided container creation output.

The cause of issue looks like more a variable context initialisation omission than a plateform or system related context.

freddydk commented 4 years ago

Thanks

pmatsconsulting commented 4 years ago

Yes, if I run the first line with F8 = works Yes, if I run the second one with F8 = fails Yes, if I run the first one twice with F8 = works No, If I run the the second one twice with F8 (after running before the first one at least one time before), the first run fails, the second one works

pmatsconsulting commented 4 years ago

If I downgrade NavContainerHelper to 0.6.4.27 and recreate the container, I have the same issue. So the cause of the issue seems to be older.