Compare commits

...

42 Commits
2.1.0 ... 2.2.0

Author SHA1 Message Date
Paula McMaw
39113d885a Merge pull request #266 from willmeek/release_2_2_0
Release prep for 2.2.0
2017-11-16 14:46:57 +00:00
Will Meek
d0c9b41d9d Release prep for 2.2.0 2017-11-16 14:33:26 +00:00
Paula McMaw
d336d79c04 Merge pull request #265 from willmeek/realpath_test_fix
Realpath test fix
2017-11-16 10:59:40 +00:00
Will Meek
e1df6498c7 Fix facter unit test when using realpath 2017-11-15 14:37:42 +00:00
Sebastian Reitenbach
e50eb64614 do not use unportable readlink utility to find the java_default_home,
use Ruby in a more portable fashion.

adapt tests as well
2017-11-15 14:37:42 +00:00
Sebastian Reitenbach
bdfc567c18 OpenBSD doesn't have /etc/environment, therefore there is no
need to fiddle with it. The default case statement, "do nothing"
is all fine here.

Facter::Util::Resolution.with_env is long time gone since
Facter > 2.x. That was even longer before introduced by me.
Remove that OpenBSD special case in the java_version fact,
and assume that $PATH is properly set in order to find
the 'java' binary.

Additionally confine the java_default_home and java_libjvm_path
to OpenBSD kernel as well. Add some flesh to the java_default_home
fact to allow it to find the java binary.
2017-11-15 14:37:42 +00:00
Michael Baker
db30eb9e2d Adding support for Ubuntu (#243)
* Translate amd64

* Fix the path creation on exec
2017-11-15 14:36:10 +00:00
Paula McMaw
d49c1f0e29 Merge pull request #264 from puppetlabs/release
2.1.1 Release Mergeback
2017-11-09 13:48:10 +00:00
Eric Putnam
336a0e2e1a Merge pull request #263 from pmcmaw/paulaTesting
(FM-6503) - Release Prep for 2.2.1
2017-11-08 09:25:50 -08:00
Paula McMaw
6592edd454 (FM-6503) - Release Prep for 2.2.1 2017-11-06 15:35:10 +00:00
Helen
e6e961e7fc Merge pull request #261 from bastelfreak/bumparchivebmjenplsmerge
allow latest archive version as dependency
2017-10-09 17:51:01 +01:00
Tim Meusel
2b2e639531 allow latest archive version as dependency 2017-10-09 18:30:09 +02:00
TP Honey
5f820fe8bd Merge pull request #257 from shuebnersr/fact1754_java_version_fails_when_JAVA_TOOL_OPTIONS_is_used
(FACT-1754) search for matching line with java version
2017-10-02 12:41:05 +01:00
shuebnersr
b7bdf96252 Fixed search for matching line with java version
Use value of variable instead of return statement
Extended unit test for checking handling of JAVA_TOOL_OPTIONS
2017-10-01 15:15:01 +02:00
TP Honey
231db77fe7 Merge pull request #203 from vrtdev/bugfix/override_package_alt_home
#MODULES-4069: Fail when required params are not available in params.
2017-09-26 14:02:45 +01:00
TP Honey
cb7105f4a2 Merge pull request #258 from shuebnersr/fact1760_test_for_java_version_when_java_not_installed
Fact1760 test for java version when java not installed
2017-09-26 14:00:12 +01:00
Jan Vansteenkiste
c40b061d97 (MODULES-4069) Fail when required params are not available in params.
When overriding all values required for the java setup, there is
no need to fail if params.pp does not support the package.
2017-09-26 07:37:41 +02:00
shuebnersr
18bd3fcb86 Merge pull request #2 from shuebnersr/fact1760_test_for_java_version_when_java_not_installed
Fact1760 test for java version when java not installed
2017-09-22 12:00:35 +02:00
shuebnersr
578eb951ea fix java_version test for other systems
mock Facter::Util::Resolution.which('java') for the "other systems" test; before it was not mocked and was based on Java being installed on the test system or not
2017-09-22 11:50:41 +02:00
shuebnersr
318f8864fd Merge pull request #1 from puppetlabs/master
sync
2017-09-22 11:39:28 +02:00
TP Honey
62f054649a Merge pull request #256 from puppetlabs/msync_18sep17_892c4cf
(maint) modulesync 892c4cf
2017-09-21 13:52:59 +01:00
shuebnersr
d89532435d search for matching line with java version
do not just try to read java version from first line, but search for the matching line from java output
2017-09-20 14:26:04 +02:00
Hailee Kenney
6397c0870b (maint) modulesync 892c4cf 2017-09-18 14:56:13 -07:00
Paula McMaw
e4888a507e Merge pull request #255 from Andor/master
Support for Ubuntu 17.04 Zesty Zapus
2017-09-08 11:41:23 +01:00
Andrew N Golovkov
525016ec02 Support for Ubuntu 17.04 Zesty Zapus 2017-09-06 20:44:48 +03:00
Helen
c5005d9cc1 Merge pull request #254 from pmcmaw/rm_debian6
Removing Debian 6
2017-08-31 11:30:33 +01:00
Paula McMaw
7f8bb518f0 Removing Debian 6
According to the followin page Debian 6 is no longer supported as an
Agent. https://docs.puppet.com/pe/latest/sys_req_os.html
2017-08-31 11:20:41 +01:00
TP Honey
771a3a6702 Merge pull request #253 from pmcmaw/rm_ubuntu
(MODULES-5501) - Remove unsupported Ubuntu
2017-08-17 16:00:54 +01:00
Paula McMaw
c74f533e0b (MODULES-5501) - Remove unsupported Ubuntu
Removing older version of Ubuntu that are not supported by the module.
2017-08-17 14:08:56 +01:00
Shaleen Gupta
43aa9af1b2 Add support for CloudLinux (#251)
Fix the fail "unsupported os CloudlLinux".
2017-08-01 13:30:38 +01:00
Paula McMaw
cceb78b7fe Merge pull request #252 from puppetlabs/maint-modsync-915cde70e20
(maint) modulesync 915cde70e20
2017-07-28 11:34:12 +01:00
Glenn Sarti
b50e762f1c (maint) modulesync 915cde70e20 2017-07-27 15:00:09 -07:00
Hunter Haugen
e9c50332bd Merge pull request #249 from puppetlabs/msync_modules5187
(MODULES-5187) msync puppet 5 and ruby 2.4
2017-07-10 14:51:42 -07:00
Eric Putnam
795b92a81d (MODULES-5187) mysnc puppet 5 and ruby 2.4 2017-07-06 14:41:47 -07:00
Glenn Sarti
31799ce4e7 Merge pull request #247 from hunner/bump_metadata
(MODULES-5144) Prep for puppet 5
2017-06-26 22:31:31 -07:00
Hunter Haugen
2829b75e83 (MODULES-5144) Prep for puppet 5 2017-06-26 14:12:02 -07:00
Bryan Jen
0ea0b663fa Merge pull request #246 from puppetlabs/release
2.1.0 mergeback
2017-06-22 16:30:00 -07:00
Hunter Haugen
6bbaacdb39 Merge pull request #244 from kBite/add-support-for-arch-linux
Add support for Archlinux
2017-06-21 14:29:25 -07:00
Kilian Engelhardt
6951263d4c fix indentation and remove a white line 2017-06-21 11:26:24 +02:00
Kilian Engelhardt
0bcdd2bc2f add basic arch linux support 2017-06-21 10:59:39 +02:00
Paula McMaw
8763d0b388 Merge pull request #239 from puppetlabs/revert-238-release
Revert "Release Mergeback 2.1.0"
2017-06-15 11:20:16 +01:00
Helen
184c745e82 Revert "Release Mergeback 2.1.0" 2017-06-15 11:03:44 +01:00
17 changed files with 423 additions and 192 deletions

View File

@@ -22,10 +22,10 @@ matrix:
script: bundle exec rake beaker script: bundle exec rake beaker
services: docker services: docker
sudo: required sudo: required
- rvm: 2.3.1 - rvm: 2.4.0
bundler_args: --without system_tests bundler_args: --without system_tests
env: PUPPET_GEM_VERSION="~> 4.0" env: PUPPET_GEM_VERSION="~> 5.0"
- rvm: 2.1.7 - rvm: 2.1.9
bundler_args: --without system_tests bundler_args: --without system_tests
env: PUPPET_GEM_VERSION="~> 4.0" env: PUPPET_GEM_VERSION="~> 4.0"
notifications: notifications:

View File

@@ -1,14 +1,41 @@
## Supported Release [2.2.0]
### Summary
This release is a maintenance release that includes a roll up of minor changes.
#### Added
- Addition of Ubuntu for Oracle Java.
- Addition of Debian 9 in supported versions.
- Addition of OpenBSD case and use `realpath` rather than `readlink` in Java Default Home Facter fact.
#### Removed
- Removal of OpenBSD as a special case and deprecated `with_env` in Java Version Facter Facter fact.
## Supported Release 2.1.1
### Summary
This release is a maintenance release that includes a roll up of minor changes.
#### Added
- Basic Arch Linux, Cloud Linux and Ubuntu 17.04 compatibility.
- Metadata bump for Puppet 5.
- Search for matching line with java version.
- ([MODULES-4069](https://tickets.puppet.com/browse/MODULES-4069)) Fail when required params are not available in params.
- A test for java version when java not installed.
- Allow latest archive version as dependency.
#### Changed
- CONTRIBUTING.md document includes updates.
- Removal of Ubuntu 10.04 ad 12.04, Debian 6 in supported versions.
## Supported Release 2.1.0 ## Supported Release 2.1.0
### Summary ### Summary
This release adds fixes to restore the ability to install Oracle Java. It also This release adds fixes to restore the ability to install Oracle Java. It also fixes the paths for the latest RHEL 7 1.7.0 and 1.8.0 OpenJDKs.
fixes the paths for the latest RHEL 7 1.7.0 and 1.8.0 OpenJDKs.
### Added ### Added
- java::oracle parameter `url` - java::oracle parameter `url`
- java::oracle parameter `url_hash` - java::oracle parameter `url_hash`
### Fixed ### Fixed
- Let `java_default_home` fact work when /usr/bin/java doesn't exist - Let `java_default_home` fact work when /usr/bin/java does not exist
- Add puppet 4 parameter types - Add puppet 4 parameter types
- Use `/usr/lib/jvm/java-1.x.0` symlinks for `java_home` defaults. - Use `/usr/lib/jvm/java-1.x.0` symlinks for `java_home` defaults.
@@ -127,7 +154,7 @@ This release adds 3 new facts for determining Java version, adds RHEL alternativ
## 2014-11-11 - Supported Version 1.2.0 ## 2014-11-11 - Supported Version 1.2.0
### Summary: ### Summary:
This release adds SLES 12 support and is tested for Future Parser Support This release adds SLES 12 support and is tested for Future Parser Support
#### Bugfixes: #### Bugfixes:
@@ -141,7 +168,7 @@ This release adds SLES 12 support and is tested for Future Parser Support
## 2014-08-25 - Supported Version 1.1.2 ## 2014-08-25 - Supported Version 1.1.2
### Summary: ### Summary:
This release begins the support coverage of the puppetlabs-java module. This release begins the support coverage of the puppetlabs-java module.
### Bugfixes: ### Bugfixes:
@@ -214,11 +241,11 @@ Scott Schneider <sschneider@puppetlabs.com>
* Add Solaris support * Add Solaris support
## 2011-06-16 - Version 0.1.5 ## 2011-06-16 - Version 0.1.5
Jeff McCune <jeff@puppetlabs.com> Jeff McCune <jeff@puppetlabs.com>
* Add Debian based distro (Lucid) support * Add Debian based distro (Lucid) support
## 2011-06-02 - Version 0.1.4 ## 2011-06-02 - Version 0.1.4
Jeff McCune <jeff@puppetlabs.com> Jeff McCune <jeff@puppetlabs.com>
* Fix class composition ordering problems * Fix class composition ordering problems
## 2011-05-28 - Version 0.1.3 ## 2011-05-28 - Version 0.1.3
@@ -235,9 +262,11 @@ Jeff McCune <jeff@puppetlabs.com>
* Add validation of class parameters * Add validation of class parameters
## 2011-05-24 - Version 0.1.0 ## 2011-05-24 - Version 0.1.0
Jeff McCune <jeff@puppetlabs.com> Jeff McCune <jeff@puppetlabs.com>
* Default to JDK version 6u25 * Default to JDK version 6u25
## 2011-05-24 - Version 0.0.1 ## 2011-05-24 - Version 0.0.1
Jeff McCune <jeff@puppetlabs.com> Jeff McCune <jeff@puppetlabs.com>
* Initial release * Initial release
[2.2.0]:https://github.com/puppetlabs/puppetlabs-java/compare/2.1.1...2.2.0

View File

@@ -1,63 +1,75 @@
Checklist (and a short version for the impatient) # Contributing to Puppet modules
=================================================
* Commits: So you want to contribute to a Puppet module: Great! Below are some instructions to get you started doing
that very thing while setting expectations around code quality as well as a few tips for making the
process as easy as possible.
- Make commits of logical units. ### Table of Contents
- Check for unnecessary whitespace with "git diff --check" before 1. [Getting Started](#getting-started)
committing. 1. [Commit Checklist](#commit-checklist)
1. [Submission](#submission)
1. [More about commits](#more-about-commits)
1. [Testing](#testing)
- [Running Tests](#running-tests)
- [Writing Tests](#writing-tests)
1. [Get Help](#get-help)
- Commit using Unix line endings (check the settings around "crlf" in ## Getting Started
git-config(1)).
- Do not check in commented out code or unneeded files. - Fork the module repository on GitHub and clone to your workspace
- The first line of the commit message should be a short - Make your changes!
description (50 characters is the soft limit, excluding ticket
number(s)), and should skip the full stop.
- Associate the issue in the message. The first line should include ## Commit Checklist
the issue number in the form "(#XXXX) Rest of message".
- The body should provide a meaningful commit message, which: ### The Basics
- uses the imperative, present tense: "change", not "changed" or - [x] my commit is a single logical unit of work
"changes".
- includes motivation for the change, and contrasts its - [x] I have checked for unnecessary whitespace with "git diff --check"
implementation with the previous behavior.
- Make sure that you have tests for the bug you are fixing, or - [x] my commit does not include commented out code or unneeded files
feature you are adding.
- Make sure the test suites passes after your commit: ### The Content
`bundle exec rspec spec/acceptance` More information on [testing](#Testing) below
- When introducing a new feature, make sure it is properly - [x] my commit includes tests for the bug I fixed or feature I added
documented in the README.md
* Submission: - [x] my commit includes appropriate documentation changes if it is introducing a new feature or changing existing functionality
- [x] my code passes existing test suites
* Pre-requisites: ### The Commit Message
- Make sure you have a [GitHub account](https://github.com/join) - [x] the first line of my commit message includes:
- [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for. - [x] an issue number (if applicable), e.g. "(MODULES-xxxx) This is the first line"
- [x] a short description (50 characters is the soft limit, excluding ticket number(s))
* Preferred method: - [x] the body of my commit message:
- Fork the repository on GitHub. - [x] is meaningful
- Push your changes to a topic branch in your fork of the - [x] uses the imperative, present tense: "change", not "changed" or "changes"
repository. (the format ticket/1234-short_description_of_change is
usually preferred for this project).
- Submit a pull request to the repository in the puppetlabs - [x] includes motivation for the change, and contrasts its implementation with the previous behavior
organization.
The long version ## Submission
================
### Pre-requisites
- Make sure you have a [GitHub account](https://github.com/join)
- [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for.
### Push and PR
- Push your changes to your fork
- [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) against the repository in the puppetlabs organization
## More about commits
1. Make separate commits for logically separate changes. 1. Make separate commits for logically separate changes.
@@ -104,37 +116,32 @@ The long version
GitHub has some pretty good GitHub has some pretty good
[general documentation](http://help.github.com/) on using [general documentation](http://help.github.com/) on using
their site. They also have documentation on their site. They also have documentation on
[creating pull requests](http://help.github.com/send-pull-requests/). [creating pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
In general, after pushing your topic branch up to your In general, after pushing your topic branch up to your
repository on GitHub, you can switch to the branch in the repository on GitHub, you can switch to the branch in the
GitHub UI and click "Pull Request" towards the top of the page GitHub UI and click "Pull Request" towards the top of the page
in order to open a pull request. in order to open a pull request.
3. Update the related JIRA issue.
3. Update the related GitHub issue. If there is a JIRA issue associated with the change you
If there is a GitHub issue associated with the change you
submitted, then you should update the ticket to include the submitted, then you should update the ticket to include the
location of your branch, along with any other commentary you location of your branch, along with any other commentary you
may wish to make. may wish to make.
Testing # Testing
=======
Getting Started ## Getting Started
---------------
Our puppet modules provide [`Gemfile`](./Gemfile)s which can tell a ruby Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages,
package manager such as [bundler](http://bundler.io/) what Ruby packages,
or Gems, are required to build, develop, and test this software. or Gems, are required to build, develop, and test this software.
Please make sure you have [bundler installed](http://bundler.io/#getting-started) Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to
on your system, then use it to install all dependencies needed for this project, install all dependencies needed for this project in the project root by running
by running
```shell ```shell
% bundle install % bundle install --path .bundle/gems
Fetching gem metadata from https://rubygems.org/........ Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.. Fetching gem metadata from https://rubygems.org/..
Using rake (10.1.0) Using rake (10.1.0)
@@ -148,7 +155,7 @@ Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed. Use `bundle show [gemname]` to see where a bundled gem is installed.
``` ```
NOTE some systems may require you to run this command with sudo. NOTE: some systems may require you to run this command with sudo.
If you already have those gems installed, make sure they are up-to-date: If you already have those gems installed, make sure they are up-to-date:
@@ -156,26 +163,27 @@ If you already have those gems installed, make sure they are up-to-date:
% bundle update % bundle update
``` ```
With all dependencies in place and up-to-date we can now run the tests: ## Running Tests
With all dependencies in place and up-to-date, run the tests:
### Unit Tests
```shell ```shell
% bundle exec rake spec % bundle exec rake spec
``` ```
This will execute all the [rspec tests](http://rspec-puppet.com/) tests This executes all the [rspec tests](http://rspec-puppet.com/) in the directories defined [here](https://github.com/puppetlabs/puppetlabs_spec_helper/blob/699d9fbca1d2489bff1736bb254bb7b7edb32c74/lib/puppetlabs_spec_helper/rake_tasks.rb#L17) and so on.
under [spec/defines](./spec/defines), [spec/classes](./spec/classes), rspec tests may have the same kind of dependencies as the module they are testing. Although the module defines these dependencies in its [metadata.json](./metadata.json),
and so on. rspec tests may have the same kind of dependencies as the
module they are testing. While the module defines in its [Modulefile](./Modulefile),
rspec tests define them in [.fixtures.yml](./fixtures.yml). rspec tests define them in [.fixtures.yml](./fixtures.yml).
Some puppet modules also come with [beaker](https://github.com/puppetlabs/beaker) ### Acceptance Tests
tests. These tests spin up a virtual machine under
[VirtualBox](https://www.virtualbox.org/)) with, controlling it with
[Vagrant](http://www.vagrantup.com/) to actually simulate scripted test
scenarios. In order to run these, you will need both of those tools
installed on your system.
You can run them by issuing the following command Some Puppet modules also come with acceptance tests, which use [beaker][]. These tests spin up a virtual machine under
[VirtualBox](https://www.virtualbox.org/), controlled with [Vagrant](http://www.vagrantup.com/), to simulate scripted test
scenarios. In order to run these, you need both Virtualbox and Vagrant installed on your system.
Run the tests by issuing the following command
```shell ```shell
% bundle exec rake spec_clean % bundle exec rake spec_clean
@@ -183,35 +191,81 @@ You can run them by issuing the following command
``` ```
This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml), This will now download a pre-fabricated image configured in the [default node-set](./spec/acceptance/nodesets/default.yml),
install puppet, copy this module and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb) install Puppet, copy this module, and install its dependencies per [spec/spec_helper_acceptance.rb](./spec/spec_helper_acceptance.rb)
and then run all the tests under [spec/acceptance](./spec/acceptance). and then run all the tests under [spec/acceptance](./spec/acceptance).
Writing Tests ## Writing Tests
-------------
XXX getting started writing tests. ### Unit Tests
If you have commit access to the repository When writing unit tests for Puppet, [rspec-puppet][] is your best friend. It provides tons of helper methods for testing your manifests against a
=========================================== catalog (e.g. contain_file, contain_package, with_params, etc). It would be ridiculous to try and top rspec-puppet's [documentation][rspec-puppet_docs]
but here's a tiny sample:
Even if you have commit access to the repository, you will still need to Sample manifest:
go through the process above, and have someone else review and merge
in your changes. The rule is that all changes must be reviewed by a
developer on the project (that did not write the code) to ensure that
all changes go through a code review process.
Having someone other than the author of the topic branch recorded as ```puppet
performing the merge is the record that they performed the code file { "a test file":
review. ensure => present,
path => "/etc/sample",
}
```
Sample test:
Additional Resources ```ruby
==================== it 'does a thing' do
expect(subject).to contain_file("a test file").with({:path => "/etc/sample"})
end
```
* [Getting additional help](http://puppet.com/community/get-help) ### Acceptance Tests
Writing acceptance tests for Puppet involves [beaker][] and its cousin [beaker-rspec][]. A common pattern for acceptance tests is to create a test manifest, apply it
twice to check for idempotency or errors, then run expectations.
```ruby
it 'does an end-to-end thing' do
pp = <<-EOF
file { 'a test file':
ensure => present,
path => "/etc/sample",
content => "test string",
}
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("/etc/sample") do
it { is_expected.to contain "test string" }
end
```
# If you have commit access to the repository
Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge
in your changes. The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that
all changes go through a code review process.**
The record of someone performing the merge is the record that they performed the code review. Again, this should be someone other than the author of the topic branch.
# Get Help
### On the web
* [Puppet help messageboard](http://puppet.com/community/get-help)
* [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing) * [Writing tests](https://docs.puppet.com/guides/module_guides/bgtm.html#step-three-module-testing)
* [General GitHub documentation](http://help.github.com/) * [General GitHub documentation](http://help.github.com/)
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
### On chat
* Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli
* IRC (freenode) #puppet-dev, #voxpupuli
[rspec-puppet]: http://rspec-puppet.com/
[rspec-puppet_docs]: http://rspec-puppet.com/documentation/
[beaker]: https://github.com/puppetlabs/beaker
[beaker-rspec]: https://github.com/puppetlabs/beaker-rspec

15
Gemfile
View File

@@ -33,13 +33,13 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}" minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}"
group :development do group :development do
gem "puppet-module-posix-default-r#{minor_version}", :require => false, :platforms => "ruby" gem "puppet-module-posix-default-r#{minor_version}", :require => false, :platforms => "ruby"
gem "puppet-module-win-default-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] gem "puppet-module-win-default-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
gem "puppet-module-posix-dev-r#{minor_version}", :require => false, :platforms => "ruby" gem "puppet-module-posix-dev-r#{minor_version}", :require => false, :platforms => "ruby"
gem "puppet-module-win-dev-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] gem "puppet-module-win-dev-r#{minor_version}", '0.0.7', :require => false, :platforms => ["mswin", "mingw", "x64_mingw"]
gem "json_pure", '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') gem "json_pure", '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
gem "fast_gettext", '1.1.0', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') gem "fast_gettext", '1.1.0', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
gem "fast_gettext", :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') gem "fast_gettext", :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
end end
group :system_tests do group :system_tests do
@@ -50,6 +50,7 @@ group :system_tests do
gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION']) gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION'])
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'])
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')
gem "puppet-blacksmith", '~> 3.4', :require => false
end end
gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'])

View File

@@ -3,24 +3,25 @@
# Purpose: get absolute path of java system home # Purpose: get absolute path of java system home
# #
# Resolution: # Resolution:
# Uses `readlink` to resolve the path of `/usr/bin/java` then returns subsubdir # Find the real java binary, and return the subsubdir
# #
# Caveats: # Caveats:
# Requires readlink # java binary has to be found in $PATH
# #
# Notes: # Notes:
# None # None
Facter.add(:java_default_home) do Facter.add(:java_default_home) do
confine :kernel => 'Linux' confine :kernel => [ 'Linux', 'OpenBSD' ]
setcode do setcode do
if Facter::Util::Resolution.which('readlink') java_bin = Facter::Util::Resolution.which('java').to_s.strip
java_bin = Facter::Util::Resolution.exec('readlink -e /usr/bin/java').strip if java_bin.empty?
if java_bin.empty? nil
nil else
elsif java_bin =~ %r(/jre/) java_path = File.realpath(java_bin)
java_default_home = File.dirname(File.dirname(File.dirname(java_bin))) if java_path =~ %r(/jre/)
java_default_home = File.dirname(File.dirname(File.dirname(java_path)))
else else
java_default_home = File.dirname(File.dirname(java_bin)) java_default_home = File.dirname(File.dirname(java_path))
end end
end end
end end

View File

@@ -11,7 +11,7 @@
# Notes: # Notes:
# None # None
Facter.add(:java_libjvm_path) do Facter.add(:java_libjvm_path) do
confine :kernel => "Linux" confine :kernel => [ "Linux", "OpenBSD" ]
setcode do setcode do
java_default_home = Facter.value(:java_default_home) java_default_home = Facter.value(:java_default_home)
java_libjvm_file = Dir.glob("#{java_default_home}/jre/lib/**/libjvm.so") java_libjvm_file = Dir.glob("#{java_default_home}/jre/lib/**/libjvm.so")

View File

@@ -21,22 +21,12 @@ Facter.add(:java_version) do
# Additionally, facter versions prior to 2.0.1 only support # Additionally, facter versions prior to 2.0.1 only support
# positive matches, so this needs to be done manually in setcode. # positive matches, so this needs to be done manually in setcode.
setcode do setcode do
unless [ 'openbsd', 'darwin' ].include? Facter.value(:operatingsystem).downcase unless [ 'darwin' ].include? Facter.value(:operatingsystem).downcase
version = nil
if Facter::Util::Resolution.which('java') if Facter::Util::Resolution.which('java')
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.first.split(/"/)[1].strip Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $~[1] if /^.+ version \"(.+)\"$/ =~ line }
end
end
end
end
Facter.add(:java_version) do
confine :operatingsystem => 'OpenBSD'
has_weight 100
setcode do
Facter::Util::Resolution.with_env("PATH" => '/usr/local/jdk-1.7.0/jre/bin:/usr/local/jre-1.7.0/bin') do
if Facter::Util::Resolution.which('java')
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.first.split(/"/)[1].strip
end end
version
end end
end end
end end
@@ -46,7 +36,9 @@ Facter.add(:java_version) do
has_weight 100 has_weight 100
setcode do setcode do
unless /Unable to find any JVMs matching version/ =~ Facter::Util::Resolution.exec('/usr/libexec/java_home --failfast 2>&1') unless /Unable to find any JVMs matching version/ =~ Facter::Util::Resolution.exec('/usr/libexec/java_home --failfast 2>&1')
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.first.split(/"/)[1].strip version = nil
Facter::Util::Resolution.exec('java -Xmx12m -version 2>&1').lines.each { |line| version = $~[1] if /^.+ version \"(.+)\"$/ =~ line }
version
end end
end end
end end

View File

@@ -22,4 +22,5 @@ gettext:
# Patterns for +Dir.glob+ used to find all files that might contain # Patterns for +Dir.glob+ used to find all files that might contain
# translatable content, relative to the project root directory # translatable content, relative to the project root directory
source_files: source_files:
- './lib/**/*.rb'

View File

@@ -44,7 +44,7 @@ class java::config ( ) {
} }
} }
} }
'OpenBSD', 'FreeBSD', 'Suse': { 'FreeBSD', 'Suse': {
if $java::use_java_home != undef { if $java::use_java_home != undef {
file_line { 'java-home-environment': file_line { 'java-home-environment':
path => '/etc/environment', path => '/etc/environment',
@@ -62,6 +62,15 @@ class java::config ( ) {
} }
} }
} }
'Archlinux': {
if $java::use_java_home != undef {
file_line { 'java-home-environment':
path => '/etc/profile',
line => "JAVA_HOME=${$java::use_java_home}",
match => 'JAVA_HOME=',
}
}
}
default: { default: {
# Do nothing. # Do nothing.
} }

View File

@@ -9,7 +9,6 @@
# or other platform-specific options where there are multiple # or other platform-specific options where there are multiple
# implementations available (eg: OpenJDK vs Oracle JDK). # implementations available (eg: OpenJDK vs Oracle JDK).
# #
#
# [*version*] # [*version*]
# The version of java to install. By default, this module simply ensures # The version of java to install. By default, this module simply ensures
# that java is present, and does not require a specific version. # that java is present, and does not require a specific version.
@@ -36,8 +35,8 @@
# correct JVM is enabled. # correct JVM is enabled.
# #
# [*java_home*] # [*java_home*]
# The path to where the JRE is installed. This will be set as an # The path to where the JRE is installed. This will be set as an
# environment variable. # environment variable.
# #
# Actions: # Actions:
# #
@@ -54,15 +53,11 @@ class java(
Optional[String] $java_alternative_path = undef, Optional[String] $java_alternative_path = undef,
Optional[String] $java_home = undef Optional[String] $java_home = undef
) { ) {
include java::params include ::java::params
if has_key($java::params::java, $distribution) { $default_package_name = has_key($java::params::java, $distribution) ? {
$default_package_name = $java::params::java[$distribution]['package'] false => undef,
$default_alternative = $java::params::java[$distribution]['alternative'] default => $java::params::java[$distribution]['package'],
$default_alternative_path = $java::params::java[$distribution]['alternative_path']
$default_java_home = $java::params::java[$distribution]['java_home']
} else {
fail("Java distribution ${distribution} is not supported.")
} }
$use_java_package_name = $package ? { $use_java_package_name = $package ? {
@@ -70,12 +65,17 @@ class java(
default => $package, default => $package,
} }
## Weird logic........
## If $java_alternative is set, use that. ## If $java_alternative is set, use that.
## Elsif the DEFAULT package is being used, then use $default_alternative. ## Elsif the DEFAULT package is being used, then use $default_alternative.
## Else undef ## Else undef
$use_java_alternative = $java_alternative ? { $use_java_alternative = $java_alternative ? {
undef => $use_java_package_name ? { undef => $use_java_package_name ? {
$default_package_name => $default_alternative, $default_package_name => has_key($java::params::java, $distribution) ? {
default => $java::params::java[$distribution]['alternative'],
false => undef,
},
default => undef, default => undef,
}, },
default => $java_alternative, default => $java_alternative,
@@ -83,21 +83,38 @@ class java(
## Same logic as $java_alternative above. ## Same logic as $java_alternative above.
$use_java_alternative_path = $java_alternative_path ? { $use_java_alternative_path = $java_alternative_path ? {
undef => $use_java_package_name ? { undef => $use_java_package_name ? {
$default_package_name => $default_alternative_path, $default_package_name => has_key($java::params::java, $distribution) ? {
default => $java::params::java[$distribution]['alternative_path'],
false => undef,
},
default => undef, default => undef,
}, },
default => $java_alternative_path, default => $java_alternative_path,
} }
$use_java_home = $java_home ? { $use_java_home = $java_home ? {
undef => $use_java_package_name ? { undef => $use_java_package_name ? {
$default_package_name => $default_java_home, $default_package_name => has_key($java::params::java, $distribution) ? {
default => $java::params::java[$distribution]['java_home'],
false => undef,
},
default => undef, default => undef,
}, },
default => $java_home, default => $java_home,
} }
## This should only be required if we did not override all the information we need.
# One of the defaults is missing and its not intentional:
if ((
$use_java_package_name == undef or $use_java_alternative == undef or
$use_java_alternative_path == undef or $use_java_home == undef
) and (
! has_key($::java::params::java, $distribution)
)) {
fail("Java distribution ${distribution} is not supported. Missing default values.")
}
$jre_flag = $use_java_package_name ? { $jre_flag = $use_java_package_name ? {
/headless/ => '--jre-headless', /headless/ => '--jre-headless',
default => '--jre' default => '--jre'

View File

@@ -166,6 +166,11 @@ define java::oracle (
} else { } else {
$package_type = 'rpm' $package_type = 'rpm'
} }
$creates_path = "/usr/java/${install_path}"
}
'Debian' : {
$package_type = 'tar.gz'
$creates_path = "/usr/lib/jvm/${install_path}"
} }
default : { default : {
fail ("unsupported platform ${$facts['os']['name']}") } fail ("unsupported platform ${$facts['os']['name']}") }
@@ -173,7 +178,6 @@ define java::oracle (
$os = 'linux' $os = 'linux'
$destination_dir = '/tmp/' $destination_dir = '/tmp/'
$creates_path = "/usr/java/${install_path}"
} }
default : { default : {
fail ( "unsupported platform ${$facts['kernel']}" ) } fail ( "unsupported platform ${$facts['kernel']}" ) }
@@ -183,6 +187,7 @@ define java::oracle (
case $facts['os']['architecture'] { case $facts['os']['architecture'] {
'i386' : { $arch = 'i586' } 'i386' : { $arch = 'i586' }
'x86_64' : { $arch = 'x64' } 'x86_64' : { $arch = 'x64' }
'amd64' : { $arch = 'x64' }
default : { default : {
fail ("unsupported platform ${$facts['os']['architecture']}") fail ("unsupported platform ${$facts['os']['architecture']}")
} }
@@ -205,6 +210,9 @@ define java::oracle (
'rpm' : { 'rpm' : {
$package_name = "${java_se}-${release_major}-${os}-${arch}.rpm" $package_name = "${java_se}-${release_major}-${os}-${arch}.rpm"
} }
'tar.gz' : {
$package_name = "${java_se}-${release_major}-${os}-${arch}.tar.gz"
}
default : { default : {
$package_name = "${java_se}-${release_major}-${os}-${arch}.rpm" $package_name = "${java_se}-${release_major}-${os}-${arch}.rpm"
} }
@@ -213,9 +221,11 @@ define java::oracle (
# if complete URL is provided, use this value for source in archive resource # if complete URL is provided, use this value for source in archive resource
if $url { if $url {
$source = $url $source = $url
} elsif $release_hash != undef { }
elsif $release_hash != undef {
$source = "${oracle_url}/${release_major}-${release_minor}/${release_hash}/${package_name}" $source = "${oracle_url}/${release_major}-${release_minor}/${release_hash}/${package_name}"
} else { }
else {
$source = "${oracle_url}/${release_major}-${release_minor}/${package_name}" $source = "${oracle_url}/${release_major}-${release_minor}/${package_name}"
} }
@@ -233,6 +243,9 @@ define java::oracle (
'rpm' : { 'rpm' : {
$install_command = "rpm --force -iv ${destination}" $install_command = "rpm --force -iv ${destination}"
} }
'tar.gz' : {
$install_command = "tar -zxf ${destination} -C /usr/lib/jvm"
}
default : { default : {
$install_command = "rpm -iv ${destination}" $install_command = "rpm -iv ${destination}"
} }
@@ -256,7 +269,16 @@ define java::oracle (
path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin', path => '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin',
command => $install_command, command => $install_command,
creates => $creates_path, creates => $creates_path,
require => Archive[$destination], require => Archive[$destination]
}
case $facts['os']['family'] {
'Debian' : {
file{'/usr/lib/jvm':
ensure => directory,
before => Exec["Install Oracle java_se ${java_se} ${version}"]
}
}
default : { }
} }
} }
default : { default : {

View File

@@ -15,7 +15,7 @@ class java::params {
case $::osfamily { case $::osfamily {
'RedHat': { 'RedHat': {
case $::operatingsystem { case $::operatingsystem {
'RedHat', 'CentOS', 'OracleLinux', 'Scientific', 'OEL', 'SLC': { 'RedHat', 'CentOS', 'OracleLinux', 'Scientific', 'OEL', 'SLC', 'CloudLinux': {
if (versioncmp($::operatingsystemrelease, '5.0') < 0) { if (versioncmp($::operatingsystemrelease, '5.0') < 0) {
$jdk_package = 'java-1.6.0-sun-devel' $jdk_package = 'java-1.6.0-sun-devel'
$jre_package = 'java-1.6.0-sun' $jre_package = 'java-1.6.0-sun'
@@ -155,7 +155,7 @@ class java::params {
}, },
} }
} }
'stretch', 'vivid', 'wily', 'xenial', 'yakkety': { 'stretch', 'vivid', 'wily', 'xenial', 'yakkety', 'zesty': {
$java = { $java = {
'jdk' => { 'jdk' => {
'package' => 'openjdk-8-jdk', 'package' => 'openjdk-8-jdk',
@@ -253,6 +253,21 @@ class java::params {
}, },
} }
} }
'Archlinux': {
$jdk_package = 'jdk8-openjdk'
$jre_package = 'jre8-openjdk'
$java_home = '/usr/lib/jvm/java-8-openjdk/jre/'
$java = {
'jdk' => {
'package' => $jdk_package,
'java_home' => $java_home,
},
'jre' => {
'package' => $jre_package,
'java_home' => $java_home,
},
}
}
default: { fail("unsupported platform ${::osfamily}") } default: { fail("unsupported platform ${::osfamily}") }
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "puppetlabs-java", "name": "puppetlabs-java",
"version": "2.1.0", "version": "2.2.0",
"author": "puppetlabs", "author": "puppetlabs",
"summary": "Installs the correct Java package on various platforms.", "summary": "Installs the correct Java package on various platforms.",
"license": "Apache-2.0", "license": "Apache-2.0",
@@ -49,16 +49,14 @@
{ {
"operatingsystem": "Debian", "operatingsystem": "Debian",
"operatingsystemrelease": [ "operatingsystemrelease": [
"6",
"7", "7",
"8" "8",
"9"
] ]
}, },
{ {
"operatingsystem": "Ubuntu", "operatingsystem": "Ubuntu",
"operatingsystemrelease": [ "operatingsystemrelease": [
"10.04",
"12.04",
"14.04", "14.04",
"16.04" "16.04"
] ]
@@ -85,7 +83,7 @@
"requirements": [ "requirements": [
{ {
"name": "puppet", "name": "puppet",
"version_requirement": ">= 4.7.0 < 5.0.0" "version_requirement": ">= 4.7.0 < 6.0.0"
} }
], ],
"dependencies": [ "dependencies": [
@@ -95,7 +93,7 @@
}, },
{ {
"name":"puppet/archive", "name":"puppet/archive",
"version_requirement": ">= 1.1.0 < 2.0.0" "version_requirement": ">= 1.1.0 < 3.0.0"
} }
] ]
} }

View File

@@ -236,7 +236,7 @@ describe 'java', :type => :class do
context 'select jdk for OpenBSD' do context 'select jdk for OpenBSD' do
let(:facts) { {:osfamily => 'OpenBSD', :architecture => 'x86_64'} } let(:facts) { {:osfamily => 'OpenBSD', :architecture => 'x86_64'} }
it { is_expected.to contain_package('java').with_name('jdk') } it { is_expected.to contain_package('java').with_name('jdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/usr/local/jdk/') } it { is_expected.to_not contain_file_line('java-home-environment') }
end end
context 'select jre for OpenBSD' do context 'select jre for OpenBSD' do
@@ -245,6 +245,34 @@ describe 'java', :type => :class do
it { is_expected.to contain_package('java').with_name('jre') } it { is_expected.to contain_package('java').with_name('jre') }
end end
describe 'custom java package' do
let(:facts) { {:osfamily => 'Debian', :operatingsystem => 'Debian', :lsbdistcodename => 'jessie', :operatingsystemrelease => '8.6', :architecture => 'amd64',} }
context 'all params provided' do
let(:params) { {
'distribution' => 'custom',
'package' => 'custom_jdk',
'java_alternative' => 'java-custom_jdk',
'java_alternative_path' => '/opt/custom_jdk/bin/java',
'java_home' => '/opt/custom_jdk',
} }
it { is_expected.to contain_package('java').with_name('custom_jdk') }
it { is_expected.to contain_file_line('java-home-environment').with_line('JAVA_HOME=/opt/custom_jdk') }
it { is_expected.to contain_exec('update-java-alternatives').with_command('update-java-alternatives --set java-custom_jdk --jre') }
end
context 'missing parameters' do
let(:params) { {
'distribution' => 'custom',
'package' => 'custom_jdk',
} }
it do
expect { catalogue }.to raise_error Puppet::Error, /is not supported. Missing default values/
end
end
end
describe 'incompatible OSs' do describe 'incompatible OSs' do
[ [
{ {

View File

@@ -130,6 +130,63 @@ describe 'java::oracle', :type => :define do
end end
end end
context 'On Ubuntu 64-bit' do
let(:facts) { {:kernel => 'Linux', :os => { :family => 'Debian', :architecture => 'amd64', :name => 'Ubuntu', :release => { :full => '16.04' } } } }
context 'Oracle Java SE 6 JDK' do
let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jdk'} }
let :title do 'jdk6' end
it { is_expected.to contain_archive('/tmp/jdk-6u45-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 6').with_command('tar -zxf /tmp/jdk-6u45-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 6').that_requires('Archive[/tmp/jdk-6u45-linux-x64.tar.gz]') }
end
context 'Oracle Java SE 7 JDK' do
let(:params) { {:ensure => 'present', :version => '7', :java_se => 'jdk'} }
let :title do 'jdk7' end
it { is_expected.to contain_archive('/tmp/jdk-7u80-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 7').with_command('tar -zxf /tmp/jdk-7u80-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 7').that_requires('Archive[/tmp/jdk-7u80-linux-x64.tar.gz]') }
end
context 'Oracle Java SE 8 JDK' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jdk'} }
let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').with_command('tar -zxf /tmp/jdk-8u131-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jdk 8').that_requires('Archive[/tmp/jdk-8u131-linux-x64.tar.gz]') }
end
context 'Oracle Java SE 6 JRE' do
let(:params) { {:ensure => 'present', :version => '6', :java_se => 'jre'} }
let :title do 'jre6' end
it { is_expected.to contain_archive('/tmp/jre-6u45-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jre 6').with_command('tar -zxf /tmp/jre-6u45-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 6').that_requires('Archive[/tmp/jre-6u45-linux-x64.tar.gz]') }
end
context 'Oracle Java SE 7 JRE' do
let(:params) { {:ensure => 'present', :version => '7', :java_se => 'jre'} }
let :title do 'jre7' end
it { is_expected.to contain_archive('/tmp/jre-7u80-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jre 7').with_command('tar -zxf /tmp/jre-7u80-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 7').that_requires('Archive[/tmp/jre-7u80-linux-x64.tar.gz]') }
end
context 'select Oracle Java SE 8 JRE' do
let(:params) { {:ensure => 'present', :version => '8', :java_se => 'jre'} }
let :title do 'jre8' end
it { is_expected.to contain_archive('/tmp/jre-8u131-linux-x64.tar.gz')}
it { is_expected.to contain_exec('Install Oracle java_se jre 8').with_command('tar -zxf /tmp/jre-8u131-linux-x64.tar.gz -C /usr/lib/jvm') }
it { is_expected.to contain_exec('Install Oracle java_se jre 8').that_requires('Archive[/tmp/jre-8u131-linux-x64.tar.gz]') }
end
context 'Pass URL to url parameter' do
let(:params) { {:ensure => 'present', :version_major => '8u131', :version_minor => 'b11', :java_se => 'jdk', :url => 'http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz'} }
let :title do 'jdk8' end
it { is_expected.to contain_archive('/tmp/jdk-8u131-linux-x64.tar.gz')}
end
end
describe 'incompatible OSes' do describe 'incompatible OSes' do
[ [
{ {

View File

@@ -1,47 +1,50 @@
require "spec_helper" require "spec_helper"
def unlink_and_delete(filename)
if File.symlink?(filename)
File.unlink(filename)
end
if File.exist?(filename)
File.delete(filename)
end
end
describe Facter::Util::Fact do describe Facter::Util::Fact do
before {
Facter.clear
Facter.fact(:kernel).stubs(:value).returns('Linux')
}
describe "java_default_home" do describe "java_default_home" do
context 'returns java home path when readlink present' do before(:each) {
context 'when java is in HOME/jre/bin/java' do Facter.clear
Facter.fact(:kernel).stubs(:value).returns('Linux')
}
context 'returns java home path when java found in PATH' do
context "when java is in /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java" do
it do it do
java_path_output = <<-EOS unlink_and_delete('./java_test')
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java File.symlink('/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java', './java_test')
EOS Facter::Util::Resolution.expects(:which).with("java").returns("./java_test")
Facter::Util::Resolution.expects(:which).with("readlink").returns(true) File.expects(:realpath).with('./java_test').returns('/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java')
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output) expect(Facter.value(:java_default_home)).to eql '/usr/lib/jvm/java-7-openjdk-amd64'
expect(Facter.value(:java_default_home)).to eql "/usr/lib/jvm/java-7-openjdk-amd64" unlink_and_delete('./java_test')
end end
end end
context 'when java is in HOME/bin/java' do
context "when java is in /usr/lib/jvm/oracle-java8-jre-amd64/bin/java" do
it do it do
java_path_output = <<-EOS unlink_and_delete('./java_test')
/usr/lib/jvm/oracle-java8-jre-amd64/bin/java File.symlink('/usr/lib/jvm/oracle-java8-jre-amd64/bin/java', './java_test')
EOS Facter::Util::Resolution.expects(:which).with("java").returns("./java_test")
Facter::Util::Resolution.expects(:which).with("readlink").returns(true) File.expects(:realpath).with('./java_test').returns('/usr/lib/jvm/oracle-java8-jre-amd64/bin/java')
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output) expect(Facter.value(:java_default_home)).to eql '/usr/lib/jvm/oracle-java8-jre-amd64'
expect(Facter.value(:java_default_home)).to eql "/usr/lib/jvm/oracle-java8-jre-amd64" unlink_and_delete('./java_test')
end end
end end
end end
context 'returns nil when readlink is present but java is not' do
it do
java_path_output = ""
Facter::Util::Resolution.expects(:which).with("readlink").returns(true)
Facter::Util::Resolution.expects(:exec).with("readlink -e /usr/bin/java").returns(java_path_output)
expect(Facter.value(:java_default_home)).to be_nil
end
end
context 'returns nil when readlink not present' do context 'returns nil when java not present' do
it do it do
Facter::Util::Resolution.stubs(:exec) Facter::Util::Resolution.stubs(:exec)
Facter::Util::Resolution.expects(:which).with("readlink").at_least(1).returns(false) Facter::Util::Resolution.expects(:which).with("java").at_least(1).returns(false)
expect(Facter.value(:java_default_home)).to be_nil expect(Facter.value(:java_default_home)).to be_nil
end end
end end

View File

@@ -7,13 +7,14 @@ describe Facter::Util::Fact do
describe "java_version" do describe "java_version" do
context 'returns java version when java present' do context 'returns java version when java present' do
context 'on OpenBSD', :with_env => true do context 'on OpenBSD' do
before do before do
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD") Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
end end
let(:facts) { {:operatingsystem => 'OpenBSD'} } let(:facts) { {:operatingsystem => 'OpenBSD'} }
it do it do
java_version_output = <<-EOS java_version_output = <<-EOS
Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
openjdk version "1.7.0_71" openjdk version "1.7.0_71"
OpenJDK Runtime Environment (build 1.7.0_71-b14) OpenJDK Runtime Environment (build 1.7.0_71-b14)
OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode) OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode)
@@ -30,6 +31,7 @@ OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode)
let(:facts) { {:operatingsystem => 'Darwin'} } let(:facts) { {:operatingsystem => 'Darwin'} }
it do it do
java_version_output = <<-EOS java_version_output = <<-EOS
Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
java version "1.7.0_71" java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14) Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode) Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
@@ -46,10 +48,12 @@ Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
let(:facts) { {:operatingsystem => 'MyOS'} } let(:facts) { {:operatingsystem => 'MyOS'} }
it do it do
java_version_output = <<-EOS java_version_output = <<-EOS
Picked up JAVA_TOOL_OPTIONS: -Djava.net.preferIPv4Stack=true
java version "1.7.0_71" java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14) Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode) Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
EOS EOS
Facter::Util::Resolution.expects(:which).with("java").returns('/path/to/java')
Facter::Util::Resolution.expects(:exec).with("java -Xmx12m -version 2>&1").returns(java_version_output) Facter::Util::Resolution.expects(:exec).with("java -Xmx12m -version 2>&1").returns(java_version_output)
expect(Facter.value(:java_version)).to eq("1.7.0_71") expect(Facter.value(:java_version)).to eq("1.7.0_71")
end end
@@ -57,7 +61,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
end end
context 'returns nil when java not present' do context 'returns nil when java not present' do
context 'on OpenBSD', :with_env => true do context 'on OpenBSD' do
before do before do
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD") Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
end end