facter-statistax 0.0.5 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -1
  3. data/.rubycritic.yml +1 -0
  4. data/CODEOWNERS +2 -0
  5. data/Gemfile +1 -1
  6. data/README.md +2 -0
  7. data/acceptance/.beaker.yml +15 -0
  8. data/acceptance/Gemfile +35 -0
  9. data/acceptance/README.md +17 -0
  10. data/acceptance/config.json +127 -0
  11. data/acceptance/config/aio/options.rb +5 -0
  12. data/acceptance/lib/helper.rb +5 -0
  13. data/acceptance/log_performance/configuration.rb +65 -0
  14. data/acceptance/log_performance/custom_exceptions.rb +5 -0
  15. data/acceptance/log_performance/execute_beaker_tests/beaker.rb +77 -0
  16. data/acceptance/log_performance/execute_beaker_tests/command_logger.rb +24 -0
  17. data/acceptance/log_performance/execute_beaker_tests/ns_pooler.rb +60 -0
  18. data/acceptance/log_performance/execute_beaker_tests/output_parser.rb +40 -0
  19. data/acceptance/log_performance/execute_beaker_tests/run_command.rb +30 -0
  20. data/acceptance/log_performance/execute_beaker_tests/test_all_platforms.rb +99 -0
  21. data/acceptance/log_performance/execute_beaker_tests/vm_pooler.rb +7 -0
  22. data/acceptance/log_performance/get_supported_platforms.rb +1904 -0
  23. data/acceptance/log_performance/performance_times_logging/facter_performance_logs_parser.rb +65 -0
  24. data/acceptance/log_performance/performance_times_logging/google_sheets.rb +133 -0
  25. data/acceptance/log_performance/performance_times_logging/log_performance_times.rb +20 -0
  26. data/acceptance/log_performance/performance_times_logging/table_logging_utils.rb +55 -0
  27. data/acceptance/log_performance/performance_times_logging/write_facter_times_to_logger.rb +109 -0
  28. data/acceptance/log_performance/rspec/file_folder_utils_rspec.rb +12 -0
  29. data/acceptance/log_performance/utils.rb +41 -0
  30. data/acceptance/presuite/011_install_facter_ng.rb +20 -0
  31. data/acceptance/presuite/01_install_puppet_agent.rb +23 -0
  32. data/acceptance/presuite/02_install_facter_statistax.rb +8 -0
  33. data/acceptance/presuite/03_install_facter_gem.rb +12 -0
  34. data/acceptance/run/run_statistax.rb +65 -0
  35. data/acceptance/run/uninstall_facter_gem.rb +8 -0
  36. data/acceptance/run/uninstall_puppet_agent.rb +7 -0
  37. data/config/boot.rb +3 -3
  38. data/lib/common/output_writer.rb +1 -1
  39. data/lib/executors/test_run_executor.rb +1 -1
  40. data/lib/version.rb +1 -1
  41. data/scripts/benchmark_script.rb +12 -10
  42. metadata +36 -5
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ test_name 'Install Puppet Agent Packages' do
4
+ opts = {
5
+ nightly_builds_url: ENV['NIGHTLY_BUILDS_URL'],
6
+ dev_builds_url: ENV['DEV_BUILDS_URL'],
7
+ puppet_agent_version: ENV['SHA'],
8
+ puppet_collection: ENV['RELEASE_STREAM']
9
+ }
10
+
11
+ install_puppet_agent_on(hosts, opts)
12
+
13
+ agents.each do |agent|
14
+ on agent, puppet('--version')
15
+ ruby = ruby_command(agent)
16
+ on agent, "#{ruby} --version"
17
+
18
+ log_dir = File.join(Pathname.new(File.expand_path('..', __dir__)), 'log_dir')
19
+ FileUtils.mkdir_p(log_dir)
20
+ host_dir = File.join(log_dir, agent['platform'])
21
+ FileUtils.mkdir_p(host_dir)
22
+ end
23
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ test_name 'Install facter statistax' do
4
+ agents.each do |agent|
5
+ gem_c = gem_command(agent)
6
+ on agent, "#{gem_c} install -f facter-statistax"
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ test_name 'Install facter gem' do
4
+ agents.each do |agent|
5
+ gem_c = gem_command(agent)
6
+ if ENV['GEM_VERSION']
7
+ on agent, "#{gem_c} install -f facter-ng -v #{ENV['GEM_VERSION']}"
8
+ else
9
+ on agent, "#{gem_c} install -f facter-ng"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+ require_relative '../log_performance/performance_times_logging/log_performance_times'
5
+
6
+ def correct_platform_name(agent)
7
+ if agent['platform'].include?('aix')
8
+ agent.to_s.split('-')[0].sub(/aix(\d)(\d)/, 'aix-\1.\2') + '-power'
9
+ elsif agent.has_key?('template') && agent['template'].include?('fips')
10
+ agent['template']
11
+ else
12
+ agent['platform']
13
+ end
14
+ end
15
+
16
+ def run_statistax(agent, home_dir, is_gem)
17
+ content = ::File.read(File.join(Pathname.new(File.expand_path('..', __dir__)), 'config.json'))
18
+ create_remote_file(agent, "#{home_dir}/config.json", content)
19
+ if agent['platform'] =~ /windows/
20
+ puppetbin_path = '"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/puppet/bin":"/cygdrive/c/Program Files/Puppet Labs/Puppet/puppet/bin"'
21
+ on agent, %( echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc )
22
+ on agent, "statistax.bat config.json #{is_gem}"
23
+ else
24
+ on agent, "statistax #{home_dir}/config.json #{is_gem}"
25
+ end
26
+ end
27
+
28
+ def save_output(agent, home_dir, host_dir, is_gem)
29
+ out_dir = File.join(host_dir, is_gem ? 'gem' : 'cpp')
30
+
31
+ FileUtils.mkdir_p(out_dir)
32
+ scp_from agent, "#{home_dir}/log/output.json", out_dir
33
+ end
34
+
35
+ test_name 'Run facter statistax' do
36
+ log_dir = File.join(File.expand_path('..', __dir__), "log_dir")
37
+
38
+ agents.each do |agent|
39
+ is_gem = false
40
+ home_dir = on(agent, 'pwd').stdout.chop
41
+ platform_name = correct_platform_name(agent)
42
+ host_dir = File.join(log_dir, "#{platform_name}")
43
+
44
+ step 'Run facter statistax for Cfacter' do
45
+ run_statistax(agent, home_dir, is_gem)
46
+ end
47
+
48
+ step 'Save output' do
49
+ save_output(agent, home_dir, host_dir, is_gem)
50
+ end
51
+
52
+ step 'Run facter statistax for facter-ng' do
53
+ is_gem = 'true'
54
+ run_statistax(agent, home_dir, is_gem)
55
+ end
56
+
57
+ step 'Save output to files' do
58
+ save_output(agent, home_dir, host_dir, is_gem)
59
+ end
60
+
61
+ step 'Copy results to Google spreadsheet' do
62
+ LogPerformanceTimes.new(log_dir).populate_logs_for(platform_name)
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ test_name 'Uninstall facter gem' do
4
+ agents.each do |agent|
5
+ gem_c = gem_command(agent)
6
+ on agent, "#{gem_c} uninstall facter-ng"
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ test_name 'Uninstall puppet' do
4
+ agents.each do |agent|
5
+ remove_puppet_on(agent)
6
+ end
7
+ end
@@ -10,7 +10,7 @@ require_relative '../lib/logger'
10
10
  ROOT_DIR = Pathname.new(File.expand_path('..', __dir__)) unless defined?(ROOT_DIR)
