Add option to configure karaf logging
[integration/packaging/puppet-opendaylight.git] / spec / spec_helper_acceptance.rb
index ab0ca093474e72505d592e5033a4a63c609a00b0..0f3d80738b7d86bba7ae3e642a34d6f4da7d79fb 100644 (file)
@@ -51,9 +51,8 @@ def install_odl(options = {})
   #   class, which are defined in opendaylight::params
   # TODO: Remove this possible source of bugs^^
   # Extract params if given, defaulting to odl class defaults if not
-  extra_features = options.fetch(:extra_features, [])
-  default_features = options.fetch(:default_features,
-    ['config', 'standard', 'region', 'package', 'kar', 'ssh', 'management'])
+  extra_features = options.fetch(:extra_features, ['odl-restconf'])
+  default_features = options.fetch(:default_features, ['standard', 'wrap', 'ssh'])
   odl_rest_port = options.fetch(:odl_rest_port, 8080)
   odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
   log_levels = options.fetch(:log_levels, {})
@@ -66,6 +65,9 @@ def install_odl(options = {})
   log_max_size = options.fetch(:log_max_size, '10GB')
   log_max_rollover = options.fetch(:log_max_rollover, 2)
   snat_mechanism = options.fetch(:snat_mechanism, 'controller')
+  enable_tls = options.fetch(:enable_tls, false)
+  tls_keystore_password = options.fetch(:tls_keystore_password, 'dummypass')
+  log_mechanism = options.fetch(:log_mechanism, 'file')
 
   # Build script for consumption by Puppet apply
   it 'should work idempotently with no errors' do
@@ -87,6 +89,9 @@ def install_odl(options = {})
       log_max_size => '#{log_max_size}',
       log_max_rollover => #{log_max_rollover},
       snat_mechanism => #{snat_mechanism},
+      enable_tls => #{enable_tls},
+      tls_keystore_password => #{tls_keystore_password},
+      log_mechanism => #{log_mechanism},
     }
     EOS
 
@@ -206,17 +211,28 @@ def generic_validations()
 end
 
 # Shared function for validations related to log file settings
-def log_file_settings_validations(options = {})
+def log_settings_validations(options = {})
   # Should contain log level config file with correct file size and rollover values
   log_max_size = options.fetch(:log_max_size, '10GB')
   log_max_rollover = options.fetch(:log_max_rollover, 2)
+  log_mechanism = options.fetch(:log_mechanism, 'file')
 
