synapse 0.13.8 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +5 -4
- data/README.md +30 -8
- data/config/synapse.conf.json +1 -0
- data/lib/synapse.rb +24 -18
- data/lib/synapse/config_generator.rb +20 -0
- data/lib/synapse/config_generator/README.md +74 -0
- data/lib/synapse/config_generator/base.rb +44 -0
- data/lib/synapse/{file_output.rb → config_generator/file_output.rb} +13 -11
- data/lib/synapse/{haproxy.rb → config_generator/haproxy.rb} +81 -42
- data/lib/synapse/service_watcher/README.md +6 -5
- data/lib/synapse/service_watcher/base.rb +38 -13
- data/lib/synapse/service_watcher/ec2tag.rb +2 -7
- data/lib/synapse/service_watcher/zookeeper.rb +2 -4
- data/lib/synapse/service_watcher/zookeeper_dns.rb +0 -1
- data/lib/synapse/version.rb +1 -1
- data/spec/lib/synapse/file_output_spec.rb +3 -2
- data/spec/lib/synapse/haproxy_spec.rb +167 -8
- data/spec/lib/synapse/service_watcher_base_spec.rb +9 -2
- data/spec/lib/synapse/service_watcher_docker_spec.rb +8 -1
- data/spec/lib/synapse/service_watcher_ec2tags_spec.rb +42 -8
- data/spec/lib/synapse/service_watcher_marathon_spec.rb +8 -1
- data/spec/lib/synapse/service_watcher_spec.rb +8 -1
- data/spec/lib/synapse/service_watcher_zookeeper_spec.rb +8 -1
- data/spec/support/minimum.conf.yaml +1 -0
- metadata +7 -4
@@ -30,7 +30,15 @@ class FakeAWSInstance
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe Synapse::ServiceWatcher::Ec2tagWatcher do
|
33
|
-
let(:mock_synapse)
|
33
|
+
let(:mock_synapse) do
|
34
|
+
mock_synapse = instance_double(Synapse::Synapse)
|
35
|
+
mockgenerator = Synapse::ConfigGenerator::BaseGenerator.new()
|
36
|
+
allow(mock_synapse).to receive(:available_generators).and_return({
|
37
|
+
'haproxy' => mockgenerator
|
38
|
+
})
|
39
|
+
allow(mock_synapse).to receive(:reconfigure!).and_return(true)
|
40
|
+
mock_synapse
|
41
|
+
end
|
34
42
|
subject { Synapse::ServiceWatcher::Ec2tagWatcher.new(basic_config, mock_synapse) }
|
35
43
|
|
36
44
|
let(:basic_config) do
|
@@ -79,6 +87,12 @@ describe Synapse::ServiceWatcher::Ec2tagWatcher do
|
|
79
87
|
args
|
80
88
|
end
|
81
89
|
|
90
|
+
def munge_arg(name, new_value)
|
91
|
+
args = basic_config.clone
|
92
|
+
args[name] = new_value
|
93
|
+
args
|
94
|
+
end
|
95
|
+
|
82
96
|
describe '#new' do
|
83
97
|
let(:args) { basic_config }
|
84
98
|
|
@@ -102,19 +116,33 @@ describe Synapse::ServiceWatcher::Ec2tagWatcher do
|
|
102
116
|
Synapse::ServiceWatcher::Ec2tagWatcher.new(remove_discovery_arg('aws_secret_access_key'), mock_synapse)
|
103
117
|
}.not_to raise_error
|
104
118
|
end
|
105
|
-
it 'complains if server_port_override
|
119
|
+
it 'complains if server_port_override and backend_port_override are missing' do
|
106
120
|
expect {
|
107
121
|
Synapse::ServiceWatcher::Ec2tagWatcher.new(remove_haproxy_arg('server_port_override'), mock_synapse)
|
108
|
-
}.to raise_error(ArgumentError, /Missing
|
122
|
+
}.to raise_error(ArgumentError, /Missing backend_port_override/)
|
123
|
+
end
|
124
|
+
it 'does not break if backend_port_override is set' do
|
125
|
+
expect {
|
126
|
+
Synapse::ServiceWatcher::Ec2tagWatcher.new(munge_arg('backend_port_override', 1234), mock_synapse)
|
127
|
+
}.not_to raise_error
|
109
128
|
end
|
110
129
|
end
|
111
130
|
|
112
131
|
context 'invalid data' do
|
113
132
|
it 'complains if the haproxy server_port_override is not a number' do
|
114
|
-
|
115
|
-
|
116
|
-
|
133
|
+
expect {
|
134
|
+
Synapse::ServiceWatcher::Ec2tagWatcher.new(munge_haproxy_arg('server_port_override', '80deadbeef'), mock_synapse)
|
135
|
+
}.to raise_error(ArgumentError, /Invalid backend_port_override/)
|
136
|
+
end
|
137
|
+
it 'complains if the backend_port_override is not a number' do
|
138
|
+
config = remove_haproxy_arg('server_port_override')
|
139
|
+
expect(config['haproxy']['backend_port_override']).to eq(nil)
|
140
|
+
config = munge_arg('backend_port_override', '80deadbeef')
|
141
|
+
expect {
|
142
|
+
Synapse::ServiceWatcher::Ec2tagWatcher.new(config, mock_synapse)
|
143
|
+
}.to raise_error(ArgumentError, /Invalid backend_port_override/)
|
117
144
|
end
|
145
|
+
|
118
146
|
end
|
119
147
|
end
|
120
148
|
|
@@ -182,9 +210,15 @@ describe Synapse::ServiceWatcher::Ec2tagWatcher do
|
|
182
210
|
end
|
183
211
|
|
184
212
|
it 'sets the backend port to server_port_override for all backends' do
|
185
|
-
|
213
|
+
discovered_backends = subject.send(:discover_instances)
|
214
|
+
expect(
|
215
|
+
discovered_backends.all? { |b| b['port'].nil? }
|
216
|
+
).to be_truthy
|
217
|
+
|
218
|
+
# Set backends is responsible for actually populating ports
|
219
|
+
expect(subject.send(:set_backends, discovered_backends)).to eq(true)
|
186
220
|
expect(
|
187
|
-
backends.all? { |b| b['port'] == basic_config['haproxy']['server_port_override'] }
|
221
|
+
subject.backends.all? { |b| b['port'] == basic_config['haproxy']['server_port_override'] }
|
188
222
|
).to be_truthy
|
189
223
|
end
|
190
224
|
end
|
@@ -2,7 +2,14 @@ require 'spec_helper'
|
|
2
2
|
require 'synapse/service_watcher/marathon'
|
3
3
|
|
4
4
|
describe Synapse::ServiceWatcher::MarathonWatcher do
|
5
|
-
let(:mocksynapse)
|
5
|
+
let(:mocksynapse) do
|
6
|
+
mock_synapse = instance_double(Synapse::Synapse)
|
7
|
+
mockgenerator = Synapse::ConfigGenerator::BaseGenerator.new()
|
8
|
+
allow(mock_synapse).to receive(:available_generators).and_return({
|
9
|
+
'haproxy' => mockgenerator
|
10
|
+
})
|
11
|
+
mock_synapse
|
12
|
+
end
|
6
13
|
let(:marathon_host) { '127.0.0.1' }
|
7
14
|
let(:marathon_port) { '8080' }
|
8
15
|
let(:app_name) { 'foo' }
|
@@ -2,7 +2,14 @@ require 'spec_helper'
|
|
2
2
|
require 'synapse/service_watcher'
|
3
3
|
|
4
4
|
describe Synapse::ServiceWatcher do
|
5
|
-
let(:mock_synapse)
|
5
|
+
let(:mock_synapse) do
|
6
|
+
mock_synapse = instance_double(Synapse::Synapse)
|
7
|
+
mockgenerator = Synapse::ConfigGenerator::BaseGenerator.new()
|
8
|
+
allow(mock_synapse).to receive(:available_generators).and_return({
|
9
|
+
'haproxy' => mockgenerator
|
10
|
+
})
|
11
|
+
mock_synapse
|
12
|
+
end
|
6
13
|
subject { Synapse::ServiceWatcher }
|
7
14
|
let(:config) do
|
8
15
|
{
|
@@ -3,7 +3,14 @@ require 'synapse/service_watcher/zookeeper'
|
|
3
3
|
require 'synapse/service_watcher/zookeeper_dns'
|
4
4
|
|
5
5
|
describe Synapse::ServiceWatcher::ZookeeperWatcher do
|
6
|
-
let(:mock_synapse)
|
6
|
+
let(:mock_synapse) do
|
7
|
+
mock_synapse = instance_double(Synapse::Synapse)
|
8
|
+
mockgenerator = Synapse::ConfigGenerator::BaseGenerator.new()
|
9
|
+
allow(mock_synapse).to receive(:available_generators).and_return({
|
10
|
+
'haproxy' => mockgenerator
|
11
|
+
})
|
12
|
+
mock_synapse
|
13
|
+
end
|
7
14
|
let(:config) do
|
8
15
|
{
|
9
16
|
'name' => 'test',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synapse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Rhoads
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-03-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|
@@ -197,8 +197,11 @@ files:
|
|
197
197
|
- config/synapse_services/service2.json
|
198
198
|
- lib/synapse.rb
|
199
199
|
- lib/synapse/base.rb
|
200
|
-
- lib/synapse/
|
201
|
-
- lib/synapse/
|
200
|
+
- lib/synapse/config_generator.rb
|
201
|
+
- lib/synapse/config_generator/README.md
|
202
|
+
- lib/synapse/config_generator/base.rb
|
203
|
+
- lib/synapse/config_generator/file_output.rb
|
204
|
+
- lib/synapse/config_generator/haproxy.rb
|
202
205
|
- lib/synapse/log.rb
|
203
206
|
- lib/synapse/service_watcher.rb
|
204
207
|
- lib/synapse/service_watcher/README.md
|