|
5 | 5 |
|
6 | 6 | def allow_standard_non_returning_calls
|
7 | 7 | allow_apply
|
8 |
| - allow_any_task |
9 | 8 | allow_any_command
|
| 9 | + execute_no_plan |
| 10 | + allow_out_message |
10 | 11 | end
|
11 | 12 |
|
12 | 13 | describe 'basic functionality' do
|
13 | 14 | let(:params) do
|
14 | 15 | {
|
15 | 16 | 'primary_host' => 'primary',
|
16 | 17 | 'compiler_host' => 'compiler',
|
17 |
| - 'avail_group_letter' => 'A', |
18 |
| - 'primary_postgresql_host' => 'primary_postgresql', |
19 | 18 | }
|
20 | 19 | end
|
21 | 20 |
|
| 21 | + let(:params_with_avail_group_b) do |
| 22 | + params.merge({ 'avail_group_letter' => 'B' }) |
| 23 | + end |
| 24 | + |
| 25 | + let(:params_with_primary_postgresql_host) do |
| 26 | + params.merge({ 'primary_postgresql_host' => 'custom_postgresql' }) |
| 27 | + end |
| 28 | + |
22 | 29 | let(:cfg) do
|
23 | 30 | {
|
24 | 31 | 'params' => {
|
25 |
| - 'primary_host' => 'primary' |
| 32 | + 'primary_host' => 'primary', |
| 33 | + 'replica_host' => nil, |
| 34 | + 'primary_postgresql_host' => nil, |
| 35 | + 'replica_postgresql_host' => nil |
26 | 36 | },
|
27 | 37 | 'role-letter' => {
|
28 | 38 | 'server' => {
|
29 | 39 | 'A' => 'server_a',
|
30 |
| - 'B' => 'server_b' |
| 40 | + 'B' => nil |
| 41 | + }, |
| 42 | + 'postgresql': { |
| 43 | + 'A' => nil, |
| 44 | + 'B' => nil |
31 | 45 | }
|
32 | 46 | }
|
33 | 47 | }
|
34 | 48 | end
|
35 |
| - let(:certdata) { { 'certname' => 'primary', 'extensions' => { '1.3.6.1.4.1.34380.1.1.9813' => 'A' } } } |
36 | 49 |
|
37 | 50 | it 'runs successfully when no alt-names are specified' do
|
38 | 51 | allow_standard_non_returning_calls
|
39 | 52 |
|
40 | 53 | expect_task('peadm::get_peadm_config').always_return(cfg)
|
| 54 | + expect_task('peadm::get_psql_version').with_targets(['server_a']) |
| 55 | + |
| 56 | + expect_plan('peadm::subplans::component_install') |
| 57 | + expect_plan('peadm::util::copy_file').be_called_times(1) |
| 58 | + expect_task('peadm::puppet_runonce').with_targets(['compiler']) |
| 59 | + expect_task('peadm::puppet_runonce').with_targets(['server_a']) |
| 60 | + expect(run_plan('peadm::add_compiler', params)).to be_ok |
| 61 | + end |
| 62 | + |
| 63 | + it 'handles different avail_group_letter values' do |
| 64 | + allow_standard_non_returning_calls |
| 65 | + cfg['role-letter']['server']['B'] = 'server_b' |
| 66 | + |
| 67 | + expect_task('peadm::get_peadm_config').always_return(cfg) |
| 68 | + expect_task('peadm::get_psql_version').with_targets(['server_b']) |
41 | 69 |
|
42 |
| - # TODO: Due to difficulty mocking get_targets, with_params modifier has been commented out |
43 | 70 | expect_plan('peadm::subplans::component_install')
|
44 |
| - # .with_params({ |
45 |
| - # 'targets' => 'compiler', |
46 |
| - # 'primary_host' => 'primary', |
47 |
| - # 'avail_group_letter' => 'A', |
48 |
| - # 'dns_alt_names' => nil, |
49 |
| - # 'role' => 'pe_compiler' |
50 |
| - # }) |
| 71 | + expect_plan('peadm::util::copy_file').be_called_times(1) |
| 72 | + expect_task('peadm::puppet_runonce').with_targets(['compiler']) |
| 73 | + expect_task('peadm::puppet_runonce').with_targets(['server_a']) |
| 74 | + expect_task('peadm::puppet_runonce').with_targets(['server_b']) |
| 75 | + expect(run_plan('peadm::add_compiler', params_with_avail_group_b)).to be_ok |
| 76 | + end |
| 77 | + |
| 78 | + it 'handles specified primary_postgresql_host' do |
| 79 | + allow_standard_non_returning_calls |
51 | 80 |
|
| 81 | + expect_task('peadm::get_peadm_config').always_return(cfg) |
| 82 | + expect_task('peadm::get_psql_version').with_targets(['custom_postgresql']) |
| 83 | + |
| 84 | + expect_plan('peadm::subplans::component_install') |
52 | 85 | expect_plan('peadm::util::copy_file').be_called_times(1)
|
| 86 | + expect_task('peadm::puppet_runonce').with_targets(['compiler']) |
| 87 | + expect_task('peadm::puppet_runonce').with_targets(['custom_postgresql']) |
| 88 | + expect(run_plan('peadm::add_compiler', params_with_primary_postgresql_host)).to be_ok |
| 89 | + end |
| 90 | + |
| 91 | + it 'handles external postgresql host group A' do |
| 92 | + allow_standard_non_returning_calls |
| 93 | + cfg['params']['primary_postgresql_host'] = 'external_postgresql' |
| 94 | + cfg['params']['replica_postgresql_host'] = 'external_postgresql' |
| 95 | + |
| 96 | + expect_task('peadm::get_peadm_config').always_return(cfg) |
| 97 | + expect_task('peadm::get_psql_version').with_targets(['external_postgresql']) |
| 98 | + |
| 99 | + expect_plan('peadm::subplans::component_install') |
| 100 | + expect_plan('peadm::util::copy_file').be_called_times(1) |
| 101 | + expect_task('peadm::puppet_runonce').with_targets(['compiler']) |
| 102 | + expect_task('peadm::puppet_runonce').with_targets(['external_postgresql']) |
53 | 103 | expect(run_plan('peadm::add_compiler', params)).to be_ok
|
54 | 104 | end
|
55 | 105 |
|
56 |
| - context 'with alt-names' do |
57 |
| - let(:params2) do |
58 |
| - params.merge({ 'dns_alt_names' => 'foo,bar' }) |
59 |
| - end |
60 |
| - |
61 |
| - it 'runs successfully when alt-names are specified' do |
62 |
| - allow_standard_non_returning_calls |
63 |
| - expect_task('peadm::get_peadm_config').always_return(cfg) |
64 |
| - |
65 |
| - # TODO: Due to difficulty mocking get_targets, with_params modifier has been commented out |
66 |
| - expect_plan('peadm::subplans::component_install') |
67 |
| - # .with_params({ |
68 |
| - # 'targets' => 'compiler', |
69 |
| - # 'primary_host' => 'primary', |
70 |
| - # 'avail_group_letter' => 'A', |
71 |
| - # 'dns_alt_names' => 'foo,bar', |
72 |
| - # 'role' => 'pe_compiler' |
73 |
| - # }) |
74 |
| - |
75 |
| - expect_plan('peadm::util::copy_file').be_called_times(1) |
76 |
| - expect(run_plan('peadm::add_compiler', params2)).to be_ok |
77 |
| - end |
| 106 | + it 'handles external postgresql host group A with replica' do |
| 107 | + allow_standard_non_returning_calls |
| 108 | + cfg['params']['primary_postgresql_host'] = 'external_postgresql' |
| 109 | + cfg['role-letter']['server']['B'] = 'replica' |
| 110 | + |
| 111 | + expect_task('peadm::get_peadm_config').always_return(cfg) |
| 112 | + expect_task('peadm::get_psql_version').with_targets(['external_postgresql']) |
| 113 | + |
| 114 | + expect_plan('peadm::subplans::component_install') |
| 115 | + expect_plan('peadm::util::copy_file').be_called_times(1) |
| 116 | + expect_task('peadm::puppet_runonce').with_targets(['compiler']) |
| 117 | + expect_task('peadm::puppet_runonce').with_targets(['external_postgresql']) |
| 118 | + expect_task('peadm::puppet_runonce').with_targets(['replica']) |
| 119 | + expect(run_plan('peadm::add_compiler', params)).to be_ok |
| 120 | + end |
| 121 | + |
| 122 | + it 'handles external postgresql host group B' do |
| 123 | + allow_standard_non_returning_calls |
| 124 | + cfg['params']['replica_postgresql_host'] = 'replica_external_postgresql' |
| 125 | + |
| 126 | + expect_task('peadm::get_peadm_config').always_return(cfg) |
| 127 | + expect_task('peadm::get_psql_version').with_targets(['replica_external_postgresql']) |
| 128 | + |
| 129 | + expect_plan('peadm::subplans::component_install') |
| 130 | + expect_plan('peadm::util::copy_file').be_called_times(1) |
| 131 | + expect_task('peadm::puppet_runonce').with_targets(['compiler']) |
| 132 | + expect_task('peadm::puppet_runonce').with_targets(['replica_external_postgresql']) |
| 133 | + expect_task('peadm::puppet_runonce').with_targets(['server_a']) |
| 134 | + expect(run_plan('peadm::add_compiler', params_with_avail_group_b)).to be_ok |
78 | 135 | end
|
79 | 136 | end
|
80 | 137 | end
|
0 commit comments