Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #582 from jeffmccune/improve/master/SERVER-297_con…
…solidate_env_handling (SERVER-297) Consolidate JRuby environment handling
- Loading branch information
Showing
9 changed files
with
258 additions
and
128 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
acceptance/suites/tests/010-puppetserver-cli/subcommand/SERVER-297_common_behavior.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'test/unit/assertions' | ||
require 'json' | ||
|
||
test_name "Puppetserver subcommand consolidated ENV handling tests." | ||
|
||
step "ruby: Check that PATH, HOME, GEM_HOME JARS_REQUIRE and JARS_NO_REQUIRE are present" | ||
on(master, "puppetserver ruby -rjson -e 'puts JSON.pretty_generate(ENV.to_hash)'") do | ||
env = JSON.parse(stdout) | ||
assert(env['PATH'], "PATH missing") | ||
assert(env['HOME'], "HOME missing") | ||
assert(env['GEM_HOME'], "GEM_HOME missing") | ||
assert(env['JARS_REQUIRE'], "JARS_REQUIRE missing") | ||
assert(env['JARS_NO_REQUIRE'], "JARS_NO_REQUIRE missing") | ||
end | ||
|
||
step "irb: Check that PATH, HOME, GEM_HOME JARS_REQUIRE and JARS_NO_REQUIRE are present" | ||
on(master, "puppetserver irb -f -rjson -e 'puts JSON.pretty_generate(ENV.to_hash)'") do | ||
assert_match(/\bPATH\b/, output, "PATH missing") | ||
assert_match(/\bHOME\b/, output, "HOME missing") | ||
assert_match(/\bGEM_HOME\b/, output, "GEM_HOME missing") | ||
assert_match(/\bJARS_REQUIRE\b/, output, "JARS_REQUIRE missing") | ||
assert_match(/\bJARS_NO_REQUIRE\b/, output, "JARS_NO_REQUIRE missing") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,7 @@ | ||
(ns puppetlabs.puppetserver.cli.ruby | ||
(:import (org.jruby Main RubyInstanceConfig CompatVersion) | ||
(java.util HashMap)) | ||
(:require [puppetlabs.puppetserver.cli.subcommand :as cli] | ||
[puppetlabs.services.jruby.jruby-puppet-internal :as jruby-internal])) | ||
|
||
(defn new-jruby-main | ||
[config] | ||
(let [jruby-config (RubyInstanceConfig.) | ||
gem-home (get-in config [:jruby-puppet :gem-home]) | ||
env (doto (HashMap. (.getEnvironment jruby-config)) | ||
(.put "GEM_HOME" gem-home) | ||
(.put "JARS_NO_REQUIRE" "true") | ||
(.put "JARS_REQUIRE" "false")) | ||
jruby-home (.getJRubyHome jruby-config) | ||
load-path (->> (get-in config [:jruby-puppet :ruby-load-path]) | ||
(cons jruby-internal/ruby-code-dir) | ||
(cons (str jruby-home "/lib/ruby/1.9")) | ||
(cons (str jruby-home "/lib/ruby/shared")) | ||
(cons (str jruby-home "/lib/ruby/1.9/site_ruby")))] | ||
(doto jruby-config | ||
(.setEnvironment env) | ||
(.setLoadPaths load-path) | ||
(.setCompatVersion (CompatVersion/RUBY1_9))) | ||
(Main. jruby-config))) | ||
|
||
(defn run! | ||
[config ruby-args] | ||
(doto (new-jruby-main config) | ||
(.run (into-array String | ||
(cons "-rjar-dependencies" ruby-args))))) | ||
[puppetlabs.services.jruby.jruby-puppet-core :as jruby-core])) | ||
|
||
(defn -main | ||
[& args] | ||
(cli/run run! args)) | ||
(cli/run jruby-core/cli-ruby! args)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.