Skip to content

Commit

Permalink
Merge pull request #15 from iconara/small_styling_fixes
Browse files Browse the repository at this point in the history
Small styling fixes
  • Loading branch information
mindreframer committed May 16, 2016
2 parents 2ca14cc + 54368b6 commit 8bd8586
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -2,9 +2,9 @@ language: ruby
script: rspec
bundler_args: --without development
rvm:
- 1.9.3
- 2.0.0
- jruby-19mode
- 2.2.2
- jruby-9.0.0.0

## jruby-head has some issues on travis, here the error:
## The command "rvm install jruby-head --binary" failed and exited with 1 during setup.
Expand Down
2 changes: 1 addition & 1 deletion lib/etcd/heartbeat.rb
Expand Up @@ -41,4 +41,4 @@ def heartbeat_command
end

end
end
end
2 changes: 1 addition & 1 deletion lib/etcd/loggable.rb
Expand Up @@ -10,4 +10,4 @@ def reset_logger!(level=Logger::WARN)
log
end
end
end
end
16 changes: 8 additions & 8 deletions lib/etcd/node.rb
Expand Up @@ -9,10 +9,10 @@ class Node

class << self
def parse_node_data(attrs)
{
:name => attrs["name"],
:id => id = attrs["id"],
:peer_urls => attrs["peerURLs"],
{
:id => attrs["id"],
:name => attrs["name"],
:peer_urls => attrs["peerURLs"],
:client_urls => attrs["clientURLs"]
}
end
Expand All @@ -31,12 +31,12 @@ def check_required(opts)
raise ArgumentError, "Client URL is required!" unless opts[:client_urls] && opts[:client_urls].any?
raise ArgumentError, "Node ID is required!" unless opts[:id]
end

def update_status
begin
leader_data = request_data(:get, leader_uri)
@status = :running
@is_leader = (leader_data["id"] == @id)
@status = :running
@is_leader = (leader_data["id"] == @id)
rescue HTTPClient::TimeoutError, Errno::ECONNREFUSED => e
@status = :down
end
Expand All @@ -54,7 +54,7 @@ def name_with_status
print_status = @is_leader ? "leader" : status
"#{name} (#{print_status})"
end

def to_json
{ :name => name, :id => id, :client_urls => client_urls, :peer_urls => peer_urls }.to_json
end
Expand Down
2 changes: 1 addition & 1 deletion lib/etcd/version.rb
Expand Up @@ -2,4 +2,4 @@

module Etcd
VERSION = '1.0.0'.freeze
end
end
3 changes: 2 additions & 1 deletion sh/cluster
@@ -1 +1,2 @@
./spec/resources/etcd-cluster $1
#!/usr/bin/env bash
./spec/resources/etcd-cluster $1
6 changes: 3 additions & 3 deletions spec/etcd/node_spec.rb
Expand Up @@ -3,19 +3,19 @@

module Etcd
describe Node do

let :node_data do
[
{"id" => "14306b09b8d69fc4","name" => "node1","peerURLs"=> ["http://127.0.0.1:7001"],"clientURLs" => ["http://127.0.0.1:4001"]},
{"id" => "d2356cd527a56a4","name" => "node2","peerURLs" => ["http://127.0.0.1:7002"],"clientURLs" => ["http://127.0.0.1:4002"]}
]
end

def default_node(opts = {})
data = Etcd::Node.parse_node_data(node_data[0])
Etcd::Node.new(data.merge(opts))
end

describe '#initialize' do
it "works with all required parameters" do
default_node({}).should_not be_nil
Expand Down
8 changes: 4 additions & 4 deletions spec/integration/etcd_spec.rb
Expand Up @@ -24,7 +24,7 @@
ClusterController.start_cluster
sleep 2 # wait a little for the cluster to come up
end

after(:all) do
ClusterController.stop_cluster
end
Expand Down Expand Up @@ -65,10 +65,10 @@
client.update(key, 'qux', 'bar').should eq(true)
end

# FIXME: this test does not pass consistently. There seem to issues
# FIXME: this test does not pass consistently. There seem to issues
# with the leader re-election handling (causing Errno::ECONNREFUSED)
it "has heartbeat, that resets observed watches" do
client = Etcd::Client.test_client(:heartbeat_freq => 0.2)
client = Etcd::Client.test_client(:heartbeat_freq => 0.1)
puts client.cluster.nodes.map(&:inspect)
client.cluster.nodes.map(&:status).uniq.should eq([:running])
changes = Queue.new
Expand Down Expand Up @@ -96,7 +96,7 @@
a.join
changes.size.should eq(2)

# restore cluster
# restore cluster
ClusterController.stop_cluster
ClusterController.start_cluster
sleep 2
Expand Down
2 changes: 1 addition & 1 deletion spec/resources/cluster_controller.rb
Expand Up @@ -16,4 +16,4 @@ def self.start_cluster
def self.stop_cluster
`#{sh_path}/cluster stop`
end
end
end
6 changes: 3 additions & 3 deletions spec/resources/etcd-cluster
Expand Up @@ -37,7 +37,7 @@ class EtcdCluster
end
end
end

def logs
cmd = "tail -f tmp/etcd/node1.out tmp/etcd/node2.out tmp/etcd/node3.out"
exec(cmd)
Expand All @@ -58,8 +58,8 @@ class EtcdCluster

def start_node(num)
node_name = "node#{num}"
server_url = "http://127.0.0.1:#{SERVER_PORT_BASE + num}"
client_url = "http://127.0.0.1:#{CLIENT_PORT_BASE + num}"
server_url = "http://127.0.0.1:#{SERVER_PORT_BASE + num}"
client_url = "http://127.0.0.1:#{CLIENT_PORT_BASE + num}"
all_nodes = 1.upto(NODE_COUNT).map { |i| "node#{i}=http://127.0.0.1:#{SERVER_PORT_BASE + i}" }

cmd = %Q(#{bin_path} --debug \
Expand Down
2 changes: 1 addition & 1 deletion spec/support/client_helper.rb
Expand Up @@ -19,5 +19,5 @@ def healthy_cluster(uri = "http://127.0.0.1:4001")
nodes.map{|node| node.status = :running}
nodes.first.is_leader = true
cluster
end
end
end
2 changes: 1 addition & 1 deletion spec/support/cluster_helper.rb
Expand Up @@ -13,7 +13,7 @@ def status_data
]
}
end

# cluster config hashes below map member client URLs to the leader client URL

def healthy_cluster_config
Expand Down

0 comments on commit 8bd8586

Please sign in to comment.