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

Run-BCPTTestsInBcContainer error: Cannot open page 149002 #2953

Closed oscarfernandezkurago closed 1 year ago

oscarfernandezkurago commented 1 year ago

Hi,

I´ve started using the Performance Toolkit in the latest 21 version (21.5.53619.54690), and it works fine running the test from Business Central, the problem comes when I try to execute a test from powershell using the Run-BCPTTestsInBcContainer command. I´m using a local docker container.

This is the command I run:

$results = Run-BCPTTestsInBcContainer -containerName devenv21perf -credential $credential -suiteCode 'PERF'

And this is the output from Powershell:

2023-03-27_10h09_49

Thanks in advance.

freddydk commented 1 year ago

Please post the full output of the container generation as well, thanks.

oscarfernandezkurago commented 1 year ago

This is the output of the container creation:

BcContainerHelper is version 4.0.15-preview918
BcContainerHelper is not running as administrator
UsePsSession is False
Host is Microsoft Windows 11 Pro - 10.0.22000.1696
Docker Client Version is 20.10.17
Docker Server Version is 20.10.17
Removing Session bcserver
Removing container bcserver
Removing entries from hosts
Removing bcserver from container hosts file
Removing bcserver-* from container hosts file
Removing Desktop shortcuts
Removing C:\ProgramData\BcContainerHelper\Extensions\bcserver
Fetching all docker images
Fetching all docker volumes
Pulling image mcr.microsoft.com/businesscentral:10.0.20348.1607-dev
10.0.20348.1607-dev: Pulling from businesscentral
Digest: sha256:fa4e056645cf0a50158eb224832b26acbfb76d7d643a910a9e2db7c6435b2da7
Status: Downloaded newer image for mcr.microsoft.com/businesscentral:10.0.20348.1607-dev
mcr.microsoft.com/businesscentral:10.0.20348.1607-dev
Using image mcr.microsoft.com/businesscentral:10.0.20348.1607-dev
Creating Container bcserver
Style: sandbox
Multitenant: Yes
Version: 21.5.53619.54690
Platform: 21.0.53597.54628
Generic Tag: 1.0.2.14-dev
Container OS Version: 10.0.20348.1607 (ltsc2022)
Host OS Version: 10.0.22000.1696 (21H2)
Using hyperv isolation
Using locale en-US
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Using license file C:\temp\7231522.bclicense
Files in C:\ProgramData\BcContainerHelper\Extensions\bcserver\my:
- AdditionalOutput.ps1
- license.bclicense
- MainLoop.ps1
- SetupNavUsers.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container bcserver from image mcr.microsoft.com/businesscentral:10.0.20348.1607-dev
ff30bcf7dbfbd2afbd03cb57a6a7ed89612885edaf6d0f9221a5b6b490cc4365
Waiting for container bcserver to be ready
Using artifactUrl https://bcartifacts.azureedge.net/sandbox/21.5.53619.54690/w1
Using installer from C:\Run\210-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\21.5.53619.54690\platform\ServiceTier\Program Files
c:\dl\sandbox\21.5.53619.54690\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\21.5.53619.54690\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\21.5.53619.54690\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\sandbox\21.5.53619.54690\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\21.5.53619.54690\platform
c:\dl\sandbox\21.5.53619.54690\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\21.5.53619.54690\platform\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\21.5.53619.54690\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\21.5.53619.54690\w1\Extensions
Copying Applications
C:\dl\sandbox\21.5.53619.54690\platform\Applications
Copying dependencies
Copying ReportBuilder
Importing PowerShell Modules
Restoring CRONUS Demo Database
Setting CompatibilityLevel for tenant on localhost\SQLEXPRESS
Exporting Application to CRONUS
Removing Application from tenant
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
Importing license file
Copying Database on localhost\SQLEXPRESS from tenant to default
Taking database tenant offline
Copying database files
Attaching files as new Database default
Putting database tenant back online
Mounting tenant database
Mounting Database for default on server localhost\SQLEXPRESS with AllowAppDatabaseWrite = False
Sync'ing Tenant
Tenant is Operational
Stopping Business Central Service Tier
Installation took 156 seconds
Installation complete
Initializing...
Setting host.docker.internal to 192.168.202.56 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.202.56 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.26.176.1 in container hosts file
Starting Container
Hostname is bcserver
PublicDnsName is bcserver
WARNING: Container starts with TimeZone = Hora estándar romance, which is not recognized in the list of TimeZones.
Using NavUserPassword Authentication
Creating Self Signed Certificate
Self Signed Certificate Thumbprint 1222AE76AC022B19ECDB684C04CCBD992B3D8C0D
DNS identity bcserver
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
Registering event sources
Creating DotNetCore Web Server Instance
Using application pool name: BC
Using default container name: NavWebApplicationContainer
Copy files to WWW root C:\inetpub\wwwroot\BC
Create the application pool BC
Create website: NavWebApplicationContainer without SSL
Update configuration: navsettings.json
Done Configuring Web Client
Enabling Financials User Experience
Using license file 'c:\run\my\license.bclicense'
Import License
Dismounting Tenant
Mounting Tenant
Mounting Database for default on server localhost\SQLEXPRESS with AllowAppDatabaseWrite = False
Sync'ing Tenant
Tenant is Operational
Creating http download site
Setting SA Password and enabling SA
Creating user as SQL User and add to sysadmin
Creating SUPER user
Assign Premium plan for USER
Container IP Address: 172.26.186.240
Container Hostname  : bcserver
Container Dns Name  : bcserver
Web Client          : http://bcserver/BC/?tenant=default
Dev. Server         : http://bcserver
Dev. ServerInstance : BC
Dev. Server Tenant  : default
Setting bcserver to 172.26.186.240 in host hosts file
Setting bcserver-default to 172.26.186.240 in host hosts file
Setting bcserver-default to 172.26.186.240 in container hosts file

