Sha256: 910da8429078dfe0832b7a7614ee533f63b1bf5fa3bb5cfcc6032700975ca6be
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'uuid' module Etcd module FunctionalSpec module Helpers def start_etcd_servers @tmpdir = Dir.mktmpdir pid = spawn_etcd_server(@tmpdir+'/leader') @pids = Array(pid) puts "Etcd leader process id :#{pid}" leader = '127.0.0.1:7001' 4.times do |n| client_port = 4002 + n server_port = 7002 + n pid = spawn_etcd_server(@tmpdir+client_port.to_s, client_port, server_port, leader) @pids << pid end end def stop_etcd_servers @pids.each do |pid| Process.kill("HUP", pid) puts "Killed #{pid}" end FileUtils.remove_entry_secure @tmpdir end def spawn_etcd_server(dir, client_port=4001, server_port=7001, leader = nil) args = " -addr 127.0.0.1:#{client_port} -peer-addr 127.0.0.1:#{server_port} -data-dir #{dir} -name node_#{client_port}" command = if leader.nil? ETCD_BIN + args else ETCD_BIN + args + " -peers #{leader}" end puts command pid = spawn(command) Process.detach(pid) sleep 1 pid end def uuid @uuid ||= UUID.new end def random_key(n=1) key='' n.times do key << '/'+ uuid.generate end key end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
etcd-0.0.6 | spec/functional_spec_helpers.rb |