From 6537a5189024e32e539e142af0062f7226eb74a4 Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Tue, 5 Dec 2017 06:43:06 -0800 Subject: [PATCH] Add integration test for status service output This patch extends the Clojure integration suite to include a test that exercises output added to the trapperkeeper status service. This test is included to make sure that we're reporting a version number and that we don't somehow break status (which would be very bad). --- .../facts_upload_service_test.clj | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/integration/puppetlabs/services/facts_upload/facts_upload_service_test.clj b/test/integration/puppetlabs/services/facts_upload/facts_upload_service_test.clj index 5c08a18..ccd8ee0 100644 --- a/test/integration/puppetlabs/services/facts_upload/facts_upload_service_test.clj +++ b/test/integration/puppetlabs/services/facts_upload/facts_upload_service_test.clj @@ -5,6 +5,7 @@ [clojure.walk :as walk] [puppetlabs.http.client.sync :as http-client] + [cheshire.core :as json] [me.raynes.fs :as fs] ;; Zweikopf converts data between JRuby and Clojure objects. ;; NOTE: To cut overhead, the tests below don't initialize zweikopf @@ -19,7 +20,8 @@ [puppetlabs.trapperkeeper.testutils.bootstrap :as tst-bootstrap] ;; Provided by puppetlabs/puppetserver with the "test" classifier. - [puppetlabs.services.jruby.jruby-puppet-testutils :as jruby-testutils])) + [puppetlabs.services.jruby.jruby-puppet-testutils :as jruby-testutils] + [puppetlabs.services.facts-upload.facts-upload-service :as facts-upload])) ;; Test Configuration @@ -82,8 +84,15 @@ :body body :as :text})) +(defn GET + [path] + (http-client/get (str base-url path) + {:headers {"Accept" "application/json"} + :ssl-ca-cert ca-cert + :as :text})) -(deftest ^:integration facts-upload-endpoint + +(deftest ^:integration facts-upload-service (tst-bootstrap/with-app-with-config app app-services base-config (let [jruby-service (tk-app/get-service app :JRubyPuppetService) jruby-instance (jruby-testutils/borrow-instance jruby-service :facts-upload-endpoint-test) @@ -106,4 +115,10 @@ (walk/keywordize-keys))] (is (= "bar" (get-in stored-facts [:values :foo])))))) (finally - (jruby-testutils/return-instance jruby-service jruby-instance :facts-upload-endpoint-test)))))) + (jruby-testutils/return-instance jruby-service jruby-instance :facts-upload-endpoint-test))) + + (testing "facts-upload plugin version number is available via status service" + (let [response (GET "/status/v1/services?level=debug") + body (-> response :body json/parse-string)] + (is (= 200 (:status response))) + (is (= facts-upload/version (get-in body ["facts-upload-service" "service_version"]))))))))