kpm 0.7.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +138 -0
  4. data/Gemfile +2 -0
  5. data/README.adoc +144 -107
  6. data/Rakefile +2 -1
  7. data/bin/kpm +4 -2
  8. data/kpm.gemspec +11 -8
  9. data/lib/kpm.rb +3 -0
  10. data/lib/kpm/account.rb +268 -338
  11. data/lib/kpm/base_artifact.rb +33 -39
  12. data/lib/kpm/base_installer.rb +69 -83
  13. data/lib/kpm/blob.rb +29 -0
  14. data/lib/kpm/cli.rb +3 -1
  15. data/lib/kpm/coordinates.rb +10 -12
  16. data/lib/kpm/database.rb +94 -113
  17. data/lib/kpm/diagnostic_file.rb +126 -147
  18. data/lib/kpm/formatter.rb +76 -48
  19. data/lib/kpm/inspector.rb +24 -34
  20. data/lib/kpm/installer.rb +53 -46
  21. data/lib/kpm/kaui_artifact.rb +4 -3
  22. data/lib/kpm/killbill_plugin_artifact.rb +10 -7
  23. data/lib/kpm/killbill_server_artifact.rb +13 -12
  24. data/lib/kpm/migrations.rb +26 -11
  25. data/lib/kpm/nexus_helper/actions.rb +52 -9
  26. data/lib/kpm/nexus_helper/cloudsmith_api_calls.rb +83 -0
  27. data/lib/kpm/nexus_helper/github_api_calls.rb +70 -0
  28. data/lib/kpm/nexus_helper/nexus_api_calls_v2.rb +130 -108
  29. data/lib/kpm/nexus_helper/nexus_facade.rb +5 -3
  30. data/lib/kpm/plugins_directory.rb +9 -8
  31. data/lib/kpm/plugins_directory.yml +14 -173
  32. data/lib/kpm/plugins_manager.rb +29 -24
  33. data/lib/kpm/sha1_checker.rb +31 -18
  34. data/lib/kpm/system.rb +104 -135
  35. data/lib/kpm/system_helpers/cpu_information.rb +56 -55
  36. data/lib/kpm/system_helpers/disk_space_information.rb +60 -63
  37. data/lib/kpm/system_helpers/entropy_available.rb +37 -39
  38. data/lib/kpm/system_helpers/memory_information.rb +52 -51
  39. data/lib/kpm/system_helpers/os_information.rb +45 -47
  40. data/lib/kpm/system_helpers/system_proxy.rb +10 -10
  41. data/lib/kpm/tasks.rb +381 -438
  42. data/lib/kpm/tenant_config.rb +68 -83
  43. data/lib/kpm/tomcat_manager.rb +10 -8
  44. data/lib/kpm/trace_logger.rb +18 -16
  45. data/lib/kpm/uninstaller.rb +81 -14
  46. data/lib/kpm/utils.rb +13 -14
  47. data/lib/kpm/version.rb +3 -1
  48. data/packaging/Gemfile +2 -0
  49. data/pom.xml +211 -40
  50. data/spec/kpm/remote/base_artifact_spec.rb +20 -20
  51. data/spec/kpm/remote/base_installer_spec.rb +35 -34
  52. data/spec/kpm/remote/cloudsmith_api_calls_spec.rb +40 -0
  53. data/spec/kpm/remote/github_api_calls_spec.rb +40 -0
  54. data/spec/kpm/remote/installer_spec.rb +80 -79
  55. data/spec/kpm/remote/kaui_artifact_spec.rb +7 -6
  56. data/spec/kpm/remote/killbill_plugin_artifact_spec.rb +25 -30
  57. data/spec/kpm/remote/killbill_server_artifact_spec.rb +17 -16
  58. data/spec/kpm/remote/migrations_spec.rb +12 -11
  59. data/spec/kpm/remote/nexus_facade_spec.rb +32 -28
  60. data/spec/kpm/remote/tenant_config_spec.rb +30 -29
  61. data/spec/kpm/remote/tomcat_manager_spec.rb +4 -3
  62. data/spec/kpm/unit/actions_spec.rb +52 -0
  63. data/spec/kpm/unit/base_artifact_spec.rb +19 -18
  64. data/spec/kpm/unit/cpu_information_spec.rb +67 -0
  65. data/spec/kpm/unit/disk_space_information_spec.rb +47 -0
  66. data/spec/kpm/unit/entropy_information_spec.rb +36 -0
  67. data/spec/kpm/unit/formatter_spec.rb +163 -0
  68. data/spec/kpm/unit/inspector_spec.rb +34 -42
  69. data/spec/kpm/unit/installer_spec.rb +7 -6
  70. data/spec/kpm/unit/memory_information_spec.rb +102 -0
  71. data/spec/kpm/unit/os_information_spec.rb +38 -0
  72. data/spec/kpm/unit/plugins_directory_spec.rb +38 -22
  73. data/spec/kpm/unit/plugins_manager_spec.rb +62 -66
  74. data/spec/kpm/unit/sha1_checker_spec.rb +107 -60
  75. data/spec/kpm/unit/uninstaller_spec.rb +118 -72
  76. data/spec/kpm/unit_mysql/account_spec.rb +127 -142
  77. data/spec/spec_helper.rb +20 -18
  78. data/tasks/package.rake +18 -18
  79. metadata +42 -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, :mode => entry.header.mode, :verbose => false
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), :verbose => false
27
- File.open dest, "wb" do |f|
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, :verbose => false
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 (top_dir.nil? || top_dir.size >= current_dir.size)
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module KPM
2
- VERSION = '0.7.2'
4
+ VERSION = '0.10.0'
3
5
  end
