microsoft / navcontainerhelper

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

Run-TestsInBcContainer uses parameter AppendToJUnitResultFile as tenant #3095

Closed achim-t closed 1 year ago

achim-t commented 1 year ago

Describe the issue Running the following command targetting a container without multi-tenancy leads to an error.

Scripts used to create container and cause the issue

Run-TestsInBcContainer -containerName $containerName -testCodeunit 132501 -credential $credential -detailed -AppendToJUnitResultFile "C:\ProgramData\BcContainerHelper\testresult.xml"

Full output of scripts

BcContainerHelper version 5.0.3
BC.HelperFunctions emits usage statistics telemetry to Microsoft
WARNING: TaskScheduler is running in the container, this can lead to test failures. Specify -EnableTaskScheduler:$false to disable Task Scheduler.
Connecting to http://localhost:80/BC/cs?tenant=C:\ProgramData\BcContainerHelper\testresult.xml
InvalidCredentialsError
at <ScriptBlock>, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\ClientContext.ps1: line 145
at AwaitState, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\ClientContext.ps1: line 222
at OpenSession, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\ClientContext.ps1: line 200
at Initialize, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\ClientContext.ps1: line 61
at ClientContext, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\ClientContext.ps1: line 28
at New-ClientContext, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\PsTestFunctions.ps1: line 40
at <ScriptBlock>, C:\ProgramData\BcContainerHelper\5f627dba-1c87-48f2-b6d3-26cc58e740ae.ps1: line 100
at <ScriptBlock>, C:\ProgramData\BcContainerHelper\5f627dba-1c87-48f2-b6d3-26cc58e740ae.ps1: line 43
at <ScriptBlock>, <No file>: line 1
at AwaitState, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\ClientContext.ps1: line 234
at OpenSession, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\ClientContext.ps1: line 200
at Initialize, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\ClientContext.ps1: line 61
at ClientContext, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\ClientContext.ps1: line 28
at New-ClientContext, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\PsTestFunctions.ps1: line 40
at <ScriptBlock>, C:\ProgramData\BcContainerHelper\5f627dba-1c87-48f2-b6d3-26cc58e740ae.ps1: line 100
at <ScriptBlock>, C:\ProgramData\BcContainerHelper\5f627dba-1c87-48f2-b6d3-26cc58e740ae.ps1: line 43
at <ScriptBlock>, <No file>: line 1
ClientSession State is Uninitialized (Wait time 10 seconds)

Container Free Physical Memory: 0.8Gb

Services in container test:
- MicrosoftDynamicsNavServer$BC is Running
- MSSQL$SQLEXPRESS is Running

Run-TestsInBcContainer Telemetry Correlation Id: 17a68b19-c1cf-40cf-bf7c-76b37b3fc518
ClientSession State is Uninitialized (Wait time 10 seconds)
In C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\5.0.3\AppHandling\Run-TestsInNavContainer.ps1:516 Zeichen:17
+                 throw $_.Exception.Message
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (ClientSession S...ime 10 seconds):String) [], RuntimeException
    + FullyQualifiedErrorId : ClientSession State is Uninitialized (Wait time 10 seconds)

I did run Run-TestsInBcContainer -containerName $containerName -testCodeunit 132500 -credential $credential -detailed -JUnitResultFileName "C:\ProgramData\BcContainerHelper\testresult.xml" before successfully to initially create the JUnit result file.

XUnit behaves the same.

Edit to Add: If I specify the tenant as default the AppendToJUnitResultFile parameter is used as company name.

Run-TestsInBcContainer -containerName $containerName -credential $credential -testCodeunit 132501 -detailed -AppendToJUnitResultFile "C:\ProgramData\BcContainerHelper\testresult.xml" -tenant default
WARNING: TaskScheduler is running in the container, this can lead to test failures. Specify -EnableTaskScheduler:$false to disable Task Scheduler.
Connecting to http://localhost:80/BC/cs?tenant=default&company=C%3A%5CProgramData%5CBcContainerHelper%5Ctestresult.xml
ERROR DIALOG: Could not open the "C:\ProgramData\BcContainerHelper\testresult.xml" company.
at Run-Tests, C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool\PsTestFunctions.ps1: line 537
at <ScriptBlock>, C:\ProgramData\BcContainerHelper\33f0795a-1622-4a92-ab82-ee692c1e1639.ps1: line 117
at <ScriptBlock>, C:\ProgramData\BcContainerHelper\33f0795a-1622-4a92-ab82-ee692c1e1639.ps1: line 43
at <ScriptBlock>, <No file>: line 1
Cannot open page 130455. You might need to import the test toolkit to the container and/or remove the folder C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool and retry. You might a
lso have URL or Company name wrong.

