From c4f71cc8c3081e16dadb36e530ad6d4ee4afbf89 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Tue, 11 Feb 2014 20:35:13 +0000 Subject: [PATCH 1/2] Use the /v2 metrics endpoint instead of /metrics The base url /metrics has long been a deprecated URL and creates noise when tested like this. Not to mention in current puppetdb master we are removing /v1 support so this test starts to break. By making it /v2, we still afford support for most of our 1.x users, and since /v2 will be around for quite some time this seems like a suitable temporary step. In the future a generic URL should really be provided by PuppetDB as something that is more permanent and generic. Signed-off-by: Ken Barber --- lib/puppet/util/puppetdb_validator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/util/puppetdb_validator.rb b/lib/puppet/util/puppetdb_validator.rb index e7203ba..ebc52af 100644 --- a/lib/puppet/util/puppetdb_validator.rb +++ b/lib/puppet/util/puppetdb_validator.rb @@ -21,7 +21,7 @@ module Puppet # All that we care about is that we are able to connect successfully via # https, so here we're simpling hitting a somewhat arbitrary low-impact URL # on the puppetdb server. - path = "/metrics/mbean/java.lang:type=Memory" + path = "/v2/metrics/mbean/java.lang:type=Memory" headers = {"Accept" => "application/json"} if @use_ssl conn = Puppet::Network::HttpPool.http_instance(@puppetdb_server, @puppetdb_port, @use_ssl) From 1c831ebe5ee9337292b0f9fcdaf03118e44e8a83 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Tue, 11 Feb 2014 20:56:48 +0000 Subject: [PATCH 2/2] Fix up unit tests after /v2 changes Signed-off-by: Ken Barber --- spec/unit/util/puppetdb_validator_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/unit/util/puppetdb_validator_spec.rb b/spec/unit/util/puppetdb_validator_spec.rb index 0631400..8bfb85c 100644 --- a/spec/unit/util/puppetdb_validator_spec.rb +++ b/spec/unit/util/puppetdb_validator_spec.rb @@ -12,12 +12,12 @@ describe 'Puppet::Util::PuppetdbValidator' do response_not_found.stubs(:msg).returns('Not found') conn_ok = stub() - conn_ok.stubs(:get).with('/metrics/mbean/java.lang:type=Memory', {"Accept" => "application/json"}).returns(response_ok) + conn_ok.stubs(:get).with('/v2/metrics/mbean/java.lang:type=Memory', {"Accept" => "application/json"}).returns(response_ok) conn_ok.stubs(:read_timeout=).with(2) conn_ok.stubs(:open_timeout=).with(2) conn_not_found = stub() - conn_not_found.stubs(:get).with('/metrics/mbean/java.lang:type=Memory', {"Accept" => "application/json"}).returns(response_not_found) + conn_not_found.stubs(:get).with('/v2/metrics/mbean/java.lang:type=Memory', {"Accept" => "application/json"}).returns(response_not_found) Puppet::Network::HttpPool.stubs(:http_instance).raises('Unknown host') Puppet::Network::HttpPool.stubs(:http_instance).with('mypuppetdb.com', 8080, true).raises('Connection refused')