data/packaging/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gem 'kpm', '~> VERSION'
data/pom.xml CHANGED
@@ -1,45 +1,216 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!--
3
- ~ Copyright 2014-2017 The Billing Project, LLC
4
- ~
5
- ~ The Billing Project licenses this file to you under the Apache License, version 2.0
6
- ~ (the "License"); you may not use this file except in compliance with the
7
- ~ License. You may obtain a copy of the License at:
8
- ~
9
- ~ http://www.apache.org/licenses/LICENSE-2.0
10
- ~
11
- ~ Unless required by applicable law or agreed to in writing, software
12
- ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- ~ License for the specific language governing permissions and limitations
15
- ~ under the License.
16
- -->
17
-
3
+ ~ Copyright 2010-2014 Ning, Inc.
4
+ ~ Copyright 2014-2020 Groupon, Inc
5
+ ~ Copyright 2020-2020 Equinix, Inc
6
+ ~ Copyright 2014-2020 The Billing Project, LLC
7
+ ~
8
+ ~ The Billing Project licenses this file to you under the Apache License, version 2.0
9
+ ~ (the "License"); you may not use this file except in compliance with the
10
+ ~ License. You may obtain a copy of the License at:
11
+ ~
12
+ ~ http://www.apache.org/licenses/LICENSE-2.0
13
+ ~
14
+ ~ Unless required by applicable law or agreed to in writing, software
15
+ ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16
+ ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17
+ ~ License for the specific language governing permissions and limitations
18
+ ~ under the License.
19
+ -->
18
20
  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19
