Skip to content

Commit

Permalink
(PE-35511) Update to tk-webserver-jetty-10
Browse files Browse the repository at this point in the history
  • Loading branch information
rileynewton committed Nov 30, 2023
1 parent 1a019f1 commit a42e2db
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 20 deletions.
2 changes: 1 addition & 1 deletion documentation/configure.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ Sets the maximum number of threads assigned to responding to HTTP
and HTTPS requests, effectively changing how many concurrent requests
can be made at one time. Defaults to 50.

> **Note:** Due to the behaviour of our web server (Jetty 9), this setting
> **Note:** Due to the behaviour of our web server (Jetty 10), this setting
must be higher then the number of CPUs on your system or it will
stop processing any HTTP requests.

Expand Down
6 changes: 3 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
'[[ring/ring-mock]
[puppetlabs/trapperkeeper :classifier "test"]
[puppetlabs/kitchensink :classifier "test"]
[puppetlabs/trapperkeeper-webserver-jetty9 :classifier "test"]
[com.puppetlabs/trapperkeeper-webserver-jetty10 :classifier "test"]
[org.flatland/ordered "1.5.9"]
[org.clojure/test.check "0.9.0"]
[com.gfredericks/test.chuck "0.2.7"
Expand Down Expand Up @@ -177,8 +177,8 @@
[puppetlabs/stockpile "0.0.4"]
[puppetlabs/structured-logging]
[puppetlabs/trapperkeeper]
[puppetlabs/trapperkeeper-webserver-jetty9]
[puppetlabs/trapperkeeper-metrics]
[com.puppetlabs/trapperkeeper-webserver-jetty10]
[puppetlabs/trapperkeeper-metrics "2.0.0"]
[puppetlabs/trapperkeeper-status]
[puppetlabs/trapperkeeper-authorization]

Expand Down
2 changes: 1 addition & 1 deletion resources/puppetlabs/puppetdb/bootstrap.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# https://github.com/puppetlabs/trapperkeeper/wiki/Bootstrapping

# Web Server
puppetlabs.trapperkeeper.services.webserver.jetty9-service/jetty9-service
puppetlabs.trapperkeeper.services.webserver.jetty10-service/jetty10-service

# Webrouting
puppetlabs.trapperkeeper.services.webrouting.webrouting-service/webrouting-service
Expand Down
5 changes: 3 additions & 2 deletions src/puppetlabs/puppetdb/http/query.clj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
[murphy :refer [try!]]
[puppetlabs.puppetdb.query-eng :as qeng]
[puppetlabs.puppetdb.query.monitor :as qmon]
[puppetlabs.trapperkeeper.services.webserver.jetty9 :as jetty9]
[puppetlabs.i18n.core :refer [trs tru]]
[puppetlabs.kitchensink.core :as kitchensink]
[schema.core :as s]
Expand Down Expand Up @@ -428,8 +427,10 @@

;; May have no response because some tests (e.g. some
;; with-http-app based tests) don't add one right now.
_ (println "-DEBUG- \n what is req? " req)
_ (println "-DEBUG- \n what is (:response req)? " (:response req))
monitor-id (when-let [chan (and query-monitor
(some-> (::jetty9/response req)
(some-> (:response req)
response->channel))]
(qmon/stop-query-at-deadline-or-disconnect query-monitor
query-uuid
Expand Down
3 changes: 1 addition & 2 deletions src/puppetlabs/puppetdb/pdb_routing.clj
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@
clean
delete-node))
(mid/wrap-cert-authn cert-allowlist)
mid/wrap-with-puppetdb-middleware)
{:include-response true})
mid/wrap-with-puppetdb-middleware))

(enable-maint-mode)
(pdb-status/register-pdb-status
Expand Down
2 changes: 1 addition & 1 deletion test-resources/integration-bootstrap.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
puppetlabs.trapperkeeper.services.webserver.jetty9-service/jetty9-service
puppetlabs.trapperkeeper.services.webserver.jetty10-service/jetty10-service
puppetlabs.trapperkeeper.services.webrouting.webrouting-service/webrouting-service
puppetlabs.trapperkeeper.services.metrics.metrics-service/metrics-webservice
puppetlabs.trapperkeeper.services.status.status-service/status-service
Expand Down
2 changes: 1 addition & 1 deletion test-resources/puppetserver/bootstrap.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ puppetlabs.services.request-handler.request-handler-service/request-handler-serv
puppetlabs.services.jruby.jruby-puppet-service/jruby-puppet-pooled-service
puppetlabs.services.jruby-pool-manager.jruby-pool-manager-service/jruby-pool-manager-service
puppetlabs.services.puppet-profiler.puppet-profiler-service/puppet-profiler-service
puppetlabs.trapperkeeper.services.webserver.jetty9-service/jetty9-service
puppetlabs.trapperkeeper.services.webserver.jetty10-service/jetty10-service
puppetlabs.trapperkeeper.services.webrouting.webrouting-service/webrouting-service
puppetlabs.services.config.puppet-server-config-service/puppet-server-config-service
puppetlabs.services.master.master-service/master-service
Expand Down
18 changes: 14 additions & 4 deletions test/puppetlabs/puppetdb/command_broadcast_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
pg2 (int/setup-postgres)
pdb1 (int/run-puppetdb pg1 {:database {:gc-interval "0"}
:database-pg1 (int/server-info pg1)
:database-pg2 (int/server-info pg2)})]
:database-pg2 (int/server-info pg2)})
_ (println "-DEBUG-:\n" pg1 "\n" pg2 "\n" pdb1 "\n")]
;; post a few commands to trigger broadcast to both pgs
(populate-db pdb1)

