From 871c6a13ce8895347d141e19ee699e46c54b2717 Mon Sep 17 00:00:00 2001 From: Trey Dockendorf Date: Fri, 5 Mar 2021 20:45:24 -0500 Subject: [PATCH] Improvements to testing, PDK sync some testing code --- .github/workflows/ci.yaml | 24 +- .sync.yml | 21 ++ spec/acceptance/1_domain_mode_cluster_spec.rb | 228 +++++++++--------- .../nodesets/centos-7-domain-mode-cluster.yml | 6 +- spec/acceptance/nodesets/centos-7.yml | 4 + spec/acceptance/nodesets/centos-8.yml | 4 + spec/acceptance/nodesets/debian-10.yml | 4 + spec/acceptance/nodesets/debian-9.yml | 4 + spec/acceptance/nodesets/ubuntu-1804.yml | 4 + 9 files changed, 168 insertions(+), 131 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e94b91c8..2a38fa1b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -88,21 +88,21 @@ jobs: keycloak_version: "12.0.1" keycloak_full: "yes" - set: "centos-7-domain-mode-cluster" - puppet: puppet5 - keycloak_version: 8.0.1 - keycloak_domain_mode_cluster: 'yes' + puppet: "puppet5" + keycloak_version: "8.0.1" + keycloak_domain_mode_cluster: "yes" - set: "centos-7-domain-mode-cluster" - puppet: puppet5 - keycloak_version: 12.0.1 - keycloak_domain_mode_cluster: 'yes' + puppet: "puppet5" + keycloak_version: "12.0.1" + keycloak_domain_mode_cluster: "yes" - set: "centos-7-domain-mode-cluster" - puppet: puppet6 - keycloak_version: 8.0.1 - keycloak_domain_mode_cluster: 'yes' + puppet: "puppet6" + keycloak_version: "8.0.1" + keycloak_domain_mode_cluster: "yes" - set: "centos-7-domain-mode-cluster" - puppet: puppet6 - keycloak_version: 12.0.1 - keycloak_domain_mode_cluster: 'yes' + puppet: "puppet6" + keycloak_version: "12.0.1" + keycloak_domain_mode_cluster: "yes" env: BUNDLE_WITHOUT: development:release BEAKER_debug: true diff --git a/.sync.yml b/.sync.yml index bd5072be..0ee21977 100644 --- a/.sync.yml +++ b/.sync.yml @@ -25,6 +25,7 @@ - '8.0.1' - '12.0.1' keycloak_full: ['no'] + keycloak_domain_mode_cluster: ['no'] acceptance_includes: - set: centos-7 puppet: puppet5 @@ -42,6 +43,26 @@ puppet: puppet6 keycloak_version: 12.0.1 keycloak_full: 'yes' + - set: centos-7-domain-mode-cluster + puppet: puppet5 + keycloak_version: 8.0.1 + keycloak_domain_mode_cluster: 'yes' + - set: centos-7-domain-mode-cluster + puppet: puppet5 + keycloak_version: 12.0.1 + keycloak_domain_mode_cluster: 'yes' + - set: centos-7-domain-mode-cluster + puppet: puppet6 + keycloak_version: 8.0.1 + keycloak_domain_mode_cluster: 'yes' + - set: centos-7-domain-mode-cluster + puppet: puppet6 + keycloak_version: 12.0.1 + keycloak_domain_mode_cluster: 'yes' +.gitignore: + paths: + - /vagrant/.vagrant/ + - /vagrant/*.log .gitlab-ci.yml: delete: true appveyor.yml: diff --git a/spec/acceptance/1_domain_mode_cluster_spec.rb b/spec/acceptance/1_domain_mode_cluster_spec.rb index 60bb589a..1a763ad1 100644 --- a/spec/acceptance/1_domain_mode_cluster_spec.rb +++ b/spec/acceptance/1_domain_mode_cluster_spec.rb @@ -1,135 +1,131 @@ require 'spec_helper_acceptance' -# This check needs to be here or Beaker will try to run find_only_one on -# non-domain-mode tests and fail miserably. -if RSpec.configuration.keycloak_domain_mode_cluster - describe 'keycloak domain mode cluster' do - domain_master = find_only_one('domain_master') - domain_slave = find_only_one('domain_slave') - db = find_only_one('db') +describe 'keycloak domain mode cluster', if: RSpec.configuration.keycloak_domain_mode_cluster do + domain_master = hosts_with_name(hosts, 'master')[0] + domain_slave = hosts_with_name(hosts, 'slave')[0] + db = hosts_with_name(hosts, 'db')[0] - context 'new cluster' do - it 'launches' do - db_pp = <<-EOS - class { '::postgresql::globals': - manage_package_repo => true, - version => '9.6', - } + context 'new cluster' do + it 'launches' do + db_pp = <<-EOS + class { '::postgresql::globals': + manage_package_repo => true, + version => '9.6', + } - class { '::postgresql::server': - listen_addresses => '*', - require => Class['::postgresql::globals'] - } + class { '::postgresql::server': + listen_addresses => '*', + require => Class['::postgresql::globals'] + } - ::postgresql::server::role { 'keycloak': - password_hash => postgresql_password('keycloak', 'keycloak'), - connection_limit => 300, - require => Class['::postgresql::server'] - } + ::postgresql::server::role { 'keycloak': + password_hash => postgresql_password('keycloak', 'keycloak'), + connection_limit => 300, + require => Class['::postgresql::server'] + } - ::postgresql::server::database_grant { 'Grant all to keycloak': - privilege => 'ALL', - db => 'keycloak', - role => 'keycloak', - } + ::postgresql::server::database_grant { 'Grant all to keycloak': + privilege => 'ALL', + db => 'keycloak', + role => 'keycloak', + } - ::postgresql::server::db { 'keycloak': - user => 'keycloak', - password => postgresql_password('keycloak', 'keycloak'), - } + ::postgresql::server::db { 'keycloak': + user => 'keycloak', + password => postgresql_password('keycloak', 'keycloak'), + } - postgresql::server::pg_hba_rule { 'Allow Keycloak instances network access to the database': - description => 'Open up PostgreSQL for access from anywhere', - type => 'host', - database => 'keycloak', - user => 'keycloak', - address => '0.0.0.0/0', - auth_method => 'md5', - require => Class['::postgresql::server'] - } - EOS + postgresql::server::pg_hba_rule { 'Allow Keycloak instances network access to the database': + description => 'Open up PostgreSQL for access from anywhere', + type => 'host', + database => 'keycloak', + user => 'keycloak', + address => '0.0.0.0/0', + auth_method => 'md5', + require => Class['::postgresql::server'] + } + EOS - master_pp = <<-EOS - class { '::keycloak': - operating_mode => 'domain', - role => 'master', - management_bind_address => $::ipaddress, - enable_jdbc_ping => true, - wildfly_user => 'wildfly', - wildfly_user_password => 'wildfly', - manage_install => true, - manage_datasource => false, - version => '10.0.1', - datasource_driver => 'postgresql', - datasource_host => 'centos-7-db', - datasource_port => 5432, - datasource_dbname => 'keycloak', - datasource_username => 'keycloak', - datasource_password => 'keycloak', - admin_user => 'admin', - admin_user_password => 'changeme', - service_bind_address => '0.0.0.0', - proxy_https => false, - } - EOS + master_pp = <<-EOS + class { '::keycloak': + operating_mode => 'domain', + role => 'master', + management_bind_address => $::ipaddress, + enable_jdbc_ping => true, + wildfly_user => 'wildfly', + wildfly_user_password => 'wildfly', + manage_install => true, + manage_datasource => false, + version => '10.0.1', + datasource_driver => 'postgresql', + datasource_host => 'db', + datasource_port => 5432, + datasource_dbname => 'keycloak', + datasource_username => 'keycloak', + datasource_password => 'keycloak', + admin_user => 'admin', + admin_user_password => 'changeme', + service_bind_address => '0.0.0.0', + proxy_https => false, + } + EOS - slave_pp = <<-EOS - class { '::keycloak': - operating_mode => 'domain', - role => 'slave', - enable_jdbc_ping => true, - management_bind_address => $::ipaddress, - wildfly_user => 'wildfly', - wildfly_user_password => 'wildfly', - master_address => 'centos-7-master', - manage_install => true, - manage_datasource => false, - version => '10.0.1', - datasource_driver => 'postgresql', - datasource_host => 'centos-7-db', - datasource_port => 5432, - datasource_dbname => 'keycloak', - datasource_username => 'keycloak', - datasource_password => 'keycloak', - admin_user => 'admin', - admin_user_password => 'changeme', - service_bind_address => '0.0.0.0', - proxy_https => false, - } - EOS + slave_pp = <<-EOS + class { '::keycloak': + operating_mode => 'domain', + role => 'slave', + enable_jdbc_ping => true, + management_bind_address => $::ipaddress, + wildfly_user => 'wildfly', + wildfly_user_password => 'wildfly', + master_address => 'master', + manage_install => true, + manage_datasource => false, + version => '10.0.1', + datasource_driver => 'postgresql', + datasource_host => 'db', + datasource_port => 5432, + datasource_dbname => 'keycloak', + datasource_username => 'keycloak', + datasource_password => 'keycloak', + admin_user => 'admin', + admin_user_password => 'changeme', + service_bind_address => '0.0.0.0', + proxy_https => false, + } + EOS - apply_manifest_on(db, db_pp, catch_failures: true) - apply_manifest_on(domain_master, master_pp, catch_failures: true) - apply_manifest_on(domain_master, master_pp, catch_changes: true) - apply_manifest_on(domain_slave, slave_pp, catch_failures: true) - apply_manifest_on(domain_slave, slave_pp, catch_changes: true) - end + apply_manifest_on(db, db_pp, catch_failures: true) + apply_manifest_on(domain_master, master_pp, catch_failures: true) + apply_manifest_on(domain_master, master_pp, catch_changes: true) + apply_manifest_on(domain_slave, slave_pp, catch_failures: true) + apply_manifest_on(domain_slave, slave_pp, catch_changes: true) + end - describe service('keycloak'), node: domain_master do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end + describe service('keycloak'), node: domain_master do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end - describe service('keycloak'), node: domain_slave do - it { is_expected.to be_enabled } - it { is_expected.to be_running } - end + describe service('keycloak'), node: domain_slave do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end - it 'data replicates from master to slave' do - on domain_master, '/opt/keycloak/bin/kcadm-wrapper.sh create roles -r master -s name=testrole' - on domain_slave, '/opt/keycloak/bin/kcadm-wrapper.sh get roles/testrole -r master' do - data = JSON.parse(stdout) - expect(data['name']).to eq('testrole') - end + it 'data replicates from master to slave' do + on domain_master, '/opt/keycloak/bin/kcadm-wrapper.sh create roles -r master -s name=testrole' + on domain_slave, '/opt/keycloak/bin/kcadm-wrapper.sh get roles/testrole -r master' do + data = JSON.parse(stdout) + expect(data['name']).to eq('testrole') end + end - it 'data replicates from slave to master' do - on domain_slave, '/opt/keycloak/bin/kcadm-wrapper.sh delete roles/testrole -r master' - on domain_master, '/opt/keycloak/bin/kcadm-wrapper.sh get roles -r master' do - data = JSON.parse(stdout) - match = data.select { |role| role['name'] == 'testrole' } - expect(match).to be_empty - end + it 'data replicates from slave to master' do + on domain_slave, '/opt/keycloak/bin/kcadm-wrapper.sh delete roles/testrole -r master' + on domain_master, '/opt/keycloak/bin/kcadm-wrapper.sh get roles -r master' do + data = JSON.parse(stdout) + match = data.select { |role| role['name'] == 'testrole' } + expect(match).to be_empty end end end diff --git a/spec/acceptance/nodesets/centos-7-domain-mode-cluster.yml b/spec/acceptance/nodesets/centos-7-domain-mode-cluster.yml index 2ec51e52..93589f4c 100644 --- a/spec/acceptance/nodesets/centos-7-domain-mode-cluster.yml +++ b/spec/acceptance/nodesets/centos-7-domain-mode-cluster.yml @@ -1,5 +1,5 @@ HOSTS: - centos-7-master: + master: roles: - agent - default @@ -13,7 +13,7 @@ HOSTS: docker_image_commands: - 'yum install -y wget which cronie iproute initscripts' docker_container_name: 'keycloak-master-el7' - centos-7-slave: + slave: roles: - agent - domain_slave @@ -26,7 +26,7 @@ HOSTS: docker_image_commands: - 'yum install -y wget which cronie iproute initscripts' docker_container_name: 'keycloak-slave-el7' - centos-7-db: + db: roles: - agent - db diff --git a/spec/acceptance/nodesets/centos-7.yml b/spec/acceptance/nodesets/centos-7.yml index a071fd9b..7e383509 100644 --- a/spec/acceptance/nodesets/centos-7.yml +++ b/spec/acceptance/nodesets/centos-7.yml @@ -10,6 +10,10 @@ HOSTS: - '/usr/sbin/init' docker_image_commands: - 'yum install -y wget which cronie iproute initscripts' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 docker_container_name: 'keycloak-el7' CONFIG: log_level: debug diff --git a/spec/acceptance/nodesets/centos-8.yml b/spec/acceptance/nodesets/centos-8.yml index 7fb073bd..6ab64458 100644 --- a/spec/acceptance/nodesets/centos-8.yml +++ b/spec/acceptance/nodesets/centos-8.yml @@ -12,6 +12,10 @@ HOSTS: - 'yum install -y dnf-utils' - 'dnf config-manager --set-enabled powertools' - 'yum install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 docker_container_name: 'keycloak-el8' CONFIG: log_level: debug diff --git a/spec/acceptance/nodesets/debian-10.yml b/spec/acceptance/nodesets/debian-10.yml index 91b3b84f..6f96bade 100644 --- a/spec/acceptance/nodesets/debian-10.yml +++ b/spec/acceptance/nodesets/debian-10.yml @@ -14,6 +14,10 @@ HOSTS: - 'echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen' - 'echo "LANG=en_US.UTF-8" > /etc/locale.conf' - 'locale-gen en_US.UTF-8' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 docker_container_name: 'keycloak-debian10' CONFIG: log_level: debug diff --git a/spec/acceptance/nodesets/debian-9.yml b/spec/acceptance/nodesets/debian-9.yml index 7987c696..0a843a23 100644 --- a/spec/acceptance/nodesets/debian-9.yml +++ b/spec/acceptance/nodesets/debian-9.yml @@ -14,6 +14,10 @@ HOSTS: - 'echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen' - 'echo "LANG=en_US.UTF-8" > /etc/locale.conf' - 'locale-gen en_US.UTF-8' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 docker_container_name: 'keycloak-debian9' CONFIG: log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-1804.yml b/spec/acceptance/nodesets/ubuntu-1804.yml index c90273ea..7e42ee99 100644 --- a/spec/acceptance/nodesets/ubuntu-1804.yml +++ b/spec/acceptance/nodesets/ubuntu-1804.yml @@ -11,6 +11,10 @@ HOSTS: - "rm -f /etc/dpkg/dpkg.cfg.d/excludes" - 'apt-get install -y wget net-tools locales apt-transport-https ca-certificates iproute2' - 'locale-gen en_US.UTF-8' + docker_env: + - LANG=en_US.UTF-8 + - LANGUAGE=en_US.UTF-8 + - LC_ALL=en_US.UTF-8 docker_container_name: 'keycloak-ubuntu1804' CONFIG: log_level: debug