Skip to content

Commit c9aaddc

Browse files
Merge pull request #2855 from justinstoller/PE-37376
(maint) Allow not applying settings catalog on startup
2 parents d02eb3e + b6815bf commit c9aaddc

File tree

9 files changed

+58
-90
lines changed

9 files changed

+58
-90
lines changed

dev-resources/puppetlabs/services/master/master_service_test/ca_files_test/puppet.conf

Lines changed: 0 additions & 20 deletions
This file was deleted.

dev/puppetserver.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ jruby-puppet: {
8989
# For testing running requests through a single JRuby instance. DO NOT ENABLE unless
9090
# explicitly testing this functionality.
9191
# multithreaded: true
92+
93+
# (optional) When (re)filling a pool one instance will be initialized first, then
94+
# the remaining instances will be initialized at the specified level of concurrency.
95+
# Set to one for the previous serialized behavior. Default is three.
96+
# instance-creation-concurrency: 1
9297
}
9398

9499
# Settings related to HTTP client requests made by Puppet Server.

project.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@
9999
:puppet-platform-version 8
100100
:java-args ~(str "-Xms2g -Xmx2g "
101101
"-Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger")
102-
:create-dirs ["/opt/puppetlabs/server/data/puppetserver/jars"]
102+
:create-dirs ["/opt/puppetlabs/server/data/puppetserver/jars"
103+
"/opt/puppetlabs/server/data/puppetserver/yaml"]
103104
:repo-target "puppet8"
104105
:nonfinal-repo-target "puppet8-nightly"
105106
:bootstrap-source :services-d

spec/puppet-server-lib/puppet/jvm/logging_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66
describe Puppet::Server::Logging do
77
context 'when setting the log level' do
8-
before :each do
9-
Puppet::Server::PuppetConfig.initialize_puppet(puppet_config: {})
8+
it 'flush logging queue' do
9+
# The logger will queue any old log messages, creating a logging destination
10+
# will force the pending queue to be flushed to this logger. We don't care
11+
# about these messages so we discard the logger, but we do not want them to
12+
# interfere with the next tests.
13+
_, _ = Puppet::Server::Logging.capture_logs('debug') do; end
1014
end
1115

1216
it 'correctly filters messages' do

src/ruby/puppetserver-lib/puppet/server/log_collector.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'puppet/util/log'
2+
13
module Puppet
24
module Server
35
# Log to an array, just for testing.

src/ruby/puppetserver-lib/puppet/server/logger.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'puppet'
2+
require 'puppet/util'
13
require 'puppet/server'
24
require 'java'
35

src/ruby/puppetserver-lib/puppet/server/logging.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'puppet'
2+
require 'puppet/util/log'
13
require 'puppet/server/log_collector'
24

35
module Puppet

src/ruby/puppetserver-lib/puppet/server/puppet_config.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
require 'puppet/server'
22
require 'puppet/server/logger'
33
require 'puppet/server/http_client'
4+
require 'puppet/indirector/indirection'
5+
require 'puppet/file_serving/content'
6+
require 'puppet/file_serving/metadata'
7+
require 'puppet/file_bucket/file'
8+
require 'puppet/node'
9+
require 'puppet/application_support'
10+
require 'puppet/ssl/oids'
411

512
class Puppet::Server::PuppetConfig
613

@@ -88,6 +95,8 @@ def self.initialize_puppet(puppet_config:)
8895
Puppet.push_context(dummy_ssl_context)
8996
end
9097

98+
# We have now added support for setting "settings_catalog" to false in the puppet.conf.
99+
# We should default to not applying the settings catalog and remove this line in Puppet 9.
91100
Puppet.settings.use :main, :server, :ssl, :metrics
92101

93102
if Puppet::Indirector::Indirection.method_defined?(:set_global_setting)

test/integration/puppetlabs/services/master/master_service_test.clj

Lines changed: 30 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -319,45 +319,6 @@
319319
(+ (:duration-millis requested-instance)
320320
(:time requested-instance))))))))))))))
321321

