-
Notifications
You must be signed in to change notification settings - Fork 1
/
edwig.rb
38 lines (31 loc) · 993 Bytes
/
edwig.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'fileutils'
$server = 'http://localhost:8081'
$adminToken = "6ceab96a-8d97-4f2a-8d69-32569a38fc64"
$token = "testtoken"
def start_edwig
unless File.directory?("tmp")
FileUtils.mkdir_p("tmp")
end
unless File.directory?("log")
FileUtils.mkdir_p("log")
end
system "EDWIG_ENV=test go run edwig.go -debug -pidfile=tmp/pid -testuuid -testclock=20170101-1200 api -listen=localhost:8081 >> log/edwig.log 2>&1 &"
time_limit = Time.now + 30
while
sleep 0.5
begin
response = RestClient::Request.execute(method: :get, url: "#{$server}/_status", timeout: 1, :headers => {:Authorization => 'Token token=6ceab96a-8d97-4f2a-8d69-32569a38fc64'})
break if response.code == 200 && JSON.parse(response.body)["status"] == "ok"
rescue Exception # => e
# puts e.inspect
end
raise "Timeout" if Time.now > time_limit
end
end
Before('~@database') do
start_edwig()
end
After do
pid = IO.read("tmp/pid")
Process.kill('KILL',pid.to_i)
end