21
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20
- <parent>
21
- <groupId>org.sonatype.oss</groupId>
22
- <artifactId>oss-parent</artifactId>
23
- <version>5</version>
24
- </parent>
25
- <modelVersion>4.0.0</modelVersion>
26
- <groupId>org.kill-bill.billing.installer</groupId>
27
- <artifactId>kpm</artifactId>
28
- <packaging>pom</packaging>
29
- <version>0.7.2</version>
30
- <name>KPM</name>
31
- <url>http://github.com/killbill/killbill-cloud</url>
32
- <description>KPM: the Kill Bill Package Manager</description>
33
- <licenses>
34
- <license>
35
- <name>Apache License 2.0</name>
36
- <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
37
- <distribution>repo</distribution>
38
- </license>
39
- </licenses>
40
- <scm>
41
- <connection>scm:git:git://github.com/killbill/killbill-cloud.git</connection>
42
- <url>https://github.com/killbill/killbill-cloud/</url>
43
- <developerConnection>scm:git:git@github.com:killbill/killbill-cloud.git</developerConnection>
44
- </scm>
22
+ <modelVersion>4.0.0</modelVersion>
23
+ <groupId>org.kill-bill.billing.installer</groupId>
24
+ <artifactId>kpm</artifactId>
25
+ <version>0.10.0</version>
26
+ <packaging>pom</packaging>
27
+ <name>KPM</name>
28
+ <description>KPM: the Kill Bill Package Manager</description>
29
+ <url>http://github.com/killbill/killbill-cloud</url>
30
+ <inceptionYear>2010</inceptionYear>
31
+ <licenses>
32
+ <license>
33
+ <name>Apache License 2.0</name>
34
+ <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
35
+ <distribution>repo</distribution>
36
+ </license>
37
+ </licenses>
38
+ <developers>
39
+ <developer>
40
+ <id>pierre</id>
41
+ <name>Pierre-Alexandre Meyer</name>
42
+ <email>pierre@mouraf.org</email>
43
+ </developer>
44
+ <developer>
45
+ <id>stephane</id>
46
+ <name>Stephane Brossier</name>
47
+ </developer>
48
+ </developers>
49
+ <mailingLists>
50
+ <mailingList>
51
+ <name>Kill Bill users</name>
52
+ <subscribe>killbilling-users+subscribe@googlegroups.com</subscribe>
53
+ <unsubscribe>killbilling-users+unsubscribe@googlegroups.com</unsubscribe>
54
+ <post>killbilling-users@googlegroups.com</post>
55
+ <archive>http://groups.google.com/group/killbilling-users</archive>
56
+ </mailingList>
57
+ </mailingLists>
58
+ <scm>
59
+ <connection>scm:git:git://github.com/killbill/killbill-cloud.git</connection>
60
+ <url>https://github.com/killbill/killbill-cloud/</url>
61
+ <developerConnection>scm:git:git@github.com:killbill/killbill-cloud.git</developerConnection>
62
+ </scm>
63
+ <issueManagement>
64
+ <system>Github</system>
65
+ <url>https://github.com/killbill/killbill-cloud/issues</url>
66
+ </issueManagement>
67
+ <distributionManagement>
68
+ <repository>
69
+ <id>${repository.release.id}</id>
70
+ <name>${repository.release.name}</name>
71
+ <url>${repository.release.url}</url>
72
+ </repository>
73
+ <snapshotRepository>
74
+ <id>${repository.snapshot.id}</id>
75
+ <name>${repository.snapshot.name}</name>
76
+ <url>${repository.snapshot.url}</url>
77
+ </snapshotRepository>
78
+ </distributionManagement>
79
+ <properties>
80
+ <repository.release.id>sonatype-nexus-staging</repository.release.id>
81
+ <repository.release.name>Nexus Release Repository</repository.release.name>
82
+ <repository.release.url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</repository.release.url>
83
+ <repository.snapshot.id>sonatype-nexus-snapshots</repository.snapshot.id>
84
+ <repository.snapshot.name>Sonatype Nexus Snapshots</repository.snapshot.name>
85
+ <repository.snapshot.url>https://oss.sonatype.org/content/repositories/snapshots/</repository.snapshot.url>
86
+ </properties>
87
+ <build>
88
+ <pluginManagement>
89
+ <plugins>
90
+ <plugin>
91
+ <artifactId>maven-compiler-plugin</artifactId>
92
+ <executions>
93
+ <execution>
94
+ <id>default-compile</id>
95
+ <phase>none</phase>
96
+ </execution>
97
+ <execution>
98
+ <id>default-testCompile</id>
99
+ <phase>none</phase>
100
+ </execution>
101
+ </executions>
102
+ </plugin>
103
+ <plugin>
104
+ <artifactId>maven-install-plugin</artifactId>
105
+ <executions>
106
+ <execution>
107
+ <id>default-install</id>
108
+ <phase>none</phase>
109
+ </execution>
110
+ </executions>
111
+ </plugin>
112
+ <plugin>
113
+ <artifactId>maven-resources-plugin</artifactId>
114
+ <executions>
115
+ <execution>
116
+ <id>default-resources</id>
117
+ <phase>none</phase>
118
+ </execution>
119
+ <execution>
120
+ <id>default-testResources</id>
121
+ <phase>none</phase>
122
+ </execution>
123
+ </executions>
124
+ </plugin>
125
+ <plugin>
126
+ <artifactId>maven-surefire-plugin</artifactId>
127
+ <executions>
128
+ <execution>
129
+ <id>default-test</id>
130
+ <phase>none</phase>
131
+ </execution>
132
+ </executions>
133
+ </plugin>
134
+ </plugins>
135
+ </pluginManagement>
136
+ <plugins>
137
+ <plugin>
138
+ <groupId>org.codehaus.mojo</groupId>
139
+ <artifactId>build-helper-maven-plugin</artifactId>
140
+ <version>3.2.0</version>
141
+ <executions>
142
+ <execution>
143
+ <id>attach-artifacts</id>
144
+ <phase>package</phase>
145
+ <goals>
146
+ <goal>attach-artifact</goal>
147
+ </goals>
148
+ <configuration>
149
+ <artifacts>
150
+ <artifact>
151
+ <file>kpm-${project.version}-linux-x86.tar.gz</file>
152
+ <type>tar.gz</type>
153
+ <classifier>linux-x86</classifier>
154
+ </artifact>
155
+ <artifact>
156
+ <file>kpm-${project.version}-linux-x86_64.tar.gz</file>
157
+ <type>tar.gz</type>
158
+ <classifier>linux-x86_64</classifier>
159
+ </artifact>
160
+ <artifact>
161
+ <file>kpm-${project.version}-osx.tar.gz</file>
162
+ <type>tar.gz</type>
163
+ <classifier>osx</classifier>
164
+ </artifact>
165
+ </artifacts>
166
+ </configuration>
167
+ </execution>
168
+ </executions>
169
+ </plugin>
170
+ </plugins>
171
+ </build>
172
+ <profiles>
173
+ <profile>
174
+ <id>sonatype-oss-release</id>
175
+ <build>
176
+ <plugins>
177
+ <plugin>
178
+ <groupId>org.apache.maven.plugins</groupId>
179
+ <artifactId>maven-gpg-plugin</artifactId>
180
+ <version>1.6</version>
181
+ <executions>
182
+ <execution>
183
+ <id>sign-artifacts</id>
184
+ <phase>verify</phase>
185
+ <goals>
186
+ <goal>sign</goal>
187
+ </goals>
188
+ <configuration>
189
+ <!-- Prevent `gpg` from using pinentry programs -->
190
+ <gpgArguments>
191
+ <arg>--pinentry-mode</arg>
192
+ <arg>loopback</arg>
193
+ </gpgArguments>
194
+ </configuration>
195
+ </execution>
196
+ </executions>
197
+ </plugin>
198
+ <plugin>
199
+ <groupId>org.sonatype.plugins</groupId>
200
+ <artifactId>nexus-staging-maven-plugin</artifactId>
201
+ <version>1.6.8</version>
202
+ <extensions>true</extensions>
203
+ <configuration>
204
+ <serverId>ossrh-releases</serverId>
205
+ <nexusUrl>https://oss.sonatype.org/</nexusUrl>
206
+ <keepStagingRepositoryOnFailure>true</keepStagingRepositoryOnFailure>
207
+ <keepStagingRepositoryOnCloseRuleFailure>true</keepStagingRepositoryOnCloseRuleFailure>
208
+ <autoReleaseAfterClose>true</autoReleaseAfterClose>
209
+ <stagingProgressTimeoutMinutes>10</stagingProgressTimeoutMinutes>
210
+ </configuration>
211
+ </plugin>
212
+ </plugins>
213
+ </build>
214
+ </profile>
215
+ </profiles>
45
216
  </project>