-  describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
-    it { should be_file }
-    it { should be_owned_by 'odl' }
-    it { should be_grouped_into 'odl' }
-    its(:content) { should match /^log4j.appender.out.maxFileSize=#{log_max_size}/ }
-    its(:content) { should match /^log4j.appender.out.maxBackupIndex=#{log_max_rollover}/ }
+  if log_mechanism == 'console'
+    describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
+      it { should be_file }
+      it { should be_owned_by 'odl' }
+      it { should be_grouped_into 'odl' }
+      its(:content) { should match /log4j.rootLogger=INFO, stdout, osgi:*/ }
+      its(:content) { should match /log4j.appender.stdout.direct=true/ }
+    end
+  else
+    describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do
+      it { should be_file }
+      it { should be_owned_by 'odl' }
+      it { should be_grouped_into 'odl' }
+      its(:content) { should match /^log4j.appender.out.maxFileSize=#{log_max_size}/ }
+      its(:content) { should match /^log4j.appender.out.maxBackupIndex=#{log_max_rollover}/ }
+    end
   end
 end
 
@@ -226,8 +242,7 @@ def karaf_config_validations(options = {})
   #   class, which are defined in opendaylight::params
   # TODO: Remove this possible source of bugs^^
   extra_features = options.fetch(:extra_features, [])
-  default_features = options.fetch(:default_features, ['config', 'standard', 'region',
-                                  'package', 'kar', 'ssh', 'management'])
+  default_features = options.fetch(:default_features, ['standard', 'wrap', 'ssh'])
 
   # Create one list of all of the features
   features = default_features + extra_features
@@ -345,7 +360,7 @@ end
 def rpm_validations()
   rpm_repo = ENV['RPM_REPO']
 
-  describe yumrepo(rpm_repo) do
+  describe yumrepo('opendaylight') do
     it { should exist }
     it { should be_enabled }
   end
@@ -383,7 +398,7 @@ def username_password_validations(options = {})
     it { should be_file }
   end
 
-  describe command("sleep 60 && curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url}") do
+  describe command("sleep 180 && curl -o /dev/null --fail --silent --head -u #{odl_username}:#{odl_password} #{odl_check_url}") do
     its(:exit_status) { should eq 0 }
   end
 end
@@ -402,3 +417,88 @@ def snat_mechanism_validations(options = {})
     its(:content) { should match /<nat-mode>#{snat_mechanism}<\/nat-mode>/ }
   end
 end
+
+# Shared function for validations related to SFC
+def sfc_validations()
+  # NB: This param default should match the one used by the opendaylight
+  #   class, which is defined in opendaylight::params
+  # TODO: Remove this possible source of bugs^^
+
+  describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/netvirt-elanmanager-config.xml') do
+    it { should be_file }
+    it { should be_owned_by 'odl' }
+    it { should be_grouped_into 'odl' }
+    its(:content) { should match /<use-of-tunnels>true<\/use-of-tunnels>/ }
+  end
+
+  describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/genius-itm-config.xml') do
+    it { should be_file }
+    it { should be_owned_by 'odl' }
+    it { should be_grouped_into 'odl' }
+    its(:content) { should match /<gpe-extension-enabled>true<\/gpe-extension-enabled>/ }
+  end
+end
+
+def websocket_address_validations(options = {})
+  # NB: This param default should match the one used by the opendaylight
+  #   class, which is defined in opendaylight::params
+  # TODO: Remove this possible source of bugs^^
+  odl_bind_ip = options.fetch(:odl_bind_ip, '0.0.0.0')
+
+  describe file('/opt/opendaylight/etc/opendaylight/karaf/10-rest-connector.xml') do
+    it { should be_file }
+    it { should be_owned_by 'odl' }
+    it { should be_grouped_into 'odl' }
+    its(:content) { should match /<websocket-address>#{odl_bind_ip}<\/websocket-address>/ }
+  end
+end
+
+def tls_validations(options = {})
+  # NB: This param default should match the one used by the opendaylight
+  #   class, which is defined in opendaylight::params
+  # TODO: Remove this possible source of bugs^^
+  tls_keystore_password = options.fetch(:tls_keystore_password)
+  odl_rest_port = options.fetch(:odl_rest_port, 8080)
+
+  describe file('/opt/opendaylight/etc/org.ops4j.pax.web.cfg') do
+    it { should be_file }
+    it { should be_owned_by 'odl' }
+    it { should be_grouped_into 'odl' }
+    its(:content) { should match /org.osgi.service.http.port.secure = #{odl_rest_port}/ }
+    its(:content) { should match /org.ops4j.pax.web.ssl.keystore = configuration\/ssl\/ctl.jks/ }
+    its(:content) { should match /org.ops4j.pax.web.ssl.password = #{tls_keystore_password}/ }
+    its(:content) { should match /org.ops4j.pax.web.ssl.keypassword = #{tls_keystore_password}/ }
+    its(:content) { should match /org.osgi.service.http.secure.enabled = true/ }
+  end
+
+  describe file('/opt/opendaylight/etc/org.opendaylight.ovsdb.library.cfg') do
+    it { should be_file }
+    it { should be_owned_by 'odl' }
+    it { should be_grouped_into 'odl' }
+    its(:content) { should match /use-ssl = true/ }
+  end
+
+  describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/default-openflow-connection-config.xml') do
+    it { should be_file }
+    it { should be_owned_by 'odl' }
+    it { should be_grouped_into 'odl' }
+    its(:content) { should match /<keystore-password>#{tls_keystore_password}<\/keystore-password>/ }
+    its(:content) { should match /<truststore-password>#{tls_keystore_password}<\/truststore-password>/ }
+    its(:content) { should match /<transport-protocol>TLS<\/transport-protocol>/ }
+  end
+
+  describe file('/opt/opendaylight/etc/opendaylight/datastore/initial/config/aaa-cert-config.xml') do
+    it { should be_file }
+    it { should be_owned_by 'odl' }
+    it { should be_grouped_into 'odl' }
+    its(:content) { should match /<store-password>#{tls_keystore_password}<\/store-password>/ }
+    its(:content) { should match /<use-mdsal>false<\/use-mdsal>/ }
+  end
+
+  describe file('/opt/opendaylight/etc/jetty.xml') do
+    it { should be_file }
+    it { should be_owned_by 'odl' }
+    it { should be_grouped_into 'odl' }
+    its(:content) { should match /<Property name="jetty.secure.port" default="#{odl_rest_port}" \/>/ }
+  end
+end