kpm 0.7.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +138 -0
- data/Gemfile +2 -0
- data/README.adoc +144 -107
- data/Rakefile +2 -1
- data/bin/kpm +4 -2
- data/kpm.gemspec +11 -8
- data/lib/kpm.rb +3 -0
- data/lib/kpm/account.rb +268 -338
- data/lib/kpm/base_artifact.rb +33 -39
- data/lib/kpm/base_installer.rb +69 -83
- data/lib/kpm/blob.rb +29 -0
- data/lib/kpm/cli.rb +3 -1
- data/lib/kpm/coordinates.rb +10 -12
- data/lib/kpm/database.rb +94 -113
- data/lib/kpm/diagnostic_file.rb +126 -147
- data/lib/kpm/formatter.rb +76 -48
- data/lib/kpm/inspector.rb +24 -34
- data/lib/kpm/installer.rb +53 -46
- data/lib/kpm/kaui_artifact.rb +4 -3
- data/lib/kpm/killbill_plugin_artifact.rb +10 -7
- data/lib/kpm/killbill_server_artifact.rb +13 -12
- data/lib/kpm/migrations.rb +26 -11
- data/lib/kpm/nexus_helper/actions.rb +52 -9
- data/lib/kpm/nexus_helper/cloudsmith_api_calls.rb +83 -0
- data/lib/kpm/nexus_helper/github_api_calls.rb +70 -0
- data/lib/kpm/nexus_helper/nexus_api_calls_v2.rb +130 -108
- data/lib/kpm/nexus_helper/nexus_facade.rb +5 -3
- data/lib/kpm/plugins_directory.rb +9 -8
- data/lib/kpm/plugins_directory.yml +14 -173
- data/lib/kpm/plugins_manager.rb +29 -24
- data/lib/kpm/sha1_checker.rb +31 -18
- data/lib/kpm/system.rb +104 -135
- data/lib/kpm/system_helpers/cpu_information.rb +56 -55
- data/lib/kpm/system_helpers/disk_space_information.rb +60 -63
- data/lib/kpm/system_helpers/entropy_available.rb +37 -39
- data/lib/kpm/system_helpers/memory_information.rb +52 -51
- data/lib/kpm/system_helpers/os_information.rb +45 -47
- data/lib/kpm/system_helpers/system_proxy.rb +10 -10
- data/lib/kpm/tasks.rb +381 -438
- data/lib/kpm/tenant_config.rb +68 -83
- data/lib/kpm/tomcat_manager.rb +10 -8
- data/lib/kpm/trace_logger.rb +18 -16
- data/lib/kpm/uninstaller.rb +81 -14
- data/lib/kpm/utils.rb +13 -14
- data/lib/kpm/version.rb +3 -1
- data/packaging/Gemfile +2 -0
- data/pom.xml +211 -40
- data/spec/kpm/remote/base_artifact_spec.rb +20 -20
- data/spec/kpm/remote/base_installer_spec.rb +35 -34
- data/spec/kpm/remote/cloudsmith_api_calls_spec.rb +40 -0
- data/spec/kpm/remote/github_api_calls_spec.rb +40 -0
- data/spec/kpm/remote/installer_spec.rb +80 -79
- data/spec/kpm/remote/kaui_artifact_spec.rb +7 -6
- data/spec/kpm/remote/killbill_plugin_artifact_spec.rb +25 -30
- data/spec/kpm/remote/killbill_server_artifact_spec.rb +17 -16
- data/spec/kpm/remote/migrations_spec.rb +12 -11
- data/spec/kpm/remote/nexus_facade_spec.rb +32 -28
- data/spec/kpm/remote/tenant_config_spec.rb +30 -29
- data/spec/kpm/remote/tomcat_manager_spec.rb +4 -3
- data/spec/kpm/unit/actions_spec.rb +52 -0
- data/spec/kpm/unit/base_artifact_spec.rb +19 -18
- data/spec/kpm/unit/cpu_information_spec.rb +67 -0
- data/spec/kpm/unit/disk_space_information_spec.rb +47 -0
- data/spec/kpm/unit/entropy_information_spec.rb +36 -0
- data/spec/kpm/unit/formatter_spec.rb +163 -0
- data/spec/kpm/unit/inspector_spec.rb +34 -42
- data/spec/kpm/unit/installer_spec.rb +7 -6
- data/spec/kpm/unit/memory_information_spec.rb +102 -0
- data/spec/kpm/unit/os_information_spec.rb +38 -0
- data/spec/kpm/unit/plugins_directory_spec.rb +38 -22
- data/spec/kpm/unit/plugins_manager_spec.rb +62 -66
- data/spec/kpm/unit/sha1_checker_spec.rb +107 -60
- data/spec/kpm/unit/uninstaller_spec.rb +118 -72
- data/spec/kpm/unit_mysql/account_spec.rb +127 -142
- data/spec/spec_helper.rb +20 -18
- data/tasks/package.rake +18 -18
- metadata +42 -22
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'rexml/document'
|
5
|
+
|
6
|
+
describe KPM::NexusFacade, skip_me_if_nil: ENV['CLOUDSMITH_TOKEN'].nil? do
|
7
|
+
let(:logger) do
|
8
|
+
logger = ::Logger.new(STDOUT)
|
9
|
+
logger.level = Logger::INFO
|
10
|
+
logger
|
11
|
+
end
|
12
|
+
let(:coordinates_map) do
|
13
|
+
{ version: '0.22.21-20210319.010242-1',
|
14
|
+
group_id: 'org.kill-bill.billing',
|
15
|
+
artifact_id: 'killbill',
|
16
|
+
packaging: 'pom',
|
17
|
+
classifier: nil }
|
18
|
+
end
|
19
|
+
let(:coordinates) { KPM::Coordinates.build_coordinates(coordinates_map) }
|
20
|
+
let(:nexus_remote) { described_class::CloudsmithApiCalls.new({ :url => "https://dl.cloudsmith.io/#{ENV['CLOUDSMITH_TOKEN']}/#{ENV['CLOUDSMITH_ORG']}/#{ENV['CLOUDSMITH_REPO']}/maven" }, true, logger) }
|
21
|
+
|
22
|
+
it {
|
23
|
+
# Not implemented
|
24
|
+
expect { nexus_remote.search_for_artifacts(coordinates) }.to raise_exception(NoMethodError, 'Cloudsmith has no search support')
|
25
|
+
}
|
26
|
+
|
27
|
+
it {
|
28
|
+
response = nil
|
29
|
+
expect { response = nexus_remote.get_artifact_info(coordinates) }.not_to raise_exception
|
30
|
+
expect(REXML::Document.new(response).elements['//version'].text).to eq(coordinates_map[:version])
|
31
|
+
}
|
32
|
+
|
33
|
+
it {
|
34
|
+
response = nil
|
35
|
+
destination = Dir.mktmpdir('artifact')
|
36
|
+
expect { response = nexus_remote.pull_artifact(coordinates, destination) }.not_to raise_exception
|
37
|
+
destination = File.join(File.expand_path(destination), response[:file_name])
|
38
|
+
expect(File.read(destination)).to match(/org.kill-bill.billing/)
|
39
|
+
}
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'rexml/document'
|
5
|
+
|
6
|
+
describe KPM::NexusFacade, skip_me_if_nil: ENV['TOKEN'].nil? do
|
7
|
+
let(:logger) do
|
8
|
+
logger = ::Logger.new(STDOUT)
|
9
|
+
logger.level = Logger::INFO
|
10
|
+
logger
|
11
|
+
end
|
12
|
+
let(:coordinates_map) do
|
13
|
+
{ version: '1.1.9',
|
14
|
+
group_id: 'org.kill-bill.billing.thirdparty',
|
15
|
+
artifact_id: 'qualpay-java-client',
|
16
|
+
packaging: 'pom',
|
17
|
+
classifier: nil }
|
18
|
+
end
|
19
|
+
let(:coordinates) { KPM::Coordinates.build_coordinates(coordinates_map) }
|
20
|
+
let(:nexus_remote) { described_class::GithubApiCalls.new({ :url => 'https://maven.pkg.github.com/killbill/qualpay-java-client', :token => ENV['TOKEN'] }, true, logger) }
|
21
|
+
|
22
|
+
it {
|
23
|
+
# Not implemented
|
24
|
+
expect { nexus_remote.search_for_artifacts(coordinates) }.to raise_exception(NoMethodError, 'GitHub Packages has no search support')
|
25
|
+
}
|
26
|
+
|
27
|
+
it {
|
28
|
+
response = nil
|
29
|
+
expect { response = nexus_remote.get_artifact_info(coordinates) }.not_to raise_exception
|
30
|
+
expect(REXML::Document.new(response).elements['//version'].text).to eq(coordinates_map[:version])
|
31
|
+
}
|
32
|
+
|
33
|
+
it {
|
34
|
+
response = nil
|
35
|
+
destination = Dir.mktmpdir('artifact')
|
36
|
+
expect { response = nexus_remote.pull_artifact(coordinates, destination) }.not_to raise_exception
|
37
|
+
destination = File.join(File.expand_path(destination), response[:file_name])
|
38
|
+
expect(File.read(destination)).to match(/qualpay-java-client/)
|
39
|
+
}
|
40
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'json'
|
3
5
|
|
4
6
|
describe KPM::Installer do
|
5
|
-
|
6
7
|
before(:all) do
|
7
8
|
@logger = Logger.new(STDOUT)
|
8
9
|
@logger.level = Logger::INFO
|
@@ -12,18 +13,18 @@ describe KPM::Installer do
|
|
12
13
|
Dir.mktmpdir do |dir|
|
13
14
|
kb_webapp_path = dir + '/KB_ROOT.war'
|
14
15
|
installer = KPM::Installer.new({
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
'killbill' => {
|
17
|
+
'webapp_path' => kb_webapp_path
|
18
|
+
}
|
18
19
|
},
|
19
20
|
@logger)
|
20
21
|
|
21
22
|
# No exception
|
22
23
|
response = nil
|
23
|
-
expect{ response = installer.install }.to_not raise_exception
|
24
|
+
expect { response = installer.install }.to_not raise_exception
|
24
25
|
response = JSON[response]
|
25
|
-
response['help'].
|
26
|
-
response['killbill']['status'].
|
26
|
+
expect(response['help']).to be_nil
|
27
|
+
expect(response['killbill']['status']).to eq 'INSTALLED'
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
@@ -31,18 +32,18 @@ describe KPM::Installer do
|
|
31
32
|
Dir.mktmpdir do |dir|
|
32
33
|
kaui_webapp_path = dir + '/KAUI_ROOT.war'
|
33
34
|
installer = KPM::Installer.new({
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
'kaui' => {
|
36
|
+
'webapp_path' => kaui_webapp_path
|
37
|
+
}
|
37
38
|
},
|
38
39
|
@logger)
|
39
40
|
|
40
41
|
# No exception
|
41
42
|
response = nil
|
42
|
-
expect{ response = installer.install }.to_not raise_exception
|
43
|
+
expect { response = installer.install }.to_not raise_exception
|
43
44
|
response = JSON[response]
|
44
|
-
response['help'].
|
45
|
-
response['kaui']['status'].
|
45
|
+
expect(response['help']).to be_nil
|
46
|
+
expect(response['kaui']['status']).to eq 'INSTALLED'
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
@@ -52,29 +53,28 @@ describe KPM::Installer do
|
|
52
53
|
kaui_webapp_path = dir + '/KAUI_ROOT.war'
|
53
54
|
plugins_dir = dir + '/bundles'
|
54
55
|
installer = KPM::Installer.new({
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
}]
|
73
|
-
}
|
74
|
-
},
|
75
|
-
'kaui' => {
|
76
|
-
'webapp_path' => kaui_webapp_path
|
56
|
+
'killbill' => {
|
57
|
+
'webapp_path' => kb_webapp_path,
|
58
|
+
'plugins_dir' => plugins_dir,
|
59
|
+
'plugins' => {
|
60
|
+
'java' => [{
|
61
|
+
'name' => 'analytics',
|
62
|
+
'version' => '0.7.1'
|
63
|
+
}, {
|
64
|
+
'name' => 'stripe',
|
65
|
+
'version' => '7.0.0'
|
66
|
+
}],
|
67
|
+
'ruby' => [{
|
68
|
+
'name' => 'payment-test-plugin',
|
69
|
+
'artifact_id' => 'payment-test-plugin',
|
70
|
+
'group_id' => 'org.kill-bill.billing.plugin.ruby',
|
71
|
+
'version' => '1.8.7'
|
72
|
+
}]
|
77
73
|
}
|
74
|
+
},
|
75
|
+
'kaui' => {
|
76
|
+
'webapp_path' => kaui_webapp_path
|
77
|
+
}
|
78
78
|
},
|
79
79
|
@logger)
|
80
80
|
|
@@ -87,11 +87,10 @@ describe KPM::Installer do
|
|
87
87
|
|
88
88
|
# Finally verify that for both (well behaved) ruby and java plugin, skipping the install will still correctly return the `:bundle_dir`
|
89
89
|
info = installer.install_plugin('payment-test-plugin', nil, 'org.kill-bill.billing.plugin.ruby', 'payment-test-plugin', nil, nil, '1.8.7', plugins_dir)
|
90
|
-
info[:bundle_dir].
|
91
|
-
|
90
|
+
expect(info[:bundle_dir]).to eq plugins_dir + '/plugins/ruby/killbill-payment-test/1.8.7'
|
92
91
|
|
93
|
-
info = installer.install_plugin('analytics', nil, nil, nil,
|
94
|
-
info[:bundle_dir].
|
92
|
+
info = installer.install_plugin('analytics', nil, nil, nil, nil, nil, '0.7.1', plugins_dir)
|
93
|
+
expect(info[:bundle_dir]).to eq plugins_dir + '/plugins/java/analytics-plugin/0.7.1'
|
95
94
|
end
|
96
95
|
end
|
97
96
|
|
@@ -99,56 +98,58 @@ describe KPM::Installer do
|
|
99
98
|
|
100
99
|
def check_installation(plugins_dir, kb_webapp_path, kaui_webapp_path)
|
101
100
|
[
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
101
|
+
plugins_dir,
|
102
|
+
plugins_dir + '/platform',
|
103
|
+
plugins_dir + '/plugins',
|
104
|
+
plugins_dir + '/plugins/java',
|
105
|
+
plugins_dir + '/plugins/java/analytics-plugin',
|
106
|
+
plugins_dir + '/plugins/java/analytics-plugin/0.7.1',
|
107
|
+
plugins_dir + '/plugins/java/stripe-plugin',
|
108
|
+
plugins_dir + '/plugins/java/stripe-plugin/7.0.0',
|
109
|
+
plugins_dir + '/plugins/ruby',
|
110
|
+
plugins_dir + '/plugins/ruby/killbill-payment-test',
|
111
|
+
plugins_dir + '/plugins/ruby/killbill-payment-test/1.8.7'
|
112
112
|
].each do |dir|
|
113
|
-
File.directory?(dir).
|
113
|
+
expect(File.directory?(dir)).to be_truthy
|
114
114
|
end
|
115
115
|
|
116
116
|
[
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
117
|
+
kb_webapp_path,
|
118
|
+
kaui_webapp_path,
|
119
|
+
plugins_dir + '/platform/jruby.jar',
|
120
|
+
plugins_dir + '/plugins/plugin_identifiers.json',
|
121
|
+
plugins_dir + '/plugins/java/analytics-plugin/0.7.1/analytics-plugin-0.7.1.jar',
|
122
|
+
plugins_dir + '/plugins/java/stripe-plugin/7.0.0/stripe-plugin-7.0.0.jar',
|
123
|
+
plugins_dir + '/plugins/ruby/killbill-payment-test/1.8.7/killbill.properties'
|
123
124
|
].each do |file|
|
124
|
-
File.file?(file).
|
125
|
+
expect(File.file?(file)).to be_truthy
|
125
126
|
end
|
126
127
|
|
127
128
|
plugin_identifiers = File.open(plugins_dir + '/plugins/plugin_identifiers.json', 'r') do |f|
|
128
129
|
JSON.parse(f.read)
|
129
130
|
end
|
130
131
|
|
131
|
-
plugin_identifiers.size.
|
132
|
-
|
133
|
-
plugin_identifiers['analytics']['plugin_name'].
|
134
|
-
plugin_identifiers['analytics']['group_id'].
|
135
|
-
plugin_identifiers['analytics']['artifact_id'].
|
136
|
-
plugin_identifiers['analytics']['packaging'].
|
137
|
-
plugin_identifiers['analytics']['version'].
|
138
|
-
plugin_identifiers['analytics']['language'].
|
139
|
-
|
140
|
-
plugin_identifiers['
|
141
|
-
plugin_identifiers['
|
142
|
-
plugin_identifiers['
|
143
|
-
plugin_identifiers['
|
144
|
-
plugin_identifiers['
|
145
|
-
plugin_identifiers['
|
146
|
-
|
147
|
-
plugin_identifiers['
|
148
|
-
plugin_identifiers['
|
149
|
-
plugin_identifiers['
|
150
|
-
plugin_identifiers['
|
151
|
-
plugin_identifiers['
|
152
|
-
plugin_identifiers['
|
132
|
+
expect(plugin_identifiers.size).to eq 3
|
133
|
+
|
134
|
+
expect(plugin_identifiers['analytics']['plugin_name']).to eq 'analytics-plugin'
|
135
|
+
expect(plugin_identifiers['analytics']['group_id']).to eq 'org.kill-bill.billing.plugin.java'
|
136
|
+
expect(plugin_identifiers['analytics']['artifact_id']).to eq 'analytics-plugin'
|
137
|
+
expect(plugin_identifiers['analytics']['packaging']).to eq 'jar'
|
138
|
+
expect(plugin_identifiers['analytics']['version']).to eq '0.7.1'
|
139
|
+
expect(plugin_identifiers['analytics']['language']).to eq 'java'
|
140
|
+
|
141
|
+
expect(plugin_identifiers['stripe']['plugin_name']).to eq 'stripe-plugin'
|
142
|
+
expect(plugin_identifiers['stripe']['group_id']).to eq 'org.kill-bill.billing.plugin.java'
|
143
|
+
expect(plugin_identifiers['stripe']['artifact_id']).to eq 'stripe-plugin'
|
144
|
+
expect(plugin_identifiers['stripe']['packaging']).to eq 'jar'
|
145
|
+
expect(plugin_identifiers['stripe']['version']).to eq '7.0.0'
|
146
|
+
expect(plugin_identifiers['stripe']['language']).to eq 'java'
|
147
|
+
|
148
|
+
expect(plugin_identifiers['payment-test-plugin']['plugin_name']).to eq 'killbill-payment-test'
|
149
|
+
expect(plugin_identifiers['payment-test-plugin']['group_id']).to eq 'org.kill-bill.billing.plugin.ruby'
|
150
|
+
expect(plugin_identifiers['payment-test-plugin']['artifact_id']).to eq 'payment-test-plugin'
|
151
|
+
expect(plugin_identifiers['payment-test-plugin']['packaging']).to eq 'tar.gz'
|
152
|
+
expect(plugin_identifiers['payment-test-plugin']['version']).to eq '1.8.7'
|
153
|
+
expect(plugin_identifiers['payment-test-plugin']['language']).to eq 'ruby'
|
153
154
|
end
|
154
155
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::KillbillPluginArtifact do
|
4
|
-
|
5
6
|
before(:all) do
|
6
7
|
@logger = Logger.new(STDOUT)
|
7
8
|
@logger.level = Logger::INFO
|
@@ -16,15 +17,15 @@ describe KPM::KillbillPluginArtifact do
|
|
16
17
|
KPM::BaseArtifact::KAUI_CLASSIFIER,
|
17
18
|
'LATEST',
|
18
19
|
dir)
|
19
|
-
info[:file_name].
|
20
|
-
info[:size].
|
20
|
+
expect(info[:file_name]).to eq "kaui-standalone-#{info[:version]}.war"
|
21
|
+
expect(info[:size]).to eq File.size(info[:file_path])
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'should be able to list versions' do
|
25
26
|
versions = KPM::KauiArtifact.versions.to_a
|
26
|
-
versions.size.
|
27
|
-
versions[0].
|
28
|
-
versions[1].
|
27
|
+
expect(versions.size).to be >= 2
|
28
|
+
expect(versions[0]).to eq '0.0.1'
|
29
|
+
expect(versions[1]).to eq '0.0.2'
|
29
30
|
end
|
30
31
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::KillbillPluginArtifact do
|
4
|
-
|
5
6
|
before(:all) do
|
6
7
|
@logger = Logger.new(STDOUT)
|
7
8
|
@logger.level = Logger::INFO
|
@@ -19,15 +20,15 @@ describe KPM::KillbillPluginArtifact do
|
|
19
20
|
|
20
21
|
Dir.mktmpdir do |dir|
|
21
22
|
info = KPM::KillbillPluginArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, version, plugin_name, dir)
|
22
|
-
info[:file_name].
|
23
|
+
expect(info[:file_name]).to be_nil
|
23
24
|
|
24
25
|
files_in_dir = Dir[info[:file_path] + '/*']
|
25
|
-
files_in_dir.size.
|
26
|
-
files_in_dir[0].
|
26
|
+
expect(files_in_dir.size).to eq 1
|
27
|
+
expect(files_in_dir[0]).to eq info[:file_path] + '/killbill-payment-test'
|
27
28
|
|
28
|
-
File.read(info[:file_path] + '/killbill-payment-test/1.8.7/killbill.properties').
|
29
|
+
expect(File.read(info[:file_path] + '/killbill-payment-test/1.8.7/killbill.properties')).to eq "mainClass=PaymentTest::PaymentPlugin\nrequire=payment_test\npluginType=PAYMENT\n"
|
29
30
|
|
30
|
-
info[:bundle_dir].
|
31
|
+
expect(info[:bundle_dir]).to eq info[:file_path] + '/killbill-payment-test/1.8.7'
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
@@ -43,8 +44,8 @@ describe KPM::KillbillPluginArtifact do
|
|
43
44
|
'killbill-analytics',
|
44
45
|
dir,
|
45
46
|
sha1_file)
|
46
|
-
info[:file_name].
|
47
|
-
info[:size].
|
47
|
+
expect(info[:file_name]).to eq "analytics-plugin-#{info[:version]}.jar"
|
48
|
+
expect(info[:size]).to eq File.size(info[:file_path])
|
48
49
|
|
49
50
|
check_yaml_for_resolved_latest_version(sha1_file, 'org.kill-bill.billing.plugin.java:analytics-plugin:jar', '3.0.0')
|
50
51
|
end
|
@@ -62,31 +63,28 @@ describe KPM::KillbillPluginArtifact do
|
|
62
63
|
sha1_file)
|
63
64
|
|
64
65
|
# No file name - since we untar'ed it
|
65
|
-
info[:file_name].
|
66
|
+
expect(info[:file_name]).to be_nil
|
66
67
|
|
67
68
|
check_yaml_for_resolved_latest_version(sha1_file, 'org.kill-bill.billing.plugin.ruby:logging-plugin:tar.gz', '3.0.0')
|
68
69
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
70
|
end
|
73
71
|
|
74
72
|
it 'should be able to list versions' do
|
75
73
|
versions = KPM::KillbillPluginArtifact.versions
|
76
74
|
|
77
|
-
versions[:java].
|
78
|
-
versions[:java]['analytics-plugin'].
|
75
|
+
expect(versions[:java]).not_to be_nil
|
76
|
+
expect(versions[:java]['analytics-plugin']).not_to be_nil
|
79
77
|
logging_plugin_versions = versions[:java]['analytics-plugin'].to_a
|
80
|
-
logging_plugin_versions.size.
|
81
|
-
logging_plugin_versions[0].
|
82
|
-
logging_plugin_versions[1].
|
83
|
-
logging_plugin_versions[2].
|
78
|
+
expect(logging_plugin_versions.size).to be >= 3
|
79
|
+
expect(logging_plugin_versions[0]).to eq '0.6.0'
|
80
|
+
expect(logging_plugin_versions[1]).to eq '0.7.0'
|
81
|
+
expect(logging_plugin_versions[2]).to eq '0.7.1'
|
84
82
|
|
85
|
-
versions[:ruby].
|
86
|
-
versions[:ruby]['logging-plugin'].
|
83
|
+
expect(versions[:ruby]).not_to be_nil
|
84
|
+
expect(versions[:ruby]['logging-plugin']).not_to be_nil
|
87
85
|
logging_plugin_versions = versions[:ruby]['logging-plugin'].to_a
|
88
|
-
logging_plugin_versions.size.
|
89
|
-
logging_plugin_versions[0].
|
86
|
+
expect(logging_plugin_versions.size).to be >= 1
|
87
|
+
expect(logging_plugin_versions[0]).to eq '1.7.0'
|
90
88
|
end
|
91
89
|
|
92
90
|
private
|
@@ -95,17 +93,14 @@ describe KPM::KillbillPluginArtifact do
|
|
95
93
|
# (we can't check against actual version because as we keep releasing those increment,
|
96
94
|
# so the best we can do it check this is *not* LATEST and greater than current version at the time the test was written )
|
97
95
|
def check_yaml_for_resolved_latest_version(sha1_file, key_prefix, minimum_version)
|
98
|
-
|
99
96
|
sha1_checker = KPM::Sha1Checker.from_file(sha1_file)
|
100
97
|
|
101
|
-
keys = sha1_checker.all_sha1.keys.select { |k| k.start_with? key_prefix}
|
102
|
-
keys.size.
|
98
|
+
keys = sha1_checker.all_sha1.keys.select { |k| k.start_with? key_prefix }
|
99
|
+
expect(keys.size).to eq 1
|
103
100
|
|
104
101
|
parts = keys[0].split(':')
|
105
|
-
parts.size.
|
106
|
-
parts[3].
|
107
|
-
parts[3].
|
102
|
+
expect(parts.size).to eq 4
|
103
|
+
expect(parts[3]).not_to eq 'LATEST'
|
104
|
+
expect(parts[3]).to be >= minimum_version
|
108
105
|
end
|
109
|
-
|
110
|
-
|
111
106
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::KillbillServerArtifact do
|
4
|
-
|
5
6
|
before(:all) do
|
6
7
|
@logger = Logger.new(STDOUT)
|
7
8
|
@logger.level = Logger::INFO
|
@@ -17,41 +18,41 @@ describe KPM::KillbillServerArtifact do
|
|
17
18
|
KPM::BaseArtifact::KILLBILL_CLASSIFIER,
|
18
19
|
'LATEST',
|
19
20
|
dir)
|
20
|
-
info[:file_name].
|
21
|
-
info[:size].
|
21
|
+
expect(info[:file_name]).to eq "killbill-profiles-killbill-#{info[:version]}.war"
|
22
|
+
expect(info[:size]).to eq File.size(info[:file_path])
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
26
|
it 'should be able to list versions' do
|
26
27
|
versions = KPM::KillbillServerArtifact.versions(KPM::BaseArtifact::KILLBILL_ARTIFACT_ID).to_a
|
27
|
-
versions.size.
|
28
|
-
versions[0].
|
29
|
-
versions[1].
|
28
|
+
expect(versions.size).to be >= 2
|
29
|
+
expect(versions[0]).to eq '0.11.10'
|
30
|
+
expect(versions[1]).to eq '0.11.11'
|
30
31
|
end
|
31
32
|
|
32
33
|
it 'should get dependencies information' do
|
33
|
-
nexus_down = {:
|
34
|
+
nexus_down = { url: 'https://does.not.exist' }
|
34
35
|
|
35
36
|
Dir.mktmpdir do |dir|
|
36
37
|
sha1_file = "#{dir}/sha1.yml"
|
37
38
|
info = KPM::KillbillServerArtifact.info('0.15.9', sha1_file)
|
38
|
-
info['killbill'].
|
39
|
-
info['killbill-oss-parent'].
|
40
|
-
info['killbill-api'].
|
41
|
-
info['killbill-plugin-api'].
|
42
|
-
info['killbill-commons'].
|
43
|
-
info['killbill-platform'].
|
44
|
-
KPM::Sha1Checker.from_file(sha1_file).killbill_info('0.15.9').
|
39
|
+
expect(info['killbill']).to eq '0.15.9'
|
40
|
+
expect(info['killbill-oss-parent']).to eq '0.62'
|
41
|
+
expect(info['killbill-api']).to eq '0.27'
|
42
|
+
expect(info['killbill-plugin-api']).to eq '0.16'
|
43
|
+
expect(info['killbill-commons']).to eq '0.10'
|
44
|
+
expect(info['killbill-platform']).to eq '0.13'
|
45
|
+
expect(KPM::Sha1Checker.from_file(sha1_file).killbill_info('0.15.9')).to eq info
|
45
46
|
|
46
47
|
# Verify the download is skipped gracefully when Nexus isn't reachable
|
47
48
|
KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down)
|
48
49
|
|
49
50
|
# Verify the download fails when Nexus isn't reachable and force_download is set
|
50
|
-
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, true, nil, nexus_down) }.to
|
51
|
+
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, true, nil, nexus_down) }.to raise_exception(SocketError, /(Failed to open TCP connection to does.not.exist:443|getaddrinfo)/)
|
51
52
|
|
52
53
|
# Verify the download fails when Nexus isn't reachable and the Nexus cache is empty
|
53
54
|
KPM::Sha1Checker.from_file(sha1_file).cache_killbill_info('0.15.9', nil)
|
54
|
-
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down) }.to
|
55
|
+
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down) }.to raise_exception(SocketError, /(Failed to open TCP connection to does.not.exist:443|getaddrinfo)/)
|
55
56
|
end
|
56
57
|
end
|
57
58
|
end
|