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
@@ -1,17 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::Installer do
|
4
|
-
|
5
6
|
context 'when no config file is specified' do
|
6
|
-
let(:all_kb_versions) { %w
|
7
|
+
let(:all_kb_versions) { %w[0.15.0 0.15.1 0.15.10 0.15.11-SNAPSHOT 0.15.2 0.15.3 0.16.0 0.16.1 0.16.10 0.16.11 0.16.12-SNAPSHOT 0.16.2 0.16.3 0.17.0 0.17.1 0.17.2 0.17.2-SNAPSHOT 0.17.3-SNAPSHOT] }
|
7
8
|
|
8
9
|
it 'finds the right stable versions' do
|
9
10
|
config = KPM::Installer.build_default_config(all_kb_versions)
|
10
|
-
config['killbill'].
|
11
|
-
config['killbill']['version'].
|
11
|
+
expect(config['killbill']).not_to be_nil
|
12
|
+
expect(config['killbill']['version']).to eq '0.16.11'
|
12
13
|
|
13
|
-
config['kaui'].
|
14
|
-
config['kaui']['version'].
|
14
|
+
expect(config['kaui']).not_to be_nil
|
15
|
+
expect(config['kaui']['version']).to eq 'LATEST'
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'kpm/system_helpers/system_proxy'
|
5
|
+
require 'kpm/system_helpers/memory_information'
|
6
|
+
|
7
|
+
describe KPM::SystemProxy::MemoryInformation do
|
8
|
+
subject { described_class.new }
|
9
|
+
|
10
|
+
context 'when running on Linux' do
|
11
|
+
let(:data) { "MemTotal: 10774024 kB\nMemFree: 3788232 kB\nMemAvailable: 9483696 kB\nBuffers: 269216 kB\nCached: 5448624 kB\nSwapCached: 0 kB\nActive: 3562072 kB\nInactive: 2913296 kB\nActive(anon): 827072 kB\nInactive(anon): 124844 kB\nActive(file): 2735000 kB\nInactive(file): 2788452 kB\nUnevictable: 0 kB\nMlocked: 0 kB\nSwapTotal: 3620520 kB\nSwapFree: 3620520 kB\nDirty: 16 kB\nWriteback: 0 kB\nAnonPages: 757472 kB\nMapped: 71548 kB\nShmem: 194392 kB\nSlab: 468096 kB\nSReclaimable: 425428 kB\nSUnreclaim: 42668 kB\nKernelStack: 4816 kB\nPageTables: 3420 kB\nNFS_Unstable: 0 kB\nBounce: 0 kB\nWritebackTmp: 0 kB\nCommitLimit: 9007532 kB\nCommitted_AS: 1711072 kB\nVmallocTotal: 34359738367 kB\nVmallocUsed: 0 kB\nVmallocChunk: 0 kB\nAnonHugePages: 622592 kB\nHugePages_Total: 0\nHugePages_Free: 0\nHugePages_Rsvd: 0\nHugePages_Surp: 0\nHugepagesize: 2048 kB\nDirectMap4k: 166848 kB\nDirectMap2M: 10883072 kB\n" }
|
12
|
+
let(:memory_info) { subject.send(:build_hash, data) }
|
13
|
+
|
14
|
+
it {
|
15
|
+
expect(subject.labels).to eq([{ label: :memory_detail },
|
16
|
+
{ label: :value }])
|
17
|
+
}
|
18
|
+
|
19
|
+
it {
|
20
|
+
expect(memory_info).to eq({ 'MemTotal' => { memory_detail: 'MemTotal', value: '10774024 kB' },
|
21
|
+
'MemFree' => { memory_detail: 'MemFree', value: '3788232 kB' },
|
22
|
+
'MemAvailable' => { memory_detail: 'MemAvailable', value: '9483696 kB' },
|
23
|
+
'Buffers' => { memory_detail: 'Buffers', value: '269216 kB' },
|
24
|
+
'Cached' => { memory_detail: 'Cached', value: '5448624 kB' },
|
25
|
+
'SwapCached' => { memory_detail: 'SwapCached', value: '0 kB' },
|
26
|
+
'Active' => { memory_detail: 'Active', value: '3562072 kB' },
|
27
|
+
'Inactive' => { memory_detail: 'Inactive', value: '2913296 kB' },
|
28
|
+
'Active(anon)' => { memory_detail: 'Active(anon)', value: '827072 kB' },
|
29
|
+
'Inactive(anon)' => { memory_detail: 'Inactive(anon)', value: '124844 kB' },
|
30
|
+
'Active(file)' => { memory_detail: 'Active(file)', value: '2735000 kB' },
|
31
|
+
'Inactive(file)' => { memory_detail: 'Inactive(file)', value: '2788452 kB' },
|
32
|
+
'Unevictable' => { memory_detail: 'Unevictable', value: '0 kB' },
|
33
|
+
'Mlocked' => { memory_detail: 'Mlocked', value: '0 kB' },
|
34
|
+
'SwapTotal' => { memory_detail: 'SwapTotal', value: '3620520 kB' },
|
35
|
+
'SwapFree' => { memory_detail: 'SwapFree', value: '3620520 kB' },
|
36
|
+
'Dirty' => { memory_detail: 'Dirty', value: '16 kB' },
|
37
|
+
'Writeback' => { memory_detail: 'Writeback', value: '0 kB' },
|
38
|
+
'AnonPages' => { memory_detail: 'AnonPages', value: '757472 kB' },
|
39
|
+
'Mapped' => { memory_detail: 'Mapped', value: '71548 kB' },
|
40
|
+
'Shmem' => { memory_detail: 'Shmem', value: '194392 kB' },
|
41
|
+
'Slab' => { memory_detail: 'Slab', value: '468096 kB' },
|
42
|
+
'SReclaimable' => { memory_detail: 'SReclaimable', value: '425428 kB' },
|
43
|
+
'SUnreclaim' => { memory_detail: 'SUnreclaim', value: '42668 kB' },
|
44
|
+
'KernelStack' => { memory_detail: 'KernelStack', value: '4816 kB' },
|
45
|
+
'PageTables' => { memory_detail: 'PageTables', value: '3420 kB' },
|
46
|
+
'NFS_Unstable' => { memory_detail: 'NFS_Unstable', value: '0 kB' },
|
47
|
+
'Bounce' => { memory_detail: 'Bounce', value: '0 kB' },
|
48
|
+
'WritebackTmp' => { memory_detail: 'WritebackTmp', value: '0 kB' },
|
49
|
+
'CommitLimit' => { memory_detail: 'CommitLimit', value: '9007532 kB' },
|
50
|
+
'Committed_AS' => { memory_detail: 'Committed_AS', value: '1711072 kB' },
|
51
|
+
'VmallocTotal' => { memory_detail: 'VmallocTotal', value: '34359738367 kB' },
|
52
|
+
'VmallocUsed' => { memory_detail: 'VmallocUsed', value: '0 kB' },
|
53
|
+
'VmallocChunk' => { memory_detail: 'VmallocChunk', value: '0 kB' },
|
54
|
+
'AnonHugePages' => { memory_detail: 'AnonHugePages', value: '622592 kB' },
|
55
|
+
'HugePages_Total' => { memory_detail: 'HugePages_Total', value: '0' },
|
56
|
+
'HugePages_Free' => { memory_detail: 'HugePages_Free', value: '0' },
|
57
|
+
'HugePages_Rsvd' => { memory_detail: 'HugePages_Rsvd', value: '0' },
|
58
|
+
'HugePages_Surp' => { memory_detail: 'HugePages_Surp', value: '0' },
|
59
|
+
'Hugepagesize' => { memory_detail: 'Hugepagesize', value: '2048 kB' },
|
60
|
+
'DirectMap4k' => { memory_detail: 'DirectMap4k', value: '166848 kB' },
|
61
|
+
'DirectMap2M' => { memory_detail: 'DirectMap2M', value: '10883072 kB' } })
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when running on MacOS' do
|
66
|
+
let(:mem_data) { "Mach Virtual Memory Statistics: (page size of 4096 bytes)\nPages free: 20436\nPages active: 279093\nPages inactive: 276175\nPages speculative: 2492\nPages throttled: 0\nPages wired down: 3328540\nPages purgeable: 47378\n\"Translation faults\": 1774872371\nPages copy-on-write: 34313850\nPages zero filled: 1023660277\nPages reactivated: 194623586\nPages purged: 70443047\nFile-backed pages: 119033\nAnonymous pages: 438727\nPages stored in compressor: 2771982\nPages occupied by compressor: 287324\nDecompressions: 252938013\nCompressions: 328708973\nPageins: 66884005\nPageouts: 1122278\nSwapins: 110783726\nSwapouts: 113589173\n" }
|
67
|
+
let(:mem_total_data) { " Memory: 16 GB\n" }
|
68
|
+
let(:memory_info) { subject.send(:build_hash_mac, mem_data, mem_total_data) }
|
69
|
+
|
70
|
+
it {
|
71
|
+
expect(subject.labels).to eq([{ label: :memory_detail },
|
72
|
+
{ label: :value }])
|
73
|
+
}
|
74
|
+
|
75
|
+
it {
|
76
|
+
expect(memory_info).to eq({ 'Memory' => { memory_detail: 'Memory', value: '16 GB' },
|
77
|
+
'Mach Virtual Memory Statistics' => { memory_detail: 'Mach Virtual Memory Statistics', value: '0MB' },
|
78
|
+
'Pages free' => { memory_detail: 'Memory free', value: '79MB' },
|
79
|
+
'Pages active' => { memory_detail: 'Memory active', value: '1090MB' },
|
80
|
+
'Pages inactive' => { memory_detail: 'Memory inactive', value: '1078MB' },
|
81
|
+
'Pages speculative' => { memory_detail: 'Memory speculative', value: '9MB' },
|
82
|
+
'Pages throttled' => { memory_detail: 'Memory throttled', value: '0MB' },
|
83
|
+
'Pages wired down' => { memory_detail: 'Memory wired down', value: '13002MB' },
|
84
|
+
'Pages purgeable' => { memory_detail: 'Memory purgeable', value: '185MB' },
|
85
|
+
'Translation faults' => { memory_detail: 'Translation faults', value: '6933095MB' },
|
86
|
+
'Pages copy-on-write' => { memory_detail: 'Memory copy-on-write', value: '134038MB' },
|
87
|
+
'Pages zero filled' => { memory_detail: 'Memory zero filled', value: '3998672MB' },
|
88
|
+
'Pages reactivated' => { memory_detail: 'Memory reactivated', value: '760248MB' },
|
89
|
+
'Pages purged' => { memory_detail: 'Memory purged', value: '275168MB' },
|
90
|
+
'File-backed pages' => { memory_detail: 'File-backed pages', value: '464MB' },
|
91
|
+
'Anonymous pages' => { memory_detail: 'Anonymous pages', value: '1713MB' },
|
92
|
+
'Pages stored in compressor' => { memory_detail: 'Memory stored in compressor', value: '10828MB' },
|
93
|
+
'Pages occupied by compressor' => { memory_detail: 'Memory occupied by compressor', value: '1122MB' },
|
94
|
+
'Decompressions' => { memory_detail: 'Decompressions', value: '988039MB' },
|
95
|
+
'Compressions' => { memory_detail: 'Compressions', value: '1284019MB' },
|
96
|
+
'Pageins' => { memory_detail: 'Pageins', value: '261265MB' },
|
97
|
+
'Pageouts' => { memory_detail: 'Pageouts', value: '4383MB' },
|
98
|
+
'Swapins' => { memory_detail: 'Swapins', value: '432748MB' },
|
99
|
+
'Swapouts' => { memory_detail: 'Swapouts', value: '443707MB' } })
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'kpm/system_helpers/system_proxy'
|
5
|
+
require 'kpm/system_helpers/os_information'
|
6
|
+
|
7
|
+
describe KPM::SystemProxy::OsInformation do
|
8
|
+
subject { described_class.new }
|
9
|
+
let(:os_data) { subject.send(:build_hash, data) }
|
10
|
+
|
11
|
+
context 'when running on Linux' do
|
12
|
+
let(:data) { "Description:Ubuntu 16.04.1 LTS \n\n" }
|
13
|
+
|
14
|
+
it {
|
15
|
+
expect(subject.labels).to eq([{ label: :os_detail },
|
16
|
+
{ label: :value }])
|
17
|
+
}
|
18
|
+
|
19
|
+
it {
|
20
|
+
expect(os_data).to eq({ 'Description' => { :os_detail => 'Description', :value => 'Ubuntu 16.04.1 LTS' } })
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when running on MacOS' do
|
25
|
+
let(:data) { "ProductName:\tMac OS X\nProductVersion:\t10.14.6\nBuildVersion:\t18G87\n" }
|
26
|
+
|
27
|
+
it {
|
28
|
+
expect(subject.labels).to eq([{ label: :os_detail },
|
29
|
+
{ label: :value }])
|
30
|
+
}
|
31
|
+
|
32
|
+
it {
|
33
|
+
expect(os_data).to eq({ 'ProductName' => { :os_detail => 'ProductName', :value => 'Mac OS X' },
|
34
|
+
'ProductVersion' => { :os_detail => 'ProductVersion', :value => '10.14.6' },
|
35
|
+
'BuildVersion' => { :os_detail => 'BuildVersion', :value => '18G87' } })
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
@@ -1,36 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::PluginsDirectory do
|
4
|
-
|
5
6
|
it 'should parse the plugins directory' do
|
6
7
|
directory = KPM::PluginsDirectory.all(false)
|
7
|
-
directory.size.
|
8
|
+
expect(directory.size).to be > 0
|
8
9
|
end
|
9
10
|
|
10
|
-
|
11
11
|
it 'should lookup plugins' do
|
12
|
-
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, '0.
|
13
|
-
group_id.
|
14
|
-
artifact_id.
|
15
|
-
packaging.
|
16
|
-
classifier.
|
17
|
-
version.
|
18
|
-
type.
|
12
|
+
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, '0.20.11')
|
13
|
+
expect(group_id).to eq 'org.kill-bill.billing.plugin.java'
|
14
|
+
expect(artifact_id).to eq 'analytics-plugin'
|
15
|
+
expect(packaging).to eq 'jar'
|
16
|
+
expect(classifier).to be_nil
|
17
|
+
expect(version).to eq '6.0.1'
|
18
|
+
expect(type).to eq :java
|
19
|
+
|
20
|
+
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, '0.20.11-SNAPSHOT')
|
21
|
+
expect(group_id).to eq 'org.kill-bill.billing.plugin.java'
|
22
|
+
expect(artifact_id).to eq 'analytics-plugin'
|
23
|
+
expect(packaging).to eq 'jar'
|
24
|
+
expect(classifier).to be_nil
|
25
|
+
expect(version).to eq '6.0.1'
|
26
|
+
expect(type).to eq :java
|
27
|
+
|
28
|
+
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, '0.20')
|
29
|
+
expect(group_id).to eq 'org.kill-bill.billing.plugin.java'
|
30
|
+
expect(artifact_id).to eq 'analytics-plugin'
|
31
|
+
expect(packaging).to eq 'jar'
|
32
|
+
expect(classifier).to be_nil
|
33
|
+
expect(version).to eq '6.0.1'
|
34
|
+
expect(type).to eq :java
|
19
35
|
|
20
36
|
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, 'LATEST')
|
21
|
-
group_id.
|
22
|
-
artifact_id.
|
23
|
-
packaging.
|
24
|
-
classifier.
|
25
|
-
version.
|
26
|
-
type.
|
37
|
+
expect(group_id).to eq 'org.kill-bill.billing.plugin.java'
|
38
|
+
expect(artifact_id).to eq 'analytics-plugin'
|
39
|
+
expect(packaging).to eq 'jar'
|
40
|
+
expect(classifier).to be_nil
|
41
|
+
expect(version).to eq 'LATEST'
|
42
|
+
expect(type).to eq :java
|
27
43
|
|
28
44
|
group_id, artifact_id, packaging, classifier, version, type = KPM::PluginsDirectory.lookup('analytics', false, '0.42')
|
29
|
-
group_id.
|
30
|
-
artifact_id.
|
31
|
-
packaging.
|
32
|
-
classifier.
|
33
|
-
version.
|
34
|
-
type.
|
45
|
+
expect(group_id).to eq 'org.kill-bill.billing.plugin.java'
|
46
|
+
expect(artifact_id).to eq 'analytics-plugin'
|
47
|
+
expect(packaging).to eq 'jar'
|
48
|
+
expect(classifier).to be_nil
|
49
|
+
expect(version).to eq 'LATEST'
|
50
|
+
expect(type).to eq :java
|
35
51
|
end
|
36
52
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe KPM::PluginsManager do
|
4
|
-
|
5
6
|
before(:each) do
|
6
7
|
logger = Logger.new(STDOUT)
|
7
8
|
logger.level = Logger::INFO
|
@@ -14,7 +15,7 @@ describe KPM::PluginsManager do
|
|
14
15
|
FileUtils.mkdir_p(@plugin_dir.join('1.0.0'))
|
15
16
|
FileUtils.mkdir_p(@plugin_dir.join('2.0.0'))
|
16
17
|
|
17
|
-
File.
|
18
|
+
expect(File.exist?(@plugin_dir.join('SET_DEFAULT'))).to be_falsey
|
18
19
|
end
|
19
20
|
|
20
21
|
after(:each) do
|
@@ -24,133 +25,128 @@ describe KPM::PluginsManager do
|
|
24
25
|
it 'creates a plugin identifier entry with no coordinate' do
|
25
26
|
# Verifies file gets created if does not exist
|
26
27
|
identifiers = @manager.add_plugin_identifier_key('foo', 'foo_name', 'type', nil)
|
27
|
-
identifiers.size.
|
28
|
-
identifiers['foo']['plugin_name'].
|
28
|
+
expect(identifiers.size).to eq 1
|
29
|
+
expect(identifiers['foo']['plugin_name']).to eq 'foo_name'
|
29
30
|
end
|
30
31
|
|
31
32
|
it 'creates a plugin identifier entry with coordinates' do
|
32
33
|
# Verifies file gets created if does not exist
|
33
|
-
coordinate_map = {:
|
34
|
+
coordinate_map = { group_id: 'group', artifact_id: 'artifact', packaging: 'packaging', version: 'version' }
|
34
35
|
identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', coordinate_map)
|
35
|
-
identifiers.size.
|
36
|
-
identifiers['bar']['plugin_name'].
|
37
|
-
identifiers['bar']['group_id'].
|
38
|
-
identifiers['bar']['artifact_id'].
|
39
|
-
identifiers['bar']['packaging'].
|
40
|
-
identifiers['bar']['classifier'].
|
41
|
-
identifiers['bar']['version'].
|
36
|
+
expect(identifiers.size).to eq 1
|
37
|
+
expect(identifiers['bar']['plugin_name']).to eq 'bar_name'
|
38
|
+
expect(identifiers['bar']['group_id']).to eq 'group'
|
39
|
+
expect(identifiers['bar']['artifact_id']).to eq 'artifact'
|
40
|
+
expect(identifiers['bar']['packaging']).to eq 'packaging'
|
41
|
+
expect(identifiers['bar']['classifier']).to be_nil
|
42
|
+
expect(identifiers['bar']['version']).to eq 'version'
|
42
43
|
end
|
43
44
|
|
44
|
-
|
45
45
|
it 'creates plugin identifier with multiple entries' do
|
46
46
|
# Verifies file gets created if does not exist
|
47
47
|
identifiers = @manager.add_plugin_identifier_key('foo', 'foo_name', 'type', nil)
|
48
|
-
identifiers.size.
|
49
|
-
identifiers['foo']['plugin_name'].
|
48
|
+
expect(identifiers.size).to eq 1
|
49
|
+
expect(identifiers['foo']['plugin_name']).to eq 'foo_name'
|
50
50
|
|
51
51
|
# Verify file was created from previous entry (prev value was read)
|
52
52
|
identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', nil)
|
53
|
-
identifiers.size.
|
54
|
-
identifiers['foo']['plugin_name'].
|
55
|
-
identifiers['bar']['plugin_name'].
|
56
|
-
|
53
|
+
expect(identifiers.size).to eq 2
|
54
|
+
expect(identifiers['foo']['plugin_name']).to eq 'foo_name'
|
55
|
+
expect(identifiers['bar']['plugin_name']).to eq 'bar_name'
|
57
56
|
|
58
57
|
# Verify file was created from previous entry (prev value was read)
|
59
58
|
identifiers = @manager.add_plugin_identifier_key('zoe', 'zoe_name', 'type', nil)
|
60
|
-
identifiers.size.
|
61
|
-
identifiers['bar']['plugin_name'].
|
62
|
-
identifiers['foo']['plugin_name'].
|
63
|
-
identifiers['zoe']['plugin_name'].
|
59
|
+
expect(identifiers.size).to eq 3
|
60
|
+
expect(identifiers['bar']['plugin_name']).to eq 'bar_name'
|
61
|
+
expect(identifiers['foo']['plugin_name']).to eq 'foo_name'
|
62
|
+
expect(identifiers['zoe']['plugin_name']).to eq 'zoe_name'
|
64
63
|
end
|
65
64
|
|
66
65
|
it 'creates plugin identifiers with duplicate entries' do
|
67
66
|
# Verifies file gets created if does not exist
|
68
67
|
identifiers = @manager.add_plugin_identifier_key('kewl', 'kewl_name', 'type', nil)
|
69
|
-
identifiers.size.
|
70
|
-
identifiers['kewl']['plugin_name'].
|
68
|
+
expect(identifiers.size).to eq 1
|
69
|
+
expect(identifiers['kewl']['plugin_name']).to eq 'kewl_name'
|
71
70
|
|
72
71
|
# Add with a different plugin_name
|
73
72
|
identifiers = @manager.add_plugin_identifier_key('kewl', 'kewl_name2', 'type', nil)
|
74
|
-
identifiers.size.
|
75
|
-
identifiers['kewl']['plugin_name'].
|
73
|
+
expect(identifiers.size).to eq 1
|
74
|
+
expect(identifiers['kewl']['plugin_name']).to eq 'kewl_name'
|
76
75
|
end
|
77
76
|
|
78
|
-
|
79
77
|
it 'creates plugin identifiers and remove entry' do
|
80
78
|
# Verifies file gets created if does not exist
|
81
79
|
identifiers = @manager.add_plugin_identifier_key('lol', 'lol_name', 'type', nil)
|
82
|
-
identifiers.size.
|
83
|
-
identifiers['lol']['plugin_name'].
|
80
|
+
expect(identifiers.size).to eq 1
|
81
|
+
expect(identifiers['lol']['plugin_name']).to eq 'lol_name'
|
84
82
|
|
85
83
|
# Remove wrong entry, nothing happens
|
86
84
|
identifiers = @manager.remove_plugin_identifier_key('lol2')
|
87
|
-
identifiers.size.
|
88
|
-
identifiers['lol']['plugin_name'].
|
85
|
+
expect(identifiers.size).to eq 1
|
86
|
+
expect(identifiers['lol']['plugin_name']).to eq 'lol_name'
|
89
87
|
|
90
88
|
# Remove correct entry
|
91
89
|
identifiers = @manager.remove_plugin_identifier_key('lol')
|
92
|
-
identifiers.size.
|
90
|
+
expect(identifiers.size).to eq 0
|
93
91
|
|
94
92
|
# Add same entry again
|
95
93
|
identifiers = @manager.add_plugin_identifier_key('lol', 'lol_name', 'type', nil)
|
96
|
-
identifiers.size.
|
97
|
-
identifiers['lol']['plugin_name'].
|
94
|
+
expect(identifiers.size).to eq 1
|
95
|
+
expect(identifiers['lol']['plugin_name']).to eq 'lol_name'
|
98
96
|
end
|
99
97
|
|
100
98
|
it 'creates plugin identifiers and validate entry' do
|
101
99
|
# Verifies file gets created if does not exist
|
102
|
-
coordinate_map = {:
|
100
|
+
coordinate_map = { group_id: 'group', artifact_id: 'artifact', packaging: 'packaging', version: 'version' }
|
103
101
|
|
104
|
-
identifiers = @manager.add_plugin_identifier_key('yoyo', 'yoyo_name', 'type',
|
105
|
-
identifiers.size.
|
106
|
-
identifiers['yoyo']['plugin_name'].
|
102
|
+
identifiers = @manager.add_plugin_identifier_key('yoyo', 'yoyo_name', 'type', coordinate_map)
|
103
|
+
expect(identifiers.size).to eq 1
|
104
|
+
expect(identifiers['yoyo']['plugin_name']).to eq 'yoyo_name'
|
107
105
|
|
108
|
-
@manager.validate_plugin_identifier_key('yoyo', coordinate_map).
|
106
|
+
expect(@manager.validate_plugin_identifier_key('yoyo', coordinate_map)).to eq true
|
109
107
|
|
110
108
|
# Negative validation
|
111
|
-
invalid_coordinate_map = {:
|
109
|
+
invalid_coordinate_map = { group_id: 'group1', artifact_id: 'artifact', packaging: 'packaging', version: 'version' }
|
112
110
|
|
113
|
-
@manager.validate_plugin_identifier_key('yoyo', invalid_coordinate_map).
|
111
|
+
expect(@manager.validate_plugin_identifier_key('yoyo', invalid_coordinate_map)).to eq false
|
114
112
|
end
|
115
113
|
|
116
|
-
|
117
114
|
it 'creates a plugin identifier entry with a new version' do
|
118
115
|
# Verifies file gets created if does not exist
|
119
116
|
|
120
|
-
coordinate_map1 = {:
|
117
|
+
coordinate_map1 = { group_id: 'group', artifact_id: 'artifact', packaging: 'packaging', version: 'version1' }
|
121
118
|
|
122
119
|
identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', coordinate_map1)
|
123
|
-
identifiers.size.
|
124
|
-
identifiers['bar']['plugin_name'].
|
125
|
-
identifiers['bar']['version'].
|
120
|
+
expect(identifiers.size).to eq 1
|
121
|
+
expect(identifiers['bar']['plugin_name']).to eq 'bar_name'
|
122
|
+
expect(identifiers['bar']['version']).to eq 'version1'
|
126
123
|
|
127
|
-
coordinate_map2 = {:
|
124
|
+
coordinate_map2 = { group_id: 'group', artifact_id: 'artifact', packaging: 'packaging', version: 'version2' }
|
128
125
|
|
129
126
|
identifiers = @manager.add_plugin_identifier_key('bar', 'bar_name', 'type', coordinate_map2)
|
130
|
-
identifiers.size.
|
131
|
-
identifiers['bar']['plugin_name'].
|
132
|
-
identifiers['bar']['version'].
|
133
|
-
|
127
|
+
expect(identifiers.size).to eq 1
|
128
|
+
expect(identifiers['bar']['plugin_name']).to eq 'bar_name'
|
129
|
+
expect(identifiers['bar']['version']).to eq 'version2'
|
134
130
|
end
|
135
131
|
|
136
132
|
it 'sets a path as active' do
|
137
133
|
@manager.set_active(@plugin_dir.join('1.0.0'))
|
138
|
-
File.
|
139
|
-
File.readlink(@plugin_dir.join('SET_DEFAULT')).
|
134
|
+
expect(File.exist?(@plugin_dir.join('SET_DEFAULT'))).to be_truthy
|
135
|
+
expect(File.readlink(@plugin_dir.join('SET_DEFAULT'))).to eq @plugin_dir.join('1.0.0').to_s
|
140
136
|
|
141
137
|
@manager.set_active(@plugin_dir.join('2.0.0'))
|
142
|
-
File.
|
143
|
-
File.readlink(@plugin_dir.join('SET_DEFAULT')).
|
138
|
+
expect(File.exist?(@plugin_dir.join('SET_DEFAULT'))).to be_truthy
|
139
|
+
expect(File.readlink(@plugin_dir.join('SET_DEFAULT'))).to eq @plugin_dir.join('2.0.0').to_s
|
144
140
|
end
|
145
141
|
|
146
142
|
it 'sets a plugin version as active' do
|
147
143
|
@manager.set_active('killbill-stripe', '2.0.0')
|
148
|
-
File.
|
149
|
-
File.readlink(@plugin_dir.join('SET_DEFAULT')).
|
144
|
+
expect(File.exist?(@plugin_dir.join('SET_DEFAULT'))).to be_truthy
|
145
|
+
expect(File.readlink(@plugin_dir.join('SET_DEFAULT'))).to eq @plugin_dir.join('2.0.0').to_s
|
150
146
|
|
151
147
|
@manager.set_active('killbill-stripe', '1.0.0')
|
152
|
-
File.
|
153
|
-
File.readlink(@plugin_dir.join('SET_DEFAULT')).
|
148
|
+
expect(File.exist?(@plugin_dir.join('SET_DEFAULT'))).to be_truthy
|
149
|
+
expect(File.readlink(@plugin_dir.join('SET_DEFAULT'))).to eq @plugin_dir.join('1.0.0').to_s
|
154
150
|
end
|
155
151
|
|
156
152
|
it 'uninstalls a plugin via a path' do
|
@@ -194,19 +190,19 @@ describe KPM::PluginsManager do
|
|
194
190
|
end
|
195
191
|
|
196
192
|
it 'guesses the plugin name' do
|
197
|
-
@manager.guess_plugin_name('tripe').
|
193
|
+
expect(@manager.guess_plugin_name('tripe')).to be_nil
|
198
194
|
# Short name
|
199
|
-
@manager.guess_plugin_name('stripe').
|
195
|
+
expect(@manager.guess_plugin_name('stripe')).to eq 'killbill-stripe'
|
200
196
|
# Artifact id
|
201
|
-
@manager.guess_plugin_name('stripe-plugin').
|
197
|
+
expect(@manager.guess_plugin_name('stripe-plugin')).to eq 'killbill-stripe'
|
202
198
|
# Plugin name (top directory in the .tar.gz)
|
203
|
-
@manager.guess_plugin_name('killbill-stripe').
|
199
|
+
expect(@manager.guess_plugin_name('killbill-stripe')).to eq 'killbill-stripe'
|
204
200
|
end
|
205
201
|
|
206
202
|
private
|
207
203
|
|
208
204
|
def check_state(version, has_restart, has_disabled)
|
209
|
-
File.
|
210
|
-
File.
|
205
|
+
expect(File.exist?(@plugin_dir.join(version).join('tmp').join('restart.txt'))).to eq has_restart
|
206
|
+
expect(File.exist?(@plugin_dir.join(version).join('tmp').join('disabled.txt'))).to eq has_disabled
|
211
207
|
end
|
212
208
|
end
|