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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcc0b315393b6dbdb88eed44a5a229093c35247fe24923e2cc933b895190427c
4
- data.tar.gz: 59b79b77581ba3a3381db50661445111ccf8d9899067fd6c777e158e07f5fb21
3
+ metadata.gz: 1ebdaaa85edad0d762e03120c79a30ece47041dcf61287bbd82c2b9ae9635bcb
4
+ data.tar.gz: 8d0b91944694256ad8455e93edcf8b09c464ae0dea51a093611dc8e6021b4fcc
5
5
  SHA512:
6
- metadata.gz: 27995fbf64a16d83b224846f6c4066bf41c45c9b362649ed3a78fff18c2a6ab7a013a67db4e9f54ab3286d3b8a0a96fa50a09a28a9bd78f95a416a920ff36379
7
- data.tar.gz: d4348406db8f0c878ef52f3b2931d38de4a33cbee26de17e693fac1dec863fcf50c60c19450ce6f158cac418da18205264ce3b5998879496bd57838752f5b591
6
+ metadata.gz: 3dbfe4ce4094370d43301e30b1fbb504dc463fd61f87b09706ce40a85f564e20996a97f3eb953347647c308ea1efaa8bbb241ee47dba7f74bb25be6fffab0304
7
+ data.tar.gz: 3c3b4615a699b39f114ba4e4d29388a0f8511c084ea6878c492dc2c15801433c495e9ae8b8329e7d8dd1754751db4d9340da49f24ee6466d4fd4fec0201c7333
@@ -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,35 @@
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"])
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
+ gem "google-api-client", "~>0.36.4"
27
+
28
+ group(:test) do
29
+ gem "rspec", "~> 2.14.0", :require => false
30
+ gem "mocha", "~> 0.10.5", :require => false
31
+ end
32
+
33
+ if File.exists? "#{__FILE__}.local"
34
+ eval(File.read("#{__FILE__}.local"), binding)
35
+ 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,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,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Configuration
4
+ BEAKER_ENV_VARS = {
5
+ 'GOOGLE_APPLICATION_CREDENTIALS' => '/Users/andrei.filipovici/projects/google-sheets/Facter Performance History-99315759f0c6.json',
6
+ 'IS_GEM' => 'true'
7
+ }
8
+ SPREADSHEET_ID = '1giARlXsBSGhxIWRlThV8QfmybeAfaBrNRzdr9C0pvPw'
9
+ USER_HOME_PATH = '/Users/andrei.filipovici/'
10
+ FACTER_NG_PROJECT_PATH = '/Users/andrei.filipovici/projects/facter-ng-for-statistax'
11
+ STATISTAX_PROJECT_PATH = '/Users/andrei.filipovici/projects/facter-statistax/acceptance/'
12
+ LOGS_FOLDER_PATH = '/Users/andrei.filipovici/projects/facter-statistax/acceptance/cron_logs'
13
+ RUN_FAILS_LOG_NAME = '_run_failures'
14
+ SCRIPT_ERRORS_LOG_NAME = '_script_failures'
15
+ PRE_TESTS_LOG_NAME = '_all'
16
+ VMPOOLERP_PLATFORMS = [
17
+ # 'centos6-32',
18
+ # 'centos6-64',
19
+ # 'debian8-32',
20
+ # 'debian8-64',
21
+ # 'debian9-32',
22
+ # 'debian9-64',
23
+ # 'debian10-64',
24
+ # 'fedora28-64',
25
+ # 'fedora29-64',
26
+ # 'fedora30-64',
27
+ # 'fedora31-64',
28
+ # 'osx1012-64',
29
+ # 'osx1013-64',
30
+ # 'osx1014-64',
31
+ # 'osx1015-64',
32
+ # 'redhat5-64',
33
+ # 'redhat7-64',
34
+ # 'redhatfips7-64',
35
+ # 'redhat8-64',
36
+ # 'sles11-32',
37
+ # 'sles11-64',
38
+ # 'sles12-64',
39
+ # 'sles15-64',
40
+ # 'solaris10-64',
41
+ # 'solaris11-64',
42
+ # 'solaris114-64',
43
+ # 'ubuntu1404-32',
44
+ 'ubuntu1404-64',
45
+ # 'ubuntu1604-32',
46
+ # 'ubuntu1604-64',
47
+ # 'ubuntu1804-64',
48
+ # 'windows2008r2-64',
49
+ # 'windows2012r2-64',
50
+ # 'windowsfips2012r2-64',
51
+ # 'windows2016-64',
52
+ # 'windows2019-64',
53
+ # 'windows10ent-32',
54
+ # 'windows10ent-64',
55
+ ]
56
+ NSPOOLER_PLATFORMS = {
57
+ # "aix61-POWER" => "aix-6.1-power",
58
+ # "aix71-POWER" => "aix-7.1-power",
59
+ # "aix72-POWER" => "aix-7.2-power",
60
+ # "redhat7-POWER" => "redhat-7.3-power8",
61
+ # "redhat7-AARCH64" => "centos-7-arm64",
62
+ # "ubuntu1604-POWER" => "ubuntu-16.04-power8",
63
+ # "sles12-POWER" => "sles-12-power8",
64
+ }
65
+ end
@@ -0,0 +1,5 @@
1
+ class FailedCommand < StandardError
2
+ def message
3
+ "Command failed!"
4
+ end
5
+ end
@@ -0,0 +1,77 @@
1
+ require_relative '../custom_exceptions'
2
+ class Beaker
3
+
4
+ def initialize(platforms, user_home_path, beaker_env_vars, logger)
5
+ @platforms = platforms
6
+ @user_home_path = user_home_path
7
+ @beaker_env_vars = beaker_env_vars
8
+ @logger = logger
9
+ end
10
+
11
+ def run_test_on_all_platforms
12
+ @platforms.each do |platform|
13
+ begin
14
+ @current_platform = platform
15
+ test_sequence
16
+ rescue FailedCommand
17
+ destroy_environment
18
+ next
19
+ end
20
+ end
21
+ end
22
+
23
+ def test_sequence
24
+ time = TimedMethods.get_run_time{
25
+ clean_beaker_home
26
+ create_vm_hosts_file
27
+ config_hosts_options
28
+ provision
29
+ install_agent_facter_statistax
30
+ run_statistax_tests
31
+ destroy_environment
32
+ }
33
+ @logger.log("Runtime was #{time} minutes.", @current_platform)
34
+ end
35
+
36
+ def clean_beaker_home
37
+ # if an error happened and beaker destroy doesn't get called, the .beaker folder remains
38
+ # and it need to be deleted. Otherwise you get an error saying the beaker parameters can't be parsed
39
+ log_run_command("cd #{@user_home_path} && rm -rf .beaker")
40
+ end
41
+
42
+ def create_vm_hosts_file
43
+ log_run_command("beaker-hostgenerator #{@current_platform} > hosts.yaml")
44
+ end
45
+
46
+ def config_hosts_options
47
+ log_run_command('beaker init -h hosts.yaml --options-file config/aio/options.rb', 2)
48
+ end
49
+
50
+ def provision
51
+ log_run_command('bundle exec beaker provision', 10)
52
+ end
53
+
54
+ def install_agent_facter_statistax
55
+ log_run_command('bundle exec beaker exec pre-suite --pre-suite presuite/01_install_puppet_agent.rb,presuite/011_install_facter_ng.rb,presuite/02_install_facter_statistax.rb', 10)
56
+ end
57
+
58
+ def run_statistax_tests
59
+ log_run_command('bundle exec beaker exec run/run_statistax.rb', 10)
60
+ end
61
+
62
+ def destroy_environment
63
+ log_run_command('beaker destroy')
64
+ end
65
+
66
+ def log_run_command(command, timeout_minutes = 1)
67
+ output = RunCommand.run_command(timeout_minutes, @beaker_env_vars, command)
68
+ has_errors, errors = OutputParser.errors?(output)
69
+ @logger.log("Running command: #{command}\n#{output}", @current_platform)
70
+
71
+ return output unless has_errors
72
+
73
+ @logger.log_error("On platform #{@current_platform},
74
+ running command:\n #{command}\ngot error:\n#{errors.join("\n")}")
75
+ raise FailedCommand
76
+ end
77
+ end
@@ -0,0 +1,24 @@
1
+ class CommandLogger
2
+ def initialize(log_folder, error_log_file, log_file = 'log.log')
3
+ @log_folder = log_folder
4
+ @log_file = log_file
5
+ @errors_file = error_log_file
6
+ end
7
+
8
+ def log(data, log_file_name = nil)
9
+ log_file = log_file_name.nil? ? @log_file : log_file_name
10
+ append_to_file(data, log_file)
11
+ end
12
+
13
+ def log_error(data)
14
+ append_to_file(data, @errors_file)
15
+ end
16
+
17
+ private
18
+
19
+ def append_to_file(data, log_file_name)
20
+ File.open("#{@log_folder}/#{log_file_name}.log", mode: 'a') do |file|
21
+ file.write("\n#{data}\n")
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,60 @@
1
+ require_relative 'beaker'
2
+
3
+ class NSPooler < Beaker
4
+ def initialize(platforms, user_home_path, env_vars, logger)
5
+ super(platforms, user_home_path, env_vars, logger)
6
+ end
7
+
8
+ def run_test_on_all_platforms
9
+ @platforms.each do |platform, platform_template|
10
+ begin
11
+ @current_platform = platform
12
+ next unless get_nspooler_vm(platform_template)
13
+
14
+ test_sequence
15
+ rescue FailedCommand
16
+ destroy_environment
17
+ next
18
+ end
19
+ end
20
+ end
21
+
22
+ def create_vm_hosts_file
23
+ log_run_command("beaker-hostgenerator #{get_beaker_platform_name(@current_platform, @nspooler_host_name)} > hosts.yaml")
24
+ end
25
+
26
+ def destroy_environment
27
+ super
28
+ log_run_command("curl -H X-AUTH-TOKEN:VmPoolerAuthToken -X POST -d '' --url https://nspooler-service-prod-1.delivery.puppetlabs.net/api/v1/maint/reset/#{@nspooler_host_name}")
29
+ end
30
+
31
+ private
32
+
33
+ def get_nspooler_vm(platform_template)
34
+ provisioned_vm = make_request_for_vm(platform_template)
35
+ if provisioned_vm['ok'] == true
36
+ @nspooler_host_name = provisioned_vm[platform_template]['hostname']
37
+ true
38
+ else
39
+ @logger.log_error("No VM available for #{@current_platform}")
40
+ false
41
+ end
42
+ end
43
+
44
+ def make_request_for_vm(platform_template)
45
+ get_vm_response = log_run_command("curl --fail --silent --show-error -H X-AUTH-TOKEN:VmPoolerAuthToken -X POST -d '{\"#{platform_template}\":1}' --url https://nspooler-service-prod-1.delivery.puppetlabs.net/api/v1/host/")
46
+ JSON.parse(get_vm_response.gsub('=>', ':'))
47
+ end
48
+
49
+ def get_beaker_platform_name(platform, nsPooler_host_name)
50
+ #because of how packaging for agent is made we need to lie beaker about aix version. If we have a version 7, we need
51
+ # to tell it, it's running on version 6
52
+ beaker_platform = if platform.include?('aix7')
53
+ platform.sub(/aix7[1-2]/, 'aix61')
54
+ else
55
+ platform
56
+ end
57
+ "#{beaker_platform}\\{hypervisor=none\\,hostname=#{nsPooler_host_name}\\}"
58
+ end
59
+ end
60
+