facter-statistax 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcc0b315393b6dbdb88eed44a5a229093c35247fe24923e2cc933b895190427c
4
- data.tar.gz: 59b79b77581ba3a3381db50661445111ccf8d9899067fd6c777e158e07f5fb21
3
+ metadata.gz: 0552de16514e7b424dfdacd4c2b9cb838ea7a48cd35995f91dfb0a6dfdc071ed
4
+ data.tar.gz: '00589c61b9d246492ce72be06863e4e6f323d6fc9ca21aa8e3c4e283203d6c61'
5
5
  SHA512:
6
- metadata.gz: 27995fbf64a16d83b224846f6c4066bf41c45c9b362649ed3a78fff18c2a6ab7a013a67db4e9f54ab3286d3b8a0a96fa50a09a28a9bd78f95a416a920ff36379
7
- data.tar.gz: d4348406db8f0c878ef52f3b2931d38de4a33cbee26de17e693fac1dec863fcf50c60c19450ce6f158cac418da18205264ce3b5998879496bd57838752f5b591
6
+ metadata.gz: a25819a961daf64421b92e2dba2a77589ba2f01a08a3bb6d43b8c7b5b4ab3e241706e5d650ea0d1a73fff2b1256cffd6863fc5b158924643718e9a028db2f4c4
7
+ data.tar.gz: d12bad1c4b1c4419e4a68cf7bbd4ab8e12097843ced39a8dbaedc6dd73d5541ef92cb84e9c9ad875b7c3eee7a89de694529ea55e070dad6109e1eb5316ce281f
@@ -1,9 +1,13 @@
1
1
  AllCops:
2
2
  Include:
3
3
  - 'lib/**/*.rb'
4
+ - 'acceptance/**/*.rb'
5
+ - 'bin/*.rb'
6
+ - 'config/*.rb'
7
+ - 'scripts/*.rb'
4
8
 
5
9
  Documentation:
6
10
  Enabled: false
7
11
 
8
12
  Metrics/LineLength:
