kpm 0.7.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,18 +1,19 @@
1
- require 'spec_helper'
1
+ # frozen_string_literal: true
2
2
 
3
- describe KPM::Migrations, :skip_me_if_nil => ENV['TOKEN'].nil? do
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 == 0
10
+ expect(migrations.size).to 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 == 1
16
+ expect(migrations.size).to 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 == 1
24
- migrations.first[:name].should == 'V20160324060345__revisit_payment_methods_indexes_509.sql'
25
- migrations.first[:sql].should == "drop index payment_methods_active_accnt on payment_methods;\n"
24
+ expect(migrations.size).to eq 1
25
+ expect(migrations.first[:name]).to eq 'V20160324060345__revisit_payment_methods_indexes_509.sql'
26
+ expect(migrations.first[:sql]).to 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 == 0
28
+ expect(KPM::Migrations.new('master', 'master', 'killbill/killbill', ENV['TOKEN']).migrations.size).to 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 == 1
34
- migrations.first[:name].should == 'V20160324060345__revisit_payment_methods_indexes_509.sql'
35
- migrations.first[:sql].should == "drop index payment_methods_active_accnt on payment_methods;\n"
34
+ expect(migrations.size).to eq 1
35
+ expect(migrations.first[:name]).to eq 'V20160324060345__revisit_payment_methods_indexes_509.sql'
36
+ expect(migrations.first[:sql]).to eq "drop index payment_methods_active_accnt on payment_methods;\n"
36
37
  end
37
38
  end
38
39
  end
@@ -1,60 +1,64 @@
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
- let(:coordinates_map){ {:version => '0.1.4',
7
- :group_id => 'org.kill-bill.billing',
8
- :artifact_id => 'killbill-platform-osgi-api',
9
- :packaging => 'jar',
10
- :classifier => nil} }
11
- let(:coordinates_with_classifier_map){ {:version => '0.1.1',
12
- :group_id => 'org.kill-bill.billing',
13
- :artifact_id => 'killbill-platform-osgi-bundles-jruby',
14
- :packaging => 'jar',
15
- :classifier => 'javadoc'} }
16
- let(:coordinates) { KPM::Coordinates.build_coordinates(coordinates_map)}
17
- let(:coordinates_with_classifier) { KPM::Coordinates.build_coordinates(coordinates_with_classifier_map)}
18
- let(:nexus_remote) { described_class::RemoteFactory.create(nil, true)}
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{ response = nexus_remote.search_for_artifacts(coordinates) }.not_to raise_exception
23
- expect(REXML::Document.new(response).elements["//artifactId"].text).to eq(coordinates_map[:artifact_id])
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{ response = nexus_remote.search_for_artifacts(coordinates_with_classifier) }.not_to raise_exception
29
- expect(REXML::Document.new(response).elements["//artifactId"].text).to eq(coordinates_with_classifier_map[:artifact_id])
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{ response = nexus_remote.get_artifact_info(coordinates) }.not_to raise_exception
35
- expect(REXML::Document.new(response).elements["//version"].text).to eq(coordinates_map[:version])
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{ response = nexus_remote.get_artifact_info(coordinates_with_classifier) }.not_to raise_exception
41
- expect(REXML::Document.new(response).elements["//version"].text).to eq(coordinates_with_classifier_map[:version])
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{ response = nexus_remote.pull_artifact(coordinates,destination) }.not_to raise_exception
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
- expect(File.exist?(destination)).to be_true
54
+ expect(File.exist?(destination)).to be_truthy
50
55
  end
51
56
 
52
57
  it 'when pull artifact with classifier' do
53
58
  response = nil
54
59
  destination = Dir.mktmpdir('artifact')
55
- expect{ response = nexus_remote.pull_artifact(coordinates_with_classifier,destination) }.not_to raise_exception
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
- expect(File.exist?(destination)).to be_true
62
+ expect(File.exist?(destination)).to be_truthy
58
63
  end
