-
Notifications
You must be signed in to change notification settings - Fork 2
/
snap_spec.rb
96 lines (82 loc) · 2.49 KB
/
snap_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
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
94
95
96
require 'rspec/retry'
require 'dockerspec/serverspec'
describe docker_build("/serverspec/snap/.") do
it { should have_maintainer /Nan Liu/ }
%w[SNAP_VERSION SNAP_TRUST_LEVEL SNAP_LOG_LEVEL].each do |e|
it { should have_env e }
end
{ "vendor" => "Intelsdi-X",
"license" => "Apache 2.0",
"build-date" => "",
"io.snap-telemetry.snap.version.is-beta" => "",
}.each do |k, v|
it { should have_label( k => v ) }
end
it { should have_expose '8181' }
it { should have_cmd ["/bin/sh", "-c", "/usr/local/bin/init_snap && /opt/snap/sbin/snapteld -t ${SNAP_TRUST_LEVEL} -l ${SNAP_LOG_LEVEL} -o ''"] }
describe docker_run(described_image) do
describe command('/usr/local/bin/init_snap') do
its(:exit_status) { should eq 0 }
end
bins = [
"/opt/snap/bin/snaptel",
"/opt/snap/sbin/snapteld",
"/usr/local/bin/init_snap",
]
bins.each do |f|
describe file(f) do
it { should be_file }
it { should be_executable }
end
end
symlinks = {
"/usr/local/sbin/snapteld" => "/opt/snap/sbin/snapteld",
"/usr/local/bin/snaptel" => "/opt/snap/bin/snaptel",
}
symlinks.each do |f, t|
describe file(f) do
it { should be_symlink }
it { should be_linked_to t }
end
end
# This can be removed after test have been migrated to the new binaries
snapd = {
"/usr/local/sbin/snapd" => "/opt/snap/sbin/snapteld",
"/usr/local/bin/snapctl" => "/opt/snap/bin/snaptel",
"/etc/snap/snapd.conf" => "/etc/snap/snapteld.conf",
}
snapd.each do |f, t|
describe file(f) do
it { should be_symlink }
it { should be_linked_to t }
end
end
folders = [
"/opt/snap/bin",
"/opt/snap/plugins",
"/var/log/snap",
"/etc/snap",
]
folders.each do |f|
describe file(f) do
it { should be_directory }
end
end
describe file('/etc/snap/snapteld.conf') do
it { should be_file }
its(:content_as_yaml) {
should include('log_path' => '/var/log/snap')
should include('control' => {
"auto_discover_path" => "/opt/snap/plugins",
"plugin_trust_level" => 0,
})
}
end
describe command('/opt/snap/sbin/snapteld --version') do
its(:stdout) { should match /snapteld version/ }
end
describe command('/opt/snap/bin/snaptel --version'),:retry => 3, :retry_wait => 10 do
its(:stdout) { should match /snaptel version/ }
end
end
end