diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f5ac00f..44674150 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,4 +22,4 @@ permissions: jobs: puppet: name: Puppet - uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v3 + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v3 diff --git a/.sync.yml b/.sync.yml index 3c2702e5..5d21319c 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,2 +1,3 @@ -.github/workflows/ci.yml: - acceptance_tests: false +--- +spec/spec_helper_acceptance.rb: + unmanaged: false diff --git a/acceptance.sh b/acceptance.sh deleted file mode 100755 index 0a7627e7..00000000 --- a/acceptance.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -PROFILES=( wildfly:8.0.0 wildfly:8.2.1 wildfly:9.0.2 wildfly:10.1.0 ) -BOXES=( default centos-72-x64 debian-78-x64 debian-82-x64 ubuntu-1404-x64 ubuntu-1604-x64 ) -for TEST_profile in "${PROFILES[@]}" -do - for BOX in "${BOXES[@]}" - do - PUPPET_INSTALL_TYPE="agent" TEST_profile="${TEST_profile}" BEAKER_set="${BOX}" bundle exec rake beaker - done -done - -BEAKER_TESTMODE=agent BEAKER_set=centos7m_centos7a PUPPET_INSTALL_TYPE=agent bundle exec rake beaker diff --git a/spec/acceptance/0_uptodate_wildfly_spec.rb b/spec/acceptance/0_uptodate_wildfly_spec.rb new file mode 100644 index 00000000..2250cde6 --- /dev/null +++ b/spec/acceptance/0_uptodate_wildfly_spec.rb @@ -0,0 +1,84 @@ +require 'spec_helper_acceptance' + +pp = <<-EOP + Exec { + path => $facts['path'], + } + + # yum install java-17-openjdk.x86_64 + + $_install_source = 'https://github.com/wildfly/wildfly/releases/download/37.0.1.Final/wildfly-37.0.1.Final.tar.gz' + $_install_source_gitlab_issue_355 = 'https://github.com/wildfly/wildfly/releases/download/32.0.1.Final/wildfly-32.0.1.Final.tar.gz' + $_properties = { + 'jboss.bind.address' => 'localhost', + # 'jboss.bind.address.management' => $mgmt_bind, + 'jboss.management.http.port' => '1081', + 'jboss.management.https.port' => '10444', + 'jboss.http.port' => '1080', + 'jboss.https.port' => '10443', + 'jboss.ajp.port' => '1234' + } + $_service_name = 'very-buggy-server' + $_uid = '1000' + $_user = 'wildfly' + $link_name = '/home/wildfly/' + + if $facts['os']['family'] == 'Debian' { + $javapkg = 'openjdk-17-jdk' + $javahome = '/usr/lib/jvm/java-17-openjdk-amd64/' + } else { + $javapkg = 'java-17-openjdk.x86_64' + $javahome = '/usr/lib/jvm/java-17-openjdk-17.0.16.0.8-2.el9.x86_64/' + } + + package { $javapkg: + ensure => present, + } + -> + group { $_user: + ensure => present, + gid => Integer($_uid), + } + -> + user { $_user: + uid => $_uid, + gid => $_uid, + } + #~> + #exec {'chown -R wildfly: /opt/wildfly-32.0.1/': + # returns => [0,1], + #} + -> + class{'wildfly': + config => 'standalone.xml', + console_log => "/var/log/wildfly/console.log", + dirname => "/opt/wildfly-32.0.1", + distribution => "wildfly", + gid => Integer($_uid), + group => $_user, + install_cache_dir => '/tmp/wildfly/', + install_source => $_install_source_gitlab_issue_355, + java_home => $javahome, + java_opts => undef, + java_maxmetaspace_size => '2048m', + java_xms => '128M', + java_xmx => '512M', + manage_user => false, + properties => $_properties, + service_name => $_service_name, + service_manage => true, + uid => Integer($_uid), + user => $_user, + user_home => $link_name, + version => '32.0.1', + } +EOP + +describe 'up to date wildfly without any frills' do + context 'it installs at least once' do + it 'applies the manfest without error, idempotently' do + apply_manifest(pp, catch_failures: true, acceptable_exit_codes: [0, 2]) + apply_manifest(pp, catch_changes: true, acceptable_exit_codes: [0]) + end + end +end diff --git a/spec/acceptance/1_standalone_spec.rb b/spec/acceptance/1_standalone_sp_disabled_ec.rb similarity index 82% rename from spec/acceptance/1_standalone_spec.rb rename to spec/acceptance/1_standalone_sp_disabled_ec.rb index e760fe5f..cf706d81 100644 --- a/spec/acceptance/1_standalone_spec.rb +++ b/spec/acceptance/1_standalone_sp_disabled_ec.rb @@ -13,7 +13,9 @@ class { 'wildfly': } wildfly::config::module { 'org.postgresql': - source => 'http://central.maven.org/maven2/org/postgresql/postgresql/9.3-1103-jdbc4/postgresql-9.3-1103-jdbc4.jar', + # TODO + # Error: /Stage[main]/Main/Wildfly::Deployment[hawtio.war]/File[/opt/hawtio-web-1.4.66.war]: Could not evaluate: Could not retrieve file metadata for http://central.maven.org/maven2/io/hawt/hawtio-web/1.4.66/hawtio-web-1.4.66.war: Request to http://central.maven.org/maven2/io/hawt/hawtio-web/1.4.66/hawtio-web-1.4.66.war failed after 0.02 seconds: Failed to open TCP connection to central.maven.org:80 (getaddrinfo: Name or service not known) + source => '#{test_data['postgres_jar_source']}', dependencies => ['javax.api', 'javax.transaction.api'] } -> @@ -56,8 +58,10 @@ class { 'wildfly': } EOS - execute_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0, 2]) - expect(execute_manifest(pp, :catch_failures => true).exit_code).to be_zero + puts "Debug: Applying this Manifest from #{__FILE__}" + puts pp + apply_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0, 2]) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero shell('sleep 25') end diff --git a/spec/acceptance/1_standalone_wildfly_spec.rb b/spec/acceptance/1_standalone_wildfly_spec.rb new file mode 100644 index 00000000..4206a2e9 --- /dev/null +++ b/spec/acceptance/1_standalone_wildfly_spec.rb @@ -0,0 +1,79 @@ +require 'spec_helper_acceptance' + +pp = <<-EOP + Exec { + path => $facts['path'], + } + + $_properties = { + 'jboss.bind.address' => 'localhost', + 'jboss.management.http.port' => '1081', + 'jboss.management.https.port' => '10444', + 'jboss.http.port' => '1080', + 'jboss.https.port' => '10443', + 'jboss.ajp.port' => '1234' + } + $_service_name = 'very-buggy-server' + $_uid = '1000' + $_user = 'wildfly' + $link_name = '/home/wildfly/' + + if $facts['os']['family'] == 'Debian' { + $javapkg = 'openjdk-17-jdk' + $javahome = '/usr/lib/jvm/java-17-openjdk-amd64/' + } else { + $javapkg = 'java-17-openjdk.x86_64' + $javahome = '/usr/lib/jvm/java-17-openjdk-17.0.16.0.8-2.el9.x86_64/' + } + + package { $javapkg: + ensure => present, + } + -> + group { $_user: + ensure => present, + gid => Integer($_uid), + } + -> + user { $_user: + uid => $_uid, + gid => $_uid, + } + #~> + #exec {'chown -R wildfly: /opt/wildfly-32.0.1/': + # returns => [0,1], + #} + -> + class{'wildfly': + config => 'standalone.xml', + console_log => "/var/log/wildfly/console.log", + dirname => "/opt/wildfly-32.0.1", + distribution => "wildfly", + gid => Integer($_uid), + group => $_user, + install_cache_dir => '/tmp/wildfly/', + install_source => '#{test_data['install_source']}', + java_home => '#{test_data['java_home']}', + java_opts => undef, + java_maxmetaspace_size => '2048m', + java_xms => '128M', + java_xmx => '512M', + manage_user => false, + properties => $_properties, + service_name => '#{test_data['service_name']}', + service_manage => true, + uid => Integer($_uid), + user => $_user, + user_home => $link_name, + version => '32.0.1', + } +EOP + +describe 'install wildfly and its dependencies and start service' do + context 'it deduces environment form test_data.rb' do + it 'applies the manfest without error, idempotently' do + apply_manifest(pp, catch_failures: true, acceptable_exit_codes: [0, 2]) + apply_manifest(pp, catch_changes: true, acceptable_exit_codes: [0]) + end + end +end diff --git a/spec/acceptance/2_deployment_spec.rb b/spec/acceptance/2_deployment_sp_disabled_ec.rb similarity index 82% rename from spec/acceptance/2_deployment_spec.rb rename to spec/acceptance/2_deployment_sp_disabled_ec.rb index e9f422aa..1ce4a64f 100644 --- a/spec/acceptance/2_deployment_spec.rb +++ b/spec/acceptance/2_deployment_sp_disabled_ec.rb @@ -14,16 +14,16 @@ class { 'wildfly': } wildfly::deployment { 'hawtio.war': - source => 'http://central.maven.org/maven2/io/hawt/hawtio-web/1.4.66/hawtio-web-1.4.66.war' + source => '#{test_data['sample_war_simple']}' } wildfly::deployment { 'sample.war': - source => 'http://central.maven.org/maven2/org/codehaus/cargo/simple-war/1.6.2/simple-war-1.6.2.war' + source => '#{test_data['sample_war_simple']}' } EOS - execute_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0, 2]) - expect(execute_manifest(pp, :catch_failures => true).exit_code).to be_zero + apply_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0, 2]) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero shell('sleep 25') end diff --git a/spec/acceptance/3_recursive_resource_spec.rb b/spec/acceptance/3_recursive_resource_sp_disabled_ec.rb similarity index 91% rename from spec/acceptance/3_recursive_resource_spec.rb rename to spec/acceptance/3_recursive_resource_sp_disabled_ec.rb index 00855ce4..2ff72007 100644 --- a/spec/acceptance/3_recursive_resource_spec.rb +++ b/spec/acceptance/3_recursive_resource_sp_disabled_ec.rb @@ -13,7 +13,7 @@ class { 'wildfly': } wildfly::config::module { 'org.postgresql': - source => 'http://central.maven.org/maven2/org/postgresql/postgresql/9.3-1103-jdbc4/postgresql-9.3-1103-jdbc4.jar', + source => '#{test_data['postgres_jar_source']}', dependencies => ['javax.api', 'javax.transaction.api'], } -> @@ -37,8 +37,8 @@ class { 'wildfly': EOS - execute_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0, 2]) - expect(execute_manifest(pp, :catch_failures => true).exit_code).to be_zero + apply_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0, 2]) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero shell('sleep 25') end diff --git a/spec/acceptance/4_domain_spec.rb b/spec/acceptance/4_domain_sp_disabled_ec.rb similarity index 78% rename from spec/acceptance/4_domain_spec.rb rename to spec/acceptance/4_domain_sp_disabled_ec.rb index 0cd7c880..d4c3b51e 100644 --- a/spec/acceptance/4_domain_spec.rb +++ b/spec/acceptance/4_domain_sp_disabled_ec.rb @@ -24,14 +24,14 @@ class { 'wildfly': } wildfly::deployment { 'hawtio.war': - source => 'http://central.maven.org/maven2/io/hawt/hawtio-web/1.4.66/hawtio-web-1.4.66.war', + source => '#{test_data['sample_war_hawtio']}', server_group => 'main-server-group', } EOS - execute_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0, 2]) - expect(execute_manifest(pp, :catch_failures => true).exit_code).to be_zero + apply_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0, 2]) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero shell('sleep 25') end @@ -57,12 +57,13 @@ class { 'wildfly': end end - it 'ExampleDS does not exists in full profile' do - shell("#{jboss_cli} '/profile=full-ha/subsystem=datasources/data-source=ExampleDS:read-resource'", - :acceptable_exit_codes => 1) do |r| - expect(r.stdout).to include 'not found' - end - end + # Dont repeat examples within a group + # it 'ExampleDS does not exists in full profile' do + # shell("#{jboss_cli} '/profile=full-ha/subsystem=datasources/data-source=ExampleDS:read-resource'", + # :acceptable_exit_codes => 1) do |r| + # expect(r.stdout).to include 'not found' + # end + # end it 'is a Domain Controller' do shell("#{jboss_cli} 'ls'", diff --git a/spec/acceptance/5_domain_spec_custom_server_group.rb b/spec/acceptance/5_domain_spec_custom_server_group.rb index e4bbc965..67886721 100644 --- a/spec/acceptance/5_domain_spec_custom_server_group.rb +++ b/spec/acceptance/5_domain_spec_custom_server_group.rb @@ -20,14 +20,14 @@ class { 'wildfly': } wildfly::deployment { 'hawtio.war': - source => 'http://central.maven.org/maven2/io/hawt/hawtio-web/1.4.66/hawtio-web-1.4.66.war', + source => '#{test_data['sample_war_hawtio']}', server_group => 'app-server-group', } EOS - execute_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0, 2]) - expect(execute_manifest(pp, :catch_failures => true).exit_code).to be_zero + apply_manifest(pp, :catch_failures => true, :acceptable_exit_codes => [0, 2]) + expect(apply_manifest(pp, :catch_failures => true).exit_code).to be_zero shell('sleep 25') end diff --git a/spec/support/acceptance/test_data.rb b/spec/support/acceptance/test_data.rb index ab902bda..4eef4a9e 100644 --- a/spec/support/acceptance/test_data.rb +++ b/spec/support/acceptance/test_data.rb @@ -1,32 +1,51 @@ def test_data - RSpec.configuration.test_data -end + # profile = ENV['TEST_profile'] || 'wildfly:9.0.2' # letzte funktionierend bekannte Version + profile = ENV['TEST_profile'] || 'wildfly:37.0.1' -profile = ENV['TEST_profile'] || 'wildfly:9.0.2' - -data = {} - -case profile -when /(wildfly):(\d{1,}\.\d{1,}\.\d{1,})/ - data['distribution'] = Regexp.last_match(1) - data['version'] = Regexp.last_match(2) - pkg_path = "wildfly/#{data['version']}.Final/wildfly-#{data['version']}.Final.tar.gz" - data['install_source'] = (data['version'].to_f < 25.0 ? "http://download.jboss.org/#{pkg_path}" : "https://github.com/wildfly/#{pkg_path}") - data['service_name'] = 'wildfly' - -when /(jboss-eap):(\d{1,}\.\d{1,})/ - data['distribution'] = Regexp.last_match(1) - data['version'] = Regexp.last_match(2) - data['install_source'] = "http://10.0.2.2:9090/jboss-eap-#{data['version']}.tar.gz" - data['service_name'] = (data['version'].to_f < 7.0 ? 'jboss-as' : 'jboss-eap') - -when 'custom' - data['distribution'] = ENV.fetch('TEST_distribution', 'wildfly') - data['version'] = ENV.fetch('TEST_version', '9.0.2') - data['install_source'] = ENV.fetch('TEST_install_source', "http://download.jboss.org/wildfly/#{data['version']}.Final/wildfly-#{data['version']}.Final.tar.gz") - data['service_name'] = ENV.fetch('TEST_service_name', 'wildfly') -end + puts "Marcus war hier" + puts "Debug: Profile" + puts profile.inspect + + data = {} + + case profile + when /(wildfly):(\d{1,}\.\d{1,}\.\d{1,})/ + data['distribution'] = Regexp.last_match(1) + data['version'] = Regexp.last_match(2) + data['install_source'] = if data['version'].to_f < 25.0 + puts "weniger als 25" + "http://download.jboss.org/wildfly/#{data['version']}.Final/wildfly-#{data['version']}.Final.tar.gz" + else + puts "neuer als 25" + "https://github.com/wildfly/wildfly/releases/download/#{data['version']}.Final/wildfly-#{data['version']}.Final.tar.gz" + end + data['service_name'] = 'wildfly' + + when /(jboss-eap):(\d{1,}\.\d{1,})/ + data['distribution'] = Regexp.last_match(1) + data['version'] = Regexp.last_match(2) + data['install_source'] = "http://10.0.2.2:9090/jboss-eap-#{data['version']}.tar.gz" + data['service_name'] = (data['version'].to_f < 7.0 ? 'jboss-as' : 'jboss-eap') -data['java_home'] = '/opt/jdk8u192-b12/' + when 'custom' + data['distribution'] = ENV.fetch('TEST_distribution', 'wildfly') + data['version'] = ENV.fetch('TEST_version', '9.0.2') + data['install_source'] = ENV.fetch('TEST_install_source', "http://download.jboss.org/wildfly/#{data['version']}.Final/wildfly-#{data['version']}.Final.tar.gz") + data['service_name'] = ENV.fetch('TEST_service_name', 'wildfly') + end -RSpec.configuration.test_data = data + data['java_home'] = `readlink /etc/alternatives/java`.gsub(%r{bin/java$}, '').strip + data['postgres_jar_source'] = "https://repo1.maven.org/maven2/org/postgresql/postgresql/9.3-1103-jdbc41/postgresql-9.3-1103-jdbc41.jar" + data['sample_war_simple'] = "https://repo1.maven.org/maven2/org/codehaus/cargo/simple-war/1.6.2/simple-war-1.6.2.war" + data['sample_war_hawtio'] = "https://repo1.maven.org/maven2/io/hawt/hawtio-web/1.4.66/hawtio-web-1.4.66.war" + data['beaker_autoconfigure'] = "true" + + puts "Debug: Test-Data" + puts data.inspect + + puts "Debug: Java-Verison mit ganzem Pfad" + puts `#{data['java_home']}/bin/java --version` + + # RSpec.configuration.test_data = data # das ist kaputt undefined method `test_data= for #