From ae452d6938aad7a833e7483012f88ac7946971fd Mon Sep 17 00:00:00 2001 From: Lightning Date: Thu, 22 Feb 2024 14:57:05 +0100 Subject: [PATCH] fix unit tests --- spec/acceptance/galera_codership_spec.rb | 2 +- spec/classes/galera_debian_spec.rb | 4 ++-- spec/classes/galera_init_spec.rb | 8 ++++---- spec/classes/galera_redhat_spec.rb | 4 ++-- spec/default_facts.yml | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/acceptance/galera_codership_spec.rb b/spec/acceptance/galera_codership_spec.rb index 4a082cb..0e39f9c 100644 --- a/spec/acceptance/galera_codership_spec.rb +++ b/spec/acceptance/galera_codership_spec.rb @@ -21,7 +21,7 @@ class { 'galera': deb_sysmaint_password => 'sysmaint', configure_firewall => false, galera_servers => ['127.0.0.1'], - galera_master => $fqdn, + galera_master => $facts['networking']['fqdn'], root_password => 'root_password', status_password => 'status_password', override_options => { diff --git a/spec/classes/galera_debian_spec.rb b/spec/classes/galera_debian_spec.rb index 3d4c873..a5f1104 100644 --- a/spec/classes/galera_debian_spec.rb +++ b/spec/classes/galera_debian_spec.rb @@ -30,7 +30,7 @@ context 'when this node is the master' do before(:each) do - facts.merge!(fqdn: 'control1') + facts.merge!(networking: {fqdn: 'control1'}) end let(:node) { 'control1' } @@ -69,7 +69,7 @@ context 'when this node is a slave' do before(:each) do - facts.merge!(fqdn: 'slave') + facts.merge!(networking: {fqdn: 'slave'}) end let(:node) { 'slave' } diff --git a/spec/classes/galera_init_spec.rb b/spec/classes/galera_init_spec.rb index 338959a..a6476c7 100644 --- a/spec/classes/galera_init_spec.rb +++ b/spec/classes/galera_init_spec.rb @@ -76,12 +76,12 @@ end context 'when node is the master' do - before(:each) { params.merge!(galera_master: facts[:fqdn]) } + before(:each) { params.merge!(galera_master: facts[:networking][:fqdn]) } it { is_expected.to contain_exec('bootstrap_galera_cluster') } end context 'when node is not the master' do - before(:each) { params.merge!(galera_master: "not_#{facts[:fqdn]}") } + before(:each) { params.merge!(galera_master: "not_#{facts[:networking][:fqdn]}") } it { is_expected.not_to contain_exec('bootstrap_galera_cluster') } end @@ -142,14 +142,14 @@ end context 'when create_root_user=undef (default) and the master' do - before(:each) { params.merge!(galera_master: facts[:fqdn]) } + before(:each) { params.merge!(galera_master: facts[:networking][:fqdn]) } it { is_expected.to contain_class('galera').with(create_root_user: nil) } it { is_expected.to contain_class('mysql::server').with(create_root_user: true) } it { is_expected.to contain_mysql_user('root@localhost') } end context 'when create_root_user=undef (default) and not the master' do - before(:each) { params.merge!(galera_master: "not_#{facts[:fqdn]}") } + before(:each) { params.merge!(galera_master: "not_#{facts[:networking][:fqdn]}") } it { is_expected.to contain_class('mysql::server').with(create_root_user: false) } it { is_expected.not_to contain_mysql_user('root@localhost') } end diff --git a/spec/classes/galera_redhat_spec.rb b/spec/classes/galera_redhat_spec.rb index 0a01d45..8b85c5f 100644 --- a/spec/classes/galera_redhat_spec.rb +++ b/spec/classes/galera_redhat_spec.rb @@ -38,7 +38,7 @@ end context 'when node is the master' do - before(:each) { params.merge!(galera_master: facts[:fqdn]) } + before(:each) { params.merge!(galera_master: facts[:networking][:fqdn]) } it { is_expected.to contain_exec('bootstrap_galera_cluster').with_command(%r{systemctl start mysql@bootstrap.service}) } end @@ -52,7 +52,7 @@ shared_examples_for 'galera on RedHat 6' do context 'when node is the master' do - before(:each) { params.merge!(galera_master: facts[:fqdn]) } + before(:each) { params.merge!(galera_master: facts[:networking][:fqdn]) } it { is_expected.to contain_exec('bootstrap_galera_cluster').with_command(%r{/etc/init.d/mysql bootstrap-pxc}) } end end diff --git a/spec/default_facts.yml b/spec/default_facts.yml index a9ef123..d8774cc 100644 --- a/spec/default_facts.yml +++ b/spec/default_facts.yml @@ -6,7 +6,7 @@ networking: ip: "172.16.254.254" ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" mac: "AA:AA:AA:AA:AA:AA" + fqdn: localhost is_pe: false root_home: "/root" -fqdn: localhost