Files:
http://bcserver:8080/ALLanguage.vsix

Container Total Physical Memory is 12.5Gb
Container Free Physical Memory is 9.6Gb

Initialization took 37 seconds
Ready for connections!
Reading CustomSettings.config from devenv21perf
Creating Desktop Shortcuts for devenv21perf
Synchronizing Permissions Mock on default
App successfully synchronized
Installing Permissions Mock on default
App successfully installed
Synchronizing Test Runner on default
App successfully synchronized
Installing Test Runner on default
App successfully installed
Synchronizing Any on default
App successfully synchronized
Installing Any on default
App successfully installed
Synchronizing Library Assert on default
App successfully synchronized
Installing Library Assert on default
App successfully installed
Skipping app 'C:\Applications\TestFramework\TestLibraries\permissions mock\Microsoft_Permissions Mock.app' as it is already installed
Synchronizing Library Variable Storage on default
App successfully synchronized
Installing Library Variable Storage on default
App successfully installed
Publishing C:\ProgramData\BcContainerHelper\Extensions\devenv21perf\a501049c-7cbc-4726-a974-7badccbbca85\Microsoft_System Application Test Library.app
Synchronizing System Application Test Library on tenant default
Installing System Application Test Library on tenant default
App Microsoft_System Application Test Library.app successfully published
Publishing C:\ProgramData\BcContainerHelper\Extensions\devenv21perf\21d89403-d108-44b2-93ca-a1c7937c4f9a\Microsoft_Tests-TestLibraries.app
Synchronizing Tests-TestLibraries on tenant default
Installing Tests-TestLibraries on tenant default
App Microsoft_Tests-TestLibraries.app successfully published
Synchronizing Performance Toolkit on default
App successfully synchronized
Installing Performance Toolkit on default
App successfully installed
Publishing C:\ProgramData\BcContainerHelper\Extensions\devenv21perf\41f8a5b9-e02f-47b7-b2a9-6755d1b20aa2\Microsoft_Performance Toolkit Samples.app
Synchronizing Performance Toolkit Samples on tenant default
Installing Performance Toolkit Samples on tenant default
App Microsoft_Performance Toolkit Samples.app successfully published
Publishing C:\ProgramData\BcContainerHelper\Extensions\devenv21perf\96a65119-370f-4b5d-b1dc-9abce81940e3\Microsoft_Performance Toolkit Tests.app
Synchronizing Performance Toolkit Tests on tenant default
Installing Performance Toolkit Tests on tenant default
App Microsoft_Performance Toolkit Tests.app successfully published
TestToolkit successfully imported
Container devenv21perf successfully created

Use:
Get-BcContainerEventLog -containerName devenv21perf to retrieve a snapshot of the event log from the container
Get-BcContainerDebugInfo -containerName devenv21perf to get debug information about the container
Enter-BcContainer -containerName devenv21perf to open a PowerShell prompt inside the container
Remove-BcContainer -containerName devenv21perf to remove the container again
docker logs devenv21perf to retrieve information about URL's again
oscarfernandezkurago commented 1 year ago

Digging into the event log of the docker container I saw an error regarding the time zone, I read a post regarding this issue that recommends to create the container with process isolation. With this setting the test is executed in the container successfully but the web client is not working.

