cluster-discovery 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -2
- data/Rakefile +4 -4
- data/lib/cluster/discovery/consul.rb +44 -2
- data/spec/cassettes/Cluster_Discovery/_discover/can_discover_nodes/discovery_with_consul.yml +44 -3
- data/spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_with_tags.yml +3 -3
- data/spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_with_tags_and_health.yml +79 -0
- data/spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_without_tags.yml +3 -3
- data/spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_without_tags_and_health.yml +79 -0
- data/spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_with_tags.yml +3 -3
- data/spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_with_tags_and_health.yml +79 -0
- data/spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_without_tags.yml +3 -3
- data/spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_without_tags_and_health.yml +79 -0
- data/spec/lib/cluster/discovery/consul_spec.rb +50 -8
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bc378c4cea55580f914d99730999d212c649c0e
|
4
|
+
data.tar.gz: 2368efc51ec94b712f63fe64bd1a4cb242f01aa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8259e0e3c2ebc5ba75c46ba85b7f78d0036e211ae521e9e81534966014b32f690001d7b8e7acccffc8be00a1ba9e1e3e281d5ad7df3331c2a4ab18d590889ebd
|
7
|
+
data.tar.gz: 49503b54d04f0319b9a331c71a96a6991b0cc46252de9bb58c052e89e251c49bfe27166a1fbff12a94abc349979fd9c31bc3386adf037c89e7ca7286d6896ddf
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -58,7 +58,9 @@ instances.map(&:instance_id)
|
|
58
58
|
|
59
59
|
### Consul
|
60
60
|
|
61
|
-
To discover cluster instances using Consul use something like the following example. The keys `consul_url` and `consul_service` are required, `leader` and `
|
61
|
+
To discover cluster instances using Consul use something like the following example. The keys `consul_url` and `consul_service` are required, `leader`, `tags`, and `health` are optional.
|
62
|
+
|
63
|
+
By default this will only return nodes passing all health checks. To change this behavior set `healthy` to `false`.
|
62
64
|
|
63
65
|
```ruby
|
64
66
|
instances = Cluster::Discovery.discover(
|
@@ -66,7 +68,8 @@ instances = Cluster::Discovery.discover(
|
|
66
68
|
consul_url: 'http://my.consul.cluster:8500',
|
67
69
|
consul_service: 'redis',
|
68
70
|
leader: true,
|
69
|
-
tags: 'master'
|
71
|
+
tags: 'master',
|
72
|
+
health: true)
|
70
73
|
instances.map(&:Address)
|
71
74
|
```
|
72
75
|
|
data/Rakefile
CHANGED
@@ -41,11 +41,11 @@ end
|
|
41
41
|
|
42
42
|
task :refresh_fixtures do
|
43
43
|
register_service(id: '1', ip: '192.168.10.10', tag: 'master', status: 'passing')
|
44
|
-
register_service(id: '2', ip: '192.168.10.11', tag: 'slave', status: '
|
45
|
-
register_service(id: '3', ip: '192.168.10.12', tag: 'master', status: '
|
44
|
+
register_service(id: '2', ip: '192.168.10.11', tag: 'slave', status: 'warning')
|
45
|
+
register_service(id: '3', ip: '192.168.10.12', tag: 'master', status: 'critical')
|
46
46
|
register_service(id: '4', ip: '192.168.10.13', tag: 'slave', status: 'passing')
|
47
|
-
register_service(id: '5', ip: '192.168.10.14', tag: 'master', status: '
|
48
|
-
register_service(id: '6', ip: '192.168.10.15', tag: 'slave', status: '
|
47
|
+
register_service(id: '5', ip: '192.168.10.14', tag: 'master', status: 'warning')
|
48
|
+
register_service(id: '6', ip: '192.168.10.15', tag: 'slave', status: 'critical')
|
49
49
|
end
|
50
50
|
|
51
51
|
task default: [:spec, :rubocop]
|
@@ -16,14 +16,55 @@ module Cluster
|
|
16
16
|
# @param [Boolean] leader: (false) Fetch :all or or :first(the leader)
|
17
17
|
# @param [Array] tags: ([]) List of tags to limit discovery by
|
18
18
|
# @return [Struct] Object representing the Node in the service
|
19
|
-
def discover(consul_service:, leader: false, tags: [])
|
19
|
+
def discover(consul_service:, leader: false, tags: [], healthy: true)
|
20
20
|
scope, options = build_extra_opts(leader: leader, tags: tags)
|
21
21
|
nodes = Diplomat::Service.get(
|
22
22
|
consul_service,
|
23
23
|
scope,
|
24
24
|
options
|
25
25
|
)
|
26
|
-
[nodes]
|
26
|
+
nodes = [nodes]
|
27
|
+
nodes.flatten!
|
28
|
+
|
29
|
+
nodes = discover_health_nodes(nodes, consul_service) if healthy
|
30
|
+
nodes
|
31
|
+
end
|
32
|
+
|
33
|
+
def discover_health_nodes(nodes, consul_service)
|
34
|
+
nodes = filtered_healthy_nodes(nodes.map(&:Address), consul_service)
|
35
|
+
nodes = nodes_passing_checks(nodes)
|
36
|
+
service_response(nodes)
|
37
|
+
end
|
38
|
+
|
39
|
+
def filtered_healthy_nodes(node_list, consul_service)
|
40
|
+
Diplomat::Health.service(consul_service).delete_if do |service|
|
41
|
+
!node_list.include?(service['Node']['Address'])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def nodes_passing_checks(nodes)
|
46
|
+
nodes.delete_if do |node|
|
47
|
+
node['Checks'].any? { |check| check['Status'] != 'passing' }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def service_response(nodes) # rubocop:disable Metrics/MethodLength
|
52
|
+
nodes.map do |node|
|
53
|
+
n = node['Node']
|
54
|
+
s = node['Service']
|
55
|
+
OpenStruct.new(
|
56
|
+
Node: n['Node'],
|
57
|
+
Address: n['Address'],
|
58
|
+
ServiceID: s['ID'],
|
59
|
+
ServiceName: s['Service'],
|
60
|
+
ServiceTags: s['Tags'],
|
61
|
+
ServiceAddress: s['Address'],
|
62
|
+
ServicePort: s['Port'],
|
63
|
+
Checks: node['Checks'],
|
64
|
+
_Node: node['Node'],
|
65
|
+
_Service: node['Service']
|
66
|
+
)
|
67
|
+
end
|
27
68
|
end
|
28
69
|
|
29
70
|
# Build args for Diplomat::Service.get
|
@@ -44,3 +85,4 @@ module Cluster
|
|
44
85
|
end
|
45
86
|
|
46
87
|
require 'diplomat'
|
88
|
+
require 'ostruct'
|
data/spec/cassettes/Cluster_Discovery/_discover/can_discover_nodes/discovery_with_consul.yml
CHANGED
@@ -21,18 +21,59 @@ http_interactions:
|
|
21
21
|
Content-Type:
|
22
22
|
- application/json
|
23
23
|
X-Consul-Index:
|
24
|
-
- '
|
24
|
+
- '278'
|
25
25
|
X-Consul-Knownleader:
|
26
26
|
- 'true'
|
27
27
|
X-Consul-Lastcontact:
|
28
28
|
- '0'
|
29
29
|
Date:
|
30
|
-
- Tue, 19 Jan 2016
|
30
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
31
31
|
Content-Length:
|
32
32
|
- '499'
|
33
33
|
body:
|
34
34
|
encoding: UTF-8
|
35
35
|
string: '[{"Node":"foobar1","Address":"192.168.10.10","ServiceID":"redis1","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar5","Address":"192.168.10.14","ServiceID":"redis5","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar3","Address":"192.168.10.12","ServiceID":"redis3","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000}]'
|
36
36
|
http_version:
|
37
|
-
recorded_at: Tue, 19 Jan 2016
|
37
|
+
recorded_at: Tue, 19 Jan 2016 18:54:27 GMT
|
38
|
+
- request:
|
39
|
+
method: get
|
40
|
+
uri: http://172.28.128.104:8500/v1/health/service/redis
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: ''
|
44
|
+
headers:
|
45
|
+
User-Agent:
|
46
|
+
- Faraday v0.9.2
|
47
|
+
Accept-Encoding:
|
48
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
49
|
+
Accept:
|
50
|
+
- "*/*"
|
51
|
+
response:
|
52
|
+
status:
|
53
|
+
code: 200
|
54
|
+
message: OK
|
55
|
+
headers:
|
56
|
+
Content-Type:
|
57
|
+
- application/json
|
58
|
+
X-Consul-Index:
|
59
|
+
- '278'
|
60
|
+
X-Consul-Knownleader:
|
61
|
+
- 'true'
|
62
|
+
X-Consul-Lastcontact:
|
63
|
+
- '0'
|
64
|
+
Date:
|
65
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
66
|
+
Transfer-Encoding:
|
67
|
+
- chunked
|
68
|
+
body:
|
69
|
+
encoding: UTF-8
|
70
|
+
string: '[{"Node":{"Node":"foobar1","Address":"192.168.10.10"},"Service":{"ID":"redis1","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar1","CheckID":"service:redis1","Name":"Redis
|
71
|
+
health check","Status":"passing","Notes":"Script based health check","Output":"","ServiceID":"redis1","ServiceName":"redis"}]},{"Node":{"Node":"foobar2","Address":"192.168.10.11"},"Service":{"ID":"redis2","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar2","CheckID":"service:redis1","Name":"Redis
|
72
|
+
health check","Status":"warning","Notes":"Script based health check","Output":"","ServiceID":"redis2","ServiceName":"redis"}]},{"Node":{"Node":"foobar3","Address":"192.168.10.12"},"Service":{"ID":"redis3","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar3","CheckID":"service:redis1","Name":"Redis
|
73
|
+
health check","Status":"critical","Notes":"Script based health check","Output":"","ServiceID":"redis3","ServiceName":"redis"}]},{"Node":{"Node":"foobar4","Address":"192.168.10.13"},"Service":{"ID":"redis4","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar4","CheckID":"service:redis1","Name":"Redis
|
74
|
+
health check","Status":"passing","Notes":"Script based health check","Output":"","ServiceID":"redis4","ServiceName":"redis"}]},{"Node":{"Node":"foobar5","Address":"192.168.10.14"},"Service":{"ID":"redis5","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar5","CheckID":"service:redis1","Name":"Redis
|
75
|
+
health check","Status":"warning","Notes":"Script based health check","Output":"","ServiceID":"redis5","ServiceName":"redis"}]},{"Node":{"Node":"foobar6","Address":"192.168.10.15"},"Service":{"ID":"redis6","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar6","CheckID":"service:redis1","Name":"Redis
|
76
|
+
health check","Status":"critical","Notes":"Script based health check","Output":"","ServiceID":"redis6","ServiceName":"redis"}]}]'
|
77
|
+
http_version:
|
78
|
+
recorded_at: Tue, 19 Jan 2016 18:54:27 GMT
|
38
79
|
recorded_with: VCR 3.0.1
|
@@ -21,18 +21,18 @@ http_interactions:
|
|
21
21
|
Content-Type:
|
22
22
|
- application/json
|
23
23
|
X-Consul-Index:
|
24
|
-
- '
|
24
|
+
- '278'
|
25
25
|
X-Consul-Knownleader:
|
26
26
|
- 'true'
|
27
27
|
X-Consul-Lastcontact:
|
28
28
|
- '0'
|
29
29
|
Date:
|
30
|
-
- Tue, 19 Jan 2016
|
30
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
31
31
|
Content-Length:
|
32
32
|
- '499'
|
33
33
|
body:
|
34
34
|
encoding: UTF-8
|
35
35
|
string: '[{"Node":"foobar1","Address":"192.168.10.10","ServiceID":"redis1","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar5","Address":"192.168.10.14","ServiceID":"redis5","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar3","Address":"192.168.10.12","ServiceID":"redis3","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000}]'
|
36
36
|
http_version:
|
37
|
-
recorded_at: Tue, 19 Jan 2016
|
37
|
+
recorded_at: Tue, 19 Jan 2016 18:54:26 GMT
|
38
38
|
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,79 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://172.28.128.104:8500/v1/catalog/service/redis?tag=master
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.2
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json
|
23
|
+
X-Consul-Index:
|
24
|
+
- '278'
|
25
|
+
X-Consul-Knownleader:
|
26
|
+
- 'true'
|
27
|
+
X-Consul-Lastcontact:
|
28
|
+
- '0'
|
29
|
+
Date:
|
30
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
31
|
+
Content-Length:
|
32
|
+
- '499'
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: '[{"Node":"foobar1","Address":"192.168.10.10","ServiceID":"redis1","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar5","Address":"192.168.10.14","ServiceID":"redis5","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar3","Address":"192.168.10.12","ServiceID":"redis3","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000}]'
|
36
|
+
http_version:
|
37
|
+
recorded_at: Tue, 19 Jan 2016 18:54:27 GMT
|
38
|
+
- request:
|
39
|
+
method: get
|
40
|
+
uri: http://172.28.128.104:8500/v1/health/service/redis
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: ''
|
44
|
+
headers:
|
45
|
+
User-Agent:
|
46
|
+
- Faraday v0.9.2
|
47
|
+
Accept-Encoding:
|
48
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
49
|
+
Accept:
|
50
|
+
- "*/*"
|
51
|
+
response:
|
52
|
+
status:
|
53
|
+
code: 200
|
54
|
+
message: OK
|
55
|
+
headers:
|
56
|
+
Content-Type:
|
57
|
+
- application/json
|
58
|
+
X-Consul-Index:
|
59
|
+
- '278'
|
60
|
+
X-Consul-Knownleader:
|
61
|
+
- 'true'
|
62
|
+
X-Consul-Lastcontact:
|
63
|
+
- '0'
|
64
|
+
Date:
|
65
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
66
|
+
Transfer-Encoding:
|
67
|
+
- chunked
|
68
|
+
body:
|
69
|
+
encoding: UTF-8
|
70
|
+
string: '[{"Node":{"Node":"foobar1","Address":"192.168.10.10"},"Service":{"ID":"redis1","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar1","CheckID":"service:redis1","Name":"Redis
|
71
|
+
health check","Status":"passing","Notes":"Script based health check","Output":"","ServiceID":"redis1","ServiceName":"redis"}]},{"Node":{"Node":"foobar2","Address":"192.168.10.11"},"Service":{"ID":"redis2","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar2","CheckID":"service:redis1","Name":"Redis
|
72
|
+
health check","Status":"warning","Notes":"Script based health check","Output":"","ServiceID":"redis2","ServiceName":"redis"}]},{"Node":{"Node":"foobar3","Address":"192.168.10.12"},"Service":{"ID":"redis3","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar3","CheckID":"service:redis1","Name":"Redis
|
73
|
+
health check","Status":"critical","Notes":"Script based health check","Output":"","ServiceID":"redis3","ServiceName":"redis"}]},{"Node":{"Node":"foobar4","Address":"192.168.10.13"},"Service":{"ID":"redis4","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar4","CheckID":"service:redis1","Name":"Redis
|
74
|
+
health check","Status":"passing","Notes":"Script based health check","Output":"","ServiceID":"redis4","ServiceName":"redis"}]},{"Node":{"Node":"foobar5","Address":"192.168.10.14"},"Service":{"ID":"redis5","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar5","CheckID":"service:redis1","Name":"Redis
|
75
|
+
health check","Status":"warning","Notes":"Script based health check","Output":"","ServiceID":"redis5","ServiceName":"redis"}]},{"Node":{"Node":"foobar6","Address":"192.168.10.15"},"Service":{"ID":"redis6","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar6","CheckID":"service:redis1","Name":"Redis
|
76
|
+
health check","Status":"critical","Notes":"Script based health check","Output":"","ServiceID":"redis6","ServiceName":"redis"}]}]'
|
77
|
+
http_version:
|
78
|
+
recorded_at: Tue, 19 Jan 2016 18:54:27 GMT
|
79
|
+
recorded_with: VCR 3.0.1
|
@@ -21,18 +21,18 @@ http_interactions:
|
|
21
21
|
Content-Type:
|
22
22
|
- application/json
|
23
23
|
X-Consul-Index:
|
24
|
-
- '
|
24
|
+
- '278'
|
25
25
|
X-Consul-Knownleader:
|
26
26
|
- 'true'
|
27
27
|
X-Consul-Lastcontact:
|
28
28
|
- '0'
|
29
29
|
Date:
|
30
|
-
- Tue, 19 Jan 2016
|
30
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
31
31
|
Content-Length:
|
32
32
|
- '994'
|
33
33
|
body:
|
34
34
|
encoding: UTF-8
|
35
35
|
string: '[{"Node":"foobar1","Address":"192.168.10.10","ServiceID":"redis1","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar2","Address":"192.168.10.11","ServiceID":"redis2","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar3","Address":"192.168.10.12","ServiceID":"redis3","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar4","Address":"192.168.10.13","ServiceID":"redis4","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar5","Address":"192.168.10.14","ServiceID":"redis5","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar6","Address":"192.168.10.15","ServiceID":"redis6","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000}]'
|
36
36
|
http_version:
|
37
|
-
recorded_at: Tue, 19 Jan 2016
|
37
|
+
recorded_at: Tue, 19 Jan 2016 18:54:26 GMT
|
38
38
|
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,79 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://172.28.128.104:8500/v1/catalog/service/redis
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.2
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json
|
23
|
+
X-Consul-Index:
|
24
|
+
- '278'
|
25
|
+
X-Consul-Knownleader:
|
26
|
+
- 'true'
|
27
|
+
X-Consul-Lastcontact:
|
28
|
+
- '0'
|
29
|
+
Date:
|
30
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
31
|
+
Content-Length:
|
32
|
+
- '994'
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: '[{"Node":"foobar1","Address":"192.168.10.10","ServiceID":"redis1","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar2","Address":"192.168.10.11","ServiceID":"redis2","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar3","Address":"192.168.10.12","ServiceID":"redis3","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar4","Address":"192.168.10.13","ServiceID":"redis4","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar5","Address":"192.168.10.14","ServiceID":"redis5","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar6","Address":"192.168.10.15","ServiceID":"redis6","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000}]'
|
36
|
+
http_version:
|
37
|
+
recorded_at: Tue, 19 Jan 2016 18:54:26 GMT
|
38
|
+
- request:
|
39
|
+
method: get
|
40
|
+
uri: http://172.28.128.104:8500/v1/health/service/redis
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: ''
|
44
|
+
headers:
|
45
|
+
User-Agent:
|
46
|
+
- Faraday v0.9.2
|
47
|
+
Accept-Encoding:
|
48
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
49
|
+
Accept:
|
50
|
+
- "*/*"
|
51
|
+
response:
|
52
|
+
status:
|
53
|
+
code: 200
|
54
|
+
message: OK
|
55
|
+
headers:
|
56
|
+
Content-Type:
|
57
|
+
- application/json
|
58
|
+
X-Consul-Index:
|
59
|
+
- '278'
|
60
|
+
X-Consul-Knownleader:
|
61
|
+
- 'true'
|
62
|
+
X-Consul-Lastcontact:
|
63
|
+
- '0'
|
64
|
+
Date:
|
65
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
66
|
+
Transfer-Encoding:
|
67
|
+
- chunked
|
68
|
+
body:
|
69
|
+
encoding: UTF-8
|
70
|
+
string: '[{"Node":{"Node":"foobar1","Address":"192.168.10.10"},"Service":{"ID":"redis1","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar1","CheckID":"service:redis1","Name":"Redis
|
71
|
+
health check","Status":"passing","Notes":"Script based health check","Output":"","ServiceID":"redis1","ServiceName":"redis"}]},{"Node":{"Node":"foobar2","Address":"192.168.10.11"},"Service":{"ID":"redis2","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar2","CheckID":"service:redis1","Name":"Redis
|
72
|
+
health check","Status":"warning","Notes":"Script based health check","Output":"","ServiceID":"redis2","ServiceName":"redis"}]},{"Node":{"Node":"foobar3","Address":"192.168.10.12"},"Service":{"ID":"redis3","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar3","CheckID":"service:redis1","Name":"Redis
|
73
|
+
health check","Status":"critical","Notes":"Script based health check","Output":"","ServiceID":"redis3","ServiceName":"redis"}]},{"Node":{"Node":"foobar4","Address":"192.168.10.13"},"Service":{"ID":"redis4","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar4","CheckID":"service:redis1","Name":"Redis
|
74
|
+
health check","Status":"passing","Notes":"Script based health check","Output":"","ServiceID":"redis4","ServiceName":"redis"}]},{"Node":{"Node":"foobar5","Address":"192.168.10.14"},"Service":{"ID":"redis5","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar5","CheckID":"service:redis1","Name":"Redis
|
75
|
+
health check","Status":"warning","Notes":"Script based health check","Output":"","ServiceID":"redis5","ServiceName":"redis"}]},{"Node":{"Node":"foobar6","Address":"192.168.10.15"},"Service":{"ID":"redis6","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar6","CheckID":"service:redis1","Name":"Redis
|
76
|
+
health check","Status":"critical","Notes":"Script based health check","Output":"","ServiceID":"redis6","ServiceName":"redis"}]}]'
|
77
|
+
http_version:
|
78
|
+
recorded_at: Tue, 19 Jan 2016 18:54:26 GMT
|
79
|
+
recorded_with: VCR 3.0.1
|
@@ -21,18 +21,18 @@ http_interactions:
|
|
21
21
|
Content-Type:
|
22
22
|
- application/json
|
23
23
|
X-Consul-Index:
|
24
|
-
- '
|
24
|
+
- '278'
|
25
25
|
X-Consul-Knownleader:
|
26
26
|
- 'true'
|
27
27
|
X-Consul-Lastcontact:
|
28
28
|
- '0'
|
29
29
|
Date:
|
30
|
-
- Tue, 19 Jan 2016
|
30
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
31
31
|
Content-Length:
|
32
32
|
- '499'
|
33
33
|
body:
|
34
34
|
encoding: UTF-8
|
35
35
|
string: '[{"Node":"foobar1","Address":"192.168.10.10","ServiceID":"redis1","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar5","Address":"192.168.10.14","ServiceID":"redis5","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar3","Address":"192.168.10.12","ServiceID":"redis3","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000}]'
|
36
36
|
http_version:
|
37
|
-
recorded_at: Tue, 19 Jan 2016
|
37
|
+
recorded_at: Tue, 19 Jan 2016 18:54:26 GMT
|
38
38
|
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,79 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://172.28.128.104:8500/v1/catalog/service/redis?tag=master
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.2
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json
|
23
|
+
X-Consul-Index:
|
24
|
+
- '278'
|
25
|
+
X-Consul-Knownleader:
|
26
|
+
- 'true'
|
27
|
+
X-Consul-Lastcontact:
|
28
|
+
- '0'
|
29
|
+
Date:
|
30
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
31
|
+
Content-Length:
|
32
|
+
- '499'
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: '[{"Node":"foobar1","Address":"192.168.10.10","ServiceID":"redis1","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar5","Address":"192.168.10.14","ServiceID":"redis5","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar3","Address":"192.168.10.12","ServiceID":"redis3","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000}]'
|
36
|
+
http_version:
|
37
|
+
recorded_at: Tue, 19 Jan 2016 18:54:26 GMT
|
38
|
+
- request:
|
39
|
+
method: get
|
40
|
+
uri: http://172.28.128.104:8500/v1/health/service/redis
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: ''
|
44
|
+
headers:
|
45
|
+
User-Agent:
|
46
|
+
- Faraday v0.9.2
|
47
|
+
Accept-Encoding:
|
48
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
49
|
+
Accept:
|
50
|
+
- "*/*"
|
51
|
+
response:
|
52
|
+
status:
|
53
|
+
code: 200
|
54
|
+
message: OK
|
55
|
+
headers:
|
56
|
+
Content-Type:
|
57
|
+
- application/json
|
58
|
+
X-Consul-Index:
|
59
|
+
- '278'
|
60
|
+
X-Consul-Knownleader:
|
61
|
+
- 'true'
|
62
|
+
X-Consul-Lastcontact:
|
63
|
+
- '0'
|
64
|
+
Date:
|
65
|
+
- Tue, 19 Jan 2016 18:54:27 GMT
|
66
|
+
Transfer-Encoding:
|
67
|
+
- chunked
|
68
|
+
body:
|
69
|
+
encoding: UTF-8
|
70
|
+
string: '[{"Node":{"Node":"foobar1","Address":"192.168.10.10"},"Service":{"ID":"redis1","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar1","CheckID":"service:redis1","Name":"Redis
|
71
|
+
health check","Status":"passing","Notes":"Script based health check","Output":"","ServiceID":"redis1","ServiceName":"redis"}]},{"Node":{"Node":"foobar2","Address":"192.168.10.11"},"Service":{"ID":"redis2","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar2","CheckID":"service:redis1","Name":"Redis
|
72
|
+
health check","Status":"warning","Notes":"Script based health check","Output":"","ServiceID":"redis2","ServiceName":"redis"}]},{"Node":{"Node":"foobar3","Address":"192.168.10.12"},"Service":{"ID":"redis3","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar3","CheckID":"service:redis1","Name":"Redis
|
73
|
+
health check","Status":"critical","Notes":"Script based health check","Output":"","ServiceID":"redis3","ServiceName":"redis"}]},{"Node":{"Node":"foobar4","Address":"192.168.10.13"},"Service":{"ID":"redis4","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar4","CheckID":"service:redis1","Name":"Redis
|
74
|
+
health check","Status":"passing","Notes":"Script based health check","Output":"","ServiceID":"redis4","ServiceName":"redis"}]},{"Node":{"Node":"foobar5","Address":"192.168.10.14"},"Service":{"ID":"redis5","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar5","CheckID":"service:redis1","Name":"Redis
|
75
|
+
health check","Status":"warning","Notes":"Script based health check","Output":"","ServiceID":"redis5","ServiceName":"redis"}]},{"Node":{"Node":"foobar6","Address":"192.168.10.15"},"Service":{"ID":"redis6","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar6","CheckID":"service:redis1","Name":"Redis
|
76
|
+
health check","Status":"critical","Notes":"Script based health check","Output":"","ServiceID":"redis6","ServiceName":"redis"}]}]'
|
77
|
+
http_version:
|
78
|
+
recorded_at: Tue, 19 Jan 2016 18:54:26 GMT
|
79
|
+
recorded_with: VCR 3.0.1
|
@@ -21,18 +21,18 @@ http_interactions:
|
|
21
21
|
Content-Type:
|
22
22
|
- application/json
|
23
23
|
X-Consul-Index:
|
24
|
-
- '
|
24
|
+
- '278'
|
25
25
|
X-Consul-Knownleader:
|
26
26
|
- 'true'
|
27
27
|
X-Consul-Lastcontact:
|
28
28
|
- '0'
|
29
29
|
Date:
|
30
|
-
- Tue, 19 Jan 2016
|
30
|
+
- Tue, 19 Jan 2016 18:54:26 GMT
|
31
31
|
Content-Length:
|
32
32
|
- '994'
|
33
33
|
body:
|
34
34
|
encoding: UTF-8
|
35
35
|
string: '[{"Node":"foobar1","Address":"192.168.10.10","ServiceID":"redis1","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar2","Address":"192.168.10.11","ServiceID":"redis2","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar3","Address":"192.168.10.12","ServiceID":"redis3","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar4","Address":"192.168.10.13","ServiceID":"redis4","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar5","Address":"192.168.10.14","ServiceID":"redis5","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar6","Address":"192.168.10.15","ServiceID":"redis6","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000}]'
|
36
36
|
http_version:
|
37
|
-
recorded_at: Tue, 19 Jan 2016
|
37
|
+
recorded_at: Tue, 19 Jan 2016 18:54:26 GMT
|
38
38
|
recorded_with: VCR 3.0.1
|
@@ -0,0 +1,79 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://172.28.128.104:8500/v1/catalog/service/redis
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.2
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json
|
23
|
+
X-Consul-Index:
|
24
|
+
- '278'
|
25
|
+
X-Consul-Knownleader:
|
26
|
+
- 'true'
|
27
|
+
X-Consul-Lastcontact:
|
28
|
+
- '0'
|
29
|
+
Date:
|
30
|
+
- Tue, 19 Jan 2016 18:55:39 GMT
|
31
|
+
Content-Length:
|
32
|
+
- '994'
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: '[{"Node":"foobar1","Address":"192.168.10.10","ServiceID":"redis1","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar2","Address":"192.168.10.11","ServiceID":"redis2","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar3","Address":"192.168.10.12","ServiceID":"redis3","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar4","Address":"192.168.10.13","ServiceID":"redis4","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar5","Address":"192.168.10.14","ServiceID":"redis5","ServiceName":"redis","ServiceTags":["master","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000},{"Node":"foobar6","Address":"192.168.10.15","ServiceID":"redis6","ServiceName":"redis","ServiceTags":["slave","v1"],"ServiceAddress":"127.0.0.1","ServicePort":8000}]'
|
36
|
+
http_version:
|
37
|
+
recorded_at: Tue, 19 Jan 2016 18:55:39 GMT
|
38
|
+
- request:
|
39
|
+
method: get
|
40
|
+
uri: http://172.28.128.104:8500/v1/health/service/redis
|
41
|
+
body:
|
42
|
+
encoding: US-ASCII
|
43
|
+
string: ''
|
44
|
+
headers:
|
45
|
+
User-Agent:
|
46
|
+
- Faraday v0.9.2
|
47
|
+
Accept-Encoding:
|
48
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
49
|
+
Accept:
|
50
|
+
- "*/*"
|
51
|
+
response:
|
52
|
+
status:
|
53
|
+
code: 200
|
54
|
+
message: OK
|
55
|
+
headers:
|
56
|
+
Content-Type:
|
57
|
+
- application/json
|
58
|
+
X-Consul-Index:
|
59
|
+
- '278'
|
60
|
+
X-Consul-Knownleader:
|
61
|
+
- 'true'
|
62
|
+
X-Consul-Lastcontact:
|
63
|
+
- '0'
|
64
|
+
Date:
|
65
|
+
- Tue, 19 Jan 2016 18:55:39 GMT
|
66
|
+
Transfer-Encoding:
|
67
|
+
- chunked
|
68
|
+
body:
|
69
|
+
encoding: UTF-8
|
70
|
+
string: '[{"Node":{"Node":"foobar1","Address":"192.168.10.10"},"Service":{"ID":"redis1","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar1","CheckID":"service:redis1","Name":"Redis
|
71
|
+
health check","Status":"passing","Notes":"Script based health check","Output":"","ServiceID":"redis1","ServiceName":"redis"}]},{"Node":{"Node":"foobar2","Address":"192.168.10.11"},"Service":{"ID":"redis2","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar2","CheckID":"service:redis1","Name":"Redis
|
72
|
+
health check","Status":"warning","Notes":"Script based health check","Output":"","ServiceID":"redis2","ServiceName":"redis"}]},{"Node":{"Node":"foobar3","Address":"192.168.10.12"},"Service":{"ID":"redis3","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar3","CheckID":"service:redis1","Name":"Redis
|
73
|
+
health check","Status":"critical","Notes":"Script based health check","Output":"","ServiceID":"redis3","ServiceName":"redis"}]},{"Node":{"Node":"foobar4","Address":"192.168.10.13"},"Service":{"ID":"redis4","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar4","CheckID":"service:redis1","Name":"Redis
|
74
|
+
health check","Status":"passing","Notes":"Script based health check","Output":"","ServiceID":"redis4","ServiceName":"redis"}]},{"Node":{"Node":"foobar5","Address":"192.168.10.14"},"Service":{"ID":"redis5","Service":"redis","Tags":["master","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar5","CheckID":"service:redis1","Name":"Redis
|
75
|
+
health check","Status":"warning","Notes":"Script based health check","Output":"","ServiceID":"redis5","ServiceName":"redis"}]},{"Node":{"Node":"foobar6","Address":"192.168.10.15"},"Service":{"ID":"redis6","Service":"redis","Tags":["slave","v1"],"Address":"127.0.0.1","Port":8000},"Checks":[{"Node":"foobar6","CheckID":"service:redis1","Name":"Redis
|
76
|
+
health check","Status":"critical","Notes":"Script based health check","Output":"","ServiceID":"redis6","ServiceName":"redis"}]}]'
|
77
|
+
http_version:
|
78
|
+
recorded_at: Tue, 19 Jan 2016 18:55:39 GMT
|
79
|
+
recorded_with: VCR 3.0.1
|
@@ -77,42 +77,84 @@ describe 'Cluster::Discovery::Consul' do
|
|
77
77
|
obj.map(&:Address)
|
78
78
|
end
|
79
79
|
|
80
|
-
let(:
|
80
|
+
let(:consul_notags_leader_health) do
|
81
81
|
map_resp(@consul.discover(consul_service: 'redis', leader: true))
|
82
82
|
end
|
83
83
|
|
84
|
-
let(:
|
84
|
+
let(:consul_notags_noleader_health) do
|
85
85
|
map_resp(@consul.discover(consul_service: 'redis'))
|
86
86
|
end
|
87
87
|
|
88
|
-
let(:
|
88
|
+
let(:consul_tags_leader_health) do
|
89
89
|
map_resp(@consul.discover(
|
90
90
|
consul_service: 'redis',
|
91
91
|
leader: true,
|
92
92
|
tags: 'master'))
|
93
93
|
end
|
94
94
|
|
95
|
-
let(:
|
95
|
+
let(:consul_tags_noleader_health) do
|
96
96
|
map_resp(@consul.discover(consul_service: 'redis', tags: 'master'))
|
97
97
|
end
|
98
98
|
|
99
|
+
let(:consul_notags_leader_nohealth) do
|
100
|
+
map_resp(@consul.discover(
|
101
|
+
consul_service: 'redis',
|
102
|
+
leader: true,
|
103
|
+
healthy: false))
|
104
|
+
end
|
105
|
+
|
106
|
+
let(:consul_notags_noleader_nohealth) do
|
107
|
+
map_resp(@consul.discover(consul_service: 'redis', healthy: false))
|
108
|
+
end
|
109
|
+
|
110
|
+
let(:consul_tags_leader_nohealth) do
|
111
|
+
map_resp(@consul.discover(
|
112
|
+
consul_service: 'redis',
|
113
|
+
leader: true,
|
114
|
+
tags: 'master',
|
115
|
+
healthy: false))
|
116
|
+
end
|
117
|
+
|
118
|
+
let(:consul_tags_noleader_nohealth) do
|
119
|
+
map_resp(@consul.discover(
|
120
|
+
consul_service: 'redis',
|
121
|
+
tags: 'master',
|
122
|
+
healthy: false))
|
123
|
+
end
|
124
|
+
|
99
125
|
context 'can discover leader node' do
|
100
126
|
it 'can discover nodes without tags' do
|
101
|
-
expect(
|
127
|
+
expect(consul_notags_leader_nohealth.first).to eq('192.168.10.10')
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'can discover nodes without tags and health' do
|
131
|
+
expect(consul_notags_leader_health.first).to eq('192.168.10.10')
|
102
132
|
end
|
103
133
|
|
104
134
|
it 'can discover nodes with tags' do
|
105
|
-
expect(
|
135
|
+
expect(consul_tags_leader_nohealth.first).to eq('192.168.10.10')
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'can discover nodes with tags and health' do
|
139
|
+
expect(consul_tags_leader_health.first).to eq('192.168.10.10')
|
106
140
|
end
|
107
141
|
end
|
108
142
|
|
109
143
|
context 'can discover all nodes' do
|
110
144
|
it 'can discover nodes without tags' do
|
111
|
-
expect(
|
145
|
+
expect(consul_notags_noleader_nohealth.last).to eq('192.168.10.15')
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'can discover nodes without tags and health' do
|
149
|
+
expect(consul_notags_noleader_health.last).to eq('192.168.10.13')
|
112
150
|
end
|
113
151
|
|
114
152
|
it 'can discover nodes with tags' do
|
115
|
-
expect(
|
153
|
+
expect(consul_tags_noleader_nohealth.length).to eq(3)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'can discover nodes with tags and health' do
|
157
|
+
expect(consul_tags_noleader_health.length).to eq(1)
|
116
158
|
end
|
117
159
|
end
|
118
160
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cluster-discovery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,9 +94,13 @@ files:
|
|
94
94
|
- lib/cluster/discovery/version.rb
|
95
95
|
- spec/cassettes/Cluster_Discovery/_discover/can_discover_nodes/discovery_with_consul.yml
|
96
96
|
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_with_tags.yml
|
97
|
+
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_with_tags_and_health.yml
|
97
98
|
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_without_tags.yml
|
99
|
+
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_without_tags_and_health.yml
|
98
100
|
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_with_tags.yml
|
101
|
+
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_with_tags_and_health.yml
|
99
102
|
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_without_tags.yml
|
103
|
+
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_without_tags_and_health.yml
|
100
104
|
- spec/cassettes/Cluster_Discovery_EC2_AutoScaling/_discover/can_reuse_the_tag_provider/can_find_instances_by_aws_auto_scaling_group.yml
|
101
105
|
- spec/cassettes/Cluster_Discovery_EC2_Tag/_discover/passing_aws_region_arg/can_find_instances_by_tag.yml
|
102
106
|
- spec/lib/cluster/discovery/consul_spec.rb
|
@@ -124,16 +128,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
128
|
version: '0'
|
125
129
|
requirements: []
|
126
130
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.4.
|
131
|
+
rubygems_version: 2.4.3
|
128
132
|
signing_key:
|
129
133
|
specification_version: 4
|
130
134
|
summary: Cluster Discovery Library
|
131
135
|
test_files:
|
132
136
|
- spec/cassettes/Cluster_Discovery/_discover/can_discover_nodes/discovery_with_consul.yml
|
133
137
|
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_with_tags.yml
|
138
|
+
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_with_tags_and_health.yml
|
134
139
|
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_without_tags.yml
|
140
|
+
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_all_nodes/can_discover_nodes_without_tags_and_health.yml
|
135
141
|
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_with_tags.yml
|
142
|
+
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_with_tags_and_health.yml
|
136
143
|
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_without_tags.yml
|
144
|
+
- spec/cassettes/Cluster_Discovery_Consul/_discover/can_discover_leader_node/can_discover_nodes_without_tags_and_health.yml
|
137
145
|
- spec/cassettes/Cluster_Discovery_EC2_AutoScaling/_discover/can_reuse_the_tag_provider/can_find_instances_by_aws_auto_scaling_group.yml
|
138
146
|
- spec/cassettes/Cluster_Discovery_EC2_Tag/_discover/passing_aws_region_arg/can_find_instances_by_tag.yml
|
139
147
|
- spec/lib/cluster/discovery/consul_spec.rb
|