riak_test_server 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/ruby/riak_test_server.rb +17 -8
- data/ruby/riak_test_server/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cc589b4f686c3f38244df43e45f1f08ef96e231
|
4
|
+
data.tar.gz: 51c600a90c4c13e29e79a1bf9c9acd864e2d80ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1675cd7edcb1ec9f00e440641539b32dad914cf92cd307b6b514c8f2fc767ae854a53ba3c3f529109f531edbc41cee67812b1bc96eb2fd528f7cd71f85a1279
|
7
|
+
data.tar.gz: 08af4d885569903f31398ec7d58443787bec317eeda854726cfd59de1c11dd34899f2abf66469039b9e7d06bbb1ed0e6e950cc986109fe9ded07468fbc3f124d
|
data/README.md
CHANGED
@@ -52,3 +52,4 @@ You can override a bunch of defaults by passing options to `RiakTestServer.setup
|
|
52
52
|
* `:repository` - supplier of docker images [default: `"ntalbott/riak_test_server"`]
|
53
53
|
* `:tag` - docker image to use; `docker search ntalbott/riak_test_server` to see if other Riak versions are available [default: `"latest"`]
|
54
54
|
* `:docker_bin` - name of the docker binary [default: `"docker"`]
|
55
|
+
* `:force_restart` - will force the hard restart of any running container (slow) [efault: `false`]
|
data/ruby/riak_test_server.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require "expect"
|
2
|
+
require "timeout"
|
2
3
|
|
3
4
|
module RiakTestServer
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
4
7
|
def self.setup(options={})
|
5
8
|
@server.stop if @server
|
6
9
|
@server = Server.new(options)
|
@@ -18,6 +21,7 @@ module RiakTestServer
|
|
18
21
|
class Server
|
19
22
|
attr_reader :repository, :tag
|
20
23
|
def initialize(options)
|
24
|
+
@force_restart = (options[:force_restart] || false)
|
21
25
|
@container_host = (options[:container_host] || "docker")
|
22
26
|
@container_name = (options[:container_name] || "riak_test_server")
|
23
27
|
@http_port = (options[:http_port] || "8098")
|
@@ -29,7 +33,8 @@ module RiakTestServer
|
|
29
33
|
|
30
34
|
def start
|
31
35
|
if docker("ps -a") =~ /\b#{@container_name}\b/
|
32
|
-
|
36
|
+
return unless @force_restart
|
37
|
+
stop
|
33
38
|
docker "rm #{@container_name}"
|
34
39
|
end
|
35
40
|
|
@@ -41,17 +46,17 @@ module RiakTestServer
|
|
41
46
|
--publish=#{@http_port}:8098
|
42
47
|
--publish=#{@pb_port}:8087
|
43
48
|
#{@repository}:#{@tag}
|
44
|
-
).join(" ")
|
49
|
+
).join(" "), 5
|
45
50
|
end
|
46
51
|
|
47
52
|
def stop
|
48
53
|
@console_io.close if @console_io
|
49
|
-
docker "stop #{@container_name}"
|
54
|
+
docker "stop #{@container_name}", 15
|
50
55
|
end
|
51
56
|
|
52
57
|
def setup
|
53
|
-
unless docker("images") =~ /#{repository}\s+#{tag}/
|
54
|
-
docker "pull #{repository}:#{tag}"
|
58
|
+
unless docker("images", 5) =~ /#{repository}\s+#{tag}/
|
59
|
+
docker "pull #{repository}:#{tag}", 60
|
55
60
|
end
|
56
61
|
end
|
57
62
|
|
@@ -74,11 +79,15 @@ module RiakTestServer
|
|
74
79
|
|
75
80
|
private
|
76
81
|
|
77
|
-
def docker(command)
|
82
|
+
def docker(command, timeout=1)
|
78
83
|
full_command = "#{@docker_bin} #{command}"
|
79
|
-
|
80
|
-
|
84
|
+
Timeout.timeout(timeout) do
|
85
|
+
`#{full_command} 2>&1`.tap do |output|
|
86
|
+
raise "#{full_command} failed: #{output}" unless $?.exitstatus == 0
|
87
|
+
end
|
81
88
|
end
|
89
|
+
rescue Timeout::Error
|
90
|
+
raise RiakTestServer::Error, "Timed out running `#{full_command}` after #{timeout} seconds; is your Docker host running?"
|
82
91
|
end
|
83
92
|
|
84
93
|
PROMPT = /\(riak@[\w\.]+\)(\d+)>\s*/
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riak_test_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathaniel Talbott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '2'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '2'
|
83
83
|
description: Makes it easy to run tests against Riak and wipe all data between each
|
84
84
|
test (or whenever you want).
|
85
85
|
email:
|