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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32c04fa1f39c69a60b478fbc2b705fff5f9be98a
4
- data.tar.gz: 02d9789d7754370e6efefccaf76b3eb318daa733
3
+ metadata.gz: e2ff5e7956416f054f2523b6853cf80ed4a83a6f
4
+ data.tar.gz: af57bc517594be455895f010a98459552793b0e2
5
5
  SHA512:
6
- metadata.gz: 9ffa2ac30980d2e94509a8dbfda57c957e46ac9235e0ba12d4a20abb226e1cc8006326da3c7c9fa877d380b1af05d75f23fa3e76e6f2abe54b48155221556d44
7
- data.tar.gz: 10c42352c1e25d7596dd2a975a189bbac5c862fb199084da4aad286d75190a20393a43620ca5574fce0693b6ca14e049169f1919b5716d50cbc6ae97ce82d15d
6
+ metadata.gz: b78364b508088e190513aed093ad6752c964196d47fc9dc05ddd95dfba61d8cae94525cc55b17f2a1dd15e73a9fc09cf1557bad774b103f112030ea8e50b20bb
7
+ data.tar.gz: 632babac3f00d28bb844265e0658aac31403916d3bbf6b1ba9a5eb57cb03db745c45418694f7bf3a46b8078a60fa95f656d9b41523a7134a4683b22167b392b9
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
- --format Fuubar
2
1
  --color
2
+ --format Fuubar
3
+ --format ParallelTests::RSpec::RuntimeLogger --out log/parallel_runtime_rspec.log
data/Gemfile CHANGED
@@ -24,4 +24,5 @@ group :development do
24
24
  gem "pry-stack_explorer"
25
25
  gem "simplecov"
26
26
  gem "fuubar"
27
+ gem "parallel_tests"
27
28
  end
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
@@ -78,6 +78,7 @@ module Mcrain
78
78
  end
79
79
  end
80
80
 
81
+ attr_accessor :before_setup
81
82
  end
82
83
 
83
84
  autoload :Base, 'mcrain/base'
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
- begin
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
@@ -139,6 +139,7 @@ module Mcrain
139
139
  end
140
140
 
141
141
  def setup
142
+ return false if Mcrain.before_setup && !Mcrain.before_setup.call(self)
142
143
  DockerMachine.setup_docker_options
143
144
  # setup_nodes(nodes[0, 1]) # primary node
144
145
  # setup_nodes(nodes[1..-1])
@@ -1,3 +1,3 @@
1
1
  module Mcrain
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
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.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-08-18 00:00:00.000000000 Z
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.