322-
(deftest ^:integration ca-files-test
323-
(testing "CA settings from puppet are honored and the CA
324-
files are created when the service starts up"
325-
(let [ca-files-test-runtime-dir (str master-service-test-runtime-dir
326-
"/ca-files-test")
327-
ca-files-test-puppet-conf (fs/file test-resources-path
328-
"ca_files_test/puppet.conf")]
329-
(fs/delete-dir ca-files-test-runtime-dir)
330-
(testutils/with-puppet-conf-files
331-
{"puppet.conf" ca-files-test-puppet-conf}
332-
ca-files-test-runtime-dir
333-
(logutils/with-test-logging
334-
(bootstrap-testutils/with-puppetserver-running
335-
app
336-
{:jruby-puppet {:gem-path gem-path
337-
:server-conf-dir ca-files-test-runtime-dir
338-
:max-active-instances 1}
339-
:webserver {:port 8081}}
340-
(let [jruby-service (tk-app/get-service app :JRubyPuppetService)]
341-
(jruby-service/with-jruby-puppet
342-
jruby-puppet jruby-service :ca-files-test
343-
(letfn [(test-path!
344-
[setting expected-path]
345-
(is (= (ks/absolute-path expected-path)
346-
(.getSetting jruby-puppet setting)))
347-
(is (fs/exists? (ks/absolute-path expected-path))))]
348-
349-
(test-path! "capub" (str ca-files-test-runtime-dir "/ca/ca_pub.pem"))
350-
(test-path! "cakey" (str ca-files-test-runtime-dir "/ca/ca_key.pem"))
351-
(test-path! "cacert" (str ca-files-test-runtime-dir "/ca/ca_crt.pem"))
352-
(test-path! "localcacert" (str ca-files-test-runtime-dir "/ca/ca.pem"))
353-
(test-path! "cacrl" (str ca-files-test-runtime-dir "/ca/ca_crl.pem"))
354-
(test-path! "hostcrl" (str ca-files-test-runtime-dir "/ca/crl.pem"))
355-
(test-path! "hostpubkey" (str ca-files-test-runtime-dir "/public_keys/localhost.pem"))
356-
(test-path! "hostprivkey" (str ca-files-test-runtime-dir "/private_keys/localhost.pem"))
357-
(test-path! "hostcert" (str ca-files-test-runtime-dir "/certs/localhost.pem"))
358-
(test-path! "serial" (str ca-files-test-runtime-dir "/certs/serial"))
359-
(test-path! "cert_inventory" (str ca-files-test-runtime-dir "/inventory.txt")))))))))))
360-
361322
(def graphite-enabled-config
362323
{:metrics {:server-id "localhost"
363324
:reporters {:graphite {:update-interval-seconds 5000
@@ -732,34 +693,36 @@
732693
(is (= 404 (:status resp)))))))
733694

734695
(deftest ^:integration facts-upload-api
735-
(bootstrap-testutils/with-puppetserver-running
736-
app
737-
{:jruby-puppet {:gem-path gem-path
738-
:max-active-instances 2 ; we need 2 jruby-instances since processing the upload uses an instance
739-
:server-code-dir test-resources-code-dir
740-
:server-conf-dir master-service-test-runtime-dir
741-
:server-var-dir (fs/tmpdir)}}
742-
(let [jruby-service (tk-app/get-service app :JRubyPuppetService)
743-
jruby-instance (jruby-testutils/borrow-instance jruby-service :facts-upload-endpoint-test)
744-
container (:scripting-container jruby-instance)]
745-
(try
746-
(let [facts (.runScriptlet container "facts = Puppet::Node::Facts.new('puppet.node.test')
747-
facts.values['foo'] = 'bar'
748-
facts.to_json")
749-
response (http-put "/puppet/v3/facts/puppet.node.test?environment=production" facts)]
750-
751-
(testing "Puppet Server responds to PUT requests for /puppet/v3/facts"
752-
(is (= 200 (:status response))))
753-
754-
(testing "Puppet Server saves facts to the configured facts terminus"
755-
;; Ensure the test is configured properly
756-
(is (= "yaml" (.runScriptlet container "Puppet::Node::Facts.indirection.terminus_class")))
757-
(let [stored-facts (-> (.runScriptlet container "facts = Puppet::Node::Facts.indirection.find('puppet.node.test')
758-
(facts.nil? ? {} : facts).to_json")
759-
(json/parse-string))]
760-
(is (= "bar" (get-in stored-facts ["values" "foo"]))))))
761-
(finally
762-
(jruby-testutils/return-instance jruby-service jruby-instance :facts-upload-endpoint-test))))))
696+
(let [tmpdir (fs/tmpdir)]
697+
(fs/mkdir (str tmpdir "/yaml"))
698+
(bootstrap-testutils/with-puppetserver-running
699+
app
700+
{:jruby-puppet {:gem-path gem-path
701+
:max-active-instances 2 ; we need 2 jruby-instances since processing the upload uses an instance
702+
:server-code-dir test-resources-code-dir
703+
:server-conf-dir master-service-test-runtime-dir
704+
:server-var-dir (fs/tmpdir)}}
705+
(let [jruby-service (tk-app/get-service app :JRubyPuppetService)
706+
jruby-instance (jruby-testutils/borrow-instance jruby-service :facts-upload-endpoint-test)
707+
container (:scripting-container jruby-instance)]
708+
(try
709+
(let [facts (.runScriptlet container "facts = Puppet::Node::Facts.new('puppet.node.test')
710+
facts.values['foo'] = 'bar'
711+
facts.to_json")
712+
response (http-put "/puppet/v3/facts/puppet.node.test?environment=production" facts)]
713+
714+
(testing "Puppet Server responds to PUT requests for /puppet/v3/facts"
715+
(is (= 200 (:status response))))
716+
717+
(testing "Puppet Server saves facts to the configured facts terminus"
718+
;; Ensure the test is configured properly
719+
(is (= "yaml" (.runScriptlet container "Puppet::Node::Facts.indirection.terminus_class")))
720+
(let [stored-facts (-> (.runScriptlet container "facts = Puppet::Node::Facts.indirection.find('puppet.node.test')
721+
(facts.nil? ? {} : facts).to_json")
722+
(json/parse-string))]
723+
(is (= "bar" (get-in stored-facts ["values" "foo"]))))))
724+
(finally
725+
(jruby-testutils/return-instance jruby-service jruby-instance :facts-upload-endpoint-test)))))))
763726

764727
(deftest ^:integration v4-queue-limit
765728
(bootstrap-testutils/with-puppetserver-running

0 commit comments

Comments
 (0)