Skip to content

Commit b53adc6

Browse files
florindragosMarkW
authored and
MarkW
committed
Fix acceptance tests for windows (#349)
* Fix timeout while waiting for windows service to stop * Fix acceptance tests for windows
1 parent 98c1552 commit b53adc6

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

spec/acceptance/docker_full_spec.rb

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
# Delete all running containers
5757
shell("#{docker_command} rm -f $(#{docker_command} ps -a -q) || true")
5858
# Delete all existing images
59-
shell("#{docker_command} rmi $(#{docker_command} images -q) || true")
59+
shell("#{docker_command} rmi -f $(#{docker_command} images -q) || true")
6060
# Check to make sure no images are present
6161
shell("#{docker_command} images | wc -l") do |r|
6262
expect(r.stdout).to match(/^0|1$/)
@@ -228,20 +228,28 @@ class { 'docker':
228228
end
229229
end
230230

231-
232231
context 'uninstall docker' do
233-
before(:each) do
232+
after(:all) do
234233
@pp =<<-EOS
235-
class {'docker':
236-
ensure => 'absent'
234+
class {'docker': #{docker_args},
235+
ensure => 'present'
237236
}
238237
EOS
239238
apply_manifest(@pp, :catch_failures => true)
240-
sleep 4
239+
240+
# Wait for reboot if windows
241+
sleep 300 if fact('osfamily') == 'windows'
241242
end
242243

243244
it 'should uninstall successfully' do
244-
shell('docker ps', :acceptable_exit_codes => [1, 127])
245+
@pp =<<-EOS
246+
class {'docker': #{docker_args},
247+
ensure => 'absent'
248+
}
249+
EOS
250+
apply_manifest(@pp, :catch_failures => true)
251+
sleep 4
252+
shell('docker ps', :acceptable_exit_codes => [1, 127])
245253
end
246254
end
247255
end

templates/windows/download_docker.ps1.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ $service = Get-Service "docker" -ErrorAction Ignore
88
if ( -not $service ) {
99
$cleanInstall = $true
1010
} elseif ( $service.Status -ne [ServiceProcess.ServiceControllerStatus]::Stopped ) {
11-
$timeSpan = New-Object Timespan 0,0,60
11+
$timeSpan = New-Timespan -Seconds 60
1212
try {
1313
$service.Stop()
14-
$service.WaitForStatus([ServiceProcess.ServiceControllerStatus]::Stopped, 60)
14+
$service.WaitForStatus([ServiceProcess.ServiceControllerStatus]::Stopped, $timeSpan)
1515
}
1616
catch [Management.Automation.MethodInvocationException],[ServiceProcess.TimeoutException] {
1717
Write-Error "Failed to stop docker service"

0 commit comments

Comments
 (0)