From 55b4fa7bbd80a85e053eaef26e2a0e887a95e1de Mon Sep 17 00:00:00 2001 From: Feng Pan Date: Fri, 1 Sep 2017 23:25:08 -0700 Subject: [PATCH 1/3] [nerve] only mkdir_p in zk_create when the path does not exist --- lib/nerve/reporter/zookeeper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nerve/reporter/zookeeper.rb b/lib/nerve/reporter/zookeeper.rb index c2da84ec..f6cd2f13 100644 --- a/lib/nerve/reporter/zookeeper.rb +++ b/lib/nerve/reporter/zookeeper.rb @@ -83,7 +83,7 @@ def zk_delete end def zk_create - @zk.mkdir_p(@zk_path) + @zk.mkdir_p(@zk_path) unless @zk.exists?(@zk_path) @full_key = @zk.create(@key_prefix, :data => @data, :mode => :ephemeral_sequential) end From 154026b2b235255c27590eb12bd16417ff60db73 Mon Sep 17 00:00:00 2001 From: Feng Pan Date: Fri, 1 Sep 2017 23:33:52 -0700 Subject: [PATCH 2/3] add comment --- lib/nerve/reporter/zookeeper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/nerve/reporter/zookeeper.rb b/lib/nerve/reporter/zookeeper.rb index f6cd2f13..a0225009 100644 --- a/lib/nerve/reporter/zookeeper.rb +++ b/lib/nerve/reporter/zookeeper.rb @@ -83,6 +83,7 @@ def zk_delete end def zk_create + # only mkdir_p if the path does not exist @zk.mkdir_p(@zk_path) unless @zk.exists?(@zk_path) @full_key = @zk.create(@key_prefix, :data => @data, :mode => :ephemeral_sequential) end From 205fb95bbd609796e878e9d9a00ceecf163e3707 Mon Sep 17 00:00:00 2001 From: Feng Pan Date: Fri, 1 Sep 2017 23:48:06 -0700 Subject: [PATCH 3/3] update version and spec test --- Gemfile.lock | 2 +- lib/nerve/version.rb | 2 +- spec/lib/nerve/reporter_zookeeper_spec.rb | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a29a29eb..40784ea9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - nerve (0.8.0) + nerve (0.8.1) bunny (= 1.1.0) etcd (~> 0.2.3) json diff --git a/lib/nerve/version.rb b/lib/nerve/version.rb index fbd45748..c1ee7aed 100644 --- a/lib/nerve/version.rb +++ b/lib/nerve/version.rb @@ -1,3 +1,3 @@ module Nerve - VERSION = "0.8.0" + VERSION = "0.8.1" end diff --git a/spec/lib/nerve/reporter_zookeeper_spec.rb b/spec/lib/nerve/reporter_zookeeper_spec.rb index 26a05bd4..2c71fdfc 100644 --- a/spec/lib/nerve/reporter_zookeeper_spec.rb +++ b/spec/lib/nerve/reporter_zookeeper_spec.rb @@ -17,6 +17,7 @@ it 'deregisters service on exit' do zk = double("zk") allow(zk).to receive(:close!) + expect(zk).to receive(:exists?) { "zk_path" }.and_return(false) expect(zk).to receive(:mkdir_p) { "zk_path" } expect(zk).to receive(:create) { "full_path" } expect(zk).to receive(:delete).with("full_path", anything())