Skip to content

Commit 0adde64

Browse files
committed
#242 Restoring GetIshDocumentObj.Tests.ps1 on CI because it does no longer test performance, just a simple get, not time consuming. Marking some tests as pester:no-parallel and avoiding hot spots by using more unique LogicalIds per test.
1 parent 6caac1a commit 0adde64

10 files changed

Lines changed: 38 additions & 21 deletions

File tree

‎.github/workflows/continuous-integration.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ jobs:
191191
ISH_PASSWORD: ${{ secrets.ISH_PASSWORD }}
192192
ISH_CLIENT_ID: ${{ secrets.ISH_CLIENT_ID }}
193193
ISH_CLIENT_SECRET: ${{ secrets.ISH_CLIENT_SECRET }}
194-
run: Invoke-Pester -Path @('Source/ISHRemote/Trisoft.ISHRemote/Scripts/Public/','Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/') -ExcludePath @('*GetIshDocumentObj.Tests.ps1','*TestAnonymization.Tests.ps1') -Output Detailed -Passthru | Export-CliXml -Path Cmdlets.Pester.Tests.xml
194+
run: Invoke-Pester -Path @('Source/ISHRemote/Trisoft.ISHRemote/Scripts/Public/','Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/') -ExcludePath @('*TestAnonymization.Tests.ps1') -Output Detailed -Passthru | Export-CliXml -Path Cmdlets.Pester.Tests.xml
195195
- name: Upload test results
196196
uses: actions/upload-artifact@v7
197197
with:

‎Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/Annotation/GetIshAnnotation.Tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Describe "Get-IshAnnotation" -Tags "Create" {
3636
}
3737
}
3838
$bmp.Save($tempFilePath, [System.Drawing.Imaging.ImageFormat]::Jpeg)
39-
$ishObjectImage = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderImage -IshType ISHIllustration -LogicalId "MYOWNGENERATEDLOGICALIDIMAGE" -Version '1' -Lng $ishLng -Resolution $ishResolution -Metadata $ishImageMetadata -Edt "EDTJPEG" -FilePath $tempFilePath
39+
$ishObjectImage = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderImage -IshType ISHIllustration -LogicalId "GETISHANNOTATION-MYOWNGENERATEDLOGICALIDIMAGE" -Version '1' -Lng $ishLng -Resolution $ishResolution -Metadata $ishImageMetadata -Edt "EDTJPEG" -FilePath $tempFilePath
4040

4141
## Publication 1
4242
#add topic

‎Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/DocumentObj/AddIshDocumentObj.Tests.ps1‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,21 @@ Describe "Add-IshDocumentObj" -Tags "Create" {
9090
$ishTopicMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "All Parameters Topic $timestamp" |
9191
Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor |
9292
Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft
93-
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderTopic -IshType ISHModule -LogicalId "MYOWNGENERATEDLOGICALIDTOPIC" -Version '2' -Lng $ishLng -Metadata $ishTopicMetadata -Edt "EDTXML" -FileContent $ditaTopicFileContent
93+
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderTopic -IshType ISHModule -LogicalId "ADDISHDOCUMENTOBJ-MYOWNGENERATEDLOGICALIDTOPIC" -Version '2' -Lng $ishLng -Metadata $ishTopicMetadata -Edt "EDTXML" -FileContent $ditaTopicFileContent
9494
$ishObject.LngRef -gt 0 | Should-Be $true
9595
}
9696
It "All Parameters (Map)" {
9797
$ishMapMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "All Parameters Map $timestamp" |
9898
Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor |
9999
Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft
100-
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderMap -IshType ISHMasterDoc -LogicalId "MYOWNGENERATEDLOGICALIDMAP" -Version '3' -Lng $ishLng -Metadata $ishMapMetadata -Edt "EDTXML" -FileContent $ditaMapFileContent
100+
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderMap -IshType ISHMasterDoc -LogicalId "ADDISHDOCUMENTOBJ-MYOWNGENERATEDLOGICALIDMAP" -Version '3' -Lng $ishLng -Metadata $ishMapMetadata -Edt "EDTXML" -FileContent $ditaMapFileContent
101101
$ishObject.LngRef -gt 0 | Should-Be $true
102102
}
103103
It "All Parameters (Lib)" {
104104
$ishLibMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "All Parameters Lib $timestamp" |
105105
Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor |
106106
Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft
107-
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderLib -IshType ISHLibrary -LogicalId "MYOWNGENERATEDLOGICALIDLIB" -Version '4' -Lng $ishLng -Metadata $ishLibMetadata -Edt "EDTXML" -FileContent $ditaTopicFileContent
107+
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderLib -IshType ISHLibrary -LogicalId "ADDISHDOCUMENTOBJ-MYOWNGENERATEDLOGICALIDLIB" -Version '4' -Lng $ishLng -Metadata $ishLibMetadata -Edt "EDTXML" -FileContent $ditaTopicFileContent
108108
$ishObject.LngRef -gt 0 | Should-Be $true
109109
}
110110
}
@@ -127,15 +127,15 @@ Describe "Add-IshDocumentObj" -Tags "Create" {
127127
}
128128
}
129129
$bmp.Save($tempFilePath, [System.Drawing.Imaging.ImageFormat]::Jpeg)
130-
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderImage -IshType ISHIllustration -LogicalId "MYOWNGENERATEDLOGICALIDIMAGE" -Version '5' -Lng $ishLng -Resolution $ishResolution -Metadata $ishImageMetadata -Edt "EDTJPEG" -FilePath $tempFilePath
130+
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderImage -IshType ISHIllustration -LogicalId "ADDISHDOCUMENTOBJ-MYOWNGENERATEDLOGICALIDIMAGE" -Version '5' -Lng $ishLng -Resolution $ishResolution -Metadata $ishImageMetadata -Edt "EDTJPEG" -FilePath $tempFilePath
131131
$ishObject.LngRef -gt 0 | Should-Be $true
132132
}
133133
It "All Parameters (Other like EDT-TEXT)" {
134134
$ishOtherMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "All Parameters Other $timestamp" |
135135
Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor |
136136
Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft
137137
Get-Process | Out-File $tempFilePath
138-
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderOther -IshType ISHTemplate -LogicalId "MYOWNGENERATEDLOGICALIDOTHER" -Version '6' -Lng $ishLng -Metadata $ishOtherMetadata -Edt "EDT-TEXT" -FilePath $tempFilePath
138+
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderOther -IshType ISHTemplate -LogicalId "ADDISHDOCUMENTOBJ-MYOWNGENERATEDLOGICALIDOTHER" -Version '6' -Lng $ishLng -Metadata $ishOtherMetadata -Edt "EDT-TEXT" -FilePath $tempFilePath
139139
$ishObject.LngRef -gt 0 | Should-Be $true
140140
}
141141
}

