Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not fail for no generator-config-path zk node #262

Merged

Conversation

jiancheung
Copy link
Contributor

Currently, if generator_config_path is pointed to a non-existent zk node, synapse will crash.
Let's fail more gracefully and use the default behavior of new_config_for_generator = {}.

@bsherrod @reissbaker
cc @juchem @lap1817 (common contributors)

@@ -150,6 +150,20 @@
expect(subject).to receive(:set_backends).with([],{})
subject.send(:watcher_callback).call
end

it 'does not crash if there is no zk node' do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the better way to do this is:

context "when there is no zk node" do
  before :each do
    expect(..)
  end
 ...
 it "does not crash" do
   ...
 end
end

This test is also very similar and has a lot of shared expect calls with the previous test (it also raises a ZK::Exceptions::NoNode but for path instead of generator_config_path) so maybe we can clean that up a bit (ex: put generator_config_path in a let(..) statement)

@jiancheung jiancheung force-pushed the jian_cheung--handle-no-node-for-generator-config-path branch from d95b2af to 6a7e367 Compare October 1, 2018 22:09

context "when generator_config_path is disabled" do
let(:discovery) { { 'method' => 'zookeeper', 'hosts' => 'somehost', 'path' => 'some/path', 'generator_config_path' => 'disabled' } }
context 'generator_config_path is defined' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit : context blocks generally start with a when ... statement

@jiancheung jiancheung force-pushed the jian_cheung--handle-no-node-for-generator-config-path branch from 6a7e367 to f84fd6e Compare October 1, 2018 23:12
@jiancheung jiancheung merged commit 5350a36 into master Oct 1, 2018
@jiancheung jiancheung deleted the jian_cheung--handle-no-node-for-generator-config-path branch October 1, 2018 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants