facter-statistax 0.0.4 → 0.0.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a067d8b6115b01681c8fc7ed3bdb1da5a40c6eae415f515c3ac42459726db6c3
4
- data.tar.gz: e9614b6e442b2caf5b67d2f63f890d384391715bb3c9172f3d6ab32002cc986d
3
+ metadata.gz: 5b94d29cf1132a42f4ae3c91d445eeba5860b65b270a6b4aec8fb3b9829f4ba0
4
+ data.tar.gz: ec72d80f143a70e187585b746f34b2e1838b03a9f0cd70ce513f186fbf764997
5
5
  SHA512:
6
- metadata.gz: 2049c59104f91ea2cb54f33d7e7127fcbfaf5721eab7983fbcb6de1763b145b3e0e2707ee9c62f135edb3eea7024fec883af26d5ea795baeda913c4a56e3e968
7
- data.tar.gz: 8b9193dd375a5a14c9cf630415ee7aad4bdafec06ba65ffddf98590bce015714d9bd3e4ae0f9addb261f0cc7a6dbc7da42ebe2f83c24b3a609179f4c21d9ba98
6
+ metadata.gz: 6b34c28e5b4735a7bcfcb38a83497a851a02d0df1747579a1c00c4a1788b427a90e8ec4a97a00e88e0a62796c37170fcd23a16e03e4d46bcc41d5b5473870a7e
7
+ data.tar.gz: 8a2a73a57347090ccd60a9838a0853ac38811364c26117007276e270cb14ad510592c862f4096d29c60644fceb9743216d70228abb23253bf4cb2175f534c473
@@ -1,9 +1,12 @@
1
1
  AllCops:
2
2
  Include:
3
3
  - 'lib/**/*.rb'
4
+ - 'bin/*.rb'
5
+ - 'config/*.rb'
6
+ - 'scripts/*.rb'
4
7
 
5
8
  Documentation:
6
9
  Enabled: false
7
10
 
8
11
  Metrics/LineLength:
9
- Max: 120
12
+ Max: 150
@@ -2,3 +2,4 @@ paths: # Files to analyse.
2
2
  - 'lib'
3
3
  - 'bin'
4
4
  - 'config'
5
+ - 'scripts'
@@ -0,0 +1,2 @@
1
+ # Default to Ghost team
2
+ * @puppetlabs/ghost @puppetlabs/night-s-watch
data/Gemfile CHANGED
@@ -7,5 +7,5 @@ gem 'fileutils'
7
7
  gem 'rubysl-open3'
8
8
  gem 'json'
9
9
  gem 'pry'
