kpm 0.7.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rubocop.yml +138 -0
- data/Gemfile +2 -0
- data/README.adoc +126 -109
- data/Rakefile +2 -1
- data/bin/kpm +4 -2
- data/kpm.gemspec +10 -8
- data/lib/kpm.rb +3 -0
- data/lib/kpm/account.rb +269 -337
- data/lib/kpm/base_artifact.rb +40 -36
- data/lib/kpm/base_installer.rb +71 -84
- 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 +93 -103
- data/lib/kpm/diagnostic_file.rb +126 -146
- 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 +24 -10
- data/lib/kpm/migrations.rb +26 -11
- data/lib/kpm/nexus_helper/actions.rb +45 -9
- 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 +14 -9
- data/lib/kpm/plugins_directory.yml +16 -175
- data/lib/kpm/plugins_manager.rb +29 -24
- data/lib/kpm/sha1_checker.rb +56 -15
- 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 +370 -443
- 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 +1 -1
- data/spec/kpm/remote/base_artifact_spec.rb +33 -17
- data/spec/kpm/remote/base_installer_spec.rb +35 -34
- data/spec/kpm/remote/github_api_calls_spec.rb +40 -0
- data/spec/kpm/remote/installer_spec.rb +80 -78
- 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 +30 -13
- 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 +144 -143
- data/spec/spec_helper.rb +20 -18
- data/tasks/package.rake +18 -18
- metadata +26 -22
data/lib/kpm/utils.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pathname'
|
2
4
|
require 'rubygems/package'
|
3
5
|
require 'zlib'
|
@@ -7,7 +9,7 @@ module KPM
|
|
7
9
|
class << self
|
8
10
|
TAR_LONGLINK = '././@LongLink'
|
9
11
|
|
10
|
-
def unpack_tgz(tar_gz_archive, destination, skip_top_dir=false)
|
12
|
+
def unpack_tgz(tar_gz_archive, destination, skip_top_dir = false)
|
11
13
|
top_dir = nil
|
12
14
|
Gem::Package::TarReader.new(Zlib::GzipReader.open(tar_gz_archive)) do |tar|
|
13
15
|
dest = nil
|
@@ -20,17 +22,17 @@ module KPM
|
|
20
22
|
|
21
23
|
if entry.directory?
|
22
24
|
File.delete dest if File.file? dest
|
23
|
-
FileUtils.mkdir_p dest, :
|
25
|
+
FileUtils.mkdir_p dest, mode: entry.header.mode, verbose: false
|
24
26
|
elsif entry.file?
|
25
27
|
FileUtils.rm_rf dest if File.directory? dest
|
26
|
-
FileUtils.mkdir_p File.dirname(dest), :
|
27
|
-
File.open dest,
|
28
|
+
FileUtils.mkdir_p File.dirname(dest), verbose: false
|
29
|
+
File.open dest, 'wb' do |f|
|
28
30
|
f.print entry.read
|
29
31
|
end
|
30
|
-
FileUtils.chmod entry.header.mode, dest, :
|
32
|
+
FileUtils.chmod entry.header.mode, dest, verbose: false
|
31
33
|
current_dir = File.dirname(dest)
|
32
34
|
# In case there are two top dirs, keep the last one by convention
|
33
|
-
top_dir = current_dir if
|
35
|
+
top_dir = current_dir if top_dir.nil? || top_dir.size >= current_dir.size
|
34
36
|
elsif entry.header.typeflag == '2' # Symlink
|
35
37
|
File.symlink entry.header.linkname, dest
|
36
38
|
end
|
@@ -48,9 +50,7 @@ module KPM
|
|
48
50
|
file_names = []
|
49
51
|
Gem::Package::TarReader.new(Zlib::GzipReader.open(tar_gz_archive)) do |tar|
|
50
52
|
tar.each do |entry|
|
51
|
-
if entry.file?
|
52
|
-
file_names.push entry.full_name
|
53
|
-
end
|
53
|
+
file_names.push entry.full_name if entry.file?
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -62,17 +62,17 @@ module KPM
|
|
62
62
|
ver = get_version_from_file_path(file_path)
|
63
63
|
ext = File.extname(base)
|
64
64
|
|
65
|
-
name = base.gsub(ext,'')
|
65
|
+
name = base.gsub(ext, '')
|
66
66
|
if ver.nil?
|
67
67
|
# this will remove SNAPSHOT and any dash that appear before it (ex --SNAPSHOT).
|
68
|
-
name = name.gsub(/((-+){,1}SNAPSHOT){,1}/,'')
|
68
|
+
name = name.gsub(/((-+){,1}SNAPSHOT){,1}/, '')
|
69
69
|
last_dash = name.rindex('-')
|
70
70
|
name = name[0..last_dash] unless last_dash.nil?
|
71
71
|
else
|
72
|
-
name = name.gsub(ver,'')
|
72
|
+
name = name.gsub(ver, '')
|
73
73
|
end
|
74
74
|
|
75
|
-
name = name[0..name.length-2] if name[-1].match(/[a-zA-z]/).nil?
|
75
|
+
name = name[0..name.length - 2] if name[-1].match(/[a-zA-z]/).nil?
|
76
76
|
name
|
77
77
|
end
|
78
78
|
|
@@ -84,7 +84,6 @@ module KPM
|
|
84
84
|
|
85
85
|
ver[0]
|
86
86
|
end
|
87
|
-
|
88
87
|
end
|
89
88
|
end
|
90
89
|
end
|
data/lib/kpm/version.rb
CHANGED
data/packaging/Gemfile
CHANGED
data/pom.xml
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
<groupId>org.kill-bill.billing.installer</groupId>
|
27
27
|
<artifactId>kpm</artifactId>
|
28
28
|
<packaging>pom</packaging>
|
29
|
-
<version>0.
|
29
|
+
<version>0.9.0</version>
|
30
30
|
<name>KPM</name>
|
31
31
|
<url>http://github.com/killbill/killbill-cloud</url>
|
32
32
|
<description>KPM: the Kill Bill Package Manager</description>
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::BaseArtifact do
|
4
|
-
|
5
6
|
before(:all) do
|
6
7
|
@logger = Logger.new(STDOUT)
|
7
8
|
@logger.level = Logger::INFO
|
@@ -25,6 +26,25 @@ describe KPM::BaseArtifact do
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
29
|
+
it 'should be able to handle download errors' do
|
30
|
+
nexus_down = { url: 'https://does.not.exist' }
|
31
|
+
Dir.mktmpdir do |dir|
|
32
|
+
sha1_file = "#{dir}/sha1.yml"
|
33
|
+
test_download dir, 'foo-oss.pom.xml', false, false, sha1_file
|
34
|
+
# Verify we skip the second time
|
35
|
+
test_download dir, 'foo-oss.pom.xml', true, false, sha1_file
|
36
|
+
# Verify the download is skipped gracefully when Nexus isn't reachable
|
37
|
+
test_download dir, 'foo-oss.pom.xml', true, false, sha1_file, nexus_down
|
38
|
+
# Verify the download fails when Nexus isn't reachable and force_download is set
|
39
|
+
expect { test_download dir, 'foo-oss.pom.xml', nil, true, sha1_file, nexus_down }.to raise_exception(SocketError, /(Failed to open TCP connection to does.not.exist:443|getaddrinfo)/)
|
40
|
+
# Verify the download fails when Nexus isn't reachable and the Nexus cache is empty
|
41
|
+
expect(KPM::Sha1Checker.from_file(sha1_file).artifact_info('org.kill-bill.billing:killbill-oss-parent:pom:0.143.33')).to_not be_nil
|
42
|
+
KPM::Sha1Checker.from_file(sha1_file).remove_entry!('org.kill-bill.billing:killbill-oss-parent:pom:0.143.33')
|
43
|
+
expect(KPM::Sha1Checker.from_file(sha1_file).artifact_info('org.kill-bill.billing:killbill-oss-parent:pom:0.143.33')).to be_nil
|
44
|
+
expect { test_download dir, 'foo-oss.pom.xml', nil, false, sha1_file, nexus_down }.to raise_exception(SocketError, /(Failed to open TCP connection to does.not.exist:443|getaddrinfo)/)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
28
48
|
it 'should be able to download and verify generic .tar.gz artifacts' do
|
29
49
|
# The artifact is not small unfortunately (23.7M)
|
30
50
|
group_id = 'org.kill-bill.billing'
|
@@ -35,14 +55,14 @@ describe KPM::BaseArtifact do
|
|
35
55
|
|
36
56
|
Dir.mktmpdir do |dir|
|
37
57
|
info = KPM::BaseArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, version, dir)
|
38
|
-
info[:file_name].
|
58
|
+
expect(info[:file_name]).to be_nil
|
39
59
|
|
40
60
|
files_in_dir = Dir[info[:file_path] + '/*']
|
41
|
-
files_in_dir.size.
|
61
|
+
expect(files_in_dir.size).to eq 20
|
42
62
|
|
43
|
-
File.file?(info[:file_path] + '/killbill-osgi-bundles-jruby-0.11.3.jar').
|
63
|
+
expect(File.file?(info[:file_path] + '/killbill-osgi-bundles-jruby-0.11.3.jar')).to be_truthy
|
44
64
|
|
45
|
-
info[:bundle_dir].
|
65
|
+
expect(info[:bundle_dir]).to eq info[:file_path]
|
46
66
|
end
|
47
67
|
end
|
48
68
|
|
@@ -57,24 +77,20 @@ describe KPM::BaseArtifact do
|
|
57
77
|
|
58
78
|
Dir.mktmpdir do |dir|
|
59
79
|
first_take = KPM::BaseArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, version, dir)
|
60
|
-
File.file?(first_take[:file_path] + '/killbill-platform-osgi-bundles-jruby-0.36.2.jar').
|
80
|
+
expect(File.file?(first_take[:file_path] + '/killbill-platform-osgi-bundles-jruby-0.36.2.jar')).to be_truthy
|
61
81
|
|
62
82
|
second_take = KPM::BaseArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, second_bundle_version, dir)
|
63
|
-
File.file?(first_take[:file_path] + '/killbill-platform-osgi-bundles-jruby-0.36.2.jar').
|
64
|
-
File.file?(second_take[:file_path] + '/killbill-platform-osgi-bundles-jruby-0.36.10.jar').
|
65
|
-
|
83
|
+
expect(File.file?(first_take[:file_path] + '/killbill-platform-osgi-bundles-jruby-0.36.2.jar')).to be_falsey
|
84
|
+
expect(File.file?(second_take[:file_path] + '/killbill-platform-osgi-bundles-jruby-0.36.10.jar')).to be_truthy
|
66
85
|
end
|
67
86
|
end
|
68
87
|
|
69
|
-
|
70
|
-
def test_download(dir, filename=nil, verify_is_skipped=false, force_download=false)
|
88
|
+
def test_download(dir, filename = nil, verify_is_skipped = false, force_download = false, sha1_file = nil, overrides = {})
|
71
89
|
path = filename.nil? ? dir : dir + '/' + filename
|
72
90
|
|
73
|
-
info = KPM::BaseArtifact.pull(@logger, 'org.kill-bill.billing', 'killbill-oss-parent', 'pom', nil, '
|
74
|
-
info[:file_name].
|
75
|
-
info[:skipped].
|
76
|
-
|
77
|
-
info[:size].should == File.size(info[:file_path])
|
78
|
-
end
|
91
|
+
info = KPM::BaseArtifact.pull(@logger, 'org.kill-bill.billing', 'killbill-oss-parent', 'pom', nil, '0.143.33', path, sha1_file, force_download, true, overrides, true)
|
92
|
+
expect(info[:file_name]).to eq(filename.nil? ? "killbill-oss-parent-#{info[:version]}.pom" : filename)
|
93
|
+
expect(info[:skipped]).to eq verify_is_skipped
|
94
|
+
expect(info[:size]).to eq File.size(info[:file_path]) unless info[:skipped]
|
79
95
|
end
|
80
96
|
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::BaseInstaller do
|
5
|
-
|
6
7
|
before(:all) do
|
7
8
|
@logger = Logger.new(STDOUT)
|
8
9
|
@logger.level = Logger::INFO
|
@@ -13,7 +14,7 @@ describe KPM::BaseInstaller do
|
|
13
14
|
bundles_dir = dir + '/bundles'
|
14
15
|
installer = KPM::BaseInstaller.new(@logger)
|
15
16
|
|
16
|
-
|
17
|
+
installer.install_plugin('analytics', nil, nil, nil, nil, nil, '0.7.1', bundles_dir)
|
17
18
|
|
18
19
|
check_installation(bundles_dir)
|
19
20
|
|
@@ -46,25 +47,25 @@ describe KPM::BaseInstaller do
|
|
46
47
|
|
47
48
|
begin
|
48
49
|
installer.install_plugin('invalid', nil, nil, nil, nil, nil, '1.2.3', bundles_dir)
|
49
|
-
|
50
|
-
rescue ArgumentError
|
50
|
+
raise 'Should not succeed to install invalid plugin'
|
51
|
+
rescue ArgumentError
|
52
|
+
# Expected
|
51
53
|
end
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
57
|
it 'should extract plugin name from file path' do
|
56
|
-
|
57
58
|
[
|
58
|
-
{:
|
59
|
-
{:
|
60
|
-
{:
|
61
|
-
{:
|
62
|
-
{:
|
63
|
-
{:
|
64
|
-
{:
|
65
|
-
{:
|
59
|
+
{ file_path: '/Somewhere/xxx-foo/target/xxx-1.0.0.jar', expected: 'xxx' },
|
60
|
+
{ file_path: '/Somewhere/xxx-foo/target/xxx-foo-bar-1.0.0.jar', expected: 'xxx-foo-bar' },
|
61
|
+
{ file_path: '/Somewhere/xxx-foo/target/xxx-foo-1.0.0.jar', expected: 'xxx-foo' },
|
62
|
+
{ file_path: '/Somewhere/xxx-foo/target/xxx-foo-1.0.0-SNAPSHOT.jar', expected: 'xxx-foo' },
|
63
|
+
{ file_path: '/Somewhere/xxx-foo/target/xxx-foo-1.0.jar', expected: 'xxx-foo' },
|
64
|
+
{ file_path: '/Somewhere/xxx-foo/target/xxx-foo-1.jar', expected: 'xxx-foo' },
|
65
|
+
{ file_path: '/Somewhere/xxx-foo/target/xxx-foo-abc-SNAPSHOT.jar', expected: 'xxx-foo' },
|
66
|
+
{ file_path: '/Somewhere/xxx-foo/target/xxx-foo-abc.jar', expected: 'xxx-foo' }
|
66
67
|
].each do |test|
|
67
|
-
KPM::Utils.get_plugin_name_from_file_path(test[:file_path]).
|
68
|
+
expect(KPM::Utils.get_plugin_name_from_file_path(test[:file_path])).to eq test[:expected]
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
@@ -75,16 +76,16 @@ describe KPM::BaseInstaller do
|
|
75
76
|
|
76
77
|
plugin_identifiers = read_plugin_identifiers(plugins_dir)
|
77
78
|
|
78
|
-
plugin_identifiers.size.
|
79
|
+
expect(plugin_identifiers.size).to eq 1
|
79
80
|
|
80
|
-
plugin_identifiers['analytics']['plugin_name'].
|
81
|
-
plugin_identifiers['analytics']['group_id'].
|
82
|
-
plugin_identifiers['analytics']['artifact_id'].
|
83
|
-
plugin_identifiers['analytics']['packaging'].
|
84
|
-
plugin_identifiers['analytics']['version'].
|
85
|
-
plugin_identifiers['analytics']['language'].
|
81
|
+
expect(plugin_identifiers['analytics']['plugin_name']).to eq 'analytics-plugin'
|
82
|
+
expect(plugin_identifiers['analytics']['group_id']).to eq 'org.kill-bill.billing.plugin.java'
|
83
|
+
expect(plugin_identifiers['analytics']['artifact_id']).to eq 'analytics-plugin'
|
84
|
+
expect(plugin_identifiers['analytics']['packaging']).to eq 'jar'
|
85
|
+
expect(plugin_identifiers['analytics']['version']).to eq '0.7.1'
|
86
|
+
expect(plugin_identifiers['analytics']['language']).to eq 'java'
|
86
87
|
|
87
|
-
File.file?(plugins_dir + '/plugins/java/analytics-plugin/0.7.1/tmp/disabled.txt').
|
88
|
+
expect(File.file?(plugins_dir + '/plugins/java/analytics-plugin/0.7.1/tmp/disabled.txt')).to be_falsey
|
88
89
|
end
|
89
90
|
|
90
91
|
def check_uninstallation(plugins_dir)
|
@@ -92,28 +93,28 @@ describe KPM::BaseInstaller do
|
|
92
93
|
|
93
94
|
plugin_identifiers = read_plugin_identifiers(plugins_dir)
|
94
95
|
|
95
|
-
plugin_identifiers.size.
|
96
|
+
expect(plugin_identifiers.size).to eq 0
|
96
97
|
|
97
|
-
File.file?(plugins_dir + '/plugins/java/analytics-plugin/0.7.1/tmp/disabled.txt').
|
98
|
+
expect(File.file?(plugins_dir + '/plugins/java/analytics-plugin/0.7.1/tmp/disabled.txt')).to be_truthy
|
98
99
|
end
|
99
100
|
|
100
101
|
def common_checks(plugins_dir)
|
101
102
|
[
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
plugins_dir,
|
104
|
+
plugins_dir + '/plugins',
|
105
|
+
plugins_dir + '/plugins/java',
|
106
|
+
plugins_dir + '/plugins/java/analytics-plugin',
|
107
|
+
plugins_dir + '/plugins/java/analytics-plugin/0.7.1',
|
108
|
+
plugins_dir + '/plugins/java/analytics-plugin/0.7.1/tmp'
|
108
109
|
].each do |dir|
|
109
|
-
File.directory?(dir).
|
110
|
+
expect(File.directory?(dir)).to be_truthy
|
110
111
|
end
|
111
112
|
|
112
113
|
[
|
113
|
-
|
114
|
-
|
114
|
+
plugins_dir + '/plugins/plugin_identifiers.json',
|
115
|
+
plugins_dir + '/plugins/java/analytics-plugin/0.7.1/analytics-plugin-0.7.1.jar'
|
115
116
|
].each do |file|
|
116
|
-
File.file?(file).
|
117
|
+
expect(File.file?(file)).to be_truthy
|
117
118
|
end
|
118
119
|
end
|
119
120
|
|
@@ -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,28 +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
|
-
'kaui' => {
|
75
|
-
'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
|
+
}]
|
76
73
|
}
|
74
|
+
},
|
75
|
+
'kaui' => {
|
76
|
+
'webapp_path' => kaui_webapp_path
|
77
|
+
}
|
77
78
|
},
|
78
79
|
@logger)
|
79
80
|
|
@@ -86,11 +87,10 @@ describe KPM::Installer do
|
|
86
87
|
|
87
88
|
# Finally verify that for both (well behaved) ruby and java plugin, skipping the install will still correctly return the `:bundle_dir`
|
88
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)
|
89
|
-
info[:bundle_dir].
|
90
|
-
|
90
|
+
expect(info[:bundle_dir]).to eq plugins_dir + '/plugins/ruby/killbill-payment-test/1.8.7'
|
91
91
|
|
92
|
-
info = installer.install_plugin('analytics', nil, nil, nil,
|
93
|
-
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'
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -98,56 +98,58 @@ describe KPM::Installer do
|
|
98
98
|
|
99
99
|
def check_installation(plugins_dir, kb_webapp_path, kaui_webapp_path)
|
100
100
|
[
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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'
|
111
112
|
].each do |dir|
|
112
|
-
File.directory?(dir).
|
113
|
+
expect(File.directory?(dir)).to be_truthy
|
113
114
|
end
|
114
115
|
|
115
116
|
[
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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'
|
122
124
|
].each do |file|
|
123
|
-
File.file?(file).
|
125
|
+
expect(File.file?(file)).to be_truthy
|
124
126
|
end
|
125
127
|
|
126
128
|
plugin_identifiers = File.open(plugins_dir + '/plugins/plugin_identifiers.json', 'r') do |f|
|
127
129
|
JSON.parse(f.read)
|
128
130
|
end
|
129
131
|
|
130
|
-
plugin_identifiers.size.
|
131
|
-
|
132
|
-
plugin_identifiers['analytics']['plugin_name'].
|
133
|
-
plugin_identifiers['analytics']['group_id'].
|
134
|
-
plugin_identifiers['analytics']['artifact_id'].
|
135
|
-
plugin_identifiers['analytics']['packaging'].
|
136
|
-
plugin_identifiers['analytics']['version'].
|
137
|
-
plugin_identifiers['analytics']['language'].
|
138
|
-
|
139
|
-
plugin_identifiers['
|
140
|
-
plugin_identifiers['
|
141
|
-
plugin_identifiers['
|
142
|
-
plugin_identifiers['
|
143
|
-
plugin_identifiers['
|
144
|
-
plugin_identifiers['
|
145
|
-
|
146
|
-
plugin_identifiers['
|
147
|
-
plugin_identifiers['
|
148
|
-
plugin_identifiers['
|
149
|
-
plugin_identifiers['
|
150
|
-
plugin_identifiers['
|
151
|
-
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'
|
152
154
|
end
|
153
155
|
end
|