Container Free Physical Memory: 0.8Gb

Services in container test:
- MicrosoftDynamicsNavServer$BC is Running
- MSSQL$SQLEXPRESS is Running

Relevant event log from container test:
- 20230622 09:19:57 - MicrosoftDynamicsNavServer$BC

  Server instance: BC
  Category: Security
  ClientSessionId: ee6ba5cf-e7e0-494a-a58f-6aff6cd95dda
  ClientActivityId: 1cdc9750-3e34-e695-10be-4fa37f2fd203
  ServerSessionUniqueId: ebb48d1a-0f30-4044-8383-564ecd89d197
  ServerActivityId: a4dde2f1-dc84-4bd7-b5b7-7120af417f71
  EventTime: 06/22/2023 07:19:57
  Message Cloud -> OnPremise call security violation. Caller App=Test Runner by Microsoft 22.2.56969.58023 Func=RunTests, Callee App=Tests-Data Exchange by Microsoft 22.2.56969.58023 Func=Tes
tMappingRepeatedColumnToOneFieldTrimTrailingSpaces
  ProcessId: 1000
  Tag: 0000D0A
  ThreadId: 106
  CounterInformation: 
  CustomParameters: {
  }
  GatewayCorrelationId: 

- 20230622 09:19:57 - MicrosoftDynamicsNavServer$BC

  Server instance: BC
  Category: Security
  ClientSessionId: ee6ba5cf-e7e0-494a-a58f-6aff6cd95dda
  ClientActivityId: 1cdc9750-3e34-e695-10be-4fa37f2fd203
  ServerSessionUniqueId: ebb48d1a-0f30-4044-8383-564ecd89d197
  ServerActivityId: a4dde2f1-dc84-4bd7-b5b7-7120af417f71
  EventTime: 06/22/2023 07:19:57
  Message Cloud -> OnPremise call security violation. Caller App=Test Runner by Microsoft 22.2.56969.58023 Func=RunTests, Callee App=Tests-Data Exchange by Microsoft 22.2.56969.58023 Func=Tes
tMappingRepeatedColumnToOneField
  ProcessId: 1000
  Tag: 0000D0A
  ThreadId: 106
  CounterInformation: 
  CustomParameters: {
  }
  GatewayCorrelationId: 

- 20230622 09:19:57 - MicrosoftDynamicsNavServer$BC

  Server instance: BC
  Category: Security
  ClientSessionId: ee6ba5cf-e7e0-494a-a58f-6aff6cd95dda
  ClientActivityId: 1cdc9750-3e34-e695-10be-4fa37f2fd203
  ServerSessionUniqueId: ebb48d1a-0f30-4044-8383-564ecd89d197
  ServerActivityId: a4dde2f1-dc84-4bd7-b5b7-7120af417f71
  EventTime: 06/22/2023 07:19:57
  Message Cloud -> OnPremise call security violation. Caller App=Test Runner by Microsoft 22.2.56969.58023 Func=RunTests, Callee App=Tests-Data Exchange by Microsoft 22.2.56969.58023 Func=Tes
tMappingMultipleColumnsToOneField
  ProcessId: 1000
  Tag: 0000D0A
  ThreadId: 106
  CounterInformation: 
  CustomParameters: {
  }
  GatewayCorrelationId: 

