Compare commits

...

10 Commits
1.4.1 ... 1.4.2

Author SHA1 Message Date
Hunter Haugen
faede8c802 Fix fixtures 2015-10-06 18:08:48 -07:00
JT (Jonny)
a9198d235d Merge pull request #144 from hunner/release_1.4.2
Release 1.4.2
2015-10-07 01:30:20 +01:00
Hunter Haugen
c47711e36e Release 1.4.2 2015-10-06 16:29:23 -07:00
Jesse Lovelace
65476bd54b Merge pull request #143 from puppetlabs/master
Update 1.4.x with master changes
2015-10-06 18:20:34 -05:00
Hunter Haugen
8eee08c143 Merge pull request #142 from DavidS/MODULES-2637-java_version_on_OSX
(MODULES-2637) Checks java actually installed
2015-10-01 11:20:49 -07:00
David Schmitt
dadc7a6c22 (MODULES-2637) Checks java actually installed
The other method for running which java doesn't work on OSX, as java is installed as an empty shim when not installed in the base OSX image:

```
vagrant:~ vagrant$ java
No Java runtime present, requesting install.
vagrant:~ vagrant$ /usr/libexec/java_home --failfast
Unable to find any JVMs matching version "(null)".
vagrant:~ vagrant$
```

We can use the `/usr/libexec/java_home --failfast` command to check if
java is actually present first.

Originally-by: Peter Souter <peter.souter@puppetlabs.com>
2015-10-01 19:09:32 +01:00
David Schmitt
3645364e5b (MAINT) declare an exclusion filter for the tests using with_env on facter 1.6
The with_env function is not available in facter 1.6 and OpenBSD is not
supported.
2015-10-01 19:09:32 +01:00
Hunter Haugen
913a810bfd Merge pull request #141 from vrtdev/feature/fix_spec_deprecation_warnings
Fix rspec deprecation warnings. .should -> expect().to
2015-09-28 21:47:57 -07:00
Jan Vansteenkiste
8bef423733 Fix rspec deprecation warnings. .should -> expect().to 2015-09-29 06:44:30 +02:00
Bryan Jen
abd490dc6a Merge pull request #137 from puppetlabs/1.4.x
mergeback 1.4.x
2015-07-15 15:39:00 -07:00
8 changed files with 72 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
fixtures:
repositories:
stdlib: http://github.com/puppetlabs/puppetlabs-stdlib.git
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
symlinks:
java: "#{source_dir}"

View File

@@ -1,3 +1,10 @@
## 2015-10-07 - Supported Release 1.4.2
### Summary
This release fixes the fact to not trigger java every time on OS X when it is not available.
#### Bugfixes
- Causes java\_version fact to not run `java` when java is not installed on OS X
## 2015-07-16 - Supported Release 1.4.1
### Summary
This release updates the metadata for the upcoming release of PE and update params for OEL to match metadata

View File