11
11
  LOG_DIR = File.join(Dir.getwd, 'log')
12
12
  SCRIPTS_DIR = ROOT_DIR.join('scripts')
13
- CONFIG_FILE = ARGV[0] || ""
13
+ CONFIG_FILE = ARGV[0] || ''
14
14
  IS_GEM = ARGV[1] || 'false'
15
15
 
16
16
  def load_files(*dirs)
@@ -18,6 +18,6 @@ def load_files(*dirs)
18
18
  end
19
19
 
20
20
  load_files(
21
- 'lib/common/*.rb',
22
- 'lib/executors/*.rb'
21
+ 'lib/common/*.rb',
22
+ 'lib/executors/*.rb'
23
23
  )
@@ -18,7 +18,7 @@ module FacterStatistax
18
18
  test_run = @test_run.merge(facts: facts)
19
19
  output << test_run
20
20
  ::File.open(File.join(LOG_DIR, 'output.json'), 'w') do |file|
21
- file.write(output.to_json)
21
+ file.write(JSON.pretty_generate(output))
22
22
  end
23
23
  end
24
24
 
@@ -32,7 +32,7 @@ module FacterStatistax
32
32
 
33
33
  def log_time(fact, time)
34
34
  FacterStatistax.logger.info("For #{fact} facts it took:")
35
- FacterStatistax.logger.info("#{format('%.2f', time)}s")
35
+ FacterStatistax.logger.info("#{format('%<time>.2f', time: time)}s")
36
36
  end
37
37
  end
38
38
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FacterStatistax
4
- VERSION = '0.0.5'
4
+ VERSION = '0.0.10'
5
5
  end
@@ -3,23 +3,27 @@
3
3
  require 'benchmark'
4
4
  require 'open3'
5
5
 
6
+ def facter_path(gems_path)
7
+ ruby_version = Dir.entries(gems_path).select { |file| file =~ /[0-9]+.[0-9]+.[0-9]+/ }
8
+ facter_ng_path = File.join(gems_path, ruby_version, 'gems')
9
+ facter_ng_version = Dir.entries(facter_ng_path).select { |file| file =~ /facter-4/ }
10
+ return File.join(facter_ng_path, facter_ng_version, 'lib', 'facter.rb')
11
+ end
12
+
6
13
  if ARGV[0].to_s == 'false'
