Skip to content

Commit aeb04ba

Browse files
authored
Revert "Revert "Revert "chore: disable failing test(s) until jenkins-infra/helpdesk#4557 infra issue is resolved"""
1 parent c2d87b8 commit aeb04ba

File tree

1 file changed

+70
-63
lines changed

1 file changed

+70
-63
lines changed

tests/sshAgent.Tests.ps1

Lines changed: 70 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -148,69 +148,76 @@ Describe "[$global:IMAGE_NAME] image has correct version of java and git-lfs ins
148148
}
149149
}
150150

151-
# TODO: restore when https://github.com/jenkins-infra/helpdesk/issues/4557 infra issue is resolved
152-
# Describe "[$global:IMAGE_NAME] create agent container with pubkey as argument" {
153-
# BeforeAll {
154-
# $exitCode, $stdout, $stderr = Run-Program 'docker' "run --detach --tty --name=`"$global:CONTAINERNAME`" --publish-all `"$global:IMAGE_NAME`" `"$global:PUBLIC_SSH_KEY`""
155-
# $exitCode | Should -Be 0
156-
# Is-ContainerRunning $global:CONTAINERNAME | Should -BeTrue
157-
# Start-Sleep -Seconds 10
158-
# }
159-
160-
# It 'runs commands via ssh' {
161-
# $exitCode, $stdout, $stderr = Run-ThruSSH $global:CONTAINERNAME "$global:PRIVATE_SSH_KEY" "$global:CONTAINERSHELL -NoLogo -C `"Write-Host 'f00'`""
162-
# $exitCode | Should -Be 0
163-
# $stdout | Should -Match 'f00'
164-
# }
165-
166-
# AfterAll {
167-
# Cleanup($global:CONTAINERNAME)
168-
# }
169-
# }
170-
171-
# TODO: restore when https://github.com/jenkins-infra/helpdesk/issues/4557 infra issue is resolved
172-
# Describe "[$global:IMAGE_NAME] create agent container with pubkey as envvar" {
173-
# BeforeAll {
174-
# $exitCode, $stdout, $stderr = Run-Program 'docker' "run --detach --tty --name=`"$global:CONTAINERNAME`" --publish-all `"$global:IMAGE_NAME`" `"$global:PUBLIC_SSH_KEY`""
175-
# $exitCode | Should -Be 0
176-
# Is-ContainerRunning $global:CONTAINERNAME | Should -BeTrue
177-
# Start-Sleep -Seconds 10
178-
# }
179-
180-
# It 'runs commands via ssh' {
181-
# $exitCode, $stdout, $stderr = Run-ThruSSH $global:CONTAINERNAME "$global:PRIVATE_SSH_KEY" "$global:CONTAINERSHELL -NoLogo -C `"Write-Host 'f00'`""
182-
# $exitCode | Should -Be 0
183-
# $stdout | Should -Match 'f00'
184-
# Start-Sleep -Seconds 10
185-
# }
186-
187-
# AfterAll {
188-
# Cleanup($global:CONTAINERNAME)
189-
# }
190-
# }
191-
192-
193-
# TODO: restore when https://github.com/jenkins-infra/helpdesk/issues/4557 infra issue is resolved
194-
# $global:DOCKER_PLUGIN_DEFAULT_ARG="/usr/sbin/sshd -D -p 22"
195-
# Describe "[$global:IMAGE_NAME] create agent container like docker-plugin with '$global:DOCKER_PLUGIN_DEFAULT_ARG' as argument" {
196-
# BeforeAll {
197-
# [string]::IsNullOrWhiteSpace($global:DOCKER_PLUGIN_DEFAULT_ARG) | Should -BeFalse
198-
# $exitCode, $stdout, $stderr = Run-Program 'docker' "run --detach --tty --name=`"$global:CONTAINERNAME`" --publish-all --env=`"JENKINS_AGENT_SSH_PUBKEY=$global:PUBLIC_SSH_KEY`" `"$global:IMAGE_NAME`" `"$global:DOCKER_PLUGIN_DEFAULT_ARG`""
199-
# $exitCode | Should -Be 0
200-
# Is-ContainerRunning $global:CONTAINERNAME | Should -BeTrue
201-
# Start-Sleep -Seconds 10
202-
# }
203-
204-
# It 'runs commands via ssh' {
205-
# $exitCode, $stdout, $stderr = Run-ThruSSH $global:CONTAINERNAME "$global:PRIVATE_SSH_KEY" "$global:CONTAINERSHELL -NoLogo -C `"Write-Host 'f00'`""
206-
# $exitCode | Should -Be 0
207-
# $stdout | Should -Match 'f00'
208-
# }
209-
210-
# AfterAll {
211-
# Cleanup($global:CONTAINERNAME)
212-
# }
213-
# }
151+
Describe "[$global:IMAGE_NAME] create agent container with pubkey as argument" {
152+
BeforeAll {
153+
$exitCode, $stdout, $stderr = Run-Program 'docker' "run --detach --tty --name=`"$global:CONTAINERNAME`" --publish-all `"$global:IMAGE_NAME`" `"$global:PUBLIC_SSH_KEY`""
154+
$exitCode | Should -Be 0
155+
Is-ContainerRunning $global:CONTAINERNAME | Should -BeTrue
156+
Start-Sleep -Seconds 10
157+
}
158+
159+
It 'can check running containers' {
160+
$exitCode, $stdout, $stderr = Run-Program 'docker' "container ls"
161+
$exitCode | Should -Be 0
162+
}
163+
164+
It 'can get logs of running container' {
165+
$exitCode, $stdout, $stderr = Run-Program 'docker' "logs `"$global:CONTAINERNAME`""
166+
$exitCode | Should -Be 0
167+
}
168+
169+
It 'runs commands via ssh' {
170+
$exitCode, $stdout, $stderr = Run-ThruSSH $global:CONTAINERNAME "$global:PRIVATE_SSH_KEY" "$global:CONTAINERSHELL -NoLogo -C `"Write-Host 'f00'`""
171+
$exitCode | Should -Be 0
172+
$stdout | Should -Match 'f00'
173+
}
174+
175+
AfterAll {
176+
Cleanup($global:CONTAINERNAME)
177+
}
178+
}
179+
180+
Describe "[$global:IMAGE_NAME] create agent container with pubkey as envvar" {
181+
BeforeAll {
182+
$exitCode, $stdout, $stderr = Run-Program 'docker' "run --detach --tty --name=`"$global:CONTAINERNAME`" --publish-all `"$global:IMAGE_NAME`" `"$global:PUBLIC_SSH_KEY`""
183+
$exitCode | Should -Be 0
184+
Is-ContainerRunning $global:CONTAINERNAME | Should -BeTrue
185+
Start-Sleep -Seconds 10
186+
}
187+
188+
It 'runs commands via ssh' {
189+
$exitCode, $stdout, $stderr = Run-ThruSSH $global:CONTAINERNAME "$global:PRIVATE_SSH_KEY" "$global:CONTAINERSHELL -NoLogo -C `"Write-Host 'f00'`""
190+
$exitCode | Should -Be 0
191+
$stdout | Should -Match 'f00'
192+
Start-Sleep -Seconds 10
193+
}
194+
195+
AfterAll {
196+
Cleanup($global:CONTAINERNAME)
197+
}
198+
}
199+
200+
201+
$global:DOCKER_PLUGIN_DEFAULT_ARG="/usr/sbin/sshd -D -p 22"
202+
Describe "[$global:IMAGE_NAME] create agent container like docker-plugin with '$global:DOCKER_PLUGIN_DEFAULT_ARG' as argument" {
203+
BeforeAll {
204+
[string]::IsNullOrWhiteSpace($global:DOCKER_PLUGIN_DEFAULT_ARG) | Should -BeFalse
205+
$exitCode, $stdout, $stderr = Run-Program 'docker' "run --detach --tty --name=`"$global:CONTAINERNAME`" --publish-all --env=`"JENKINS_AGENT_SSH_PUBKEY=$global:PUBLIC_SSH_KEY`" `"$global:IMAGE_NAME`" `"$global:DOCKER_PLUGIN_DEFAULT_ARG`""
206+
$exitCode | Should -Be 0
207+
Is-ContainerRunning $global:CONTAINERNAME | Should -BeTrue
208+
Start-Sleep -Seconds 10
209+
}
210+
211+
It 'runs commands via ssh' {
212+
$exitCode, $stdout, $stderr = Run-ThruSSH $global:CONTAINERNAME "$global:PRIVATE_SSH_KEY" "$global:CONTAINERSHELL -NoLogo -C `"Write-Host 'f00'`""
213+
$exitCode | Should -Be 0
214+
$stdout | Should -Match 'f00'
215+
}
216+
217+
AfterAll {
218+
Cleanup($global:CONTAINERNAME)
219+
}
220+
}
214221

215222
Describe "[$global:IMAGE_NAME] build args" {
216223
BeforeAll {

0 commit comments

Comments
 (0)