@@ -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
@@ -26,7 +27,7 @@ describe KPM::BaseArtifact do
26
27
  end
27
28
 
28
29
  it 'should be able to handle download errors' do
29
- nexus_down = {:url => 'https://does.not.exist'}
30
+ nexus_down = { url: 'https://does.not.exist' }
30
31
  Dir.mktmpdir do |dir|
31
32
  sha1_file = "#{dir}/sha1.yml"
32
33
  test_download dir, 'foo-oss.pom.xml', false, false, sha1_file
@@ -35,10 +36,12 @@ describe KPM::BaseArtifact do
35
36
  # Verify the download is skipped gracefully when Nexus isn't reachable
36
37
  test_download dir, 'foo-oss.pom.xml', true, false, sha1_file, nexus_down
37
38
  # Verify the download fails when Nexus isn't reachable and force_download is set
38
- expect { test_download dir, 'foo-oss.pom.xml', nil, true, sha1_file, nexus_down }.to raise_error(SocketError)
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)/)
39
40
  # Verify the download fails when Nexus isn't reachable and the Nexus cache is empty
40
- KPM::Sha1Checker.from_file(sha1_file).cache_artifact_info('org.kill-bill.billing:killbill-oss-parent:pom:LATEST', nil)
41
- expect { test_download dir, 'foo-oss.pom.xml', nil, false, sha1_file, nexus_down }.to raise_error(SocketError)
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)/)
42
45
  end
43
46
  end
44
47
 
@@ -52,14 +55,14 @@ describe KPM::BaseArtifact do
52
55
 
53
56
  Dir.mktmpdir do |dir|
54
57
  info = KPM::BaseArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, version, dir)
55
- info[:file_name].should be_nil
58
+ expect(info[:file_name]).to be_nil
56
59
 
57
60
  files_in_dir = Dir[info[:file_path] + '/*']
58
- files_in_dir.size.should == 20
61
+ expect(files_in_dir.size).to eq 20
59
62
 
60
- File.file?(info[:file_path] + '/killbill-osgi-bundles-jruby-0.11.3.jar').should be_true
63
+ expect(File.file?(info[:file_path] + '/killbill-osgi-bundles-jruby-0.11.3.jar')).to be_truthy
61
64
 
