mcrain 0.4.0 → 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/.rspec +2 -1
- data/Gemfile +1 -0
- data/README.md +20 -0
- data/Rakefile +11 -0
- data/lib/mcrain.rb +1 -0
- data/lib/mcrain/base.rb +20 -14
- data/lib/mcrain/riak.rb +1 -0
- data/lib/mcrain/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2ff5e7956416f054f2523b6853cf80ed4a83a6f
|
4
|
+
data.tar.gz: af57bc517594be455895f010a98459552793b0e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b78364b508088e190513aed093ad6752c964196d47fc9dc05ddd95dfba61d8cae94525cc55b17f2a1dd15e73a9fc09cf1557bad774b103f112030ea8e50b20bb
|
7
|
+
data.tar.gz: 632babac3f00d28bb844265e0658aac31403916d3bbf6b1ba9a5eb57cb03db745c45418694f7bf3a46b8078a60fa95f656d9b41523a7134a4683b22167b392b9
|
data/.rspec
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -170,6 +170,26 @@ $ mcrain stop riak 5
|
|
170
170
|
OK
|
171
171
|
```
|
172
172
|
|
173
|
+
## Mcrain.before_setup
|
174
|
+
|
175
|
+
Use Mcrain.before_setup hook if you don't want your test or spec always works with mcrain.
|
176
|
+
Set block to Mcrain.before_setup like this:
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
unless ENV['WITH_MCRAIN'] =~ /true|yes|on|1/i
|
180
|
+
Mcrain.before_setup = ->(s){
|
181
|
+
# RSpec::Core::Pending#skip
|
182
|
+
# https://github.com/rspec/rspec-core/blob/5fc29a15b9af9dc1c9815e278caca869c4769767/lib/rspec/core/pending.rb#L118-L124
|
183
|
+
message = "skip examples which uses mcrain"
|
184
|
+
current_example = RSpec.current_example
|
185
|
+
RSpec::Core::Pending.mark_skipped!(current_example, message) if current_example
|
186
|
+
raise RSpec::Core::Pending::SkipDeclaredInExample.new(message)
|
187
|
+
}
|
188
|
+
end
|
189
|
+
```
|
190
|
+
|
191
|
+
|
192
|
+
|
173
193
|
|
174
194
|
## Development
|
175
195
|
|
data/Rakefile
CHANGED
@@ -4,3 +4,14 @@ require "rspec/core/rake_task"
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
6
|
task :default => :spec
|
7
|
+
|
8
|
+
namespace :parallel do
|
9
|
+
desc 'run `parallel_rspec spec at this directory`'
|
10
|
+
task :spec, :count do |_, args|
|
11
|
+
cmd = "parallel_rspec spec"
|
12
|
+
if n = args[:count]
|
13
|
+
cmd << " -n #{n}"
|
14
|
+
end
|
15
|
+
exit(1) unless system(cmd)
|
16
|
+
end
|
17
|
+
end
|
data/lib/mcrain.rb
CHANGED
data/lib/mcrain/base.rb
CHANGED
@@ -24,27 +24,19 @@ module Mcrain
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def start
|
28
|
-
setup
|
27
|
+
def start(&block)
|
28
|
+
r = setup
|
29
|
+
return nil unless r
|
29
30
|
if block_given?
|
30
|
-
|
31
|
-
wait_port
|
32
|
-
wait
|
33
|
-
return yield(self)
|
34
|
-
rescue Exception => e
|
35
|
-
logs = container.logs(stdout: 1, stderr: 1)
|
36
|
-
logger.error("[#{e.class.name}] #{e.message}\nthe container logs...\n#{logs}")
|
37
|
-
raise e
|
38
|
-
ensure
|
39
|
-
teardown
|
40
|
-
end
|
31
|
+
start_callback(&block)
|
41
32
|
else
|
42
33
|
wait
|
43
|
-
return self
|
44
34
|
end
|
35
|
+
return self
|
45
36
|
end
|
46
37
|
|
47
38
|
def setup
|
39
|
+
return false if Mcrain.before_setup && !Mcrain.before_setup.call(self)
|
48
40
|
Timeout.timeout(30) do
|
49
41
|
DockerMachine.setup_docker_options
|
50
42
|
container.start!
|
@@ -52,6 +44,20 @@ module Mcrain
|
|
52
44
|
return container
|
53
45
|
end
|
54
46
|
|
47
|
+
def start_callback
|
48
|
+
begin
|
49
|
+
wait_port
|
50
|
+
wait
|
51
|
+
return yield(self)
|
52
|
+
rescue Exception => e
|
53
|
+
logs = container.logs(stdout: 1, stderr: 1)
|
54
|
+
logger.error("[#{e.class.name}] #{e.message}\nthe container logs...\n#{logs}")
|
55
|
+
raise e
|
56
|
+
ensure
|
57
|
+
teardown
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
55
61
|
# ポートがLISTENされるまで待つ
|
56
62
|
def wait_port
|
57
63
|
Mcrain.wait_port_opened(host, port, interval: 0.5, timeout: 30)
|
data/lib/mcrain/riak.rb
CHANGED
data/lib/mcrain/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcrain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logger_pipe
|
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
|
-
rubygems_version: 2.4.5
|
154
|
+
rubygems_version: 2.4.5.1
|
155
155
|
signing_key:
|
156
156
|
specification_version: 4
|
157
157
|
summary: mcrain supports to run docker container for test.
|