Skip to content

Commit

Permalink
Improvements to testing, PDK sync some testing code
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock committed Mar 6, 2021
1 parent 2196a28 commit 871c6a1
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 131 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
228 changes: 112 additions & 116 deletions spec/acceptance/1_domain_mode_cluster_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/acceptance/nodesets/centos-7-domain-mode-cluster.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
HOSTS:
centos-7-master:
master:
roles:
- agent
- default
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/acceptance/nodesets/centos-7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/acceptance/nodesets/centos-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/acceptance/nodesets/debian-10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/acceptance/nodesets/debian-9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions spec/acceptance/nodesets/ubuntu-1804.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 871c6a1

Please sign in to comment.