62
- info[:bundle_dir].should == info[:file_path]
65
+ expect(info[:bundle_dir]).to eq info[:file_path]
63
66
  end
64
67
  end
65
68
 
@@ -74,23 +77,20 @@ describe KPM::BaseArtifact do
74
77
 
75
78
  Dir.mktmpdir do |dir|
76
79
  first_take = KPM::BaseArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, version, dir)
77
- File.file?(first_take[:file_path] + '/killbill-platform-osgi-bundles-jruby-0.36.2.jar').should be_true
80
+ expect(File.file?(first_take[:file_path] + '/killbill-platform-osgi-bundles-jruby-0.36.2.jar')).to be_truthy
78
81
 
79
82
  second_take = KPM::BaseArtifact.pull(@logger, group_id, artifact_id, packaging, classifier, second_bundle_version, dir)
80
- File.file?(first_take[:file_path] + '/killbill-platform-osgi-bundles-jruby-0.36.2.jar').should be_false
81
- File.file?(second_take[:file_path] + '/killbill-platform-osgi-bundles-jruby-0.36.10.jar').should be_true
82
-
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
83
85
  end
84
86
  end
85
87
 
86
- def test_download(dir, filename=nil, verify_is_skipped=false, force_download=false, sha1_file=nil, overrides={})
88
+ def test_download(dir, filename = nil, verify_is_skipped = false, force_download = false, sha1_file = nil, overrides = {})
87
89
  path = filename.nil? ? dir : dir + '/' + filename
88
90
 
89
- info = KPM::BaseArtifact.pull(@logger, 'org.kill-bill.billing', 'killbill-oss-parent', 'pom', nil, 'LATEST', path, sha1_file, force_download, true, overrides, true)
90
- info[:file_name].should == (filename.nil? ? "killbill-oss-parent-#{info[:version]}.pom" : filename)
91
- info[:skipped].should == verify_is_skipped
92
- if !info[:skipped]
93
- info[:size].should == File.size(info[:file_path])
94
- 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]
95
95
  end
96
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
- info = installer.install_plugin('analytics', nil, nil, nil, nil, nil, '0.7.1', bundles_dir)
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
- fail "Should not succeed to install invalid plugin"
50
- rescue ArgumentError => e
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
- {:file_path => '/Somewhere/xxx-foo/target/xxx-1.0.0.jar', :expected => 'xxx'},
59
- {:file_path => '/Somewhere/xxx-foo/target/xxx-foo-bar-1.0.0.jar', :expected => 'xxx-foo-bar'},
60
- {:file_path => '/Somewhere/xxx-foo/target/xxx-foo-1.0.0.jar', :expected => 'xxx-foo'},
61
- {:file_path => '/Somewhere/xxx-foo/target/xxx-foo-1.0.0-SNAPSHOT.jar', :expected => 'xxx-foo'},
62
- {:file_path => '/Somewhere/xxx-foo/target/xxx-foo-1.0.jar', :expected => 'xxx-foo'},
63
- {:file_path => '/Somewhere/xxx-foo/target/xxx-foo-1.jar', :expected => 'xxx-foo'},
64
- {:file_path => '/Somewhere/xxx-foo/target/xxx-foo-abc-SNAPSHOT.jar', :expected => 'xxx-foo'},
65
- {:file_path => '/Somewhere/xxx-foo/target/xxx-foo-abc.jar', :expected => 'xxx-foo'}
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]).should eq test[:expected]
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.should == 1
79
+ expect(plugin_identifiers.size).to eq 1
79
80
 
80
- plugin_identifiers['analytics']['plugin_name'].should == 'analytics-plugin'
81
- plugin_identifiers['analytics']['group_id'].should == 'org.kill-bill.billing.plugin.java'
82
- plugin_identifiers['analytics']['artifact_id'].should == 'analytics-plugin'
83
- plugin_identifiers['analytics']['packaging'].should == 'jar'
84
- plugin_identifiers['analytics']['version'].should == '0.7.1'
85
- plugin_identifiers['analytics']['language'].should == 'java'
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').should be_false
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.should == 0
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').should be_true
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
- plugins_dir,
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/analytics-plugin/0.7.1/tmp',
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).should be_true
110
+ expect(File.directory?(dir)).to be_truthy
110
111
  end
111
112
 
112
113
  [
113
- plugins_dir + '/plugins/plugin_identifiers.json',
114
- plugins_dir + '/plugins/java/analytics-plugin/0.7.1/analytics-plugin-0.7.1.jar'
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).should be_true
117
+ expect(File.file?(file)).to be_truthy
117
118
  end
118
119
  end
119
120