|
2 | 2 |
|
3 | 3 | require 'spec_helper_acceptance' |
4 | 4 |
|
5 | | -describe 'jira 10 postgresql' do |
6 | | - it 'installs jira 10 with defaults' do |
7 | | - prepare = <<-EOS |
8 | | -
|
9 | | - package {'diffutils': |
10 | | - ensure => installed |
11 | | - } |
12 | | - file_line{'enable show_diff': |
13 | | - path => '/etc/puppetlabs/puppet/puppet.conf', |
14 | | - line => 'show_diff = true' |
15 | | - } |
16 | | - EOS |
17 | | - apply_manifest(prepare, catch_failures: true) |
18 | | - |
19 | | - pp = <<-EOS |
20 | | -
|
21 | | - $java_package = $facts['os']['family'] ? { |
22 | | - 'RedHat' => 'java-17-openjdk-headless', |
23 | | - 'Debian' => 'openjdk-17-jre-headless', |
24 | | - } |
25 | | -
|
26 | | - $java_home = $facts['os']['family'] ? { |
27 | | - 'RedHat' => '/usr/lib/jvm/jre-17-openjdk', |
28 | | - 'Debian' => '/usr/lib/jvm/java-1.17.0-openjdk-amd64', |
29 | | - } |
30 | | -
|
31 | | - # The output of `systemctl status postgresql` is non ascii which |
32 | | - # breaks the Exec in Postgresql::Server::Instance::Reload |
33 | | - # on rhel based docker containers |
34 | | - # We don't need the output. |
35 | | - class { 'postgresql::server': |
36 | | - service_status => 'systemctl status postgresql > /dev/null' |
37 | | - } |
38 | | -
|
39 | | - postgresql::server::db { 'jira': |
40 | | - user => 'jiraadm', |
41 | | - password => postgresql::postgresql_password('jiraadm', 'mypassword'), |
42 | | - } |
43 | | -
|
44 | | - # There is a bug in the check-java.sh that prevents jira from starting on Centos Stream 8 |
45 | | - # https://jira.atlassian.com/browse/JRASERVER-77097 |
46 | | - # Running with script_check_java_manage => true to solve this |
47 | | - class { 'jira': |
48 | | - version => '10.3.2', |
49 | | - change_dbpassword => true, |
50 | | - java_package => $java_package, |
51 | | - javahome => $java_home, |
52 | | - script_check_java_manage => false, |
53 | | - connection_settings => 'tcpKeepAlive=true', |
54 | | - require => Postgresql::Server::Db['jira'] |
55 | | - } |
56 | | - EOS |
57 | | - |
58 | | - pp_upgrade = <<-EOS |
59 | | - $java_package = $facts['os']['family'] ? { |
60 | | - 'RedHat' => 'java-17-openjdk-headless', |
61 | | - 'Debian' => 'openjdk-17-jre-headless', |
62 | | - } |
63 | | -
|
64 | | - $java_home = $facts['os']['family'] ? { |
65 | | - 'RedHat' => '/usr/lib/jvm/jre-17-openjdk', |
66 | | - 'Debian' => '/usr/lib/jvm/java-1.17.0-openjdk-amd64', |
67 | | - } |
68 | | -
|
69 | | - class { 'jira': |
70 | | - version => '10.3.3', |
71 | | - change_dbpassword => true, |
72 | | - java_package => $java_package, |
73 | | - javahome => $java_home, |
74 | | - connection_settings => 'tcpKeepAlive=true', |
75 | | - script_check_java_manage => false |
76 | | - } |
77 | | - EOS |
78 | | - |
79 | | - # jira just takes *ages* to start up :-( |
80 | | - wget_cmd = 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080' |
81 | | - apply_manifest(pp, catch_failures: true) |
82 | | - sleep SLEEP_SECONDS |
83 | | - shell wget_cmd, acceptable_exit_codes: [0, 8] |
84 | | - sleep SLEEP_SECONDS |
85 | | - shell wget_cmd, acceptable_exit_codes: [0, 8] |
86 | | - pp = pp.gsub(/change_dbpassword.+=> true,/, 'change_dbpassword => false,') |
87 | | - apply_manifest(pp, catch_changes: true) |
88 | | - |
89 | | - apply_manifest(pp_upgrade, catch_failures: true) |
90 | | - sleep SLEEP_SECONDS |
91 | | - shell wget_cmd, acceptable_exit_codes: [0, 8] |
92 | | - sleep SLEEP_SECONDS |
93 | | - shell wget_cmd, acceptable_exit_codes: [0, 8] |
94 | | - |
95 | | - pp_upgrade = pp_upgrade.gsub(/change_dbpassword.+=> true,/, 'change_dbpassword => false,') |
96 | | - apply_manifest(pp_upgrade, catch_changes: true) |
97 | | - end |
98 | | - |
99 | | - describe process('java') do |
100 | | - it { is_expected.to be_running } |
101 | | - end |
102 | | - |
103 | | - describe port(8080) do |
104 | | - it { is_expected.to be_listening } |
105 | | - end |
106 | | - |
107 | | - describe service('jira') do |
108 | | - it { is_expected.to be_enabled } |
109 | | - it { is_expected.to be_running } |
110 | | - end |
111 | | - |
112 | | - describe user('jira') do |
113 | | - it { is_expected.to belong_to_group 'jira' } |
114 | | - it { is_expected.to have_login_shell '/bin/true' } |
115 | | - end |
116 | | - describe command('sleep 1200') do |
117 | | - end |
118 | | - describe command('wget -q --tries=54 --retry-connrefused --read-timeout=10 -O- localhost:8080') do |
119 | | - its(:stdout) { is_expected.to include('10.3.3') } |
120 | | - end |
| 5 | +def on_supported_os |
| 6 | + (fact('os.family') == 'Debian' and fact('os.release.major') == '11') or (fact('os.family') == 'RedHat' and fact('os.release.major') >= '8') |
| 7 | +end |
121 | 8 |
|
122 | | - describe 'shutdown' do |
123 | | - it { shell('service jira stop', acceptable_exit_codes: [0, 1]) } |
124 | | - it { shell('pkill -9 -f postgres', acceptable_exit_codes: [0, 1]) } |
125 | | - it { shell('pkill -9 -f jira', acceptable_exit_codes: [0, 1]) } |
| 9 | +context 'jira 10 only on RedHat >=8 and Debian-11', if: on_supported_os do |
| 10 | + describe 'jira 10 postgresql' do |
| 11 | + it 'installs jira 10 with defaults' do |
| 12 | + prepare = <<-EOS |
| 13 | + package {'diffutils': |
| 14 | + ensure => installed |
| 15 | + } |
| 16 | + file_line{'enable show_diff': |
| 17 | + path => '/etc/puppetlabs/puppet/puppet.conf', |
| 18 | + line => 'show_diff = true' |
| 19 | + } |
| 20 | + EOS |
| 21 | + apply_manifest(prepare, catch_failures: true) |
| 22 | + |
| 23 | + pre = <<-EOS |
| 24 | + if $facts['os']['family'] == 'RedHat' { |
| 25 | + $java_package = 'java-17-openjdk' |
| 26 | + $java_home = '/usr/lib/jvm/jre-17-openjdk' |
| 27 | + $manage_dnf_module = true |
| 28 | + } |
| 29 | + elsif $facts['os']['family'] == 'Debian' { |
| 30 | + $java_package = 'openjdk-17-jre' |
| 31 | + $java_home = '/usr/lib/jvm/java-1.17.0-openjdk-amd64' |
| 32 | + $manage_dnf_module = false |
| 33 | + } |
| 34 | + EOS |
| 35 | + |
| 36 | + pp = <<-EOS |
| 37 | + # The output of `systemctl status postgresql` is non ascii which |
| 38 | + # breaks the Exec in Postgresql::Server::Instance::Reload |
| 39 | + # on rhel based docker containers |
| 40 | + # We don't need the output. |
| 41 | + class { 'postgresql::globals': |
| 42 | + manage_dnf_module => $manage_dnf_module, |
| 43 | + version => '13', |
| 44 | + } |
| 45 | + class { 'postgresql::server': |
| 46 | + service_status => 'systemctl status postgresql > /dev/null' |
| 47 | + } |
| 48 | +
|
| 49 | + postgresql::server::db { 'jira': |
| 50 | + user => 'jiraadm', |
| 51 | + password => postgresql::postgresql_password('jiraadm', 'mypassword'), |
| 52 | + } |
| 53 | +
|
| 54 | + # There is a bug in the check-java.sh that prevents jira from starting on Centos Stream 8 |
| 55 | + # https://jira.atlassian.com/browse/JRASERVER-77097 |
| 56 | + # Running with script_check_java_manage => true to solve this |
| 57 | + class { 'jira': |
| 58 | + version => '10.3.2', |
| 59 | + java_package => $java_package, |
| 60 | + javahome => $java_home, |
| 61 | + script_check_java_manage => false, |
| 62 | + connection_settings => 'tcpKeepAlive=true', |
| 63 | + require => Postgresql::Server::Db['jira'] |
| 64 | + } |
| 65 | + EOS |
| 66 | + pp = pre + pp |
| 67 | + |
| 68 | + pp_upgrade = <<-EOS |
| 69 | + class { 'jira': |
| 70 | + version => '10.3.3', |
| 71 | + java_package => $java_package, |
| 72 | + javahome => $java_home, |
| 73 | + connection_settings => 'tcpKeepAlive=true', |
| 74 | + script_check_java_manage => false |
| 75 | + } |
| 76 | + EOS |
| 77 | + pp_upgrade = pre + pp_upgrade |
| 78 | + |
| 79 | + # jira just takes *ages* to start up :-( |
| 80 | + wget_cmd = 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080' |
| 81 | + apply_manifest(pp, catch_failures: true) |
| 82 | + sleep SLEEP_SECONDS |
| 83 | + shell wget_cmd, acceptable_exit_codes: [0, 8] |
| 84 | + sleep SLEEP_SECONDS |
| 85 | + shell wget_cmd, acceptable_exit_codes: [0, 8] |
| 86 | + apply_manifest(pp, catch_changes: true) |
| 87 | + |
| 88 | + apply_manifest(pp_upgrade, catch_failures: true) |
| 89 | + sleep SLEEP_SECONDS |
| 90 | + shell wget_cmd, acceptable_exit_codes: [0, 8] |
| 91 | + sleep SLEEP_SECONDS |
| 92 | + shell wget_cmd, acceptable_exit_codes: [0, 8] |
| 93 | + |
| 94 | + apply_manifest(pp_upgrade, catch_changes: true) |
| 95 | + end |
| 96 | + |
| 97 | + describe process('java') do |
| 98 | + it { is_expected.to be_running } |
| 99 | + end |
| 100 | + |
| 101 | + describe port(8080) do |
| 102 | + it { is_expected.to be_listening } |
| 103 | + end |
| 104 | + |
| 105 | + describe service('jira') do |
| 106 | + it { is_expected.to be_enabled } |
| 107 | + it { is_expected.to be_running } |
| 108 | + end |
| 109 | + |
| 110 | + describe user('jira') do |
| 111 | + it { is_expected.to belong_to_group 'jira' } |
| 112 | + it { is_expected.to have_login_shell '/bin/true' } |
| 113 | + end |
| 114 | + |
| 115 | + describe command('wget -q --tries=54 --retry-connrefused --read-timeout=10 -O- localhost:8080') do |
| 116 | + its(:stdout) { is_expected.to include('10.3.3') } |
| 117 | + end |
| 118 | + |
| 119 | + describe 'shutdown' do |
| 120 | + it { shell('service jira stop', acceptable_exit_codes: [0, 1]) } |
| 121 | + it { shell('pkill -9 -f postgres', acceptable_exit_codes: [0, 1]) } |
| 122 | + it { shell('pkill -9 -f jira', acceptable_exit_codes: [0, 1]) } |
| 123 | + end |
126 | 124 | end |
127 | 125 | end |
0 commit comments