vanagon 0.15.37 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +48 -23
- data/bin/build +4 -25
- data/bin/build_host_info +4 -17
- data/bin/build_requirements +4 -31
- data/bin/inspect +4 -21
- data/bin/render +4 -22
- data/bin/ship +4 -28
- data/bin/sign +4 -11
- data/bin/vanagon +7 -0
- data/extras/completions/vanagon.bash +38 -0
- data/extras/completions/vanagon.zsh +41 -0
- data/lib/vanagon.rb +1 -1
- data/lib/vanagon/cli.rb +102 -0
- data/lib/vanagon/cli/build.rb +83 -0
- data/lib/vanagon/cli/build_host_info.rb +57 -0
- data/lib/vanagon/cli/build_requirements.rb +68 -0
- data/lib/vanagon/cli/completion.rb +43 -0
- data/lib/vanagon/cli/inspect.rb +73 -0
- data/lib/vanagon/cli/list.rb +75 -0
- data/lib/vanagon/cli/render.rb +59 -0
- data/lib/vanagon/cli/ship.rb +52 -0
- data/lib/vanagon/cli/sign.rb +34 -0
- data/lib/vanagon/driver.rb +34 -28
- data/lib/vanagon/engine/always_be_scheduling.rb +271 -1
- data/lib/vanagon/engine/docker.rb +101 -14
- data/lib/vanagon/engine/pooler.rb +7 -3
- data/lib/vanagon/platform.rb +5 -3
- data/lib/vanagon/platform/deb.rb +3 -1
- data/lib/vanagon/platform/dsl.rb +11 -0
- data/lib/vanagon/platform/rpm.rb +1 -1
- data/lib/vanagon/platform/windows.rb +29 -2
- data/lib/vanagon/project.rb +23 -4
- data/lib/vanagon/project/dsl.rb +33 -0
- data/lib/vanagon/utilities.rb +30 -8
- data/resources/osx/postinstall.erb +1 -1
- data/resources/solaris/10/postinstall.erb +1 -1
- data/spec/lib/vanagon/cli_spec.rb +226 -0
- data/spec/lib/vanagon/driver_spec.rb +1 -1
- data/spec/lib/vanagon/engine/always_be_scheduling_spec.rb +113 -1
- data/spec/lib/vanagon/engine/docker_spec.rb +74 -16
- data/spec/lib/vanagon/engine/ec2_spec.rb +2 -0
- data/spec/lib/vanagon/engine/pooler_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +57 -30
- data/lib/vanagon/optparse.rb +0 -86
- data/spec/lib/vanagon/optparse_spec.rb +0 -64
@@ -5,7 +5,7 @@
|
|
5
5
|
<%- get_configfiles.each do |config|
|
6
6
|
dest_file = config.path.gsub(/\.pristine$/, '') -%>
|
7
7
|
|
8
|
-
if [ -f "<%= dest_file %>" ]; then
|
8
|
+
if [ -f "<%= dest_file %>" ] && ! diff "<%= config.path %>" "<%= dest_file %>" > /dev/null; then
|
9
9
|
echo "Detected file at '<%= dest_file %>'; updated file at '<%= config.path %>'."
|
10
10
|
else
|
11
11
|
mv '<%= config.path %>' '<%= dest_file %>'
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<%- get_configfiles.each do |config|
|
10
10
|
dest_file = config.path.gsub(/\.pristine$/, '') -%>
|
11
11
|
|
12
|
-
if [ -f "<%= dest_file %>" ]; then
|
12
|
+
if [ -f "<%= dest_file %>" ] && ! diff "<%= config.path %>" "<%= dest_file %>" > /dev/null; then
|
13
13
|
echo "Detected file at '<%= dest_file %>'; updated file at '<%= config.path %>'."
|
14
14
|
else
|
15
15
|
cp -pr '<%= config.path %>' '<%= dest_file %>'
|
@@ -0,0 +1,226 @@
|
|
1
|
+
require 'vanagon/cli'
|
2
|
+
|
3
|
+
##
|
4
|
+
## Ignore the CLI calling 'exit'
|
5
|
+
##
|
6
|
+
RSpec.configure do |rspec|
|
7
|
+
rspec.around(:example) do |ex|
|
8
|
+
begin
|
9
|
+
ex.run
|
10
|
+
rescue SystemExit => e
|
11
|
+
puts "Got SystemExit: #{e.inspect}. Ignoring"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe Vanagon::CLI do
|
17
|
+
describe "options that don't take a value" do
|
18
|
+
[:skipcheck, :verbose].each do |flag|
|
19
|
+
it "can create an option parser that accepts the #{flag} flag" do
|
20
|
+
subject = described_class.new
|
21
|
+
expect(subject.parse(%W[build --#{flag} project platform])).to have_key(flag)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "short options" do
|
26
|
+
[["v", :verbose]].each do |short, long|
|
27
|
+
it "maps the short option #{short} to #{long}" do
|
28
|
+
subject = described_class.new
|
29
|
+
expect(subject.parse(%W[build -#{short} project platform])).to include(long => true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "options that only allow limited values" do
|
36
|
+
[[:preserve, ["always", "never", "on-failure"]]].each do |option, values|
|
37
|
+
values.each do |value|
|
38
|
+
it "can create a parser that accepts \"--#{option} #{value}\"" do
|
39
|
+
subject = described_class.new
|
40
|
+
expect(subject.parse(%W[build --#{option} #{value} project platform]))
|
41
|
+
.to include(option => value.to_sym)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
[[:preserve, ["bad-argument"]]].each do |option, values|
|
46
|
+
values.each do |value|
|
47
|
+
it "rejects the bad argument \"--#{option} #{value}\"" do
|
48
|
+
subject = described_class.new
|
49
|
+
expect{subject.parse(%W[build --#{option} #{value} project platform])}
|
50
|
+
.to raise_error(Vanagon::InvalidArgument)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
it "preserve defaults to :on-failure" do
|
55
|
+
subject = described_class.new
|
56
|
+
expect(subject.parse([])).to include(:preserve => :'on-failure')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
describe "options that take a value" do
|
62
|
+
[:workdir, :configdir, :engine].each do |option|
|
63
|
+
it "can create an option parser that accepts the #{option} option" do
|
64
|
+
subject = described_class.new
|
65
|
+
expect(subject.parse(%W[build --#{option} hello project platform]))
|
66
|
+
.to include(option => "hello")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "short options" do
|
71
|
+
[["w", :workdir], ["c", :configdir], ["e", :engine]].each do |short, long|
|
72
|
+
it "maps the short option #{short} to #{long}" do
|
73
|
+
subject = described_class.new
|
74
|
+
expect(subject.parse(%W[build -#{short} hello project platform]))
|
75
|
+
.to include(long => "hello")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe Vanagon::CLI::List do
|
83
|
+
let(:cli) { Vanagon::CLI::List.new }
|
84
|
+
|
85
|
+
describe "#output" do
|
86
|
+
let(:list) { ['a', 'b', 'c']}
|
87
|
+
it "returns an array if space is false" do
|
88
|
+
expect(cli.output(list, false)).to eq(list)
|
89
|
+
end
|
90
|
+
it "returns space separated if space is true" do
|
91
|
+
expect(cli.output(list, true)).to eq('a b c')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#run" do
|
96
|
+
let(:projects){ ['foo', 'bar', 'baz'] }
|
97
|
+
let(:platforms){ ['1', '2', '3'] }
|
98
|
+
let(:output_both){
|
99
|
+
"- Projects
|
100
|
+
foo
|
101
|
+
bar
|
102
|
+
baz
|
103
|
+
|
104
|
+
- Platforms
|
105
|
+
1
|
106
|
+
2
|
107
|
+
3
|
108
|
+
"
|
109
|
+
}
|
110
|
+
context "specs with standard config path" do
|
111
|
+
before(:each) do
|
112
|
+
expect(Dir).to receive(:exist?)
|
113
|
+
.with("#{File.join(Dir.pwd, 'configs', 'platforms')}")
|
114
|
+
.and_return(true)
|
115
|
+
expect(Dir).to receive(:exist?)
|
116
|
+
.with("#{File.join(Dir.pwd, 'configs', 'projects')}")
|
117
|
+
.and_return(true)
|
118
|
+
expect(Dir).to receive(:children)
|
119
|
+
.with("#{File.join(Dir.pwd, 'configs', 'projects')}")
|
120
|
+
.and_return(projects)
|
121
|
+
expect(Dir).to receive(:children)
|
122
|
+
.with("#{File.join(Dir.pwd, 'configs', 'platforms')}")
|
123
|
+
.and_return(platforms)
|
124
|
+
end
|
125
|
+
let(:options_empty) { {
|
126
|
+
nil=>false,
|
127
|
+
:configdir=>"#{Dir.pwd}/configs",
|
128
|
+
:platforms=>false,
|
129
|
+
:projects=>false,
|
130
|
+
:use_spaces=>false
|
131
|
+
} }
|
132
|
+
let(:options_platforms_only) { {
|
133
|
+
nil=>false,
|
134
|
+
:configdir=>"#{Dir.pwd}/configs",
|
135
|
+
:platforms=>true,
|
136
|
+
:projects=>false,
|
137
|
+
:use_spaces=>false
|
138
|
+
} }
|
139
|
+
let(:options_projects_only) { {
|
140
|
+
nil=>false,
|
141
|
+
:configdir=>"#{Dir.pwd}/configs",
|
142
|
+
:platforms=>false,
|
143
|
+
:projects=>true,
|
144
|
+
:use_spaces=>false
|
145
|
+
} }
|
146
|
+
let(:options_space_only) { {
|
147
|
+
nil=>false,
|
148
|
+
:configdir=>"#{Dir.pwd}/configs",
|
149
|
+
:platforms=>false,
|
150
|
+
:projects=>false,
|
151
|
+
:use_spaces=>true
|
152
|
+
} }
|
153
|
+
|
154
|
+
it "outputs projects and platforms with no options passed" do
|
155
|
+
expect do
|
156
|
+
cli.run(options_empty)
|
157
|
+
end.to output(output_both).to_stdout
|
158
|
+
end
|
159
|
+
|
160
|
+
let(:output_both_space){
|
161
|
+
"- Projects
|
162
|
+
foo bar baz
|
163
|
+
|
164
|
+
- Platforms
|
165
|
+
1 2 3
|
166
|
+
"
|
167
|
+
}
|
168
|
+
it "outputs projects and platforms space separated" do
|
169
|
+
expect do
|
170
|
+
cli.run(options_space_only)
|
171
|
+
end.to output(output_both_space).to_stdout
|
172
|
+
end
|
173
|
+
|
174
|
+
let(:output_platforms){
|
175
|
+
"- Platforms
|
176
|
+
1
|
177
|
+
2
|
178
|
+
3
|
179
|
+
"
|
180
|
+
}
|
181
|
+
it "outputs only platforms when platforms is passed" do
|
182
|
+
expect do
|
183
|
+
cli.run(options_platforms_only)
|
184
|
+
end.to output(output_platforms).to_stdout
|
185
|
+
end
|
186
|
+
|
187
|
+
let(:output_projects){
|
188
|
+
"- Projects
|
189
|
+
foo
|
190
|
+
bar
|
191
|
+
baz
|
192
|
+
"
|
193
|
+
}
|
194
|
+
it "outputs only projects when projects is passed" do
|
195
|
+
expect do
|
196
|
+
cli.run(options_projects_only)
|
197
|
+
end.to output(output_projects).to_stdout
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context "spec with a configdir specified" do
|
202
|
+
let(:options_configdir) { {
|
203
|
+
nil=>false,
|
204
|
+
:configdir=> '/configs',
|
205
|
+
:platforms=>false,
|
206
|
+
:projects=>false,
|
207
|
+
:use_spaces=>false} }
|
208
|
+
it "it successfully takes the configs directory" do
|
209
|
+
expect(Dir).to receive(:exist?).with('/configs' + '/platforms')
|
210
|
+
.and_return(true)
|
211
|
+
expect(Dir).to receive(:exist?).with('/configs' + '/projects')
|
212
|
+
.and_return(true)
|
213
|
+
expect(Dir).to receive(:children).with('/configs' + '/projects')
|
214
|
+
.and_return(projects)
|
215
|
+
expect(Dir).to receive(:children).with('/configs' + '/platforms')
|
216
|
+
.and_return(platforms)
|
217
|
+
expect do
|
218
|
+
cli.run(options_configdir)
|
219
|
+
end.to output(output_both).to_stdout
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
|
@@ -50,7 +50,7 @@ describe 'Vanagon::Driver' do
|
|
50
50
|
info = create_driver(redhat).build_host_info
|
51
51
|
|
52
52
|
expect(info).to match({ 'name' => 'centos-7-x86_64',
|
53
|
-
'engine' => '
|
53
|
+
'engine' => 'always_be_scheduling' })
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'returns the vmpooler template with an explicit engine' do
|
@@ -2,6 +2,7 @@ require 'vanagon/engine/always_be_scheduling'
|
|
2
2
|
require 'vanagon/driver'
|
3
3
|
require 'vanagon/platform'
|
4
4
|
require 'logger'
|
5
|
+
require 'spec_helper'
|
5
6
|
|
6
7
|
class Vanagon
|
7
8
|
class Driver
|
@@ -45,6 +46,8 @@ describe 'Vanagon::Engine::AlwaysBeScheduling' do
|
|
45
46
|
end")
|
46
47
|
plat._platform
|
47
48
|
}
|
49
|
+
let(:pooler_token_file) { File.expand_path('~/.vanagon-token') }
|
50
|
+
let(:floaty_config) { File.expand_path('~/.vmfloaty.yml') }
|
48
51
|
|
49
52
|
describe '#validate_platform' do
|
50
53
|
it 'returns true if the platform has the required attributes' do
|
@@ -81,4 +84,113 @@ describe 'Vanagon::Engine::AlwaysBeScheduling' do
|
|
81
84
|
.to eq('always_be_scheduling')
|
82
85
|
end
|
83
86
|
end
|
84
|
-
|
87
|
+
|
88
|
+
describe '#read_vanagon_token' do
|
89
|
+
it 'takes the first line for abs token, second line is optional' do
|
90
|
+
token_value = 'decade'
|
91
|
+
allow(File).to receive(:exist?)
|
92
|
+
.with(pooler_token_file)
|
93
|
+
.and_return(true)
|
94
|
+
|
95
|
+
allow(File).to receive(:read)
|
96
|
+
.with(pooler_token_file)
|
97
|
+
.and_return(token_value)
|
98
|
+
|
99
|
+
abs_service = Vanagon::Engine::AlwaysBeScheduling.new(platform, nil)
|
100
|
+
expect(abs_service.token).to eq('decade')
|
101
|
+
expect(abs_service.token_vmpooler).to eq(nil)
|
102
|
+
end
|
103
|
+
it 'takes the second line as vmpooler token' do
|
104
|
+
token_value = "decade\nanddaycade"
|
105
|
+
allow(File).to receive(:exist?)
|
106
|
+
.with(pooler_token_file)
|
107
|
+
.and_return(true)
|
108
|
+
|
109
|
+
allow(File).to receive(:read)
|
110
|
+
.with(pooler_token_file)
|
111
|
+
.and_return(token_value)
|
112
|
+
|
113
|
+
abs_service = Vanagon::Engine::AlwaysBeScheduling.new(platform, nil)
|
114
|
+
expect(abs_service.token).to eq('decade')
|
115
|
+
expect(abs_service.token_vmpooler).to eq('anddaycade')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe '#read_vmfloaty_token' do
|
120
|
+
before :each do
|
121
|
+
allow(File).to receive(:exist?)
|
122
|
+
.with(pooler_token_file)
|
123
|
+
.and_return(false)
|
124
|
+
|
125
|
+
allow(File).to receive(:exist?)
|
126
|
+
.with(floaty_config)
|
127
|
+
.and_return(true)
|
128
|
+
end
|
129
|
+
token_value = 'decade'
|
130
|
+
it %(reads a token from '~/.vmfloaty.yml at the top level') do
|
131
|
+
allow(YAML).to receive(:load_file)
|
132
|
+
.with(floaty_config)
|
133
|
+
.and_return({'token' => token_value})
|
134
|
+
|
135
|
+
abs_service = Vanagon::Engine::AlwaysBeScheduling.new(platform, nil)
|
136
|
+
expect(abs_service.token).to eq(token_value)
|
137
|
+
expect(abs_service.token_vmpooler).to eq(nil)
|
138
|
+
end
|
139
|
+
it %(reads a token from '~/.vmfloaty.yml in the abs service') do
|
140
|
+
allow(YAML).to receive(:load_file)
|
141
|
+
.with(floaty_config)
|
142
|
+
.and_return({'services' =>
|
143
|
+
{'MYabs' => {'type'=>'abs', 'token'=>token_value, 'url'=>'foo'}}
|
144
|
+
})
|
145
|
+
|
146
|
+
abs_service = Vanagon::Engine::AlwaysBeScheduling.new(platform, nil)
|
147
|
+
expect(abs_service.token).to eq(token_value)
|
148
|
+
expect(abs_service.token_vmpooler).to eq(nil)
|
149
|
+
end
|
150
|
+
it %(reads a token from '~/.vmfloaty.yml in the abs service and includes the vmpooler token') do
|
151
|
+
vmp_token_value = 'deecade'
|
152
|
+
allow(YAML).to receive(:load_file)
|
153
|
+
.with(floaty_config)
|
154
|
+
.and_return({'services' =>
|
155
|
+
{'MYabs' => {'type'=>'abs', 'token'=>token_value, 'url'=>'foo', 'vmpooler_fallback' => 'myvmp'},
|
156
|
+
'myvmp' => {'token'=>vmp_token_value, 'url'=>'bar'}}
|
157
|
+
})
|
158
|
+
|
159
|
+
abs_service = Vanagon::Engine::AlwaysBeScheduling.new(platform, nil)
|
160
|
+
expect(abs_service.token).to eq(token_value)
|
161
|
+
expect(abs_service.token_vmpooler).to eq(vmp_token_value)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
describe '#select_target_from' do
|
165
|
+
it 'runs successfully' do
|
166
|
+
hostname = 'faint-whirlwind.puppet.com'
|
167
|
+
stub_request(:post, "https://foobar/request").
|
168
|
+
to_return({status: 202, body: "", headers: {}},{status: 200, body: '[{"hostname":"'+hostname+'","type":"aix-6.1-ppc","engine":"nspooler"}]', headers: {}})
|
169
|
+
abs_service = Vanagon::Engine::AlwaysBeScheduling.new(platform, nil)
|
170
|
+
abs_service.select_target_from("https://foobar")
|
171
|
+
expect(abs_service.target).to eq(hostname)
|
172
|
+
end
|
173
|
+
it 'returns a warning if the first request is not a 202' do
|
174
|
+
hostname = 'fainter-whirlwind.puppet.com'
|
175
|
+
stub_request(:post, "https://foobar/request").
|
176
|
+
to_return({status: 404, body: "", headers: {}},{status: 200, body: '[{"hostname":"'+hostname+'","type":"aix-6.1-ppc","engine":"nspooler"}]', headers: {}})
|
177
|
+
allow_any_instance_of(Object).to receive(:warn)
|
178
|
+
expect_any_instance_of(Object).to receive(:warn).with("failed to request ABS with code 404")
|
179
|
+
abs_service = Vanagon::Engine::AlwaysBeScheduling.new(platform, nil)
|
180
|
+
pooler = abs_service.select_target_from("https://foobar")
|
181
|
+
expect(pooler).to eq('')
|
182
|
+
end
|
183
|
+
it 'returns a warning and retries until request is a 200' do
|
184
|
+
hostname = 'faintest-whirlwind.puppet.com'
|
185
|
+
stub_request(:post, "https://foobar/request").
|
186
|
+
to_return({status: 202, body: "", headers: {}},
|
187
|
+
{status: 503, body: "", headers: {}},
|
188
|
+
{status: 200, body: '[{"hostname":"'+hostname+'","type":"aix-6.1-ppc","engine":"nspooler"}]', headers: {}})
|
189
|
+
allow_any_instance_of(Object).to receive(:warn)
|
190
|
+
expect_any_instance_of(Object).to receive(:warn).with(/Waiting 1 seconds to check if ABS request has been filled/)
|
191
|
+
abs_service = Vanagon::Engine::AlwaysBeScheduling.new(platform, nil)
|
192
|
+
abs_service.select_target_from("https://foobar")
|
193
|
+
expect(abs_service.target).to eq(hostname)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -1,21 +1,36 @@
|
|
1
1
|
require 'vanagon/engine/docker'
|
2
2
|
require 'vanagon/platform'
|
3
3
|
|
4
|
-
describe
|
5
|
-
let (:platform_with_docker_image)
|
6
|
-
plat = Vanagon::Platform::DSL.new('debian-
|
7
|
-
plat.instance_eval(
|
8
|
-
|
9
|
-
|
4
|
+
describe Vanagon::Engine::Docker do
|
5
|
+
let (:platform_with_docker_image) do
|
6
|
+
plat = Vanagon::Platform::DSL.new('debian-10-amd64')
|
7
|
+
plat.instance_eval(<<~EOF)
|
8
|
+
platform 'debian-10-amd64' do |plat|
|
9
|
+
plat.docker_image 'debian:10-slim'
|
10
|
+
end
|
11
|
+
EOF
|
10
12
|
plat._platform
|
11
|
-
|
13
|
+
end
|
12
14
|
|
13
|
-
let (:platform_without_docker_image)
|
14
|
-
plat = Vanagon::Platform::DSL.new('debian-
|
15
|
-
plat.instance_eval(
|
16
|
-
|
15
|
+
let (:platform_without_docker_image) do
|
16
|
+
plat = Vanagon::Platform::DSL.new('debian-10-amd64')
|
17
|
+
plat.instance_eval(<<~EOF)
|
18
|
+
platform 'debian-10-amd64' do |plat|
|
19
|
+
end
|
20
|
+
EOF
|
21
|
+
plat._platform
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:platform_with_docker_exec) do
|
25
|
+
plat = Vanagon::Platform::DSL.new('debian-10-amd64')
|
26
|
+
plat.instance_eval(<<~EOF)
|
27
|
+
platform 'debian-10-amd64' do |plat|
|
28
|
+
plat.docker_image 'debian:10-slim'
|
29
|
+
plat.use_docker_exec true
|
30
|
+
end
|
31
|
+
EOF
|
17
32
|
plat._platform
|
18
|
-
|
33
|
+
end
|
19
34
|
|
20
35
|
describe '#initialize' do
|
21
36
|
it 'fails without docker installed' do
|
@@ -23,24 +38,67 @@ describe 'Vanagon::Engine::Docker' do
|
|
23
38
|
expect(FileTest).to receive(:executable?).with(File.join(path_elem, 'docker')).and_return(false)
|
24
39
|
end
|
25
40
|
|
26
|
-
expect {
|
41
|
+
expect { described_class.new(platform_with_docker_image) }.to raise_error(RuntimeError)
|
27
42
|
end
|
28
43
|
end
|
29
44
|
|
30
45
|
describe "#validate_platform" do
|
31
46
|
it 'raises an error if the platform is missing a required attribute' do
|
32
47
|
expect(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
|
33
|
-
expect {
|
48
|
+
expect { described_class.new(platform_without_docker_image).validate_platform }.to raise_error(Vanagon::Error)
|
34
49
|
end
|
35
50
|
|
36
51
|
it 'returns true if the platform has the required attributes' do
|
37
52
|
expect(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
|
38
|
-
expect(
|
53
|
+
expect(described_class.new(platform_with_docker_image).validate_platform).to be(true)
|
39
54
|
end
|
40
55
|
end
|
41
56
|
|
42
57
|
it 'returns "docker" name' do
|
43
58
|
expect(Vanagon::Utilities).to receive(:find_program_on_path).with('docker').and_return('/usr/bin/docker')
|
44
|
-
expect(
|
59
|
+
expect(described_class.new(platform_with_docker_image).name).to eq('docker')
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#dispatch' do
|
63
|
+
context 'when platform has use_docker_exec set' do
|
64
|
+
subject { described_class.new(platform_with_docker_exec) }
|
65
|
+
|
66
|
+
it 'uses docker exec' do
|
67
|
+
expect(Vanagon::Utilities).to receive(:remote_ssh_command).never
|
68
|
+
expect(subject).to receive(:docker_exec)
|
69
|
+
|
70
|
+
subject.dispatch('true', true)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#ship_workdir' do
|
76
|
+
context 'when platform has use_docker_exec set' do
|
77
|
+
subject { described_class.new(platform_with_docker_exec) }
|
78
|
+
|
79
|
+
it 'uses docker cp' do
|
80
|
+
expect(Vanagon::Utilities).to receive(:rsync_to).never
|
81
|
+
expect(subject).to receive(:docker_cp_globs_to)
|
82
|
+
|
83
|
+
subject.ship_workdir('foo/')
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#retrieve_built_artifact' do
|
89
|
+
context 'when platform has use_docker_exec set' do
|
90
|
+
subject { described_class.new(platform_with_docker_exec) }
|
91
|
+
|
92
|
+
before(:each) do
|
93
|
+
allow(FileUtils).to receive(:mkdir_p)
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'uses docker cp' do
|
97
|
+
expect(Vanagon::Utilities).to receive(:rsync_from).never
|
98
|
+
expect(subject).to receive(:docker_cp_globs_from)
|
99
|
+
|
100
|
+
subject.retrieve_built_artifact('output/*', false)
|
101
|
+
end
|
102
|
+
end
|
45
103
|
end
|
46
104
|
end
|