10
- gem 'rubocop'
10
+ gem 'rubocop', '~> 0.73.0'
11
11
  gem 'rubycritic'
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # facter-statistax
2
+ [![Build Status](https://travis-ci.com/puppetlabs/facter-statistax.svg?branch=master)](https://travis-ci.com/puppetlabs/facter-statistax)
3
+
2
4
  Benchmark tool for different versions of Puppet Facter.
3
5
 
4
6
  In order to run this script you must create a 'config.json' file with the following format:
@@ -0,0 +1,15 @@
1
+ ---
2
+ ssh:
3
+ keys:
4
+ - id_rsa_acceptance
5
+ - ~/.ssh/id_rsa-acceptance
6
+ xml: true
7
+ timesync: false
8
+ repo_proxy: true
9
+ add_el_extras: false
10
+ forge_host: api-forge-aio02-petest.puppet.com
11
+ 'master-start-curl-retries': 30
12
+ log_level: debug
13
+ preserve_hosts: onfail
14
+ helper: ./lib/helper.rb
15
+ options_file: ./config/aio/options.rb
@@ -0,0 +1,34 @@
1
+ # Specifies a gem mirror; duplicated in acceptance setup
2
+ # to ensure a similar environment on acceptance hosts.
3
+ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
4
+
5
+ def location_for(place, fake_version = nil)
6
+ if place =~ /^(git:[^#]*)#(.*)/
7
+ [fake_version, { :git => $1, :branch => $2, :require => false }].compact
8
+ elsif place =~ /^file:\/\/(.*)/
9
+ ['>= 0', { :path => File.expand_path($1), :require => false }]
10
+ else
11
+ [place, { :require => false }]
12
+ end
13
+ end
14
+
15
+ gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.0')
16
+ gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || ["~>1.0", ">= 1.18.4"])
17
+ gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 1.1")
18
+ gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || "~> 0.4")
19
+ gem "beaker-vagrant", *location_for(ENV['BEAKER_VAGRANT_VERSION'] || "~> 0")
20
+ gem "beaker-vmpooler", *location_for(ENV['BEAKER_VMPOOLER_VERSION'] || "~> 1.3")
21
+ gem "beaker-vcloud", *location_for(ENV['BEAKER_VCLOUD_VERSION'] || "~> 1.0")
22
+ gem "beaker-docker", *location_for(ENV['BEAKER_DOCKER_VERSION'] || "~> 0.5")
23
+ gem "rake", "~> 10.1"
24
+ gem "httparty", :require => false
25
+ gem 'uuidtools', :require => false
26
+
27
+ group(:test) do
28
+ gem "rspec", "~> 2.14.0", :require => false
29
+ gem "mocha", "~> 0.10.5", :require => false
30
+ end
31
+
32
+ if File.exists? "#{__FILE__}.local"
33
+ eval(File.read("#{__FILE__}.local"), binding)
34
+ end
@@ -0,0 +1,17 @@
1
+ # Steps for collecting facter statistics
2
+
3
+ 1. ```bundle install```
4
+ 2. ```export SHA=6.0.9``` - puppet agent SHA/VERSION to be installed and tested (please note that this projects
5
+ is working with puppet agent >= 6.0.x)
6
+ 3. ```export GEM_VERSION=2.5.5``` - gem facter version you want to test (if this env variable isn't set, the latest
7
+ version will be downloaded)
8
+ 4. Modify config.json from acceptance directory to meet your testing needs
9
+ 5. To test using vmpooler:\
10
+ ```beaker-hostgenerator redhat7-64a-debian9-64a > hosts.yaml```\
11
+ ```beaker init -h hosts.yaml --options-file config/aio/options.rb```\
12
+ To test using nspooler you have to require the vm from nspooler first, then:\
13
+ ```beaker-hostgenerator centos6-64a-solaris11-SPARC\{hypervisor=none\,hostname=$THE_HOST_NSPOOLER_PROVIDED\} > hosts.yaml```\
14
+ ```bundle exec beaker init --hosts hosts.yaml --options-file config/aio/options.rb```
15
+ 6. ```bundle exec beaker provision```
16
+ 7. ```bundle exec beaker exec pre-suite --pre-suite presuite/01_install_puppet_agent.rb,presuite/02_install_facter_statistax.rb,presuite/03_install_facter_gem.rb --preserve-state```
17
+ 8. ```bundle exec beaker exec run/run_statistax.rb```
@@ -0,0 +1 @@
1
+ gem build ../../facter-ng/facter-ng.gemspec
@@ -0,0 +1,127 @@
1
+ [
2
+ {
3
+ "test_run":"TestRun1",
4
+ "runs":[
5
+ {
6
+ "fact": "aio_agent_version",
7
+ "repetitions": 10
8
+ },
9
+ {
10
+ "fact": "augeas",
11
+ "repetitions": 10
12
+ },
13
+ {
14
+ "fact": "disks",
15
+ "repetitions": 10
16
+ },
17
+ {
18
+ "fact":"dmi",
19
+ "repetitions":10
20
+ },
21
+ {
22
+ "fact": "facterversion",
23
+ "repetitions": 10
24
+ },
25
+ {
26
+ "fact":"filesystems",
27
+ "repetitions":10
28
+ },
29
+ {
30
+ "fact": "hypervisors",
31
+ "repetitions": 10
32
+ },
33
+ {
34
+ "fact":"identity",
35
+ "repetitions":10
36
+ },
37
+ {
38
+ "fact":"is_virtual",
39
+ "repetitions":10
40
+ },
41
+ {
42
+ "fact":"kernel",
43
+ "repetitions":10
44
+ },
45
+ {
46
+ "fact":"kernelmajversion",
47
+ "repetitions":10
48
+ },
49
+ {
50
+ "fact":"kernelrelease",
51
+ "repetitions":10
52
+ },
53
+ {
54
+ "fact":"kernelversion",
55
+ "repetitions":10
56
+ },
57
+ {
58
+ "fact":"load_averages",
59
+ "repetitions":10
60
+ },
61
+ {
62
+ "fact":"memory",
63
+ "repetitions":10
64
+ },
65
+ {
66
+ "fact":"networking",
67
+ "repetitions":10
68
+ },
69
+ {
70
+ "fact":"os",
71
+ "repetitions":10
72
+ },
73
+ {
74
+ "fact":"path",
75
+ "repetitions":10
76
+ },
77
+ {
78
+ "fact":"processors",
79
+ "repetitions":10
80
+ },
81
+ {
82
+ "fact":"ruby",
83
+ "repetitions":10
84
+ },
85
+ {
86
+ "fact":"solaris_zones",
87
+ "repetitions":10
88
+ },
89
+ {
90
+ "fact":"ssh",
91
+ "repetitions":10
92
+ },
93
+ {
94
+ "fact":"system_uptime",
95
+ "repetitions":10
96
+ },
97
+ {
98
+ "fact":"timezone",
99
+ "repetitions":10
100
+ },
101
+ {
102
+ "fact":"virtual",
103
+ "repetitions":10
104
+ },
105
+ {
106
+ "fact":"zfs_featurenumbers",
107
+ "repetitions":10
108
+ },
109
+ {
110
+ "fact":"zfs_version",
111
+ "repetitions":10
112
+ },
113
+ {
114
+ "fact":"zpool_featurenumbers",
115
+ "repetitions":10
116
+ },
117
+ {
118
+ "fact":"zpool_version",
119
+ "repetitions":10
120
+ },
121
+ {
122
+ "fact": "all",
123
+ "repetitions": 10
124
+ }
125
+ ]
126
+ }
127
+ ]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ {
4
+ type: 'aio'
5
+ }
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH << __dir__
4
+
5
+ require 'beaker-puppet'
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ test_name 'Install facter gem' do
4
+ agents.each do |agent|
5
+ current_dir = Pathname.new(File.expand_path('..', __dir__))
6
+ facter_ng_path = Dir.entries(current_dir).select { |file| file =~ /facter-ng-[0-9]+.[0-9]+.[0-9]+.gem/ }
7
+ facter_gem = File.join(current_dir, facter_ng_path)
8
+ home_dir = on(agent, 'pwd').stdout.chop
9
+
10
+ scp_to agent, facter_gem, home_dir
11
+
12
+ gem_c = gem_command(agent)
13
+ on agent, "#{gem_c} uninstall facter-ng"
14
+ on agent, "#{gem_c} install -f facter-ng-*.gem"
15
+ if agent['platform'] =~ /windows/
16
+ puppetbin_path = '"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/puppet/bin":"/cygdrive/c/Program Files/Puppet Labs/Puppet/puppet/bin"'
17
+ on agent, %( echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc )
18
+ end
19
+ end
20
+ end
@@ -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,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+ test_name 'Run facter statistax' do
5
+ agents.each do |agent|
6
+ is_gem = 'false'
7
+ home_dir = on(agent, 'pwd').stdout.chop
8
+ host_dir = File.join(Pathname.new(File.expand_path('..', __dir__)), "log_dir/#{agent['platform']}")
9
+
10
+ step 'Run facter statistax for Cfacter' do
11
+ content = ::File.read(File.join(Pathname.new(File.expand_path('..', __dir__)), 'config.json'))
12
+ create_remote_file(agent, "#{home_dir}/config.json", content)
13
+ if agent['platform'] =~ /windows/
14
+ puppetbin_path = '"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/puppet/bin":"/cygdrive/c/Program Files/Puppet Labs/Puppet/puppet/bin"'
15
+ on agent, %( echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc )
16
+ on agent, "statistax.bat config.json #{is_gem}"
17
+ else
18
+ on agent, "statistax #{home_dir}/config.json #{is_gem}"
19
+ end
20
+ end
21
+
22
+ step 'Save output' do
23
+ out_dir = File.join(host_dir, 'cpp')
24
+
25
+ FileUtils.mkdir_p(out_dir)
26
+ scp_from agent, "#{home_dir}/log/output.json", out_dir
27
+ end
28
+
29
+ step 'Run facter statistax for facter-ng' do
30
+ is_gem = 'true'
31
+ content = ::File.read(File.join(Pathname.new(File.expand_path('..', __dir__)), 'config.json'))
32
+ create_remote_file(agent, "#{home_dir}/config.json", content)
33
+ if agent['platform'] =~ /windows/
34
+ puppetbin_path = '"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/puppet/bin":"/cygdrive/c/Program Files/Puppet Labs/Puppet/puppet/bin"'
35
+ on agent, %( echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc )
36
+ on agent, "statistax.bat config.json #{is_gem}"
37
+ else
38
+ on agent, "statistax #{home_dir}/config.json #{is_gem}"
39
+ end
40
+ end
41
+
42
+ step 'Save output' do
43
+ out_dir = File.join(host_dir, 'cpp')
44
+
45
+ FileUtils.mkdir_p(out_dir)
46
+ scp_from agent, "#{home_dir}/log/output.json", out_dir
47
+ end
48
+ end
49
+ 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
 
@@ -12,7 +12,7 @@ module FacterStatistax
12
12
 
13
13
  def execute
14
14
  sum = sum_for_each_repetition do
15
- time, _status = Open3.capture2("ruby #{SCRIPTS_DIR}/benchmark_script.rb #{IS_GEM} #{fact}")
15
+ time, _status = Open3.capture2("ruby \"#{SCRIPTS_DIR}/benchmark_script.rb\" #{IS_GEM} #{fact}")
16
16
  log_time(fact, time)
17
17
  time.to_f
18
18
  end
@@ -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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module FacterStatistax
2
- VERSION = '0.0.4'
4
+ VERSION = '0.0.9'
3
5
  end
@@ -5,21 +5,23 @@ require 'open3'
5
5
 
6
6
  if ARGV[0].to_s == 'false'
7
7
  if Gem.win_platform?
8
- facter_dir = "C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/vendor_ruby/../../../"
9
- ENV['PATH'] = "#{File.join(facter_dir, 'bin')}#{File::PATH_SEPARATOR}#{File.join(facter_dir, '../puppet/bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
10
- require "#{facter_dir}/bin/libfacter.so"
8
+ facter_dir = 'C:/Program Files/Puppet Labs/Puppet/puppet/bin'
9
+ ENV['PATH'] = "#{facter_dir}#{File::PATH_SEPARATOR}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
10
+ require "#{facter_dir}/libfacter.so"
11
11
  else
12
- require "/opt/puppetlabs/puppet/lib/libfacter.so"
12
+ require '/opt/puppetlabs/puppet/lib/libfacter.so'
13
13
  end
14
+ elsif Gem.win_platform?
15
+ gems_path = 'C:/Program Files/Puppet Labs/Puppet/puppet/lib/ruby/gems'
16
+ ruby_version = Dir.entries(gems_path).select { |file| file =~ /[0-9]+.[0-9]+.[0-9]+/ }
17
+ facter_ng_path = File.join(gems_path, ruby_version, 'gems')
18
+ facter_ng_version = Dir.entries(facter_ng_path).select { |file| file =~ /facter-4/ }
19
+ facter_ng_path = File.join(facter_ng_path, facter_ng_version, 'lib', 'facter.rb')
20
+ require facter_ng_path
14
21
  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
22
+ require 'facter'
20
23
  end
21
24
 
22
-
23
25
  time = Benchmark.realtime do
24
26
  if ARGV[1] == 'all'
25
27
  Facter.to_hash
@@ -29,5 +31,3 @@ time = Benchmark.realtime do
29
31
  end
30
32
 
31
33
  puts time
32
-
33
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter-statistax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -77,9 +77,24 @@ 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/build_facter_ng_gem.sh
88
+ - acceptance/config.json
89
+ - acceptance/config/aio/options.rb
90
+ - acceptance/lib/helper.rb
91
+ - acceptance/presuite/011_install_facter_ng.rb
92
+ - acceptance/presuite/01_install_puppet_agent.rb
93
+ - acceptance/presuite/02_install_facter_statistax.rb
94
+ - acceptance/presuite/03_install_facter_gem.rb
95
+ - acceptance/run/run_statistax.rb
96
+ - acceptance/run/uninstall_facter_gem.rb
97
+ - acceptance/run/uninstall_puppet_agent.rb
83
98
  - bin/statistax
84
99
  - config/boot.rb
85
100
  - facter-statistax.gemspec
@@ -113,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
128
  - !ruby/object:Gem::Version
114
129
  version: '0'
115
130
  requirements: []
116
- rubygems_version: 3.0.1
131
+ rubygems_version: 3.0.6
117
132
  signing_key:
118
133
  specification_version: 4
119
134
  summary: Facter-Statistax, benchmark for facter