-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockspec.rb
93 lines (74 loc) · 2.58 KB
/
Dockspec.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
require "serverspec"
require "docker-api"
describe "Dockerfile" do
before( :all ) do
print "Running Tests for Docker\n"
print " ---> Docker Version " + Docker.version["Version"] + "\n\n"
@image = Docker::Image.build_from_dir( "." )
set :os, family: :debian, :release => '8'
set :backend, :docker
set :docker_image, @image.id
@container = Docker::Container.create(
'Image' => @image.id,
'Cmd' => [ "nginx", "-g", "deamon off;" ]
)
@container.start
print " ---> Details\n"
print " OS: " + host_inventory["platform"]
print " " + host_inventory["platform_version"] + "\n"
print " Docker Container: " + host_inventory["hostname"] + "\n"
print " Memory: " + host_inventory["memory"]["total"] + "\n\n"
print " ---> Running tests\n"
end
after( :all ) do
print "\n\n ---> Cleaning up. Removing container."
@container.stop
@container.kill
@container.delete( :force => true )
@image.remove( :force => true )
end
it "Image should exist" do
expect( @image ).to_not be_nil
end
it "Installs the right OS" do
expect( command( "lsb_release -a" ).stdout ).to include( "Debian" )
expect( command( "lsb_release -a" ).stdout ).to include( "jessie" )
end
it "Installs the right OS Version" do
expect( command( "cat /etc/debian_version" ).stdout ).to include( "8" )
end
it "Installs 'lsb-release' package" do
expect( package( "lsb-release" ) ).to be_installed
end
it "Installs 'ca-certificates' package" do
expect( package( "ca-certificates" ) ).to be_installed
end
it "Installs 'gettext-base' package" do
expect( package( "gettext-base" ) ).to be_installed
end
it "Installs Nginx" do
expect( package( "nginx" ) ).to be_installed
end
it "Nginx service should be enabled and running" do
expect( service( "nginx" ) ).to be_enabled
expect( service( "nginx" ) ).to be_running
end
it "Nginx process should be running" do
expect( process( "nginx" ) ).to be_running
end
it "Has a logs directory and routes stdout to log files" do
expect( file( "/etc/nginx/logs" ) ).to exist
expect( file( "/etc/nginx/logs" ) ).to be_directory
expect( file( "/var/log/nginx/access.log" ) ).to be_symlink
expect( file( "/var/log/nginx/error.log" ) ).to be_symlink
end
it "Has a cache directory" do
expect( file( "/var/cache/nginx/temp" ) ).to exist
expect( file( "/var/cache/nginx/temp" ) ).to be_directory
end
it "Has a sites config and sites enabled directory" do
expect( file( "/etc/nginx/sites-available" ) ).to exist
expect( file( "/etc/nginx/sites-available" ) ).to be_directory
expect( file( "/etc/nginx/sites-enabled" ) ).to be_symlink
end
end