7
14
  if Gem.win_platform?
8
- facter_dir = "C:/Program Files/Puppet Labs/Puppet/puppet/bin"
15
+ facter_dir = 'C:/Program Files/Puppet Labs/Puppet/puppet/bin'
9
16
  ENV['PATH'] = "#{facter_dir}#{File::PATH_SEPARATOR}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
10
17
  require "#{facter_dir}/libfacter.so"
11
18
  else
12
- require "/opt/puppetlabs/puppet/lib/libfacter.so"
19
+ require '/opt/puppetlabs/puppet/lib/libfacter.so'
13
20
  end
21
+ elsif Gem.win_platform?
22
+ require facter_path('C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/gems')
14
23
  else
15
- if Gem.win_platform?
16
- require 'C:\Program Files\Puppet Labs\Puppet\puppet\lib\ruby\gems\2.5.0\gems\facter-2.5.5-x64-mingw32\lib\facter.rb'
17
- else
18
- require 'facter'
19
- end
24
+ require facter_path('/opt/puppetlabs/puppet/lib/ruby/gems')
20
25
  end
21
26
 
22
-
23
27
  time = Benchmark.realtime do
24
28
  if ARGV[1] == 'all'
25
29
  Facter.to_hash
@@ -29,5 +33,3 @@ time = Benchmark.realtime do
29
33
  end
30
34
 
31
35
  puts time
32
-
33
-
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter-statistax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2019-08-08 00:00:00.000000000 Z
@@ -77,9 +77,40 @@ files:
77
77
  - ".rubocop.yml"
78
78
  - ".rubycritic.yml"
79
79
  - ".travis.yml"
80
+ - CODEOWNERS
80
81
  - Gemfile
81
82
  - LICENSE
82
83
  - README.md
84
+ - acceptance/.beaker.yml
85
+ - acceptance/Gemfile
86
+ - acceptance/README.md
87
+ - acceptance/config.json
88
+ - acceptance/config/aio/options.rb
89
+ - acceptance/lib/helper.rb
90
+ - acceptance/log_performance/configuration.rb
91
+ - acceptance/log_performance/custom_exceptions.rb
92
+ - acceptance/log_performance/execute_beaker_tests/beaker.rb
93
+ - acceptance/log_performance/execute_beaker_tests/command_logger.rb
94
+ - acceptance/log_performance/execute_beaker_tests/ns_pooler.rb
95
+ - acceptance/log_performance/execute_beaker_tests/output_parser.rb
96
+ - acceptance/log_performance/execute_beaker_tests/run_command.rb
97
+ - acceptance/log_performance/execute_beaker_tests/test_all_platforms.rb
98
+ - acceptance/log_performance/execute_beaker_tests/vm_pooler.rb
99
+ - acceptance/log_performance/get_supported_platforms.rb
100
+ - acceptance/log_performance/performance_times_logging/facter_performance_logs_parser.rb
101
+ - acceptance/log_performance/performance_times_logging/google_sheets.rb
102
+ - acceptance/log_performance/performance_times_logging/log_performance_times.rb
103
+ - acceptance/log_performance/performance_times_logging/table_logging_utils.rb
104
+ - acceptance/log_performance/performance_times_logging/write_facter_times_to_logger.rb
105
+ - acceptance/log_performance/rspec/file_folder_utils_rspec.rb
106
+ - acceptance/log_performance/utils.rb
107
+ - acceptance/presuite/011_install_facter_ng.rb
108
+ - acceptance/presuite/01_install_puppet_agent.rb
109
+ - acceptance/presuite/02_install_facter_statistax.rb
110
+ - acceptance/presuite/03_install_facter_gem.rb
111
+ - acceptance/run/run_statistax.rb
112
+ - acceptance/run/uninstall_facter_gem.rb
113
+ - acceptance/run/uninstall_puppet_agent.rb
83
114
  - bin/statistax
84
115
  - config/boot.rb
85
116
  - facter-statistax.gemspec
@@ -93,7 +124,7 @@ files:
93
124
  homepage: ''
94
125
  licenses: []
95
126
  metadata: {}
96
- post_install_message:
127
+ post_install_message:
97
128
  rdoc_options:
98
129
  - "--title"
99
130
  - 'Facter-Statistax '
@@ -113,8 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
144
  - !ruby/object:Gem::Version
114
145
  version: '0'
115
146
  requirements: []
116
- rubygems_version: 3.0.1
117
- signing_key:
147
+ rubygems_version: 3.0.6
148
+ signing_key:
118
149
  specification_version: 4
119
150
  summary: Facter-Statistax, benchmark for facter
120
151
  test_files: []