59
-
60
- end
64
+ end
@@ -1,58 +1,59 @@
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) { described_class.new([killbill_api_key,killbill_api_secrets],
11
- [killbill_user, killbill_password],url,logger)}
12
- let(:options){{
13
- :username => killbill_user,
14
- :password => killbill_password,
15
- :api_key => killbill_api_key,
16
- :api_secret => killbill_api_secrets
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
25
30
 
26
31
  it 'when initialized with options' do
27
- tenant_config_class.should be_an_instance_of(KPM::TenantConfig)
32
+ expect(tenant_config_class).to 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(:@killbill_api_secrets)).to eq(killbill_api_secrets)
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
- expect(File.exist?(export_file)).to be_true
51
- expect(File.readlines(export_file).grep(/#{key}/)).to be_true
52
-
53
- #remove created tenant config
52
+ expect(File.exist?(export_file)).to be_truthy
53
+ expect(File.readlines(export_file).grep(/#{key}/)).to be_truthy
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
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe KPM::TomcatManager do
4
-
5
6
  before(:all) do
6
7
  @logger = Logger.new(STDOUT)
7
8
  @logger.level = Logger::INFO
@@ -12,10 +13,10 @@ describe KPM::TomcatManager do
12
13
  manager = KPM::TomcatManager.new(dir, @logger)
13
14
 
14
15
  tomcat_path = manager.download
15
- tomcat_path.should_not be_nil
16
+ expect(tomcat_path).not_to be_nil
16
17
 
17
18
  root_war_path = manager.setup
18
- root_war_path.should_not be_nil
19
+ expect(root_war_path).not_to be_nil
19
20
  end
20
21
  end
21
22
  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
+ allow(KPM::NexusFacade::NexusApiCallsV2).to receive(: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_truthy
49
+ expect(calls).to eq(2)
50
+ end
51
+ end
52
+ end
@@ -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
@@ -13,16 +14,16 @@ describe KPM::BaseArtifact do
13
14
  Dir.mktmpdir do |dir|
14
15
  info = KPM::BaseArtifact.pull_from_fs(@logger, file_path, dir)
15
16
 
16
- info[:skipped].should be_false
17
- info[:is_tgz].should be_false
18
- info[:repository_path].should == file_path
19
- info[:dir_name].should == dir
20
- info[:bundle_dir].should == dir
21
- info[:file_name].should == 'sha1_test.yml'
17
+ expect(info[:skipped]).to be_falsey
18
+ expect(info[:is_tgz]).to be_falsey
19
+ expect(info[:repository_path]).to eq file_path
20
+ expect(info[:dir_name]).to eq dir
21
+ expect(info[:bundle_dir]).to eq dir
22
+ expect(info[:file_name]).to eq 'sha1_test.yml'
22
23
 
23
24
  files_in_dir = Dir[dir + '/*']
24
- files_in_dir.size.should == 1
25
- files_in_dir[0].should == info[:file_path]
25
+ expect(files_in_dir.size).to eq 1
26
+ expect(files_in_dir[0]).to eq info[:file_path]
26
27
  end
27
28
  end
28
29
 
@@ -75,18 +76,18 @@ describe KPM::BaseArtifact do
75
76
 
76
77
  def check_fs_info(specified_destination_path, repository_path, is_tgz, version, expected_dir_name, expected_file_name, expected_file_path)
77
78
  info = {
78
- :repository_path => repository_path,
79
- :is_tgz => is_tgz,
80
- :version => version
79
+ repository_path: repository_path,
80
+ is_tgz: is_tgz,
81
+ version: version
81
82
  }
82
83
 
83
84
  KPM::BaseArtifact.send('populate_fs_info', info, specified_destination_path)
84
85
 
85
- info[:repository_path].should == repository_path
86
- info[:is_tgz].should == is_tgz
87
- info[:version].should == version
88
- info[:dir_name].should == expected_dir_name
89
- info[:file_name].should == expected_file_name
90
- info[:file_path].should == expected_file_path
86
+ expect(info[:repository_path]).to eq repository_path
87
+ expect(info[:is_tgz]).to eq is_tgz
88
+ expect(info[:version]).to eq version
89
+ expect(info[:dir_name]).to eq expected_dir_name
90
+ expect(info[:file_name]).to eq expected_file_name
91
+ expect(info[:file_path]).to eq expected_file_path
91
92
  end
92
93
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'kpm/system_helpers/system_proxy'
5
+ require 'kpm/system_helpers/cpu_information'
6
+
7
+ describe KPM::SystemProxy::CpuInformation do
8
+ subject { described_class.new }
9
+ let(:cpu_info) { subject.send(:build_hash, data) }
10
+
11
+ context 'when running on Linux' do
12
+ let(:data) { "processor: 0\nvendor_id: GenuineIntel\ncpu family: 6\nmodel: 78\nmodel name: Intel(R) Core(TM) i5-6287U CPU @ 3.10GHz\nstepping: 3\ncpu MHz: 3096.000\ncache size: 4096 KB\nphysical id: 0\nsiblings: 2\ncore id: 0\ncpu cores: 2\napicid: 0\ninitial apicid: 0\nfpu: yes\nfpu_exception: yes\ncpuid level: 22\nwp: yes\nflags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase avx2 invpcid rdseed clflushopt\nbugs:\nbogomips: 6192.00\nclflush size: 64\ncache_alignment: 64\naddress sizes: 39 bits physical, 48 bits virtual\npower management:\n\nprocessor: 1\nvendor_id: GenuineIntel\ncpu family: 6\nmodel: 78\nmodel name: Intel(R) Core(TM) i5-6287U CPU @ 3.10GHz\nstepping: 3\ncpu MHz: 3096.000\ncache size: 4096 KB\nphysical id: 0\nsiblings: 2\ncore id: 1\ncpu cores: 2\napicid: 1\ninitial apicid: 1\nfpu: yes\nfpu_exception: yes\ncpuid level: 22\nwp: yes\nflags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase avx2 invpcid rdseed clflushopt\nbugs:\nbogomips: 6192.00\nclflush size: 64\ncache_alignment: 64\naddress sizes: 39 bits physical, 48 bits virtual\npower management:\n\n" }
13
+
14
+ it {
15
+ expect(subject.labels).to eq([{ label: :cpu_detail },
16
+ { label: :value }])
17
+ }
18
+
19
+ it {
20
+ expect(cpu_info).to eq({ 'processor' => { cpu_detail: 'processor', value: '1' },
21
+ 'vendor_id' => { cpu_detail: 'vendor_id', value: 'GenuineIntel' },
22
+ 'cpu family' => { cpu_detail: 'cpu family', value: '6' },
23
+ 'model' => { cpu_detail: 'model', value: '78' },
24
+ 'model name' =>
25
+ { cpu_detail: 'model name',
26
+ value: 'Intel(R) Core(TM) i5-6287U CPU @ 3.10GHz' },
27
+ 'stepping' => { cpu_detail: 'stepping', value: '3' },
28
+ 'cpu MHz' => { cpu_detail: 'cpu MHz', value: '3096.000' },
29
+ 'cache size' => { cpu_detail: 'cache size', value: '4096 KB' },
30
+ 'physical id' => { cpu_detail: 'physical id', value: '0' },
31
+ 'siblings' => { cpu_detail: 'siblings', value: '2' },
32
+ 'core id' => { cpu_detail: 'core id', value: '1' },
33
+ 'cpu cores' => { cpu_detail: 'cpu cores', value: '2' },
34
+ 'apicid' => { cpu_detail: 'apicid', value: '1' },
35
+ 'initial apicid' => { cpu_detail: 'initial apicid', value: '1' },
36
+ 'fpu' => { cpu_detail: 'fpu', value: 'yes' },
37
+ 'fpu_exception' => { cpu_detail: 'fpu_exception', value: 'yes' },
38
+ 'cpuid level' => { cpu_detail: 'cpuid level', value: '22' },
39
+ 'wp' => { cpu_detail: 'wp', value: 'yes' },
40
+ 'bugs' => { cpu_detail: 'bugs', value: '' },
41
+ 'bogomips' => { cpu_detail: 'bogomips', value: '6192.00' },
42
+ 'clflush size' => { cpu_detail: 'clflush size', value: '64' },
43
+ 'cache_alignment' => { cpu_detail: 'cache_alignment', value: '64' },
44
+ 'address sizes' =>
45
+ { cpu_detail: 'address sizes', value: '39 bits physical, 48 bits virtual' },
46
+ 'power management' => { cpu_detail: 'power management', value: '' } })
47
+ }
48
+ end
49
+
50
+ context 'when running on MacOS' do
51
+ let(:data) { " Processor Name: Intel Core i5\n Processor Speed: 3.1 GHz\n Number of Processors: 1\n Total Number of Cores: 2\n L2 Cache (per Core): 256 KB\n L3 Cache: 4 MB\n" }
52
+
53
+ it {
54
+ expect(subject.labels).to eq([{ label: :cpu_detail },
55
+ { label: :value }])
56
+ }
57
+
58
+ it {
59
+ expect(cpu_info).to eq({ 'Processor Name' => { cpu_detail: 'Processor Name', value: 'Intel Core i5' },
60
+ 'Processor Speed' => { cpu_detail: 'Processor Speed', value: '3.1 GHz' },
61
+ 'Number of Processors' => { cpu_detail: 'Number of Processors', value: '1' },
62
+ 'Total Number of Cores' => { cpu_detail: 'Total Number of Cores', value: '2' },
63
+ 'L2 Cache (per Core)' => { cpu_detail: 'L2 Cache (per Core)', value: '256 KB' },
64
+ 'L3 Cache' => { cpu_detail: 'L3 Cache', value: '4 MB' } })
65
+ }
66
+ end
67
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'kpm/system_helpers/system_proxy'
5
+ require 'kpm/system_helpers/disk_space_information'
6
+
7
+ describe KPM::SystemProxy::DiskSpaceInformation do
8
+ subject { described_class.new }
9
+ let(:data_keys) { [] }
10
+ let!(:disk_space_info) { subject.send(:build_hash, data, cols_count, true, data_keys) }
11
+
12
+ context 'when running on Linux' do
13
+ let(:cols_count) { 5 }
14
+ let(:data) { "Filesystem 1K-blocks Used Available Use% Mounted on\nnone 58419028 24656532 30723884 45% /\ntmpfs 65536 0 65536 0% /dev\ntmpfs 5387012 0 5387012 0% /sys/fs/cgroup\n/dev/sda1 58419028 24656532 30723884 45% /etc/hosts\nshm 65536 0 65536 0% /dev/shm\ntmpfs 5387012 0 5387012 0% /sys/firmware\n" }
15
+
16
+ it {
17
+ expect(data_keys).to eq(['Filesystem', '1K-blocks', 'Used', 'Available', 'Use%', 'Mounted on'])
18
+ }
19
+
20
+ it {
21
+ expect(disk_space_info).to eq({ 'DiskInfo_2' => { :Filesystem => 'none', :"1K-blocks" => '58419028', :Used => '24656532', :Available => '30723884', :"Use%" => '45%', :Mounted_on => '/' },
22
+ 'DiskInfo_3' => { :Filesystem => 'tmpfs', :"1K-blocks" => '65536', :Used => '0', :Available => '65536', :"Use%" => '0%', :Mounted_on => '/dev' },
23
+ 'DiskInfo_4' => { :Filesystem => 'tmpfs', :"1K-blocks" => '5387012', :Used => '0', :Available => '5387012', :"Use%" => '0%', :Mounted_on => '/sys/fs/cgroup' },
24
+ 'DiskInfo_5' => { :Filesystem => '/dev/sda1', :"1K-blocks" => '58419028', :Used => '24656532', :Available => '30723884', :"Use%" => '45%', :Mounted_on => '/etc/hosts' },
25
+ 'DiskInfo_6' => { :Filesystem => 'shm', :"1K-blocks" => '65536', :Used => '0', :Available => '65536', :"Use%" => '0%', :Mounted_on => '/dev/shm' },
26
+ 'DiskInfo_7' => { :Filesystem => 'tmpfs', :"1K-blocks" => '5387012', :Used => '0', :Available => '5387012', :"Use%" => '0%', :Mounted_on => '/sys/firmware' } })
27
+ }
28
+ end
29
+
30
+ context 'when running on MacOS' do
31
+ let(:cols_count) { 8 }
32
+ let(:data) { "Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on\n/dev/disk1s1 976490576 778131600 173031648 82% 2431747 9223372036852344060 0% /\ndevfs 690 690 0 100% 1194 0 100% /dev\n/dev/disk1s4 976490576 23925200 173031648 13% 5 9223372036854775802 0% /private/var/vm\nmap -hosts 0 0 0 100% 0 0 100% /net\nmap auto_home 0 0 0 100% 0 0 100% /home\n/dev/disk1s3 976490576 996584 173031648 1% 34 9223372036854775773 0% /Volumes/Recovery\n" }
33
+
34
+ it {
35
+ expect(data_keys).to eq(['Filesystem', '512-blocks', 'Used', 'Available', 'Capacity', 'iused', 'ifree', '%iused', 'Mounted on'])
36
+ }
37
+
38
+ it {
39
+ expect(disk_space_info).to eq({ 'DiskInfo_2' => { :Filesystem => '/dev/disk1s1', :"512-blocks" => '976490576', :Used => '778131600', :Available => '173031648', :Capacity => '82%', :iused => '2431747', :ifree => '9223372036852344060', :"%iused" => '0%', :Mounted_on => '/' },
40
+ 'DiskInfo_3' => { :Filesystem => 'devfs', :"512-blocks" => '690', :Used => '690', :Available => '0', :Capacity => '100%', :iused => '1194', :ifree => '0', :"%iused" => '100%', :Mounted_on => '/dev' },
41
+ 'DiskInfo_4' => { :Filesystem => '/dev/disk1s4', :"512-blocks" => '976490576', :Used => '23925200', :Available => '173031648', :Capacity => '13%', :iused => '5', :ifree => '9223372036854775802', :"%iused" => '0%', :Mounted_on => '/private/var/vm' },
42
+ 'DiskInfo_5' => { :Filesystem => 'map', :"512-blocks" => '-hosts', :Used => '0', :Available => '0', :Capacity => '0', :iused => '100%', :ifree => '0', :"%iused" => '0', :Mounted_on => '100% /net ' },
43
+ 'DiskInfo_6' => { :Filesystem => 'map', :"512-blocks" => 'auto_home', :Used => '0', :Available => '0', :Capacity => '0', :iused => '100%', :ifree => '0', :"%iused" => '0', :Mounted_on => '100% /home ' },
44
+ 'DiskInfo_7' => { :Filesystem => '/dev/disk1s3', :"512-blocks" => '976490576', :Used => '996584', :Available => '173031648', :Capacity => '1%', :iused => '34', :ifree => '9223372036854775773', :"%iused" => '0%', :Mounted_on => '/Volumes/Recovery' } })
45
+ }
46
+ end
47
+ end