@@ -12,12 +12,23 @@
# Notes:
# None
Facter.add(:java_version) do
# the OS-specific overrides need to be able to return nil,
# to indicate "no java available". Usually returning nil
# would mean that facter falls back to a lower priority
# resolution, which would then trigger MODULES-2637. To
# avoid that, we confine the "default" here to not run
# on those OS.
# Additionally, facter versions prior to 2.0.1 only support
# positive matches, so this needs to be done manually in setcode.
setcode do
unless [ 'openbsd', 'darwin' ].include? Facter.value(:operatingsystem).downcase
if Facter::Util::Resolution.which('java')
Facter::Util::Resolution.exec('java -Xmx8m -version 2>&1').lines.first.split(/"/)[1].strip
end
end
end
end
Facter.add(:java_version) do
confine :operatingsystem => 'OpenBSD'
has_weight 100
@@ -29,3 +40,13 @@ Facter.add(:java_version) do
end
end
end
Facter.add(:java_version) do
confine :operatingsystem => 'Darwin'
has_weight 100
setcode do
unless /Unable to find any JVMs matching version/ =~ Facter::Util::Resolution.exec('/usr/libexec/java_home --failfast 2>&1')
Facter::Util::Resolution.exec('java -Xmx8m -version 2>&1').lines.first.split(/"/)[1].strip
end
end
end

View File

@@ -1,6 +1,6 @@
{
"name": "puppetlabs-java",
"version": "1.4.1",
"version": "1.4.2",
"author": "puppetlabs",
"summary": "Installs the correct Java package on various platforms.",
"license": "Apache-2.0",

View File

@@ -1 +1,6 @@
require 'puppetlabs_spec_helper/module_spec_helper'
RSpec.configure do |c|
# declare an exclusion filter for the tests using with_env on facter 1.6, as the function is not available on 1.6
c.filter_run_excluding :with_env => true if Facter.version =~ /^1\.6\./
end

View File

@@ -11,7 +11,7 @@ describe Facter::Util::Fact do
Facter.fact(:java_version).stubs(:value).returns('1.7.0_71')
end
it do
Facter.fact(:java_major_version).value.should == "7"
expect(Facter.fact(:java_major_version).value).to eq("7")
end
end
@@ -20,7 +20,7 @@ describe Facter::Util::Fact do
Facter.fact(:java_version).stubs(:value).returns(nil)
end
it do
Facter.fact(:java_major_version).value.should be_nil
expect(Facter.fact(:java_major_version).value).to be_nil
end
end
end

View File

@@ -12,7 +12,7 @@ describe Facter::Util::Fact do
Facter.fact(:java_version).stubs(:value).returns('1.7.0_71')
end
it do
Facter.fact(:java_patch_level).value.should == "71"
expect(Facter.fact(:java_patch_level).value).to eq("71")
end
end
end
@@ -23,7 +23,7 @@ describe Facter::Util::Fact do
Facter.fact(:java_version).stubs(:value).returns(nil)
end
it do
Facter.fact(:java_patch_level).value.should be_nil
expect(Facter.fact(:java_patch_level).value).to be_nil
end
end
end

View File

@@ -7,7 +7,7 @@ describe Facter::Util::Fact do
describe "java_version" do
context 'returns java version when java present' do
context 'on OpenBSD' do
context 'on OpenBSD', :with_env => true do
before do
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
end
@@ -20,6 +20,22 @@ OpenJDK 64-Bit Server VM (build 24.71-b01, mixed mode)
EOS
Facter::Util::Resolution.expects(:which).with("java").returns('/usr/local/jdk-1.7.0/jre/bin/java')
Facter::Util::Resolution.expects(:exec).with("java -Xmx8m -version 2>&1").returns(java_version_output)
expect(Facter.value(:java_version)).to eq("1.7.0_71")
end
end
context 'on Darwin' do
before do
Facter.fact(:operatingsystem).stubs(:value).returns("Darwin")
end
let(:facts) { {:operatingsystem => 'Darwin'} }
it do
java_version_output = <<-EOS
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
EOS
Facter::Util::Resolution.expects(:exec).with("/usr/libexec/java_home --failfast 2>&1").returns("/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home")
Facter::Util::Resolution.expects(:exec).with("java -Xmx8m -version 2>&1").returns(java_version_output)
Facter.value(:java_version).should == "1.7.0_71"
end
end
@@ -35,19 +51,29 @@ Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
EOS
Facter::Util::Resolution.expects(:exec).with("java -Xmx8m -version 2>&1").returns(java_version_output)
Facter.value(:java_version).should == "1.7.0_71"
expect(Facter.value(:java_version)).to eq("1.7.0_71")
end
end
end
context 'returns nil when java not present' do
context 'on OpenBSD' do
context 'on OpenBSD', :with_env => true do
before do
Facter.fact(:operatingsystem).stubs(:value).returns("OpenBSD")
end
let(:facts) { {:operatingsystem => 'OpenBSD'} }
it do
Facter::Util::Resolution.stubs(:exec)
expect(Facter.value(:java_version)).to be_nil
end
end
context 'on Darwin' do
before do
Facter.fact(:operatingsystem).stubs(:value).returns("Darwin")
end
let(:facts) { {:operatingsystem => 'Darwin'} }
it do
Facter::Util::Resolution.expects(:exec).at_least(1).with("/usr/libexec/java_home --failfast 2>&1").returns('Unable to find any JVMs matching version "(null)".')
Facter.value(:java_version).should be_nil
end
end
@@ -58,7 +84,7 @@ Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
let(:facts) { {:operatingsystem => 'MyOS'} }
it do
Facter::Util::Resolution.expects(:which).at_least(1).with("java").returns(false)
Facter.value(:java_version).should be_nil
expect(Facter.value(:java_version)).to be_nil
end
end
end