- 20230622 09:19:57 - MicrosoftDynamicsNavServer$BC

  Server instance: BC
  Category: Security
  ClientSessionId: ee6ba5cf-e7e0-494a-a58f-6aff6cd95dda
  ClientActivityId: 1cdc9750-3e34-e695-10be-4fa37f2fd203
  ServerSessionUniqueId: ebb48d1a-0f30-4044-8383-564ecd89d197
  ServerActivityId: a4dde2f1-dc84-4bd7-b5b7-7120af417f71
  EventTime: 06/22/2023 07:19:57
  Message Cloud -> OnPremise call security violation. Caller App=Test Runner by Microsoft 22.2.56969.58023 Func=RunTests, Callee App=Tests-Data Exchange by Microsoft 22.2.56969.58023 Func=Tes
tImportMissingColumns
  ProcessId: 1000
  Tag: 0000D0A
  ThreadId: 106
  CounterInformation: 
  CustomParameters: {
  }
  GatewayCorrelationId: 

- 20230622 09:19:57 - MicrosoftDynamicsNavServer$BC

  Server instance: BC
  Category: Security
  ClientSessionId: ee6ba5cf-e7e0-494a-a58f-6aff6cd95dda
  ClientActivityId: 1cdc9750-3e34-e695-10be-4fa37f2fd203
  ServerSessionUniqueId: ebb48d1a-0f30-4044-8383-564ecd89d197
  ServerActivityId: a4dde2f1-dc84-4bd7-b5b7-7120af417f71
  EventTime: 06/22/2023 07:19:57
  Message Cloud -> OnPremise call security violation. Caller App=Test Runner by Microsoft 22.2.56969.58023 Func=RunTests, Callee App=Tests-Data Exchange by Microsoft 22.2.56969.58023 Func=Tes
tImportMultiRowMultiColumns
  ProcessId: 1000
  Tag: 0000D0A
  ThreadId: 106
  CounterInformation: 
  CustomParameters: {
  }
  GatewayCorrelationId: 

- 20230622 09:19:56 - MicrosoftDynamicsNavServer$BC

  Server instance: BC
  Category: Runtime
  ClientSessionId: c83e3a42-cf71-491d-bd94-7bd7e5030243
  ClientActivityId: d221cf5e-0b1b-aaf2-8e20-713e82ccf4a2
  ServerSessionUniqueId: 1ee2f5fe-7052-4847-8966-1b873642269d
  ServerActivityId: 3d2f9653-ff1c-45d9-9096-703c8f9dbd0d
  EventTime: 06/22/2023 07:19:56
  Message (NavNCLInvalidCompanyNameException): RootException: NavNCLInvalidCompanyNameException
  Message not shown because the NavBaseException constructor was used without privacy classification
  CallerStackTrace:
     at Microsoft.Dynamics.Nav.Runtime.NavSession.OpenCompany(String companyName, Boolean updateUserPersonalization, Boolean openedForRenameOrDelete)
     at Microsoft.Dynamics.Nav.Service.NSService.OpenCompany(String companyName, Boolean overridePersonalization)
     at Microsoft.Dynamics.Nav.Service.NSService.Microsoft.Dynamics.Nav.Types.IClientApi.OpenCompany(String companyName, Boolean overridePersonalization)
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Run-TestsInBcContainer Telemetry Correlation Id: d01ec0ac-a41e-45d6-8d30-c5e7574dab59
Cannot open page 130455. You might need to import the test toolkit to the container and/or remove the folder C:\ProgramData\BcContainerHelper\Extensions\test\PsTestTool and retry. You might 
also have URL or Company name wrong.
In C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\5.0.3\AppHandling\Run-TestsInNavContainer.ps1:516 Zeichen:17
+                 throw $_.Exception.Message
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Cannot open pag...any name wrong.:String) [], RuntimeException
    + FullyQualifiedErrorId : Cannot open page 130455. You might need to import the test toolkit to the container and/or remove the folder C:\ProgramData\BcContainerHelper\Extensions\test\P 
   sTestTool and retry. You might also have URL or Company name wrong.
freddydk commented 1 year ago

-AppendToJUnitResultFile is a switch parameter, you use it as a string parameter. The right command would be: Run-TestsInBcContainer -containerName $containerName -testCodeunit 132501 -credential $credential -detailed -JUnitResultFileName "C:\ProgramData\BcContainerHelper\testresult.xml" -AppendToJUnitResultFile