Skip to content

Commit

Permalink
issue 3420 and 3411 (#3421)
Browse files Browse the repository at this point in the history
Fixes #3420
Use process isolation on Windows Server 2022 by default

Fixes #3411 - best explained by the following code
```powershell
$json = '{"time": "2024-03-14T16:49:31.6130000Z"}'
$obj = $json | ConvertFrom-Json
$obj.time | Out-Host
$obj.time.GetType().Name | Out-Host
```
will return
```
2024-03-14T16:49:31.6130000Z
String
```
in PowerShell 5.1, and
```
Thursday, 14 March 2024 16.49.31
DateTime
```
in PowerShell 7

---------

Co-authored-by: freddydk <[email protected]>
  • Loading branch information
freddydk and freddydk committed Mar 14, 2024
1 parent 896b152 commit 40d0c89
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
28 changes: 20 additions & 8 deletions AppHandling/PsTestFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,19 @@ function Run-ConnectionTest {
Write-Host "Extension Management successfully closed"
}

function GetDT {
Param(
$val
)

if ($val -is [DateTime]) {
$val
}
else {
[DateTime]::Parse($val)
}
}

function Run-Tests {
Param(
[ClientContext] $clientContext,
Expand Down Expand Up @@ -661,8 +674,8 @@ function Run-Tests {
$XUnitAssembly = $XUnitDoc.CreateElement("assembly")
$XUnitAssembly.SetAttribute("name","$($result.codeUnit) $($result.name)")
$XUnitAssembly.SetAttribute("test-framework", "PS Test Runner")
$XUnitAssembly.SetAttribute("run-date", [DateTime]::Parse($result.startTime).ToString("yyyy-MM-dd"))
$XUnitAssembly.SetAttribute("run-time", [DateTime]::Parse($result.startTime).ToString("HH':'mm':'ss"))
$XUnitAssembly.SetAttribute("run-date", (GetDT -val $result.startTime).ToString("yyyy-MM-dd"))
$XUnitAssembly.SetAttribute("run-time", (GetDT -val $result.startTime).ToString("HH':'mm':'ss"))
$XUnitAssembly.SetAttribute("total", $result.testResults.Count)
$XUnitCollection = $XUnitDoc.CreateElement("collection")
$XUnitAssembly.AppendChild($XUnitCollection) | Out-Null
Expand Down Expand Up @@ -715,7 +728,7 @@ function Run-Tests {
$property.SetAttribute("value", "{ ""Version"": ""$($VersionInfo.ProductVersion)"" }")
$JunitTestSuiteProperties.AppendChild($property) | Out-Null

Get-NavAppInfo -ServerInstance $serverInstance | % {
Get-NavAppInfo -ServerInstance $serverInstance | ForEach-Object {
$property = $JUnitDoc.CreateElement("property")
$property.SetAttribute("name", "app.info")
$property.SetAttribute("value", "{ ""Name"": ""$($_.Name)"", ""Publisher"": ""$($_.Publisher)"", ""Version"": ""$($_.Version)"" }")
Expand All @@ -724,13 +737,12 @@ function Run-Tests {
$dumpAppsToTestOutput = $false
}
}

}

$totalduration = [Timespan]::Zero
if ($result.PSobject.Properties.name -eq "testResults") {
$result.testResults | % {
$testduration = [DateTime]::Parse($_.finishTime).Subtract([DateTime]::Parse($_.startTime))
$result.testResults | ForEach-Object {
$testduration = (GetDT -val $_.finishTime).Subtract((GetDT -val $_.startTime))
if ($testduration.TotalSeconds -lt 0) { $testduration = [timespan]::Zero }
$totalduration += $testduration
}
Expand All @@ -752,8 +764,8 @@ function Run-Tests {
$skipped = 0

if ($result.PSobject.Properties.name -eq "testResults") {
$result.testResults | % {
$testduration = [DateTime]::Parse($_.finishTime).Subtract([DateTime]::Parse($_.startTime))
$result.testResults | ForEach-Object {
$testduration = (GetDT -val $_.finishTime).Subtract((GetDT -val $_.startTime))
if ($testduration.TotalSeconds -lt 0) { $testduration = [timespan]::Zero }

if ($XUnitResultFileName) {
Expand Down
7 changes: 6 additions & 1 deletion ContainerHandling/Flush-ContainerHelperCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ try {
$containerName = $_.Split(':')[1]
$inspect = docker inspect $containerID | ConvertFrom-Json
try {
$finishedAt = [DateTime]::Parse($inspect.state.FinishedAt)
if ($inspect.state.FinishedAt -is [datetime]) {
$finishedAt = $inspect.state.FinishedAt
}
else {
$finishedAt = [DateTime]::Parse($inspect.state.FinishedAt)
}
$exitedDaysAgo = [DateTime]::Now.Subtract($finishedAt).Days
if ($exitedDaysAgo -ge $keepDays) {
if (($inspect.Config.Labels.psobject.Properties.Match('maintainer').Count -ne 0 -and $inspect.Config.Labels.maintainer -eq "Dynamics SMB")) {
Expand Down
8 changes: 2 additions & 6 deletions ContainerHandling/New-NavImage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -411,12 +411,8 @@ try {
}
elseif ($hostOsVersion.Build -ge 20348 -and $containerOsVersion.Build -ge 20348) {
if ($isolation -eq "") {
if ($containerOsVersion -le $hostOsVersion) {
$isolation = "process"
}
else {
$isolation = "hyperv"
}
Write-Host -ForegroundColor Yellow "WARNING: Container and host OS build is 20348 or above, defaulting to process isolation. If you encounter issues, you could try to install HyperV."
$isolation = "process"
}
}
elseif (("$hostOsVersion".StartsWith('10.0.19043.') -or "$hostOsVersion".StartsWith('10.0.19044.') -or "$hostOsVersion".StartsWith('10.0.19045.')) -and "$containerOsVersion".StartsWith("10.0.19041.")) {
Expand Down
4 changes: 4 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
6.0.11
Issue 3420 New-BcImage uses hyperv even if it is disabled
Issue 3411 Run-AlPipeline: Exception calling "Parse" with "1" argument(s): "String '' was not recognized as a valid DateTime.

6.0.10
Issue 3415 Use process isolation

Expand Down
2 changes: 1 addition & 1 deletion Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.10-dev
6.0.11-dev

0 comments on commit 40d0c89

Please sign in to comment.