-
Notifications
You must be signed in to change notification settings - Fork 35
/
Dockerfile_spec.rb
54 lines (47 loc) · 1 KB
/
Dockerfile_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require "serverspec"
require "docker"
describe "Dockerfile" do
before(:all) do
if ENV['IMAGEID']
image = Docker::Image.get(ENV['IMAGEID'])
else
image = Docker::Image.build_from_dir('.')
end
set :os, family: :debian
set :backend, :docker
set :docker_image, image.id
end
describe port(53) do
it "unbound should be listening" do
wait_retry 30 do
should be_listening.with('tcp')
end
end
end
describe port(53) do
it "unbound should be listening" do
wait_retry 30 do
should be_listening.with('udp')
end
end
end
describe service('unbound') do
it "unbound should be running" do
wait_retry 30 do
should be_running
end
end
end
end
def wait_retry(time, increment = 1, elapsed_time = 0, &block)
begin
yield
rescue Exception => e
if elapsed_time >= time
raise e
else
sleep increment
wait_retry(time, increment, elapsed_time + increment, &block)
end
end
end