riak_test_server 1.1.0 → 1.1.1
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 +28 -12
- data/ruby/riak_test_server/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26aee048f49421dff9f93e39d5037e705fb20992
|
4
|
+
data.tar.gz: a6822d14361536f8a50b8dd1c5a0d5cb1a493cda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f51252686c65c863fb5d5f2289e84aae57ce9a5f5e588290587af0d1d06a21910932919668082546ae3d240064cd6fa56da2356932ba95a16f82925ee4a59d2a
|
7
|
+
data.tar.gz: 4ffb03b6f2d3947d2f3849f58de24173282486b115d6d9b9a52629fc8ba9f6b6f64585dc16ca73a5ace2d02b31befd3731b0e1ef91f2fed9e5d25f629d893e9e
|
data/README.md
CHANGED
@@ -11,6 +11,7 @@ the Riak backend inbetween tests.
|
|
11
11
|
* [docker](https://docs.docker.com/installation/)
|
12
12
|
* A working docker host environment (I like [dvm](https://github.com/fnichol/dvm) on OS X)
|
13
13
|
* A hostname of `docker` mapped to the IP of your container host (192.168.42.43 for dvm)
|
14
|
+
* At least 1Gb available to the docker VM. The base Erlang runtime seems to be a bit of a memory hog. (`export DOCKER_MEMORY=1024` for dvm)
|
14
15
|
|
15
16
|
## Installation
|
16
17
|
|
data/ruby/riak_test_server.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "expect"
|
2
2
|
require "timeout"
|
3
|
+
require "open3"
|
4
|
+
require "json"
|
3
5
|
|
4
6
|
module RiakTestServer
|
5
7
|
class Error < StandardError; end
|
@@ -32,10 +34,16 @@ module RiakTestServer
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def start
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
details = JSON.parse(docker("inspect #{@container_name}", allowed_exits: [0, 1]))
|
38
|
+
if details.size > 0
|
39
|
+
detail = details.first
|
40
|
+
running = (detail["State"] && detail["State"]["Running"])
|
41
|
+
if(@force_restart || !running)
|
42
|
+
stop
|
43
|
+
docker "rm #{@container_name}"
|
44
|
+
else
|
45
|
+
return
|
46
|
+
end
|
39
47
|
end
|
40
48
|
|
41
49
|
docker %W(
|
@@ -46,17 +54,17 @@ module RiakTestServer
|
|
46
54
|
--publish=#{@http_port}:8098
|
47
55
|
--publish=#{@pb_port}:8087
|
48
56
|
#{@repository}:#{@tag}
|
49
|
-
).join(" "), 5
|
57
|
+
).join(" "), timeout: 5
|
50
58
|
end
|
51
59
|
|
52
60
|
def stop
|
53
61
|
@console_io.close if @console_io
|
54
|
-
docker "stop #{@container_name}", 15
|
62
|
+
docker "stop #{@container_name}", timeout: 15
|
55
63
|
end
|
56
64
|
|
57
65
|
def setup
|
58
|
-
unless docker("images", 5) =~ /#{repository}\s+#{tag}/
|
59
|
-
docker "pull #{repository}:#{tag}", 60
|
66
|
+
unless docker("images", timeout: 5) =~ /#{repository}\s+#{tag}/
|
67
|
+
docker "pull #{repository}:#{tag}", timeout: 60
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
@@ -79,12 +87,20 @@ module RiakTestServer
|
|
79
87
|
|
80
88
|
private
|
81
89
|
|
82
|
-
def docker(command,
|
90
|
+
def docker(command, options={})
|
83
91
|
full_command = "#{@docker_bin} #{command}"
|
92
|
+
timeout = (options[:timeout] || 1)
|
93
|
+
allowed_exits = (options[:allowed_exits] || [0])
|
84
94
|
Timeout.timeout(timeout) do
|
85
|
-
|
86
|
-
|
95
|
+
stdout, stderr, status = Open3.capture3(full_command)
|
96
|
+
unless(allowed_exits.include?(status.exitstatus))
|
97
|
+
raise [
|
98
|
+
"#{full_command} exited with unexpected status #{status.exitstatus} (expected: #{allowed_exits.inspect})",
|
99
|
+
"STDOUT: #{stdout}",
|
100
|
+
"STDERR: #{stderr}"
|
101
|
+
].join("\n")
|
87
102
|
end
|
103
|
+
stdout
|
88
104
|
end
|
89
105
|
rescue Timeout::Error
|
90
106
|
raise RiakTestServer::Error, "Timed out running `#{full_command}` after #{timeout} seconds; is your Docker host running?"
|
@@ -109,7 +125,7 @@ module RiakTestServer
|
|
109
125
|
@console_io = IO.popen([@docker_bin, "attach", @container_name], "r+", err: :out).tap{|io| io.sync = true}
|
110
126
|
@console_io.puts("ok.")
|
111
127
|
unless @console_io.expect(PROMPT, 10)
|
112
|
-
raise "Unable to get a prompt on the console"
|
128
|
+
raise "Unable to get a prompt on the console: @console_io.read"
|
113
129
|
end
|
114
130
|
end
|
115
131
|
|