Skip to content

Commit b274728

Browse files
committed
remove jira::facts and simplify upgrade logic
Also test upgrade in acceptance
1 parent 5198c24 commit b274728

File tree

9 files changed

+53
-173
lines changed

9 files changed

+53
-173
lines changed

manifests/facts.pp

-50
This file was deleted.

manifests/init.pp

+5-12
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@
107107
Boolean $service_enable = true,
108108
$service_notify = undef,
109109
$service_subscribe = undef,
110-
# Command to stop jira in preparation to updgrade. This is configurable
110+
# Command to stop jira in preparation to upgrade. This is configurable
111111
# incase the jira service is managed outside of puppet. eg: using the
112112
# puppetlabs-corosync module: 'crm resource stop jira && sleep 15'
113-
String $stop_jira = 'service jira stop && sleep 15',
113+
# Note: the command should return either 0 or 5
114+
# when the service doesn't exist
115+
String $stop_jira = '/usr/bin/systemctl stop jira.service && sleep 15',
114116
# Whether to manage the 'check-java.sh' script, and where to retrieve
115117
# the script from.
116118
Boolean $script_check_java_manage = false,
@@ -165,7 +167,7 @@
165167
Optional[String] $jvm_permgen = undef,
166168
Optional[Integer[0]] $poolsize = undef,
167169
Optional[Boolean] $enable_connection_pooling = undef,
168-
) inherits jira::params {
170+
) {
169171
if versioncmp($jira::version, '8.0.0') < 0 {
170172
fail('JIRA versions older than 8.0.0 are no longer supported. Please use an older version of this module to upgrade first.')
171173
}
@@ -198,15 +200,6 @@
198200

199201
$webappdir = "${installdir}/atlassian-${product_name}-${version}-standalone"
200202

201-
if defined('$::jira_version') {
202-
# If the running version of JIRA is less than the expected version of JIRA
203-
# Shut it down in preparation for upgrade.
204-
if versioncmp($version, $::jira_version) > 0 {
205-
notify { 'Attempting to upgrade JIRA': }
206-
exec { $stop_jira: before => Class['jira::install'] }
207-
}
208-
}
209-
210203
if ! empty($ajp) {
211204
if ! ('port' in $ajp) {
212205
fail('You need to specify a valid port for the AJP connector.')

manifests/install.pp

+15
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@
9393
subscribe => User[$jira::user],
9494
}
9595

96+
file { "${jira::installdir}/atlassian-${jira::product_name}-running":
97+
ensure => 'link',
98+
target => $jira::webappdir,
99+
notify => Exec['stop-jira-for-version-change'],
100+
require => Archive["/tmp/${file}"],
101+
}
102+
103+
exec { 'stop-jira-for-version-change':
104+
path => ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'],
105+
command => $jira::stop_jira,
106+
refreshonly => true,
107+
# 5 means the service doesn't exist; that's fine
108+
returns => [0, 5],
109+
}
110+
96111
if $jira::db == 'mysql' and $jira::mysql_connector_manage {
97112
class { 'jira::mysql_connector':
98113
require => Archive["/tmp/${file}"],

manifests/params.pp

-13
This file was deleted.

spec/acceptance/default_parameters_spec.rb

+25-3
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,39 @@ class { 'jira':
2525
javahome => $java_home,
2626
require => Postgresql::Server::Db['jira'],
2727
}
28+
EOS
29+
pp_upgrade = <<-EOS
30+
$java_package = $facts['os']['family'] ? {
31+
'RedHat' => 'java-11-openjdk-headless',
32+
'Debian' => 'openjdk-11-jre-headless',
33+
}
34+
35+
$java_home = $facts['os']['family'] ? {
36+
'RedHat' => '/usr/lib/jvm/jre-11-openjdk',
37+
'Debian' => '/usr/lib/jvm/java-1.11.0-openjdk-amd64',
38+
}
2839
29-
class { 'jira::facts': }
40+
class { 'jira':
41+
version => '8.16.0',
42+
java_package => $java_package,
43+
javahome => $java_home,
44+
}
3045
EOS
3146

47+
# jira just takes *ages* to start up :-(
3248
apply_manifest(pp, catch_failures: true)
3349
sleep 60
3450
shell 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080', acceptable_exit_codes: [0, 8]
3551
sleep 60
3652
shell 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080', acceptable_exit_codes: [0, 8]
3753
sleep 60
38-
apply_manifest(pp, catch_changes: true)
54+
apply_manifest(pp_upgrade, catch_failures: true)
55+
sleep 60
56+
shell 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080', acceptable_exit_codes: [0, 8]
57+
sleep 60
58+
shell 'wget -q --tries=24 --retry-connrefused --read-timeout=10 localhost:8080', acceptable_exit_codes: [0, 8]
59+
sleep 60
60+
apply_manifest(pp_upgrade, catch_failures: true)
3961
end
4062

4163
describe process('java') do
@@ -64,7 +86,7 @@ class { 'jira::facts': }
6486
end
6587

6688
describe command('wget -q --tries=24 --retry-connrefused --read-timeout=10 -O- localhost:8080') do
67-
its(:stdout) { is_expected.to include('8.13.5') }
89+
its(:stdout) { is_expected.to include('8.16.0') }
6890
end
6991

7092
describe 'shutdown' do

spec/acceptance/mysql_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ class { 'jira':
4848
tomcat_keystore_file => '/tmp/jira.ks',
4949
require => [Mysql::Db['jira'], Java_ks['jira']],
5050
}
51-
52-
class { 'jira::facts': }
5351
EOS
5452

5553
apply_manifest(pp, catch_failures: true)

spec/classes/jira_facts_spec.rb

-63
This file was deleted.

spec/classes/jira_upgrade_spec.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
end
1919

2020
it { is_expected.to compile.with_all_deps }
21-
it { is_expected.to contain_exec('service jira stop && sleep 15') }
21+
it do
22+
is_expected.to contain_exec('stop-jira-for-version-change').
23+
with_command('/usr/bin/systemctl stop jira.service && sleep 15')
24+
end
2225
end
2326
context 'custom params' do
2427
let(:params) do
@@ -31,7 +34,10 @@
3134
facts.merge(jira_version: '8.0.0')
3235
end
3336

34-
it { is_expected.to contain_exec('stop service please') }
37+
it do
38+
is_expected.to contain_exec('stop-jira-for-version-change').
39+
with_command('stop service please')
40+
end
3541
end
3642
end
3743
end

templates/facts.rb.epp

-28
This file was deleted.

0 commit comments

Comments
 (0)