9
- Max: 120
13
+ 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/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,20 @@
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. ```export IS_GEM=true\false``` - it will indicate which facter to test ruby\cpp version (if this isn't set, cpp
9
+ facter will be tested)
10
+ 5. Modify config.json from acceptance directory to meet your testing needs
11
+ 6. To test using vmpooler:\
12
+ ```beaker-hostgenerator redhat7-64a-debian9-64a > hosts.yaml```\
13
+ ```beaker init -h hosts.yaml --options-file config/aio/options.rb```\
14
+ To test using nspooler you have to require the vm from nspooler first, then:\
15
+ ```beaker-hostgenerator centos6-64a-solaris11-SPARC\{hypervisor=none\,hostname=$THE_HOST_NSPOOLER_PROVIDED\} > hosts.yaml```\
16
+ ```bundle exec beaker init --hosts hosts.yaml --options-file config/aio/options.rb```
17
+ 7. ```bundle exec beaker provision```
18
+ 8. ```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```
19
+ 9. Before this step you can set/unset ```IS_GEM env``` variable to meet your test needs\
20
+ ```bundle exec beaker exec run/run_statistax.rb```
@@ -0,0 +1,23 @@
1
+ [
2
+ {
3
+ "test_run":"TestRun1",
4
+ "runs":[
5
+ {
6
+ "fact":"os",
7
+ "repetitions":3
8
+ },
9
+ {
10
+ "fact":"processors",
11
+ "repetitions":1
12
+ },
13
+ {
14
+ "fact":"virtual",
15
+ "repetitions":3
16
+ },
17
+ {
18
+ "fact":"all",
19
+ "repetitions":3
20
+ }
21
+ ]
22
+ }
23
+ ]
@@ -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,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ test_name 'Install facter gem' do
4
+ agents.each do |agent|
5
+ facter_gem = File.join(Pathname.new(File.expand_path('..', __dir__)), 'facter-ng-0.0.10.gem')
6
+ home_dir = on(agent, 'pwd').stdout.chop
7
+
8
+ scp_to agent, facter_gem, home_dir
9
+
10
+ gem_c = gem_command(agent)
11
+ on agent, "#{gem_c} install -f facter-ng-0.0.10.gem"
12
+ if agent['platform'] =~ /windows/
13
+ puppetbin_path = '"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/puppet/bin":"/cygdrive/c/Program Files/Puppet Labs/Puppet/puppet/bin"'
14
+ on agent, %( echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc )
15
+ end
16
+ end
17
+ 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,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ test_name 'Run facter-ng gem' do
4
+ agents.each do |agent|
5
+ ruby = ruby_command(agent)
6
+ if agent['platform'] =~ /windows/
7
+ puppetbin_path = '"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/puppet/bin":"/cygdrive/c/Program Files/Puppet Labs/Puppet/puppet/bin"'
8
+ on agent, %( echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc )
9
+ end
10
+ # on agent, 'cd "C:\Program Files\Puppet Labs\Puppet\puppet\lib\ruby\gems\2.5.0\gems\facter-0.0.1"'
11
+ on(agent, 'pwd').stdout.chop
12
+ # on agent, ruby.to_s + ' "C:\Program Files\Puppet Labs\Puppet\puppet\lib\ruby\gems\2.5.0\gems\facter-0.0.1\bin\facter"'
13
+ on agent, ruby.to_s + ' /opt/puppetlabs/puppet/lib/ruby/gems/2.5.0/gems/facter-0.0.1/bin/facter'
14
+ on agent, 'facter'
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+ test_name 'Run facter statistax' do
5
+ agents.each do |agent|
6
+ is_gem = ENV['IS_GEM'] || 'false'
7
+ home_dir = on(agent, 'pwd').stdout.chop
8
+ step 'Run facter statistax' do
9
+ content = ::File.read(File.join(Pathname.new(File.expand_path('..', __dir__)), 'config.json'))
10
+ create_remote_file(agent, "#{home_dir}/config.json", content)
11
+ if agent['platform'] =~ /windows/
12
+ puppetbin_path = '"/cygdrive/c/Program Files (x86)/Puppet Labs/Puppet/puppet/bin":"/cygdrive/c/Program Files/Puppet Labs/Puppet/puppet/bin"'
13
+ on agent, %( echo 'export PATH=$PATH:#{puppetbin_path}' > /etc/bash.bashrc )
14
+ on agent, "statistax.bat config.json #{is_gem}"
15
+ else
16
+ on agent, "statistax #{home_dir}/config.json #{is_gem}"
17
+ end
18
+ end
19
+
20
+ step 'Save output' do
21
+ host_dir = File.join(Pathname.new(File.expand_path('..', __dir__)), "log_dir/#{agent['platform']}")
22
+
23
+ out_dir = if is_gem == 'true'
24
+ File.join(host_dir, 'gem')
25
+ else
26
+ File.join(host_dir, 'cpp')
27
+ end
28
+ scp_from agent, "#{home_dir}/log/output.json", out_dir
29
+ end
30
+ end
31
+ 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.6'
5
5
  end
@@ -5,21 +5,18 @@ 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/bin"
8
+ facter_dir = 'C:/Program Files/Puppet Labs/Puppet/puppet/bin'
9
9
  ENV['PATH'] = "#{facter_dir}#{File::PATH_SEPARATOR}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
10
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
+ require 'C:\Program Files\Puppet Labs\Puppet\puppet\lib\ruby\gems\2.5.0\gems\facter-ng-0.0.10\lib\facter-ng.rb'
14
16
  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
17
+ require 'facter-ng'
20
18
  end
21
19
 
22
-
23
20
  time = Benchmark.realtime do
24
21
  if ARGV[1] == 'all'
25
22
  Facter.to_hash
@@ -29,5 +26,3 @@ time = Benchmark.realtime do
29
26
  end
30
27
 
31
28
  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.5
4
+ version: 0.0.6
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/config.json
88
+ - acceptance/config/aio/options.rb
89
+ - acceptance/lib/helper.rb
90
+ - acceptance/presuite/011_install_facter_ng.rb
91
+ - acceptance/presuite/01_install_puppet_agent.rb
92
+ - acceptance/presuite/02_install_facter_statistax.rb
93
+ - acceptance/presuite/03_install_facter_gem.rb
94
+ - acceptance/run/run_facter_ng.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