freddydk commented 1 year ago

Very strange as the tests are using the web client to run the tests. What error do you get when logging into the webclient?

oscarfernandezkurago commented 1 year ago

Just the standard ERR_CONNECTION_TIMED_OUT, by the way, doing the same test with an v22 container I had to replace the C:\Applications\testframework\TestRunner\internal\Microsoft.IdentityModel.Clients.ActiveDirectory.dll file with one from a v21 version containter to avoid an "Unable to find type [Microsoft.IdentityModel.Clients.ActiveDirectory.UserPasswordCredential]." error.

freddydk commented 1 year ago

Sorry for the delay in response - things have been pretty crazy. I can repro the problem with 22.0 - have contacted the team behind this and asked whether they placed the wrong DLL there, thanks.

On 21 - I cannot repro any problems with running BCPT tests, I use this script for testing BCPT tests, and that seems to work fine:

Pls. modify secrets.

$licenseFile = $LicenseFileSecret.SecretValue | Get-PlainText
$auth = "UserPassword"
$credential = New-Object pscredential -ArgumentList 'admin', $PasswordSecret.SecretValue
$containerName = "bcserver"
$countryCode = "us"
$artifactUrl = Get-BCArtifactUrl -country $countryCode -version 21

New-BCContainer -accept_eula -alwayspull `
                -containername $containername `
                -Auth UserPassword `
                -artifactUrl $artifactUrl `
                -Credential $credential `
                -shortcuts Desktop `
                -updateHosts `
                -includeTestToolkit -includeTestFrameworkOnly -includePerformanceToolkit

# Publish sample app from inside container (:C:\...)
if (Get-BcContainerPath -containerName $containerName -path ":C:\Applications.$countryCode\Microsoft_Performance Toolkit Samples_*.app") {
    Publish-BcContainerApp -containerName $containerName -appFile ":C:\Applications.$countryCode\Microsoft_Performance Toolkit Samples_*.app" -skipVerification -install -sync
}
else {
    Publish-BcContainerApp -containerName $containerName -appFile ":C:\Applications\testframework\performancetoolkit\Microsoft_Performance Toolkit Samples.app" -skipVerification -install -sync

}

$bcptSuite = @'
{
  "code": "10UserTest",
  "description": "10 User Test",
  "durationInMinutes": 5,
  "defaultMinimumUserDelayInMilliSeconds": 120,
  "oneDayCorrespondsToInMinutes": 10,
  "tag": "10UserTest",
  "bcptSuiteLines": [
    {
      "codeunitID": 149107,
      "numberOfSessions": 1,
      "description": "BCPT Detail Trial Bal. Report",
      "minimumUserDelay": 100,
      "maximumUserDelay": 1000,
      "delayBetweenIterations": 10,
      "delayType": "Fixed",
      "runInForeground": false
    },
    {
      "codeunitID": 149103,
      "numberOfSessions": 1,
      "description": "BCPT Create PO with N Lines",
      "minimumUserDelay": 100,
      "maximumUserDelay": 1000,
      "delayBetweenIterations": 5,
      "delayType": "Fixed",
      "runInForeground": false,
      "parameters": "Lines=10"
    },
    {
      "codeunitID": 149105,
      "numberOfSessions": 1,
      "description": "BCPT Create SQ with N Lines",
      "minimumUserDelay": 100,
      "maximumUserDelay": 1000,
      "delayBetweenIterations": 5,
      "delayType": "Fixed",
      "runInForeground": false,
      "parameters": "Lines=10"
    },
    {
      "codeunitID": 149104,
      "numberOfSessions": 1,
      "description": "BCPT Create SO with N Lines",
      "minimumUserDelay": 100,
      "maximumUserDelay": 1000,
      "delayBetweenIterations": 5,
      "delayType": "Fixed",
      "runInForeground": false,
      "parameters": "Lines=10"
    }
  ]
}
'@ | ConvertFrom-Json 

$results = Run-BCPTTestsInBcContainer -containerName bcserver -credential $credential -BCPTSuite $bcptSuite -connectFromHost
$results | Out-Host
$results | ConvertTo-Json -Depth 99 | Set-Content -Path c:\temp\bcptTestResults.json -Encoding UTF8

This works fine.

If I remove -connectFromHost, then it will run from inside the container, which might give wrong results depending on isolation mode etc. of the container, but it still works.

oscarfernandezkurago commented 1 year ago

Thanks for the answer, the problems in the v21 running the tests disappeared when I changed the isolation of the container to process.