Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Commit

Permalink
Add integration test for status service output
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
Sharpie committed Dec 5, 2017
1 parent ae6a44a commit 6537a51
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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"]))))))))

0 comments on commit 6537a51

Please sign in to comment.