Support multiple argumets for EXTRA_JAVA_OPTS 33/77533/6
authorJanki Chhatbar <jchhatba@redhat.com>
Tue, 6 Nov 2018 11:38:52 +0000 (17:08 +0530)
committerJanki Chhatbar <jchhatba@redhat.com>
Tue, 13 Nov 2018 09:06:04 +0000 (14:36 +0530)
Add double quotes to allow passing multiple arguments to
EXTRA_JAVA_OPTS.

JIRA: INTPAK-217

Change-Id: I5e7224727d72d515b2465a1ccf8bc9b46fc2b1ce
Signed-Off-By: Janki Chhatbar <jchhatba@redhat.com>
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
manifests/config.pp
manifests/init.pp
spec/acceptance/class_spec.rb
spec/spec_helper.rb
spec/spec_helper_acceptance.rb

index 5b9cedd6246808c7cd70bf45f373e349abf9d226..c834d5e7c85b0f6aaa2461406bed74fdbc43295d 100644 (file)
@@ -23,7 +23,7 @@ class opendaylight::config {
   file_line {'Karaf Java Options':
     ensure => present,
     path   => '/opt/opendaylight/bin/karaf',
-    line   => "EXTRA_JAVA_OPTS=${opendaylight::java_options}",
+    line   => "EXTRA_JAVA_OPTS=\"${opendaylight::java_options}\"",
     match  => '^EXTRA_JAVA_OPTS=.*$',
     after  => '^PROGNAME=.*$'
   }
index a7e8753952d0ec2b7ee0a08fe45c9a56df4f38fe..94c80bb3abf28e105221e05223f29729ac55a1b9 100644 (file)
@@ -157,11 +157,11 @@ class opendaylight (
 
   if $opendaylight::odl_bind_ip =~ Stdlib::Compat::Ipv6 {
     $enable_ipv6 = true
-    $java_options = join(union(['-Djava.net.preferIPv6Addresses=true'], any2array($opendaylight::java_opts)), ' ')
+    $java_options = strip(join(union(['-Djava.net.preferIPv6Addresses=true'], any2array($opendaylight::java_opts)), ' '))
   }
   else {
     $enable_ipv6 = false
-    $java_options = join(union(['-Djava.net.preferIPv4Stack=true'], any2array($opendaylight::java_opts)), ' ')
+    $java_options = strip(join(union(['-Djava.net.preferIPv4Stack=true'], any2array($opendaylight::java_opts)), ' '))
   }
 
   class { '::opendaylight::install': }
index 53abe8969ad05c7d71c1fc188fa7c207e11edbdb..7117fb71a7ca7df108c60258953e077535f44b63 100644 (file)
@@ -328,6 +328,16 @@ describe 'opendaylight class' do
     end
   end
 
+  describe 'testing passing extra java option' do
+    context 'pass java heap size' do
+      # Call specialized helper fn to install OpenDaylight
+      install_odl(java_opts: '-Xmx8192m')
+
+      # Call specialized helper fn for polling enablement validations
+      generic_validations(java_opts: '-Xmx8192m')
+    end
+  end
+
   describe 'testing configuring inactivity probe' do
     context 'with specifying inactivity probe timer' do
       # Call specialized helper fn to install OpenDaylight
index d932cec926edcaab7147603e20b95535bd1ea098..de4a25195efb6a7df225a23cca1e3b0a69a1ca9f 100644 (file)
@@ -74,7 +74,7 @@ def generic_tests(options = {})
     should contain_file_line('Karaf Java Options').with(
       'ensure' => 'present',
       'path'   => '/opt/opendaylight/bin/karaf',
-      'line'   => "EXTRA_JAVA_OPTS=#{java_options}",
+      'line'   => "EXTRA_JAVA_OPTS=\"#{java_options}\"",
       'match'  => '^EXTRA_JAVA_OPTS=.*$',
       'after'  => '^PROGNAME=.*$'
     )
index 31b6e7c8f51296ed7de65836f7cefbe020911749..60d62500052e91bc3657126eaba4b8a05efc6707 100644 (file)
@@ -77,6 +77,7 @@ def install_odl(options = {})
   inherit_dscp_marking = options.fetch(:inherit_dscp_marking, false)
   stats_polling_enabled = options.fetch(:stats_polling_enabled, false)
   inactivity_probe = options.fetch(:inactivity_probe, :undef)
+  java_opts = options.fetch(:java_opts, '')
 
   # Build script for consumption by Puppet apply
   it 'should work idempotently with no errors' do
@@ -105,6 +106,7 @@ def install_odl(options = {})
       inherit_dscp_marking => #{inherit_dscp_marking},
       stats_polling_enabled => #{stats_polling_enabled},
       inactivity_probe => #{inactivity_probe},
+      java_opts => '#{java_opts}',
     }
     EOS
 
@@ -122,7 +124,6 @@ end
 # Shared function that handles generic validations
 # These should be common for all odl class param combos
 def generic_validations(options = {})
-  java_opts = options.fetch(:java_opts, [])
   # Verify ODL's directory
   describe file('/opt/opendaylight/') do
     it { should be_directory }
@@ -173,11 +174,12 @@ def generic_validations(options = {})
     it { should be_grouped_into 'odl' }
   end
 
+  java_opts = options.fetch(:java_opts, '')
   odl_bind_ip = options.fetch(:odl_bind_ip, '127.0.0.1')
   if odl_bind_ip == '127.0.0.1'
-    java_options = ['-Djava.net.preferIPv4Stack=true'] + java_opts
+    java_options = ['-Djava.net.preferIPv4Stack=true', java_opts].join(' ').strip
   else
-    java_options = ['-Djava.net.preferIPv6Addresses=true'] + java_opts
+    java_options = ['-Djava.net.preferIPv6Addresses=true', java_opts].join(' ').strip
   end
 
   # Should contain karaf file with Java options set
@@ -185,7 +187,11 @@ def generic_validations(options = {})
     it { should be_file }
     it { should be_owned_by 'odl' }
     it { should be_grouped_into 'odl' }
-    its(:content) { should match /^EXTRA_JAVA_OPTS=#{java_options.join(" ")}/ }
+    its(:content) { should match /^EXTRA_JAVA_OPTS=\"#{java_options}\"/ }
+  end
+
+  describe command do ("ps -ef | grep opendaylight | grep #{java_options}")
+    its(:exit_status) { should eq 0 }
   end
 
   # Should contain ODL NB port config file