bigrig 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +24 -26
- data/bigrig.gemspec +2 -2
- data/lib/bigrig/models/container.rb +2 -2
- data/lib/bigrig/runner.rb +2 -10
- data/lib/bigrig/version.rb +1 -1
- data/lib/bigrig/waiter.rb +20 -0
- data/lib/bigrig.rb +1 -0
- data/spec/bigrig/actions/run_action_spec.rb +8 -0
- data/spec/bigrig/docker_adapter_spec.rb +1 -1
- data/spec/bigrig/models/container_spec.rb +0 -18
- data/spec/bigrig_spec.rb +20 -6
- data/spec/data/wait_for/Dockerfile +4 -0
- data/spec/data/wait_for/bigrig-wait.sh +5 -0
- data/spec/data/wait_for/bigrig.json +8 -0
- data/spec/data/wait_for_broken/Dockerfile +4 -0
- data/spec/data/wait_for_broken/bigrig-wait.sh +3 -0
- data/spec/data/wait_for_broken/bigrig.json +8 -0
- data/spec/vcr/Bigrig_DestroyAction/_perform/given_json_with_a_single_container/and_the_container_has_exited/should_remove_the_container.yml +65 -65
- data/spec/vcr/Bigrig_DestroyAction/_perform/given_json_with_a_single_container/and_the_container_is_running/kills_and_removes_the_container.yml +71 -71
- data/spec/vcr/Bigrig_DockerAdapter/_build/builds_the_given_directory.yml +11 -11
- data/spec/vcr/Bigrig_DockerAdapter/_build/passes_build_input_to_a_block.yml +5 -5
- data/spec/vcr/Bigrig_DockerAdapter/_container_exists_/when_the_container_does_not_exist/is_false.yml +20 -20
- data/spec/vcr/Bigrig_DockerAdapter/_container_exists_/when_the_container_exists/is_true.yml +13 -13
- data/spec/vcr/Bigrig_DockerAdapter/_image_id_by_tag/when_the_image_does_not_exist/raise_a_ImageNotFoundError.yml +20 -20
- data/spec/vcr/Bigrig_DockerAdapter/_image_id_by_tag/when_the_image_exists/returns_the_image_id.yml +19 -19
- data/spec/vcr/Bigrig_DockerAdapter/_kill/given_the_container_does_not_exist/should_raise_an_error.yml +20 -20
- data/spec/vcr/Bigrig_DockerAdapter/_kill/given_the_container_is_running/should_kill_the_container.yml +29 -29
- data/spec/vcr/Bigrig_DockerAdapter/_logs/streams_logs_to_a_block.yml +23 -23
- data/spec/vcr/Bigrig_DockerAdapter/_pull/given_a_block_to_capture_output/should_capture_output.yml +8 -8
- data/spec/vcr/Bigrig_DockerAdapter/_pull/given_the_repo_does_not_exist/raises_a_RepoNotFoundError.yml +3 -3
- data/spec/vcr/Bigrig_DockerAdapter/_pull/given_the_repo_exists/returns_the_image_id.yml +13 -13
- data/spec/vcr/Bigrig_DockerAdapter/_push/given_credentials/will_pass_login_and_password.yml +54 -54
- data/spec/vcr/Bigrig_DockerAdapter/_push/should_push_the_image.yml +1059 -553
- data/spec/vcr/Bigrig_DockerAdapter/_remove_container/when_the_container_does_not_exist/raises_a_ContainerNotFoundError.yml +40 -40
- data/spec/vcr/Bigrig_DockerAdapter/_remove_container/when_the_container_exists/should_remove_the_container.yml +44 -44
- data/spec/vcr/Bigrig_DockerAdapter/_remove_container/when_the_container_is_running/raises_a_ContainerRunningError.yml +13 -13
- data/spec/vcr/Bigrig_DockerAdapter/_remove_image/when_the_image_doesnt_exist/raises_an_error.yml +12 -12
- data/spec/vcr/Bigrig_DockerAdapter/_remove_image/when_the_image_exists/removes_the_image.yml +35 -35
- data/spec/vcr/Bigrig_DockerAdapter/_run/given_an_image_id_that_exists/and_a_name/starts_the_container_with_the_right_name.yml +35 -35
- data/spec/vcr/Bigrig_DockerAdapter/_run/given_an_image_id_that_exists/and_a_name_and_env_variables/starts_the_container_with_env_set.yml +35 -35
- data/spec/vcr/Bigrig_DockerAdapter/_run/given_an_image_id_that_exists/and_a_name_and_ports/starts_the_container_with_ports_exposed.yml +41 -41
- data/spec/vcr/Bigrig_DockerAdapter/_running_/when_the_container_does_not_exist/returns_false.yml +20 -20
- data/spec/vcr/Bigrig_DockerAdapter/_running_/when_the_container_is_not_running/returns_false.yml +13 -15
- data/spec/vcr/Bigrig_DockerAdapter/_running_/when_the_container_is_running/returns_true.yml +17 -17
- data/spec/vcr/Bigrig_DockerAdapter/_tag/should_tag_the_image.yml +34 -34
- data/spec/vcr/Bigrig_LogAction/_perform/follows_the_log.yml +43 -43
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_a_path/builds_the_image_before_starting_it.yml +222 -26
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_hosts_by_ip/should_pass_hosts_to_container.yml +180 -74
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_hosts_by_name/should_lookup_ips_for_hosts_with_a_hostname.yml +181 -75
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_links/should_pass_links_to_the_right_container.yml +351 -139
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_multiple_containers/launches_both_containers_in_parallel.yml +130 -130
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_multiple_containers/spins_up_multiple_containers.yml +140 -140
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_one_container/should_spin_up_a_single_container.yml +175 -69
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_one_container/when_a_dead_container_exists/should_remove_existing_containers.yml +159 -53
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_volumes/should_pass_volumes_to_the_right_container.yml +180 -74
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_volumes_from/should_pass_volumes_from_to_the_right_container.yml +351 -139
- data/spec/vcr/Bigrig_RunAction/_perform/given_a_file_with_volumes_from/starts_the_dependant_container_last.yml +130 -130
- data/spec/vcr/Bigrig_RunAction/_perform/when_activating_profiles_that_do_not_exist/ignores_the_missing_profile.yml +268 -77
- data/spec/vcr/Bigrig_RunAction/_perform/with_a_file_with_active_profiles/uses_the_overridden_image.yml +180 -74
- data/spec/vcr/bigrig/destroy/spec/data/single_json/kills_the_container.yml +28 -28
- data/spec/vcr/bigrig/dev/spec/data/dev_json/activates_the_dev_profile.yml +266 -158
- data/spec/vcr/bigrig/dev/spec/data/dev_json/destroys_containers_on_exit.yml +78 -158
- data/spec/vcr/bigrig/dev/spec/data/dev_json/starts_the_containers.yml +187 -191
- data/spec/vcr/bigrig/dev/spec/data/dev_json/tails_the_logs.yml +38 -118
- data/spec/vcr/bigrig/dev/spec/data/scan_json/leaves_unaffected_containers_alone_when_the_scanned_file_changes.yml +811 -345
- data/spec/vcr/bigrig/dev/spec/data/scan_json/restarts_dependant_containers_when_the_scanned_file_changes.yml +813 -375
- data/spec/vcr/bigrig/dev/spec/data/scan_json/restarts_the_container_when_the_scanned_file_changes.yml +855 -363
- data/spec/vcr/bigrig/logs/spec/data/log_json/tails_the_logs.yml +23 -23
- data/spec/vcr/bigrig/run/spec/data/profiles_json_-p_qa/leaves_existing_env_values_alone.yml +14 -14
- data/spec/vcr/bigrig/run/spec/data/profiles_json_-p_qa/overrides_the_env.yml +14 -14
- data/spec/vcr/bigrig/run/spec/data/profiles_json_-p_qa/overrides_the_tag.yml +17 -17
- data/spec/vcr/bigrig/run/spec/data/single_json/sends_the_name_of_the_container_to_stdout.yml +12 -12
- data/spec/vcr/bigrig/run/spec/data/single_json/starts_the_container.yml +17 -17
- data/spec/vcr/bigrig/run/spec/data/wait_for/bigrig_json/waits_for_wait_for.yml +180 -0
- data/spec/vcr/bigrig/run/spec/data/wait_for_broken_json/fails_with_an_error.yml +12 -12
- data/spec/vcr/bigrig/ship/spec/data/ship_json/with_a_version/-c/cleans_the_image_when_its_done.yml +28 -28
- data/spec/vcr/bigrig/ship/spec/data/ship_json/with_a_version/builds_and_pushes_the_image.yml +21 -21
- data/spec/vcr/bigrig_bin_bigrig_destroy_spec/data/single_json_kills_the_container.yml +28 -28
- data/spec/vcr/bigrig_bin_bigrig_dev_spec/data/dev_json_activates_the_dev_profile.yml +135 -486
- data/spec/vcr/bigrig_bin_bigrig_dev_spec/data/dev_json_starts_the_containers.yml +146 -472
- data/spec/vcr/bigrig_bin_bigrig_dev_spec/data/dev_json_tails_the_logs.yml +402 -192
- data/spec/vcr/bigrig_bin_bigrig_dev_spec/data/scan_json_leaves_unaffected_containers_alone_when_the_scanned_file_changes.yml +980 -396
- data/spec/vcr/bigrig_bin_bigrig_dev_spec/data/scan_json_restarts_dependant_containers_when_the_scanned_file_changes.yml +916 -388
- data/spec/vcr/bigrig_bin_bigrig_dev_spec/data/scan_json_restarts_the_container_when_the_scanned_file_changes.yml +919 -391
- data/spec/vcr/bigrig_bin_bigrig_logs_spec/data/log_json_tails_the_logs.yml +23 -23
- data/spec/vcr/bigrig_bin_bigrig_run_spec/data/profiles_json_-p_qa_leaves_existing_env_values_alone.yml +159 -53
- data/spec/vcr/bigrig_bin_bigrig_run_spec/data/profiles_json_-p_qa_overrides_the_env.yml +159 -53
- data/spec/vcr/bigrig_bin_bigrig_run_spec/data/profiles_json_-p_qa_overrides_the_tag.yml +286 -31
- data/spec/vcr/bigrig_bin_bigrig_run_spec/data/single_json_sends_the_name_of_the_container_to_stdout.yml +159 -53
- data/spec/vcr/bigrig_bin_bigrig_run_spec/data/single_json_starts_the_container.yml +159 -53
- data/spec/vcr/bigrig_bin_bigrig_run_spec/data/wait_for/bigrig_json_waits_for_wait_for.yml +522 -0
- data/spec/vcr/bigrig_bin_bigrig_run_spec/data/wait_for_broken_json_fails_with_an_error.yml +175 -80
- data/spec/vcr/bigrig_bin_bigrig_ship_spec/data/ship_json_with_a_version_-c_cleans_the_image_when_its_done.yml +1036 -526
- data/spec/vcr/bigrig_bin_bigrig_ship_spec/data/ship_json_with_a_version_builds_and_pushes_the_image.yml +1024 -514
- metadata +17 -12
- data/spec/data/wait_for.json +0 -9
- data/spec/data/wait_for_broken.json +0 -9
- data/spec/vcr/bigrig/run/spec/data/wait_for_json/waits_for_wait_for.yml +0 -180
- data/spec/vcr/bigrig_bin_bigrig_run_spec/data/wait_for_json_waits_for_wait_for.yml +0 -412
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7efe9f59950d19fdb1cdf53db16d27936f113506
|
4
|
+
data.tar.gz: 0b7009c17a3ac7afb42c453dce0c07a2a2002806
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efc06d73bb0ef865abbe7a66b37194ea77f946cf2833c3206cb4c8f9655d64e90e355041f6bfe6c53ba483fa58314e9ce1326404d9f2e0b605fabec04a03c166
|
7
|
+
data.tar.gz: dce81ac7df035ba0e1135e6ecc532253772fd302b5e602c1334a37a5b8148d1364538b1b9a1181be51830e463e5f057556719d189c144a584ba042938cc6107a
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bigrig (0.
|
4
|
+
bigrig (0.5.0)
|
5
5
|
colorize (= 0.7.5)
|
6
|
-
docker-api (= 1.
|
6
|
+
docker-api (= 1.21.4)
|
7
7
|
filewatcher (= 0.4.0)
|
8
8
|
gli (= 2.12.2)
|
9
9
|
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
13
|
Platform (0.4.0)
|
14
|
-
addressable (2.3.
|
14
|
+
addressable (2.3.8)
|
15
15
|
ast (2.0.0)
|
16
16
|
astrolabe (1.3.0)
|
17
17
|
parser (>= 2.2.0.pre.3, < 3.0)
|
@@ -19,49 +19,48 @@ GEM
|
|
19
19
|
crack (0.4.2)
|
20
20
|
safe_yaml (~> 1.0.0)
|
21
21
|
diff-lcs (1.2.5)
|
22
|
-
docker-api (1.
|
22
|
+
docker-api (1.21.4)
|
23
23
|
excon (>= 0.38.0)
|
24
24
|
json
|
25
|
-
excon (0.45.
|
25
|
+
excon (0.45.3)
|
26
26
|
filewatcher (0.4.0)
|
27
27
|
trollop (~> 2.0)
|
28
28
|
gli (2.12.2)
|
29
|
-
json (1.8.
|
29
|
+
json (1.8.3)
|
30
30
|
open4 (1.3.4)
|
31
|
-
parser (2.2.
|
31
|
+
parser (2.2.2.5)
|
32
32
|
ast (>= 1.1, < 3.0)
|
33
|
-
slop (~> 3.4, >= 3.4.5)
|
34
33
|
popen4 (0.1.2)
|
35
34
|
Platform (>= 0.4.0)
|
36
35
|
open4 (>= 0.4.0)
|
37
36
|
powerpack (0.0.9)
|
38
37
|
rainbow (2.0.0)
|
39
38
|
rake (10.4.2)
|
40
|
-
rspec (3.
|
41
|
-
rspec-core (~> 3.
|
42
|
-
rspec-expectations (~> 3.
|
43
|
-
rspec-mocks (~> 3.
|
44
|
-
rspec-core (3.
|
45
|
-
rspec-support (~> 3.
|
39
|
+
rspec (3.2.0)
|
40
|
+
rspec-core (~> 3.2.0)
|
41
|
+
rspec-expectations (~> 3.2.0)
|
42
|
+
rspec-mocks (~> 3.2.0)
|
43
|
+
rspec-core (3.2.3)
|
44
|
+
rspec-support (~> 3.2.0)
|
46
45
|
rspec-eventually (0.0.1)
|
47
|
-
rspec-expectations (3.1
|
46
|
+
rspec-expectations (3.2.1)
|
48
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.
|
50
|
-
rspec-its (1.0
|
51
|
-
rspec-core (>=
|
52
|
-
rspec-expectations (>=
|
53
|
-
rspec-mocks (3.1
|
54
|
-
|
55
|
-
|
48
|
+
rspec-support (~> 3.2.0)
|
49
|
+
rspec-its (1.2.0)
|
50
|
+
rspec-core (>= 3.0.0)
|
51
|
+
rspec-expectations (>= 3.0.0)
|
52
|
+
rspec-mocks (3.2.1)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.2.0)
|
55
|
+
rspec-support (3.2.2)
|
56
56
|
rubocop (0.27.1)
|
57
57
|
astrolabe (~> 1.3)
|
58
58
|
parser (>= 2.2.0.pre.7, < 3.0)
|
59
59
|
powerpack (~> 0.0.6)
|
60
60
|
rainbow (>= 1.99.1, < 3.0)
|
61
61
|
ruby-progressbar (~> 1.4)
|
62
|
-
ruby-progressbar (1.7.
|
62
|
+
ruby-progressbar (1.7.5)
|
63
63
|
safe_yaml (1.0.4)
|
64
|
-
slop (3.6.0)
|
65
64
|
trollop (2.1.2)
|
66
65
|
vcr (2.9.3)
|
67
66
|
webmock (1.20.4)
|
@@ -69,7 +68,6 @@ GEM
|
|
69
68
|
crack (>= 0.3.2)
|
70
69
|
|
71
70
|
PLATFORMS
|
72
|
-
java
|
73
71
|
ruby
|
74
72
|
|
75
73
|
DEPENDENCIES
|
@@ -79,6 +77,6 @@ DEPENDENCIES
|
|
79
77
|
rspec
|
80
78
|
rspec-eventually
|
81
79
|
rspec-its
|
82
|
-
rubocop
|
80
|
+
rubocop (~> 0.27.1)
|
83
81
|
vcr (~> 2.9.3)
|
84
82
|
webmock (~> 1.20.4)
|
data/bigrig.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_development_dependency('rake')
|
18
18
|
s.add_development_dependency('rspec')
|
19
19
|
s.add_development_dependency('rspec-its')
|
20
|
-
s.add_development_dependency('rubocop')
|
20
|
+
s.add_development_dependency('rubocop', '~> 0.27.1')
|
21
21
|
s.add_development_dependency('vcr', '~> 2.9.3')
|
22
22
|
s.add_development_dependency('webmock', '~> 1.20.4')
|
23
23
|
s.add_development_dependency('popen4')
|
@@ -25,6 +25,6 @@ Gem::Specification.new do |s|
|
|
25
25
|
|
26
26
|
s.add_runtime_dependency('gli', '2.12.2')
|
27
27
|
s.add_runtime_dependency('colorize', '0.7.5')
|
28
|
-
s.add_runtime_dependency('docker-api', '1.
|
28
|
+
s.add_runtime_dependency('docker-api', '1.21.4')
|
29
29
|
s.add_runtime_dependency('filewatcher', '0.4.0')
|
30
30
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Bigrig
|
2
2
|
class Container < BaseModel
|
3
|
-
ARRAY_ATTRS = :volumes_from, :links, :hosts, :volumes
|
3
|
+
ARRAY_ATTRS = :volumes_from, :links, :hosts, :volumes
|
4
4
|
attr_accessor :env, :name, :path, :ports, :tag, :volumes_from, :links, :hosts, :repo,
|
5
|
-
:volumes, :scan
|
5
|
+
:volumes, :scan
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def from_json(name, json)
|
data/lib/bigrig/runner.rb
CHANGED
@@ -43,8 +43,7 @@ module Bigrig
|
|
43
43
|
volumes: container.volumes,
|
44
44
|
links: container.links,
|
45
45
|
hosts: container.hosts,
|
46
|
-
image_id: image_id(container)
|
47
|
-
wait_for: container.wait_for }
|
46
|
+
image_id: image_id(container) }
|
48
47
|
end
|
49
48
|
|
50
49
|
def image_id(container)
|
@@ -72,7 +71,7 @@ module Bigrig
|
|
72
71
|
Thread.new do
|
73
72
|
puts "Starting #{container[:name]}"
|
74
73
|
puts DockerAdapter.run(container)
|
75
|
-
|
74
|
+
Waiter.new(container[:name]).wait_if_needed
|
76
75
|
end
|
77
76
|
end
|
78
77
|
|
@@ -91,12 +90,5 @@ module Bigrig
|
|
91
90
|
end
|
92
91
|
steps
|
93
92
|
end
|
94
|
-
|
95
|
-
def wait_for(container)
|
96
|
-
container[:wait_for].empty? && return
|
97
|
-
puts "Waiting for `#{container[:wait_for].join ' '}` to compelte on #{container[:name]}"
|
98
|
-
result = DockerAdapter.exec(container[:name], container[:wait_for])
|
99
|
-
result[2] != 0 && fail("Error waiting for container: #{result.first.first}")
|
100
|
-
end
|
101
93
|
end
|
102
94
|
end
|
data/lib/bigrig/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Bigrig
|
2
|
+
class Waiter
|
3
|
+
def initialize(name)
|
4
|
+
@name = name
|
5
|
+
end
|
6
|
+
|
7
|
+
def wait_if_needed
|
8
|
+
script_present? || return
|
9
|
+
puts "Waiting for `/bigrig-wait.sh` to compelte on #{@name}"
|
10
|
+
result = DockerAdapter.exec @name, '/bigrig-wait.sh'
|
11
|
+
result[2] != 0 && fail("Error waiting for container: #{result.first.first}")
|
12
|
+
end
|
13
|
+
|
14
|
+
def script_present?
|
15
|
+
DockerAdapter.exec(@name, ['ls', '/bigrig-wait.sh'])[2] == 0
|
16
|
+
rescue Docker::Error::NotFoundError => e
|
17
|
+
puts "Unable to determine if wait script is available: #{e}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/bigrig.rb
CHANGED
@@ -56,6 +56,10 @@ module Bigrig
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
before do
|
60
|
+
allow_any_instance_of(Waiter).to receive :wait_if_needed
|
61
|
+
end
|
62
|
+
|
59
63
|
it 'spins up multiple containers', :vcr do
|
60
64
|
perform
|
61
65
|
expect(running?).to be true
|
@@ -199,6 +203,8 @@ module Bigrig
|
|
199
203
|
sleep 0.5
|
200
204
|
expect(running).to eq 0
|
201
205
|
end
|
206
|
+
|
207
|
+
allow_any_instance_of(Waiter).to receive :wait_if_needed
|
202
208
|
perform
|
203
209
|
end
|
204
210
|
end
|
@@ -231,6 +237,7 @@ module Bigrig
|
|
231
237
|
image_id: 'env-testid',
|
232
238
|
env: { 'NAME1' => 'VALUE1', 'NAME2' => 'VALUE2' }
|
233
239
|
)
|
240
|
+
allow_any_instance_of(Waiter).to receive :wait_if_needed
|
234
241
|
|
235
242
|
subject
|
236
243
|
end
|
@@ -247,6 +254,7 @@ module Bigrig
|
|
247
254
|
image_id: 'env-testid',
|
248
255
|
ports: ['80:8080', '12345']
|
249
256
|
)
|
257
|
+
allow_any_instance_of(Waiter).to receive :wait_if_needed
|
250
258
|
|
251
259
|
subject
|
252
260
|
end
|
@@ -20,8 +20,6 @@ module Bigrig
|
|
20
20
|
it { is_expected.to respond_to :volumes_from= }
|
21
21
|
it { is_expected.to respond_to :volumes }
|
22
22
|
it { is_expected.to respond_to :volumes= }
|
23
|
-
it { is_expected.to respond_to :wait_for }
|
24
|
-
it { is_expected.to respond_to :wait_for= }
|
25
23
|
|
26
24
|
it 'accepts volumes as an array' do
|
27
25
|
expect(Container.from_json(nil, 'volumes' => ['test']).volumes).to be_kind_of Array
|
@@ -63,14 +61,6 @@ module Bigrig
|
|
63
61
|
expect(Container.from_json(nil, 'links' => 'machine:alias').dependencies).to eq ['machine']
|
64
62
|
end
|
65
63
|
|
66
|
-
it 'accepts wait_for as an array' do
|
67
|
-
expect(Container.from_json(nil, 'wait_for' => ['test']).wait_for).to be_kind_of Array
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'wraps a single wait_for in an array' do
|
71
|
-
expect(Container.from_json(nil, 'wait_for' => 'test').wait_for).to be_kind_of Array
|
72
|
-
end
|
73
|
-
|
74
64
|
describe '#dependencies' do
|
75
65
|
it 'returns an empty array when no dependencies are present' do
|
76
66
|
expect(Container.from_json(nil, {}).dependencies).to eq []
|
@@ -142,14 +132,6 @@ module Bigrig
|
|
142
132
|
expect(subject.ports).to eq ['80:8080', '12345']
|
143
133
|
end
|
144
134
|
end
|
145
|
-
|
146
|
-
context 'given json with wait_for' do
|
147
|
-
let(:json) { { 'wait_for' => 'random command' } }
|
148
|
-
|
149
|
-
it 'has wait_for' do
|
150
|
-
expect(subject.wait_for).to eq ['random command']
|
151
|
-
end
|
152
|
-
end
|
153
135
|
end
|
154
136
|
end
|
155
137
|
end
|
data/spec/bigrig_spec.rb
CHANGED
@@ -216,28 +216,42 @@ describe 'bigrig' do
|
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
219
|
-
context 'spec/data/wait_for.json' do
|
219
|
+
context 'spec/data/wait_for/bigrig.json' do
|
220
220
|
let(:args) { ['run'] }
|
221
221
|
let(:output) { subject }
|
222
|
-
let(:file) { '
|
222
|
+
let(:file) { 'bigrig.json' }
|
223
|
+
let(:here) { "#{File.expand_path '../..', __FILE__}/" }
|
223
224
|
let(:container) { Docker::Container.get 'wait_for-test' }
|
224
225
|
let(:result) do
|
225
|
-
Docker::Container.get('wait_for-test').exec(['cat', '/tmp/result.txt']).first.first.
|
226
|
+
Docker::Container.get('wait_for-test').exec(['cat', '/tmp/result.txt']).first.first.strip
|
227
|
+
end
|
228
|
+
|
229
|
+
around do |example|
|
230
|
+
Dir.chdir 'spec/data/wait_for' do
|
231
|
+
example.run
|
232
|
+
end
|
226
233
|
end
|
227
234
|
|
228
235
|
it 'waits for wait_for', :vcr do
|
229
236
|
subject
|
230
|
-
expect(result).to
|
237
|
+
expect(result).to eq '2'
|
231
238
|
end
|
232
239
|
end
|
233
240
|
|
234
241
|
context 'spec/data/wait_for_broken.json' do
|
235
|
-
let(:command) { %(spec/support/bigrig_vcr "#{casette_name}" #{args.join ' '}) }
|
236
|
-
let(:args) {
|
242
|
+
let(:command) { %(#{here}spec/support/bigrig_vcr "#{casette_name}" #{args.join ' '}) }
|
243
|
+
let(:args) { ['run'] }
|
244
|
+
let(:here) { "#{File.expand_path '../..', __FILE__}/" }
|
237
245
|
let(:container) do
|
238
246
|
Docker::Container.get('wait_for_broken-test')
|
239
247
|
end
|
240
248
|
|
249
|
+
around do |example|
|
250
|
+
Dir.chdir 'spec/data/wait_for_broken' do
|
251
|
+
example.run
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
241
255
|
it 'fails with an error', :vcr do
|
242
256
|
pid, output = capture_stdout command
|
243
257
|
Process.kill :SIGINT, pid
|