kpm 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +66 -0
- data/Gemfile +2 -0
- data/README.adoc +111 -109
- data/Rakefile +2 -1
- data/bin/kpm +4 -2
- data/kpm.gemspec +8 -6
- data/lib/kpm.rb +3 -0
- data/lib/kpm/account.rb +267 -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 +6 -9
- data/lib/kpm/database.rb +90 -114
- data/lib/kpm/diagnostic_file.rb +126 -147
- data/lib/kpm/formatter.rb +74 -46
- data/lib/kpm/inspector.rb +22 -32
- 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 +8 -7
- data/lib/kpm/nexus_helper/actions.rb +47 -8
- data/lib/kpm/nexus_helper/nexus_api_calls_v2.rb +87 -94
- data/lib/kpm/nexus_helper/nexus_facade.rb +5 -3
- data/lib/kpm/plugins_directory.rb +9 -8
- data/lib/kpm/plugins_directory.yml +8 -175
- data/lib/kpm/plugins_manager.rb +29 -24
- data/lib/kpm/sha1_checker.rb +31 -18
- data/lib/kpm/system.rb +105 -136
- 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 +364 -437
- data/lib/kpm/tenant_config.rb +68 -83
- data/lib/kpm/tomcat_manager.rb +9 -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 +13 -15
- data/spec/kpm/remote/base_installer_spec.rb +30 -29
- data/spec/kpm/remote/installer_spec.rb +73 -73
- data/spec/kpm/remote/kaui_artifact_spec.rb +7 -6
- data/spec/kpm/remote/killbill_plugin_artifact_spec.rb +19 -24
- 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 +30 -26
- data/spec/kpm/remote/tenant_config_spec.rb +27 -26
- data/spec/kpm/remote/tomcat_manager_spec.rb +2 -1
- data/spec/kpm/unit/actions_spec.rb +52 -0
- data/spec/kpm/unit/base_artifact_spec.rb +17 -16
- 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 +5 -4
- 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 +34 -18
- data/spec/kpm/unit/plugins_manager_spec.rb +61 -65
- data/spec/kpm/unit/sha1_checker_spec.rb +107 -60
- data/spec/kpm/unit/uninstaller_spec.rb +107 -61
- data/spec/kpm/unit_mysql/account_spec.rb +120 -135
- data/spec/spec_helper.rb +19 -17
- data/tasks/package.rake +18 -18
- metadata +17 -8
@@ -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].should
|
20
|
-
info[:size].should
|
20
|
+
info[:file_name].should eq "kaui-standalone-#{info[:version]}.war"
|
21
|
+
info[:size].should 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].should
|
28
|
-
versions[1].should
|
27
|
+
expect(versions.size).to be >= 2
|
28
|
+
versions[0].should eq '0.0.1'
|
29
|
+
versions[1].should 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
|
@@ -22,12 +23,12 @@ describe KPM::KillbillPluginArtifact do
|
|
22
23
|
info[:file_name].should be_nil
|
23
24
|
|
24
25
|
files_in_dir = Dir[info[:file_path] + '/*']
|
25
|
-
files_in_dir.size.should
|
26
|
-
files_in_dir[0].should
|
26
|
+
files_in_dir.size.should eq 1
|
27
|
+
files_in_dir[0].should eq info[:file_path] + '/killbill-payment-test'
|
27
28
|
|
28
|
-
File.read(info[:file_path] + '/killbill-payment-test/1.8.7/killbill.properties').should
|
29
|
+
File.read(info[:file_path] + '/killbill-payment-test/1.8.7/killbill.properties').should eq "mainClass=PaymentTest::PaymentPlugin\nrequire=payment_test\npluginType=PAYMENT\n"
|
29
30
|
|
30
|
-
info[:bundle_dir].should
|
31
|
+
info[:bundle_dir].should 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].should
|
47
|
-
info[:size].should
|
47
|
+
info[:file_name].should eq "analytics-plugin-#{info[:version]}.jar"
|
48
|
+
info[:size].should 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
|
@@ -66,9 +67,6 @@ describe KPM::KillbillPluginArtifact do
|
|
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
|
@@ -77,16 +75,16 @@ describe KPM::KillbillPluginArtifact do
|
|
77
75
|
versions[:java].should_not be_nil
|
78
76
|
versions[:java]['analytics-plugin'].should_not be_nil
|
79
77
|
logging_plugin_versions = versions[:java]['analytics-plugin'].to_a
|
80
|
-
logging_plugin_versions.size.
|
81
|
-
logging_plugin_versions[0].should
|
82
|
-
logging_plugin_versions[1].should
|
83
|
-
logging_plugin_versions[2].should
|
78
|
+
expect(logging_plugin_versions.size).to be >= 3
|
79
|
+
logging_plugin_versions[0].should eq '0.6.0'
|
80
|
+
logging_plugin_versions[1].should eq '0.7.0'
|
81
|
+
logging_plugin_versions[2].should eq '0.7.1'
|
84
82
|
|
85
83
|
versions[:ruby].should_not be_nil
|
86
84
|
versions[:ruby]['logging-plugin'].should_not be_nil
|
87
85
|
logging_plugin_versions = versions[:ruby]['logging-plugin'].to_a
|
88
|
-
logging_plugin_versions.size.
|
89
|
-
logging_plugin_versions[0].should
|
86
|
+
expect(logging_plugin_versions.size).to be >= 1
|
87
|
+
logging_plugin_versions[0].should 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.should
|
98
|
+
keys = sha1_checker.all_sha1.keys.select { |k| k.start_with? key_prefix }
|
99
|
+
keys.size.should eq 1
|
103
100
|
|
104
101
|
parts = keys[0].split(':')
|
105
|
-
parts.size.should
|
106
|
-
parts[3].should_not
|
107
|
-
parts[3].
|
102
|
+
parts.size.should eq 4
|
103
|
+
parts[3].should_not 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].should
|
21
|
-
info[:size].should
|
21
|
+
info[:file_name].should eq "killbill-profiles-killbill-#{info[:version]}.war"
|
22
|
+
info[:size].should 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].should
|
29
|
-
versions[1].should
|
28
|
+
expect(versions.size).to be >= 2
|
29
|
+
versions[0].should eq '0.11.10'
|
30
|
+
versions[1].should 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'].should
|
39
|
-
info['killbill-oss-parent'].should
|
40
|
-
info['killbill-api'].should
|
41
|
-
info['killbill-plugin-api'].should
|
42
|
-
info['killbill-commons'].should
|
43
|
-
info['killbill-platform'].should
|
44
|
-
KPM::Sha1Checker.from_file(sha1_file).killbill_info('0.15.9').should
|
39
|
+
info['killbill'].should eq '0.15.9'
|
40
|
+
info['killbill-oss-parent'].should eq '0.62'
|
41
|
+
info['killbill-api'].should eq '0.27'
|
42
|
+
info['killbill-plugin-api'].should eq '0.16'
|
43
|
+
info['killbill-commons'].should eq '0.10'
|
44
|
+
info['killbill-platform'].should eq '0.13'
|
45
|
+
KPM::Sha1Checker.from_file(sha1_file).killbill_info('0.15.9').should 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 raise_error
|
51
|
+
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, true, nil, nexus_down) }.to raise_error
|
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 raise_error
|
55
|
+
expect { KPM::KillbillServerArtifact.info('0.15.9', sha1_file, false, nil, nexus_down) }.to raise_error
|
55
56
|
end
|
56
57
|
end
|
57
58
|
end
|
@@ -1,18 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'spec_helper'
|
4
4
|
|
5
|
+
describe KPM::Migrations, skip_me_if_nil: ENV['TOKEN'].nil? do
|
5
6
|
context 'plugins' do
|
6
7
|
it 'should be able to find migrations for a java plugin' do
|
7
8
|
migrations = KPM::Migrations.new('analytics-plugin-3.0.2', nil, 'killbill/killbill-analytics-plugin', ENV['TOKEN']).migrations
|
8
9
|
# No migration yet
|
9
|
-
migrations.size.should
|
10
|
+
migrations.size.should eq 0
|
10
11
|
end
|
11
12
|
|
12
13
|
it 'should be able to find migrations for a ruby plugin' do
|
13
14
|
migrations = KPM::Migrations.new('master', nil, 'killbill/killbill-cybersource-plugin', ENV['TOKEN']).migrations
|
14
15
|
# No migration yet
|
15
|
-
migrations.size.should
|
16
|
+
migrations.size.should eq 1
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -20,19 +21,19 @@ describe KPM::Migrations, :skip_me_if_nil => ENV['TOKEN'].nil? do
|
|
20
21
|
it 'should be able to find migrations between two versions' do
|
21
22
|
migrations = KPM::Migrations.new('killbill-0.16.3', 'killbill-0.16.4', 'killbill/killbill', ENV['TOKEN']).migrations
|
22
23
|
|
23
|
-
migrations.size.should
|
24
|
-
migrations.first[:name].should
|
25
|
-
migrations.first[:sql].should
|
24
|
+
migrations.size.should eq 1
|
25
|
+
migrations.first[:name].should eq 'V20160324060345__revisit_payment_methods_indexes_509.sql'
|
26
|
+
migrations.first[:sql].should eq "drop index payment_methods_active_accnt on payment_methods;\n"
|
26
27
|
|
27
|
-
KPM::Migrations.new('master', 'master', 'killbill/killbill', ENV['TOKEN']).migrations.size.should
|
28
|
+
KPM::Migrations.new('master', 'master', 'killbill/killbill', ENV['TOKEN']).migrations.size.should eq 0
|
28
29
|
end
|
29
30
|
|
30
31
|
it 'should be able to find migrations for a given version' do
|
31
32
|
migrations = KPM::Migrations.new('killbill-0.16.4', nil, 'killbill/killbill', ENV['TOKEN']).migrations
|
32
33
|
|
33
|
-
migrations.size.should
|
34
|
-
migrations.first[:name].should
|
35
|
-
migrations.first[:sql].should
|
34
|
+
migrations.size.should eq 1
|
35
|
+
migrations.first[:name].should eq 'V20160324060345__revisit_payment_methods_indexes_509.sql'
|
36
|
+
migrations.first[:sql].should eq "drop index payment_methods_active_accnt on payment_methods;\n"
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
@@ -1,50 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'rexml/document'
|
3
5
|
|
4
6
|
describe KPM::NexusFacade do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
7
|
+
let(:coordinates_map) do
|
8
|
+
{ version: '0.1.4',
|
9
|
+
group_id: 'org.kill-bill.billing',
|
10
|
+
artifact_id: 'killbill-platform-osgi-api',
|
11
|
+
packaging: 'jar',
|
12
|
+
classifier: nil }
|
13
|
+
end
|
14
|
+
let(:coordinates_with_classifier_map) do
|
15
|
+
{ version: '0.1.1',
|
16
|
+
group_id: 'org.kill-bill.billing',
|
17
|
+
artifact_id: 'killbill-platform-osgi-bundles-jruby',
|
18
|
+
packaging: 'jar',
|
19
|
+
classifier: 'javadoc' }
|
20
|
+
end
|
21
|
+
let(:coordinates) { KPM::Coordinates.build_coordinates(coordinates_map) }
|
22
|
+
let(:coordinates_with_classifier) { KPM::Coordinates.build_coordinates(coordinates_with_classifier_map) }
|
23
|
+
let(:nexus_remote) { described_class::RemoteFactory.create(nil, true) }
|
19
24
|
|
20
25
|
it 'when searching for artifacts' do
|
21
26
|
response = nil
|
22
|
-
expect{
|
23
|
-
expect(REXML::Document.new(response).elements[
|
27
|
+
expect { response = nexus_remote.search_for_artifacts(coordinates) }.not_to raise_exception
|
28
|
+
expect(REXML::Document.new(response).elements['//artifactId'].text).to eq(coordinates_map[:artifact_id])
|
24
29
|
end
|
25
30
|
|
26
31
|
it 'when searching for artifact with classifier' do
|
27
32
|
response = nil
|
28
|
-
expect{
|
29
|
-
expect(REXML::Document.new(response).elements[
|
33
|
+
expect { response = nexus_remote.search_for_artifacts(coordinates_with_classifier) }.not_to raise_exception
|
34
|
+
expect(REXML::Document.new(response).elements['//artifactId'].text).to eq(coordinates_with_classifier_map[:artifact_id])
|
30
35
|
end
|
31
36
|
|
32
37
|
it 'when getting artifact info' do
|
33
38
|
response = nil
|
34
|
-
expect{
|
35
|
-
expect(REXML::Document.new(response).elements[
|
39
|
+
expect { response = nexus_remote.get_artifact_info(coordinates) }.not_to raise_exception
|
40
|
+
expect(REXML::Document.new(response).elements['//version'].text).to eq(coordinates_map[:version])
|
36
41
|
end
|
37
42
|
|
38
43
|
it 'when getting artifact info with classifier' do
|
39
44
|
response = nil
|
40
|
-
expect{
|
41
|
-
expect(REXML::Document.new(response).elements[
|
45
|
+
expect { response = nexus_remote.get_artifact_info(coordinates_with_classifier) }.not_to raise_exception
|
46
|
+
expect(REXML::Document.new(response).elements['//version'].text).to eq(coordinates_with_classifier_map[:version])
|
42
47
|
end
|
43
48
|
|
44
49
|
it 'when pull artifact' do
|
45
50
|
response = nil
|
46
51
|
destination = Dir.mktmpdir('artifact')
|
47
|
-
expect{
|
52
|
+
expect { response = nexus_remote.pull_artifact(coordinates, destination) }.not_to raise_exception
|
48
53
|
destination = File.join(File.expand_path(destination), response[:file_name])
|
49
54
|
expect(File.exist?(destination)).to be_true
|
50
55
|
end
|
@@ -52,9 +57,8 @@ describe KPM::NexusFacade do
|
|
52
57
|
it 'when pull artifact with classifier' do
|
53
58
|
response = nil
|
54
59
|
destination = Dir.mktmpdir('artifact')
|
55
|
-
expect{
|
60
|
+
expect { response = nexus_remote.pull_artifact(coordinates_with_classifier, destination) }.not_to raise_exception
|
56
61
|
destination = File.join(File.expand_path(destination), response[:file_name])
|
57
62
|
expect(File.exist?(destination)).to be_true
|
58
63
|
end
|
59
|
-
|
60
|
-
end
|
64
|
+
end
|
@@ -1,24 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::TenantConfig do
|
4
6
|
include_context 'connection_setup'
|
5
7
|
|
6
|
-
let(:value) {"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<catalog>\n <effectiveDate>2017-04-25T15:57:43Z</effectiveDate>\n <catalogName>DEFAULT</catalogName>\n <recurringBillingMode>IN_ADVANCE</recurringBillingMode>\n <currencies/>\n <units/>\n <products/>\n <rules>\n <changePolicy>\n <changePolicyCase>\n <policy>IMMEDIATE</policy>\n </changePolicyCase>\n </changePolicy>\n <changeAlignment>\n <changeAlignmentCase>\n <alignment>START_OF_BUNDLE</alignment>\n </changeAlignmentCase>\n </changeAlignment>\n <cancelPolicy>\n <cancelPolicyCase>\n <policy>IMMEDIATE</policy>\n </cancelPolicyCase>\n </cancelPolicy>\n <createAlignment>\n <createAlignmentCase>\n <alignment>START_OF_BUNDLE</alignment>\n </createAlignmentCase>\n </createAlignment>\n <billingAlignment>\n <billingAlignmentCase>\n <alignment>ACCOUNT</alignment>\n </billingAlignmentCase>\n </billingAlignment>\n <priceList>\n <priceListCase>\n <toPriceList>DEFAULT</toPriceList>\n </priceListCase>\n </priceList>\n </rules>\n <plans/>\n <priceLists>\n <defaultPriceList name=\"DEFAULT\">\n <plans/>\n </defaultPriceList>\n </priceLists>\n</catalog>\n"}
|
7
|
-
let(:key) {'CATALOG_RSPEC'}
|
8
|
-
|
9
|
-
let(:user) {'KPM Tenant Spec'}
|
10
|
-
let(:tenant_config_class)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
let(:value) { "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<catalog>\n <effectiveDate>2017-04-25T15:57:43Z</effectiveDate>\n <catalogName>DEFAULT</catalogName>\n <recurringBillingMode>IN_ADVANCE</recurringBillingMode>\n <currencies/>\n <units/>\n <products/>\n <rules>\n <changePolicy>\n <changePolicyCase>\n <policy>IMMEDIATE</policy>\n </changePolicyCase>\n </changePolicy>\n <changeAlignment>\n <changeAlignmentCase>\n <alignment>START_OF_BUNDLE</alignment>\n </changeAlignmentCase>\n </changeAlignment>\n <cancelPolicy>\n <cancelPolicyCase>\n <policy>IMMEDIATE</policy>\n </cancelPolicyCase>\n </cancelPolicy>\n <createAlignment>\n <createAlignmentCase>\n <alignment>START_OF_BUNDLE</alignment>\n </createAlignmentCase>\n </createAlignment>\n <billingAlignment>\n <billingAlignmentCase>\n <alignment>ACCOUNT</alignment>\n </billingAlignmentCase>\n </billingAlignment>\n <priceList>\n <priceListCase>\n <toPriceList>DEFAULT</toPriceList>\n </priceListCase>\n </priceList>\n </rules>\n <plans/>\n <priceLists>\n <defaultPriceList name=\"DEFAULT\">\n <plans/>\n </defaultPriceList>\n </priceLists>\n</catalog>\n" }
|
9
|
+
let(:key) { 'CATALOG_RSPEC' }
|
10
|
+
|
11
|
+
let(:user) { 'KPM Tenant Spec' }
|
12
|
+
let(:tenant_config_class) do
|
13
|
+
described_class.new([killbill_api_key, killbill_api_secret],
|
14
|
+
[killbill_user, killbill_password], url, logger)
|
15
|
+
end
|
16
|
+
let(:options) do
|
17
|
+
{
|
18
|
+
username: killbill_user,
|
19
|
+
password: killbill_password,
|
20
|
+
api_key: killbill_api_key,
|
21
|
+
api_secret: killbill_api_secret
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
19
25
|
describe '#initialize' do
|
20
26
|
context 'when creating an instance of tenant config class' do
|
21
|
-
|
22
27
|
it 'when initialized with defaults' do
|
23
28
|
expect(described_class.new).to be_an_instance_of(KPM::TenantConfig)
|
24
29
|
end
|
@@ -26,33 +31,29 @@ describe KPM::TenantConfig do
|
|
26
31
|
it 'when initialized with options' do
|
27
32
|
tenant_config_class.should be_an_instance_of(KPM::TenantConfig)
|
28
33
|
expect(tenant_config_class.instance_variable_get(:@killbill_api_key)).to eq(killbill_api_key)
|
29
|
-
expect(tenant_config_class.instance_variable_get(:@
|
34
|
+
expect(tenant_config_class.instance_variable_get(:@killbill_api_secret)).to eq(killbill_api_secret)
|
30
35
|
expect(tenant_config_class.instance_variable_get(:@killbill_user)).to eq(killbill_user)
|
31
36
|
expect(tenant_config_class.instance_variable_get(:@killbill_password)).to eq(killbill_password)
|
32
37
|
expect(tenant_config_class.instance_variable_get(:@killbill_url)).to eq(url)
|
33
|
-
|
34
38
|
end
|
35
|
-
|
36
39
|
end
|
40
|
+
end
|
37
41
|
|
38
|
-
end
|
39
|
-
|
40
42
|
describe '#export' do
|
41
43
|
it 'when retrieving tenant configuration' do
|
42
44
|
KillBillClient.url = url
|
43
45
|
|
44
|
-
#Add a new tenant config
|
46
|
+
# Add a new tenant config
|
45
47
|
tenant_config = KillBillClient::Model::Tenant.upload_tenant_user_key_value(key, value, user, nil, nil, options)
|
46
48
|
expect(tenant_config.key).to eq(key)
|
47
|
-
|
48
|
-
#get created tenant config
|
49
|
+
|
50
|
+
# get created tenant config
|
49
51
|
export_file = tenant_config_class.export(key)
|
50
52
|
expect(File.exist?(export_file)).to be_true
|
51
53
|
expect(File.readlines(export_file).grep(/#{key}/)).to be_true
|
52
|
-
|
53
|
-
#remove created tenant config
|
54
|
+
|
55
|
+
# remove created tenant config
|
54
56
|
KillBillClient::Model::Tenant.delete_tenant_user_key_value(key, user, nil, nil, options)
|
55
|
-
|
56
57
|
end
|
57
58
|
end
|
58
|
-
end
|
59
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe KPM::NexusFacade::Actions do
|
6
|
+
subject { described_class.new({}, nil, logger) }
|
7
|
+
let(:logger) { Logger.new(STDOUT) }
|
8
|
+
let(:nexus_mock) { double(KPM::NexusFacade::NexusApiCallsV2) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
KPM::NexusFacade::NexusApiCallsV2.stub(:new).and_return(nexus_mock)
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when Nexus throws a non-retryable exception' do
|
15
|
+
it 'never retries' do
|
16
|
+
calls = 0
|
17
|
+
expect do
|
18
|
+
subject.send(:retry_exceptions, 'foo') do
|
19
|
+
calls += 1
|
20
|
+
raise StandardError, '404'
|
21
|
+
end
|
22
|
+
end.to raise_error(StandardError)
|
23
|
+
expect(calls).to eq(1)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when Nexus throws a retryable exception' do
|
28
|
+
it 'retries until giving up' do
|
29
|
+
calls = 0
|
30
|
+
expect do
|
31
|
+
subject.send(:retry_exceptions, 'foo') do
|
32
|
+
calls += 1
|
33
|
+
raise KPM::NexusFacade::UnexpectedStatusCodeException, 503
|
34
|
+
end
|
35
|
+
end.to raise_error(StandardError)
|
36
|
+
expect(calls).to eq(3)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when networking is flaky' do
|
41
|
+
it 'retries until call succeeds' do
|
42
|
+
calls = 0
|
43
|
+
expect(subject.send(:retry_exceptions, 'foo') do
|
44
|
+
calls += 1
|
45
|
+
raise OpenSSL::SSL::SSLErrorWaitReadable if calls < 2
|
46
|
+
|
47
|
+
true
|
48
|
+
end).to be_true
|
49
|
+
expect(calls).to eq(2)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|