‎Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/DocumentObj/RemoveIshDocumentObj.Tests.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ Describe "Remove-IshDocumentObj" -Tags "Delete" {
6666
}
6767
It "Parameters (Map). Force=Yes" {
6868
$ishMapMetadata = $ishObjectMetadata | Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "$($____Pester.CurrentTest.Name) $timestamp"
69-
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderMap -IshType ISHMasterDoc -LogicalId "MYOWNGENERATEDLOGICALIDMAP" -Version '3' -Lng $ishLng -Metadata $ishMapMetadata -Edt "EDTXML" -FileContent $ditaMapFileContent
69+
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderMap -IshType ISHMasterDoc -LogicalId "REMOVEISHDOCUMENTOBJ-MYOWNGENERATEDLOGICALIDMAP" -Version '3' -Lng $ishLng -Metadata $ishMapMetadata -Edt "EDTXML" -FileContent $ditaMapFileContent
7070
Remove-IshDocumentObj -IshSession $ishSession -LogicalId $ishObject.IshRef -Version $ishObject.version_version_value -Lng $ishObject.doclanguage -Force
7171
$ishObjectRetrieved = Get-IshDocumentObj -IshSession $ishSession -IshObject $ishObject
7272
$ishObjectRetrieved.length -eq 0 | Should-Be $true
7373
}
7474
It "Parameters (Lib). Force=Yes" {
7575
$ishLibMetadata = $ishObjectMetadata | Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "$($____Pester.CurrentTest.Name) $timestamp"
76-
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderLib -IshType ISHLibrary -LogicalId "MYOWNGENERATEDLOGICALIDLIB" -Version '4' -Lng $ishLng -Metadata $ishLibMetadata -Edt "EDTXML" -FileContent $ditaTopicFileContent
76+
$ishObject = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderLib -IshType ISHLibrary -LogicalId "REMOVEISHDOCUMENTOBJ-MYOWNGENERATEDLOGICALIDLIB" -Version '4' -Lng $ishLng -Metadata $ishLibMetadata -Edt "EDTXML" -FileContent $ditaTopicFileContent
7777
$ishObject.LngRef -gt 0 | Should-Be $true
7878
Remove-IshDocumentObj -IshSession $ishSession -LogicalId $ishObject.IshRef -Version $ishObject.version_version_value -Lng $ishObject.doclanguage -Force
7979
$ishObjectRetrieved = Get-IshDocumentObj -IshSession $ishSession -IshObject $ishObject

‎Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/Folder/SetIshFolder.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#pester:no-parallel # renames the BaseFolders which could confuse other parallel tests
12
BeforeAll {
23
$cmdletName = "Set-IshFolder"
34
Write-Host ("`r`nLoading ISHRemote.PesterSetup.ps1 on PSVersion[" + $psversionTable.PSVersion + "] over BeforeAll-block for MyCommand[" + $cmdletName + "]...")

‎Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/PublicationOutput/AddIshPublicationOutput.Tests.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ Describe "Add-IshPublicationOutput" -Tags "Create" {
3030
$ishMapMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "All Parameters Map $timestamp" |
3131
Set-IshMetadataField -IshSession $ishSession -Name "FAUTHOR" -Level Lng -ValueType Element -Value $ishUserAuthor |
3232
Set-IshMetadataField -IshSession $ishSession -Name "FSTATUS" -Level Lng -ValueType Element -Value $ishStatusDraft
33-
$ishObjectMap = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderMap -IshType ISHMasterDoc -LogicalId "MYOWNGENERATEDLOGICALIDMAP" -Version '3' -Lng $ishLng -Metadata $ishMapMetadata -Edt "EDTXML" -FileContent $ditaMapFileContent
33+
$ishObjectMap = Add-IshDocumentObj -IshSession $ishSession -IshFolder $ishFolderMap -IshType ISHMasterDoc -LogicalId "ADDISHPUBLICATIONTOUTPUT-MYOWNGENERATEDLOGICALIDMAP" -Version '3' -Lng $ishLng -Metadata $ishMapMetadata -Edt "EDTXML" -FileContent $ditaMapFileContent
3434

3535
$ishFolderPub = Add-IshFolder -IshSession $ishSession -ParentFolderId($global:ishFolderCmdlet.IshFolderRef) -FolderType ISHPublication -FolderName "Pub" -OwnedBy $ownedByTestRootOriginal -ReadAccess $readAccessTestRootOriginal
3636
$ishPubMetadata = Set-IshMetadataField -IshSession $ishSession -Name "FTITLE" -Level Logical -Value "All Parameters Pub $timestamp" |
3737
Set-IshMetadataField -IshSession $ishSession -Name "FISHMASTERREF" -Level Version -ValueType Element -Value $ishObjectMap.IshRef |
3838
Set-IshMetadataField -IshSession $ishSession -Name "FISHPUBSOURCELANGUAGES" -Level Version -ValueType Element -Value $ishLng |
3939
Set-IshMetadataField -IshSession $ishSession -Name "FISHREQUIREDRESOLUTIONS" -Level Version -ValueType Element -Value $ishResolution
40-
$ishObjectPub = Add-IshPublicationOutput -IshSession $ishSession -IshFolder $ishFolderPub -LogicalId "MYOWNGENERATEDLOGICALIDPUB" -Version '1' -LanguageCombination $ishLngCombination -OutputFormat $ishOutputFormatDitaXml -Metadata $ishPubMetadata
40+
$ishObjectPub = Add-IshPublicationOutput -IshSession $ishSession -IshFolder $ishFolderPub -LogicalId "ADDISHPUBLICATIONTOUTPUT-MYOWNGENERATEDLOGICALIDPUB" -Version '1' -LanguageCombination $ishLngCombination -OutputFormat $ishOutputFormatDitaXml -Metadata $ishPubMetadata
4141

4242
$tempFilePath = (New-TemporaryFile).FullName
4343
}

‎Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/Settings/GetIshTypeFieldDefinition.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#pester:no-parallel #this test manipulates SessionState variables directly and calls cmdlets that use WriteDebug, both of which are fragile in parallel runspaces.
12
BeforeAll {
23
$cmdletName = "Get-IshTypeFieldDefinition"
34
Write-Host ("`r`nLoading ISHRemote.PesterSetup.ps1 on PSVersion[" + $psversionTable.PSVersion + "] over BeforeAll-block for MyCommand[" + $cmdletName + "]...")

‎Source/ISHRemote/Trisoft.ISHRemote/Cmdlets/_TestEnvironment/TestPrerequisite.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#pester:no-parallel # Checks if the remote system is ready which will fail if other tests are already creating folders
12
BeforeAll {
23
$cmdletName = "TestPrerequisite.Tests.ps1"
34
Write-Host ("`r`nLoading ISHRemote.PesterSetup.ps1 on PSVersion[" + $psversionTable.PSVersion + "] over BeforeAll-block for MyCommand[" + $cmdletName + "]...")

‎Source/ISHRemote/Trisoft.ISHRemote/ISHRemote.PesterSetup.ps1‎

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,30 @@ $isLinuxContainerized = $baseUrl.Contains('.sdldev.net')
128128
#{
129129
$webServicesConnectionConfigurationUrl = $webServicesBaseUrl + "connectionconfiguration.xml"
130130
Write-Host "Running ISHRemote.PesterSetup.ps1 Detect version over webServicesConnectionConfigurationUrl[$webServicesConnectionConfigurationUrl] webServicesConnectionConfigurationUrl.Length[$($webServicesConnectionConfigurationUrl.Length)]"
131-
# $connectionConfigurationRaw = Invoke-RestMethod -Uri $webServicesConnectionConfigurationUrl #Only PS7#-SkipCertificateCheck
132-
$connectionConfigurationRaw = (Invoke-WebRequest -Uri $webServicesConnectionConfigurationUrl -UseBasicParsing).Content #as Kestrel/IIS behave differently
133-
$connectionConfigurationRaw -match "<infosharesoftwareversion>(?<myVersion>.*)</infosharesoftwareversion>" # Straight string handling avoids UTF8-BOM cross-platform handling
134-
[version]$infosharesoftwareversion = $matches['myVersion']
135-
if ($infosharesoftwareversion.Major -lt 15) # 14SP4 and earlier, initialize ONE session over -IshUserName/-IshPassword
136-
{
137-
$global:ishSession = New-IshSession -Protocol WcfSoapWithWsTrust -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -WarningAction SilentlyContinue
131+
try {
132+
# $connectionConfigurationRaw = Invoke-RestMethod -Uri $webServicesConnectionConfigurationUrl #Only PS7#-SkipCertificateCheck
133+
$connectionConfigurationRaw = (Invoke-WebRequest -Uri $webServicesConnectionConfigurationUrl -UseBasicParsing).Content #as Kestrel/IIS behave differently
134+
if (-not ($connectionConfigurationRaw -match "<infosharesoftwareversion>(?<myVersion>.*)</infosharesoftwareversion>")) # Straight string handling avoids UTF8-BOM cross-platform handling
135+
{
136+
throw "ISHRemote.PesterSetup.ps1: Could not find <infosharesoftwareversion> in response from $webServicesConnectionConfigurationUrl. Response length[$($connectionConfigurationRaw.Length)]"
137+
}
138+
[version]$infosharesoftwareversion = $matches['myVersion']
139+
if ($infosharesoftwareversion.Major -lt 15) # 14SP4 and earlier, initialize ONE session over -IshUserName/-IshPassword
140+
{
141+
$global:ishSession = New-IshSession -Protocol WcfSoapWithWsTrust -WsBaseUrl $webServicesBaseUrl -IshUserName $ishUserName -IshPassword $ishPassword -WarningAction SilentlyContinue
142+
}
143+
else # 15 and later, initialize ONE session over -ClientId/-ClientSecret
144+
{
145+
$global:ishSession = New-IshSession -Protocol WcfSoapWithOpenIdConnect -WsBaseUrl $webServicesBaseUrl -ClientId $amClientId -ClientSecret $amClientSecret -WarningAction SilentlyContinue
146+
}
147+
if ($null -eq $global:ishSession)
148+
{
149+
throw "ISHRemote.PesterSetup.ps1: New-IshSession returned null for webServicesBaseUrl[$webServicesBaseUrl]"
150+
}
138151
}
139-
else # 15 and later, initialize ONE session over -ClientId/-ClientSecret
140-
{
141-
$global:ishSession = New-IshSession -Protocol WcfSoapWithOpenIdConnect -WsBaseUrl $webServicesBaseUrl -ClientId $amClientId -ClientSecret $amClientSecret -WarningAction SilentlyContinue
152+
catch {
153+
Write-Error "ISHRemote.PesterSetup.ps1: Session initialization failed on PSVersion[$($PSVersionTable.PSVersion)] webServicesBaseUrl[$webServicesBaseUrl]: $_"
154+
throw
142155
}
143156
#}
144157
$ishSession = $global:ishSession

‎Source/ISHRemote/Trisoft.ISHRemote/Scripts/Public/Start-IshRemoteMcpServer.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#pester:no-parallel #Mock -ModuleName uses cross-module mocking which installs hooks into the ISHRemote module's session state. In a parallel runspace, each worker loads its own ISHRemote module instance, but the mock infrastructure that Mock -ModuleName relies on requires the parent session's module context. This causes the worker runspace to hang waiting for something that never resolves.
12
BeforeAll {
23
$cmdletName = "Start-IshRemoteMcpServer"
34
Write-Host ("`r`nLoading ISHRemote.PesterSetup.ps1 on PSVersion[" + $psversionTable.PSVersion + "] over BeforeAll-block for MyCommand[" + $cmdletName + "]...")

0 commit comments

Comments
 (0)