Expand All @@ -64,19 +65,28 @@
(is (= expected (int/pql-query pdb1 "catalogs [certname] {}")))))

(let [port (-> pdb1 int/server-info :base-url :port)
get-response-body (:body (svc-utils/get-ssl (str "https://localhost:" port "/metrics/v2/list")))
get-response-body-value (-> get-response-body
:value)
get-response-body-value-storage (-> get-response-body-value
:puppetlabs.puppetdb.storage)
list-metrics (fn [metric-type]
;; return metrics in :name=pg1.<metric-name> format
(-> (str "https://localhost:" port "/metrics/v2/list")
svc-utils/get-ssl
(-> get-response-body
:body
:value
metric-type
keys))]
keys))
_ (println "-DEBUG-: \n get-response-body: \n " get-response-body "\n")
_ (println "-DEBUG-: \n get-response-body-value: \n " get-response-body-value "\n")
_ (println "-DEBUG-: \n get-response-body-value-storage: \n " get-response-body-value-storage "\n")]

(testing "Expected number of storage metrics are created for both PGs"
(let [storage-metrics (list-metrics :puppetlabs.puppetdb.storage)
_ (println "-DEBUG-: \n storage-metrics: \n " storage-metrics "\n")
;; filter out non-broadcast metrics created in the registry during other tests
broadcast-metrics (filter #(re-find (re-pattern (str "pg1" "|" "pg2")) (str %)) storage-metrics)
_ (println "-DEBUG-: \n broadcast-metrics: \n " broadcast-metrics "\n")
expected-count 22 ;; 22 per pg metrics registered in storage.clj
[pg-1 pg-2] (vals (group-by #(subs (str %) 1 9) broadcast-metrics))]
(is (= expected-count (count pg-1)))
Expand Down
4 changes: 2 additions & 2 deletions test/puppetlabs/puppetdb/testutils/repl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[puppetlabs.puppetdb.testutils :as testutils]
[me.raynes.fs :as fs]
[puppetlabs.puppetdb.cli.services :as svcs :refer [puppetdb-service]]
[puppetlabs.trapperkeeper.services.webserver.jetty9-service :refer [jetty9-service]]
[puppetlabs.trapperkeeper.services.webserver.jetty10-service :refer [jetty10-service]]
[puppetlabs.trapperkeeper.core :as tk]
[puppetlabs.trapperkeeper.app :as tka]
[clojure.tools.namespace.repl :refer (refresh)]))
Expand Down Expand Up @@ -41,7 +41,7 @@
(defn start [config-path]
(alter-var-root #'system
(fn [_] (tk/boot-services-with-cli-data
[jetty9-service puppetdb-service]
[jetty10-service puppetdb-service]
{:config config-path}))))

(defn stop []
Expand Down
8 changes: 5 additions & 3 deletions test/puppetlabs/puppetdb/testutils/services.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[clojure.walk :as walk]
[puppetlabs.trapperkeeper.app :as tk-app :refer [get-service]]
[puppetlabs.trapperkeeper.testutils.bootstrap :as tkbs]
[puppetlabs.trapperkeeper.services.webserver.jetty9-service :refer [jetty9-service]]
[puppetlabs.trapperkeeper.services.webserver.jetty10-service :refer [jetty10-service]]
[puppetlabs.trapperkeeper.services.webrouting.webrouting-service :refer [webrouting-service]]
[puppetlabs.trapperkeeper.services.status.status-service :refer [status-service]]
[puppetlabs.trapperkeeper.services.scheduler.scheduler-service :refer [scheduler-service]]
Expand Down Expand Up @@ -78,7 +78,7 @@
(def ^:dynamic *server*)

(def default-services
[#'jetty9-service
[#'jetty10-service
#'webrouting-service
#'puppetdb-service
#'command-service
Expand Down Expand Up @@ -291,7 +291,9 @@
[url-str :- String
& [opts]]
(let [resp (get-unparsed url-str opts)
ctype (rr/get-header resp "content-type")]
ctype (rr/get-header resp "content-type")
_ (println "-DEBUG- what is ctype? " ctype)
_ (println "-DEBUG- json-utf8-ctype? " (json-utf8-ctype? ctype))]
(if (some-> ctype json-utf8-ctype?)
(update resp :body #(json/parse-string % true))
resp)))
Expand Down

0 comments on commit a42e2db

Please sign in to comment.