puppetlabs-onceover 5.0.3
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 +7 -0
- data/.devcontainer/devcontainer.json +31 -0
- data/.gitattributes +2 -0
- data/.github/workflows/ci.yml +81 -0
- data/.github/workflows/mend.yml +14 -0
- data/.github/workflows/nightly.yml +66 -0
- data/.github/workflows/release.yaml +16 -0
- data/.github/workflows/release_prep.yml +20 -0
- data/.gitignore +19 -0
- data/.rubocop.yml +19 -0
- data/.rubocop_todo.yml +804 -0
- data/.vscode/extensions.json +4 -0
- data/ARCHIVE.md +395 -0
- data/CHANGELOG.md +25 -0
- data/CODEOWNERS +2 -0
- data/Gemfile +65 -0
- data/LICENSE +202 -0
- data/README.md +965 -0
- data/Rakefile +86 -0
- data/bin/puppetlabs-onceover +17 -0
- data/cucumber.yml +1 -0
- data/factsets/AIX-6.1-powerpc.json +210 -0
- data/factsets/AIX-7.1-powerpc.json +215 -0
- data/factsets/Amazon-2018.03.json +420 -0
- data/factsets/CentOS-5.11-32.json +263 -0
- data/factsets/CentOS-5.11-64.json +263 -0
- data/factsets/CentOS-6.6-32.json +306 -0
- data/factsets/CentOS-6.6-64.json +342 -0
- data/factsets/CentOS-7.0-64.json +352 -0
- data/factsets/CentOS-8.3.2011-64.json +485 -0
- data/factsets/Debian-10.4-64.json +476 -0
- data/factsets/Debian-6.0.10-32.json +322 -0
- data/factsets/Debian-6.0.10-64.json +322 -0
- data/factsets/Debian-7.8-32.json +338 -0
- data/factsets/Debian-7.8-64.json +338 -0
- data/factsets/Debian-8.11-64.json +480 -0
- data/factsets/Debian-9.12-64.json +476 -0
- data/factsets/RHEL-6.7.json +415 -0
- data/factsets/RHEL-7.4.json +489 -0
- data/factsets/SLES-11.3-64.json +317 -0
- data/factsets/SLES-12.1-64.json +353 -0
- data/factsets/Ubuntu-12.04-32.json +328 -0
- data/factsets/Ubuntu-12.04-64.json +328 -0
- data/factsets/Ubuntu-14.04-32.json +337 -0
- data/factsets/Ubuntu-14.04-64.json +373 -0
- data/factsets/Ubuntu-18.04-64.json +556 -0
- data/factsets/Ubuntu-20.04-64.json +504 -0
- data/factsets/Windows_Server-2008r2-64.json +184 -0
- data/factsets/Windows_Server-2012r2-64.json +165 -0
- data/factsets/solaris-10_u9-sparc-64.json +769 -0
- data/factsets/solaris-11.2-sparc-64.json +774 -0
- data/factsets/windows-10-64.json +104 -0
- data/features/auto_vendored.feature +27 -0
- data/features/cache.feature +38 -0
- data/features/factsets.feature +48 -0
- data/features/formatting.feature +36 -0
- data/features/help.feature +14 -0
- data/features/init.feature +18 -0
- data/features/show.feature +28 -0
- data/features/step_definitions/cache.rb +38 -0
- data/features/step_definitions/common.rb +123 -0
- data/features/step_definitions/formatter.rb +41 -0
- data/features/step_definitions/init.rb +17 -0
- data/features/step_definitions/run.rb +17 -0
- data/features/support/cache_helper.rb +54 -0
- data/features/support/command_helper.rb +32 -0
- data/features/support/controlrepo_helper.rb +36 -0
- data/features/support/env.rb +2 -0
- data/features/windows.feature +35 -0
- data/features/zzz_run.feature +93 -0
- data/lib/puppetlabs-onceover/beaker/spec_helper.rb +71 -0
- data/lib/puppetlabs-onceover/beaker.rb +241 -0
- data/lib/puppetlabs-onceover/class.rb +56 -0
- data/lib/puppetlabs-onceover/cli/init.rb +34 -0
- data/lib/puppetlabs-onceover/cli/plugins.rb +10 -0
- data/lib/puppetlabs-onceover/cli/run.rb +85 -0
- data/lib/puppetlabs-onceover/cli/show.rb +79 -0
- data/lib/puppetlabs-onceover/cli/update.rb +48 -0
- data/lib/puppetlabs-onceover/cli.rb +47 -0
- data/lib/puppetlabs-onceover/controlrepo.rb +688 -0
- data/lib/puppetlabs-onceover/deploy.rb +171 -0
- data/lib/puppetlabs-onceover/group.rb +78 -0
- data/lib/puppetlabs-onceover/logger.rb +32 -0
- data/lib/puppetlabs-onceover/node.rb +72 -0
- data/lib/puppetlabs-onceover/rake_tasks.rb +95 -0
- data/lib/puppetlabs-onceover/rspec/formatters.rb +315 -0
- data/lib/puppetlabs-onceover/runner.rb +139 -0
- data/lib/puppetlabs-onceover/test.rb +135 -0
- data/lib/puppetlabs-onceover/testconfig.rb +315 -0
- data/lib/puppetlabs-onceover/vendored_modules.rb +202 -0
- data/lib/puppetlabs-onceover/version.rb +5 -0
- data/puppetlabs-onceover.gemspec +40 -0
- data/spec/fixtures/controlrepos/basic/Puppetfile +17 -0
- data/spec/fixtures/controlrepos/basic/environment.conf +7 -0
- data/spec/fixtures/controlrepos/basic/hieradata/common.yaml +2 -0
- data/spec/fixtures/controlrepos/basic/hieradata/nodes/example-node.yaml +1 -0
- data/spec/fixtures/controlrepos/basic/manifests/site.pp +32 -0
- data/spec/fixtures/controlrepos/basic/manifests_alternate/site.pp +2 -0
- data/spec/fixtures/controlrepos/basic/site/profile/manifests/base.pp +5 -0
- data/spec/fixtures/controlrepos/basic/site/profile/manifests/example.pp +3 -0
- data/spec/fixtures/controlrepos/basic/site/role/manifests/database_server.pp +7 -0
- data/spec/fixtures/controlrepos/basic/site/role/manifests/example.pp +3 -0
- data/spec/fixtures/controlrepos/basic/site/role/manifests/webserver.pp +7 -0
- data/spec/fixtures/controlrepos/caching/.gitignore +1 -0
- data/spec/fixtures/controlrepos/caching/.travis.yml +2 -0
- data/spec/fixtures/controlrepos/caching/Gemfile +5 -0
- data/spec/fixtures/controlrepos/caching/Puppetfile +17 -0
- data/spec/fixtures/controlrepos/caching/Rakefile +1 -0
- data/spec/fixtures/controlrepos/caching/deleteme.txt +0 -0
- data/spec/fixtures/controlrepos/caching/environment.conf +2 -0
- data/spec/fixtures/controlrepos/caching/hieradata/common.yaml +2 -0
- data/spec/fixtures/controlrepos/caching/hieradata/nodes/example-node.yaml +1 -0
- data/spec/fixtures/controlrepos/caching/manifests/site.pp +33 -0
- data/spec/fixtures/controlrepos/caching/site/profile/manifests/base.pp +5 -0
- data/spec/fixtures/controlrepos/caching/site/profile/manifests/example.pp +3 -0
- data/spec/fixtures/controlrepos/caching/site/role/manifests/database_server.pp +7 -0
- data/spec/fixtures/controlrepos/caching/site/role/manifests/example.pp +3 -0
- data/spec/fixtures/controlrepos/caching/site/role/manifests/webserver.pp +7 -0
- data/spec/fixtures/controlrepos/caching/spec/factsets/Debian-10-facter-4.json +1091 -0
- data/spec/fixtures/controlrepos/caching/spec/factsets/README.md +7 -0
- data/spec/fixtures/controlrepos/caching/spec/onceover.yaml +55 -0
- data/spec/fixtures/controlrepos/caching/spec/pre_conditions/README.md +24 -0
- data/spec/fixtures/controlrepos/caching/spec/pre_conditions/escaping.pp +7 -0
- data/spec/fixtures/controlrepos/caching/spec/r10k.yaml +3 -0
- data/spec/fixtures/controlrepos/control_branch/Puppetfile +18 -0
- data/spec/fixtures/controlrepos/control_branch/environment.conf +2 -0
- data/spec/fixtures/controlrepos/custom_puppetfile/Puppetfile.custom +3 -0
- data/spec/fixtures/controlrepos/custom_puppetfile/environment.conf +7 -0
- data/spec/fixtures/controlrepos/factsets/environment.conf +1 -0
- data/spec/fixtures/controlrepos/factsets/site/profile/manifests/base.pp +6 -0
- data/spec/fixtures/controlrepos/factsets/site/role/manifests/example.pp +4 -0
- data/spec/fixtures/controlrepos/factsets/site/role/manifests/trusted_extensions.pp +6 -0
- data/spec/fixtures/controlrepos/factsets/site/role/manifests/trusted_external.pp +6 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/README.md +7 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos7_notrusted.json +530 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos7_trusted_extensions_nested.json +535 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos7_trusted_extensions_top.json +533 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos7_trusted_external_nested.json +537 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos7_trusted_external_top.json +535 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos_7_facter_4.json +706 -0
- data/spec/fixtures/controlrepos/factsets/spec/factsets/centos_with_env.json +353 -0
- data/spec/fixtures/controlrepos/function_mocking/.gitignore +1 -0
- data/spec/fixtures/controlrepos/function_mocking/Puppetfile +4 -0
- data/spec/fixtures/controlrepos/function_mocking/Rakefile +1 -0
- data/spec/fixtures/controlrepos/function_mocking/environment.conf +2 -0
- data/spec/fixtures/controlrepos/function_mocking/site/profile/functions/fail_puppet.pp +5 -0
- data/spec/fixtures/controlrepos/function_mocking/site/profile/lib/puppet/functions/profile/fail_ruby.rb +9 -0
- data/spec/fixtures/controlrepos/function_mocking/site/profile/manifests/base.pp +10 -0
- data/spec/fixtures/controlrepos/function_mocking/site/role/manifests/fail.pp +7 -0
- data/spec/fixtures/controlrepos/function_mocking/site/role/manifests/test_data_return.pp +19 -0
- data/spec/fixtures/controlrepos/function_mocking/site/role/manifests/test_new_functions.pp +12 -0
- data/spec/fixtures/controlrepos/function_mocking/spec/onceover.yaml +50 -0
- data/spec/fixtures/controlrepos/minimal/environment.conf +2 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/.atom-build.json +9 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/.gitignore +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/.ruby-version +1 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/.travis.yml +13 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/Gemfile +22 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/Jenkinsfile +50 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/Puppetfile +102 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/README.md +4 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/Rakefile +33 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/common.yaml +558 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/datacenter/melbourne.yaml +12 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/datacenter/singapore.yaml +12 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/environments/development.yaml +3 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/environments/production.yaml +3 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/data/size/vol.large.yaml +27 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/environment.conf +3 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/hiera.yaml +25 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/manifests/site.pp +11 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/code_manager_config_version.rb +19 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/config_version.rb +25 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/config_version.sh +12 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/count_changed_classes.rb +26 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/get_changed_classes.rb +26 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/functions/user/token.pp +10 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/manifests/init.pp +14 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/manifests/user.pp +35 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/deployments/lib/puppet/functions/deployments/generate.rb +15 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/deployments/plans/signed_deployment.pp +126 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/facts.d/test.sh +2 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/artifactory/config_descriptor.xml +265 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/autosign.sh +23 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/hudson.tasks.Shell.xml +4 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/motd +4 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/polar_clock/index.html +198 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/apt.pp +9 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/aws_nodes.pp +54 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/aws.pp +9 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/rhel.pp +50 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/windows/hardening.pp +57 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/windows.pp +52 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base.pp +79 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/artifactory.pp +64 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/connection.pp +95 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/haproxy.pp +65 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/replicated.pp +53 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/compile/balancer.pp +28 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/compile/master.pp +19 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/dns/host_record.pp +16 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/dns/server.pp +66 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/docker.pp +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/base.pp +43 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/core/database_connection.pp +42 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/core.pp +72 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/ctrl.pp +57 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/database.pp +32 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/exec.pp +11 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/file_sync/client.pp +165 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/file_sync/master_patch.pp +37 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/grafana/dashboard.pp +17 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/haproxy.pp +43 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/init.pp +3 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jenkins/plugins.pp +87 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jenkins.pp +65 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/aio.pp +39 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/app.pp +27 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/db.pp +25 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/collectd/compile.pp +82 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/collectd.pp +28 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/dashboard.pp +28 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/mysql_server.pp +7 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/nginx.pp +24 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/polar_clock.pp +55 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/api_auth.pp +82 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/autosign.pp +33 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/aws.pp +58 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/tuning.pp +139 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster.pp +139 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/rvm.pp +13 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/sumologic.pp +11 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/sunburst/windows.pp +104 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/vagrant.pp +25 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/windows/webserver.pp +27 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/cd4pe/connection_script.sh.epp +110 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/controlrepo_deploy_jenkins_job.xml.epp +51 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/dashboard.json.epp +403 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/jenkins_secret_text.json.epp +1 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/onceover_jenkins_job.xml.epp +51 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/userdata.epp +17 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/cd4pe.pp +29 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/clock.pp +16 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/compile/balancer.pp +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/compile/master.pp +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/aio.pp +10 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/controller.pp +10 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/database.pp +7 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/exec.pp +6 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/init.pp +3 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/lb.pp +14 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/metrics.pp +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/mysql.pp +13 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/windows/base.pp +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/windows/webserver.pp +6 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/.gitignore +5 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/acceptance/nodesets/onceover-nodes.yml +94 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/classes/test_spec.rb +8 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64-master-2017.3.2.json +531 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64-master.json +429 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64.json +353 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/Windows_Server-2008r2-64.json +184 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/Windows_Server-2012r2-64.json +165 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/hiera.yaml +18 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/matchers/file_matchers.rb +16 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/onceover.yaml +54 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/pre_conditions/site.pp +150 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/r10k.yaml +2 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/shared_examples/helper.rb +91 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/00_parse_spec.rb +76 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/01_linting_spec_example.rb +69 -0
- data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/03_puppetfile_spec_example.rb +35 -0
- data/spec/fixtures/controlrepos/vendored/Puppetfile +3 -0
- data/spec/fixtures/controlrepos/vendored/Puppetfile.cron +5 -0
- data/spec/fixtures/controlrepos/vendored/environment.conf +1 -0
- data/spec/fixtures/controlrepos/vendored/site-modules/role/manifests/cron.pp +9 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/augeas_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/augeas_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/cron_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/cron_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/host_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/host_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/mount_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/mount_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/repo_tree-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/repo_tree-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/scheduled_task-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/scheduled_task-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/selinux_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/selinux_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/sshkeys_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/sshkeys_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/yumrepo_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/yumrepo_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zfs_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zfs_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zone_core-puppet_agent-7.30.0.json +1 -0
- data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zone_core-puppet_agent-8.6.0.json +1 -0
- data/spec/fixtures/controlrepos/windows/Gemfile +3 -0
- data/spec/fixtures/controlrepos/windows/Puppetfile +8 -0
- data/spec/fixtures/controlrepos/windows/environment.conf +1 -0
- data/spec/fixtures/controlrepos/windows/site/role/manifests/groups.pp +8 -0
- data/spec/fixtures/controlrepos/windows/site/role/manifests/users.pp +9 -0
- data/spec/fixtures/controlrepos/windows/site-modules/role/manifests/acl.pp +12 -0
- data/spec/fixtures/controlrepos/windows/site-modules/role/manifests/choco.pp +9 -0
- data/spec/fixtures/controlrepos/windows/site-modules/role/manifests/groups.pp +8 -0
- data/spec/fixtures/controlrepos/windows/site-modules/role/manifests/users.pp +9 -0
- data/spec/fixtures/controlrepos/windows/spec/onceover.yaml +24 -0
- data/spec/puppetlabs-onceover/controlrepo_spec.rb +18 -0
- data/spec/spec_helper.rb +8 -0
- data/templates/.fixtures.yml.erb +24 -0
- data/templates/Gemfile.erb +3 -0
- data/templates/Rakefile.erb +1 -0
- data/templates/acceptance_test_spec.rb.erb +66 -0
- data/templates/controlrepo.yaml.erb +38 -0
- data/templates/error_summary.yaml.erb +17 -0
- data/templates/factsets_README.md.erb +10 -0
- data/templates/nodeset.yaml.erb +12 -0
- data/templates/pre_conditions_README.md.erb +24 -0
- data/templates/spec_helper.rb.erb +35 -0
- data/templates/spec_helper_acceptance.rb.erb +1 -0
- data/templates/test_spec.rb.erb +150 -0
- data/templates/testconfig_Rakefile.erb +47 -0
- metadata +602 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
require 'rspec'
|
|
2
|
+
require 'rspec-puppet'
|
|
3
|
+
require 'pathname'
|
|
4
|
+
require 'English'
|
|
5
|
+
|
|
6
|
+
class PuppetlabsOnceoverFormatter
|
|
7
|
+
RSpec::Core::Formatters.register(
|
|
8
|
+
self,
|
|
9
|
+
:example_group_started,
|
|
10
|
+
:example_passed,
|
|
11
|
+
:example_failed,
|
|
12
|
+
:example_pending,
|
|
13
|
+
:dump_failures,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
COMPILATION_ERROR = %r{error during compilation: (?<error>.*)}
|
|
17
|
+
# rubocop:disable-next Lint/MixedRegexpCaptureTypes
|
|
18
|
+
ERROR_WITH_LOCATION = %r{(?<error>.*?)\s(at )?(\((file: (?<file>.*?), )?line: (?<line>\d+)(, column: (?<column>\d+))?\))(; )?}
|
|
19
|
+
ERROR_WITHOUT_LOCATION = %r{(?<error>.*?)\son node}
|
|
20
|
+
|
|
21
|
+
def initialize output
|
|
22
|
+
@output = output
|
|
23
|
+
@previous_role = nil
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def example_group_started notification
|
|
27
|
+
if notification.group.parent_groups == [notification.group]
|
|
28
|
+
# If this is the highest level group (The role)
|
|
29
|
+
role = notification.group.description
|
|
30
|
+
if role != @previous_role
|
|
31
|
+
@output << "\n"
|
|
32
|
+
@output << class_name("#{notification.group.description}:")
|
|
33
|
+
|
|
34
|
+
# Calculate the padding required
|
|
35
|
+
padding = (longest_group - role.length) + 1
|
|
36
|
+
# Create padding
|
|
37
|
+
padding.times { @output << ' ' }
|
|
38
|
+
|
|
39
|
+
# Save the role name
|
|
40
|
+
@previous_role = role
|
|
41
|
+
end
|
|
42
|
+
else
|
|
43
|
+
# If not then this will be a test for that role
|
|
44
|
+
@output << '? '
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def example_passed notification
|
|
49
|
+
@output << "\b\b"
|
|
50
|
+
@output << "#{green('P')} "
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def example_failed notification
|
|
54
|
+
@output << "\b\b"
|
|
55
|
+
@output << "#{red('F')} "
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def example_pending notification
|
|
59
|
+
@output << "\b\b"
|
|
60
|
+
@output << "#{yellow('?')} "
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def dump_failures notification
|
|
64
|
+
require 'puppetlabs-onceover/controlrepo'
|
|
65
|
+
|
|
66
|
+
failures = extract_failures(notification)
|
|
67
|
+
|
|
68
|
+
# Put some spacing before the results
|
|
69
|
+
@output << "\n\n\n"
|
|
70
|
+
|
|
71
|
+
failures.each do |name, errors|
|
|
72
|
+
@output << PuppetlabsOnceover::Controlrepo.evaluate_template('error_summary.yaml.erb', binding)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
@output << "\n"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# rubocop:disable Style/CombinableLoops
|
|
79
|
+
#
|
|
80
|
+
# This method takes a notification and formats it into a hash that can be
|
|
81
|
+
# printed easily
|
|
82
|
+
def extract_failures notification
|
|
83
|
+
# Group by role
|
|
84
|
+
grouped = notification.failed_examples.group_by { |e| e.metadata[:example_group][:parent_example_group][:description]}
|
|
85
|
+
|
|
86
|
+
# Further group by error
|
|
87
|
+
grouped.each do |role, failures|
|
|
88
|
+
grouped[role] = failures.group_by { |f| f.metadata[:execution_result].exception.to_s }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Extract the errors and remove all RSpec objects
|
|
92
|
+
grouped.each do |role, failures|
|
|
93
|
+
grouped[role] = failures.map { |_description, fails| extract_failure_data(fails)}.flatten
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
grouped
|
|
97
|
+
end
|
|
98
|
+
# rubocop:enable Style/CombinableLoops
|
|
99
|
+
|
|
100
|
+
# Extaracts data out of RSpec failres
|
|
101
|
+
def extract_failure_data(fails)
|
|
102
|
+
# The only difference between these failures should be the factsets that it
|
|
103
|
+
# failed on. Extract that list then just use the first failure for the rest
|
|
104
|
+
# of the data as it should be the same
|
|
105
|
+
metadata = fails[0].metadata
|
|
106
|
+
raw_error = metadata[:execution_result].exception.to_s
|
|
107
|
+
factsets = fails.map { |f| f.metadata[:example_group][:description].gsub('using fact set ','') }
|
|
108
|
+
results = parse_errors(raw_error)
|
|
109
|
+
# Add the details of the factsets tio each result
|
|
110
|
+
results.map do |r|
|
|
111
|
+
r[:factsets] = factsets
|
|
112
|
+
r
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Parses information out of a string error
|
|
117
|
+
def parse_errors(raw_error)
|
|
118
|
+
# Check if the error is a compilation error
|
|
119
|
+
match = COMPILATION_ERROR.match(raw_error)
|
|
120
|
+
if match
|
|
121
|
+
compilation_error = match['error']
|
|
122
|
+
# Check if we car parse it
|
|
123
|
+
if ERROR_WITH_LOCATION.match(compilation_error)
|
|
124
|
+
scanned_errors = match['error'].scan(ERROR_WITH_LOCATION)
|
|
125
|
+
|
|
126
|
+
# Delete any matches where there was no error text
|
|
127
|
+
scanned_errors.delete_if { |e| e.first.empty? }
|
|
128
|
+
|
|
129
|
+
scanned_errors.map do |error_matches|
|
|
130
|
+
{
|
|
131
|
+
text: error_matches[0],
|
|
132
|
+
file: calculate_relative_source(error_matches[1]),
|
|
133
|
+
line: error_matches[2],
|
|
134
|
+
column: error_matches[3],
|
|
135
|
+
}
|
|
136
|
+
end
|
|
137
|
+
elsif ERROR_WITHOUT_LOCATION.match(compilation_error)
|
|
138
|
+
scanned_errors = match['error'].scan(ERROR_WITHOUT_LOCATION)
|
|
139
|
+
|
|
140
|
+
# Delete any matches where there was no error text
|
|
141
|
+
scanned_errors.delete_if { |e| e.first.empty? }
|
|
142
|
+
|
|
143
|
+
scanned_errors.map do |error_matches|
|
|
144
|
+
{
|
|
145
|
+
text: error_matches[0],
|
|
146
|
+
}
|
|
147
|
+
end
|
|
148
|
+
else
|
|
149
|
+
[{
|
|
150
|
+
text: raw_error,
|
|
151
|
+
}]
|
|
152
|
+
end
|
|
153
|
+
else
|
|
154
|
+
[{
|
|
155
|
+
text: raw_error,
|
|
156
|
+
}]
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# This method calculates where the original source file is relative to the
|
|
161
|
+
# user's current location. This is more compliacted than it sounds because
|
|
162
|
+
# if we are running from the root of the controlrepo and we have an error in:
|
|
163
|
+
#
|
|
164
|
+
# /Users/dylan/git/puppet_controlrepo/.onceover/etc/puppetlabs/code/environments/production/site/role/manifests/lb.pp
|
|
165
|
+
#
|
|
166
|
+
# We need that to end up pointing at the original source file not the cached
|
|
167
|
+
# one i.e.
|
|
168
|
+
#
|
|
169
|
+
# site/role/manifests/lb.pp
|
|
170
|
+
#
|
|
171
|
+
def calculate_relative_source(file)
|
|
172
|
+
return nil if file.nil?
|
|
173
|
+
|
|
174
|
+
file = Pathname.new(file)
|
|
175
|
+
tempdir = Pathname.new(RSpec.configuration.onceover_tempdir)
|
|
176
|
+
root = Pathname.new(RSpec.configuration.onceover_root)
|
|
177
|
+
environmentpath = Pathname.new(RSpec.configuration.onceover_environmentpath)
|
|
178
|
+
|
|
179
|
+
# Calculate the full relative path
|
|
180
|
+
file.relative_path_from(tempdir + environmentpath + "production").to_s
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Below are defined the styles for the output
|
|
184
|
+
def class_name(text)
|
|
185
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :bold)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def black(text)
|
|
189
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :black)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def red(text)
|
|
193
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :red)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def green(text)
|
|
197
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :green)
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def yellow(text)
|
|
201
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :yellow)
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
def blue(text)
|
|
205
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :blue)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def magenta(text)
|
|
209
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :magenta)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def cyan(text)
|
|
213
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :cyan)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def white(text)
|
|
217
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :white)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def bold(text)
|
|
221
|
+
RSpec::Core::Formatters::ConsoleCodes.wrap(text, :bold)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def longest_group
|
|
225
|
+
RSpec.configuration.world.example_groups.max { |a,b| a.description.length <=> b.description.length}.description.length
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
class PuppetlabsOnceoverFormatterParallel < PuppetlabsOnceoverFormatter
|
|
230
|
+
require 'yaml'
|
|
231
|
+
|
|
232
|
+
RSpec::Core::Formatters.register(
|
|
233
|
+
self,
|
|
234
|
+
:example_group_started,
|
|
235
|
+
:example_passed,
|
|
236
|
+
:example_failed,
|
|
237
|
+
:example_pending,
|
|
238
|
+
:dump_failures,
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
def example_group_started notification
|
|
242
|
+
# Do nothing
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def example_passed notification
|
|
246
|
+
@output << green('P')
|
|
247
|
+
@output.flush
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def example_failed notification
|
|
251
|
+
@output << red('F')
|
|
252
|
+
@output.flush
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def example_pending notification
|
|
256
|
+
@output << yellow('?')
|
|
257
|
+
@output.flush
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def dump_failures notification
|
|
261
|
+
# Create a random string
|
|
262
|
+
require 'securerandom'
|
|
263
|
+
random_string = SecureRandom.hex
|
|
264
|
+
|
|
265
|
+
# Ensure that the folder exists
|
|
266
|
+
FileUtils.mkdir_p "#{RSpec.configuration.onceover_tempdir}/parallel"
|
|
267
|
+
|
|
268
|
+
# Dump the notification to a unique file
|
|
269
|
+
File.write("#{RSpec.configuration.onceover_tempdir}/parallel/results-#{random_string}.yaml", extract_failures(notification).to_yaml)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def output_results(directory)
|
|
273
|
+
require 'rspec/core/example'
|
|
274
|
+
# Read all yaml files
|
|
275
|
+
results = {}
|
|
276
|
+
files = Dir["#{directory}/*.yaml"]
|
|
277
|
+
|
|
278
|
+
# Merge data
|
|
279
|
+
roles = files.reduce({}) do |errs, file|
|
|
280
|
+
# Read all files and merge them
|
|
281
|
+
errs.merge(YAML.load_file(file)) {|key, oldval, newval| [oldval, newval].flatten }
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Delete files from the disk
|
|
285
|
+
files.each { |f| File.delete(f) }
|
|
286
|
+
|
|
287
|
+
@output << "\n\n\n"
|
|
288
|
+
|
|
289
|
+
# Output errors
|
|
290
|
+
roles.each do |name, errors|
|
|
291
|
+
@output << PuppetlabsOnceover::Controlrepo.evaluate_template('error_summary.yaml.erb', binding)
|
|
292
|
+
end
|
|
293
|
+
@output << "\n"
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
class FailureCollector
|
|
298
|
+
RSpec::Core::Formatters.register self, :dump_failures
|
|
299
|
+
|
|
300
|
+
def initialize(output)
|
|
301
|
+
FileUtils.touch(File.expand_path("#{RSpec.configuration.onceover_tempdir}/failures.out"))
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
def dump_failures(failures)
|
|
305
|
+
File.open(File.expand_path("#{RSpec.configuration.onceover_tempdir}/failures.out"), 'a') { |f|
|
|
306
|
+
failures.failed_examples.each do |fe|
|
|
307
|
+
f.puts
|
|
308
|
+
f.puts "#{fe.metadata[:description]}"
|
|
309
|
+
f.puts "#{fe.metadata[:execution_result].exception.to_s}"
|
|
310
|
+
f.puts "#{fe.metadata[:file_path]}:#{fe.metadata[:line_number]}"
|
|
311
|
+
f.puts "------------------------------------------------------"
|
|
312
|
+
end
|
|
313
|
+
}
|
|
314
|
+
end
|
|
315
|
+
end
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
require 'backticks'
|
|
2
|
+
require 'io/console'
|
|
3
|
+
|
|
4
|
+
class PuppetlabsOnceover
|
|
5
|
+
class Runner
|
|
6
|
+
attr_reader :repo
|
|
7
|
+
attr_reader :config
|
|
8
|
+
|
|
9
|
+
def initialize(repo, config, mode = [:spec, :acceptance])
|
|
10
|
+
@repo = repo
|
|
11
|
+
@config = config
|
|
12
|
+
@mode = [mode].flatten
|
|
13
|
+
@command_prefix = ENV['BUNDLE_GEMFILE'] ? 'bundle exec ' : ''
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def prepare!
|
|
17
|
+
# Remove the entire spec directory to make sure we have
|
|
18
|
+
# all the latest tests
|
|
19
|
+
FileUtils.rm_rf("#{@repo.tempdir}/spec")
|
|
20
|
+
|
|
21
|
+
# Remove any previous failure log
|
|
22
|
+
FileUtils.rm_f("#{@repo.tempdir}/failures.out")
|
|
23
|
+
|
|
24
|
+
# Create the other directories we need
|
|
25
|
+
FileUtils.mkdir_p("#{@repo.tempdir}/spec/classes")
|
|
26
|
+
FileUtils.mkdir_p("#{@repo.tempdir}/spec/acceptance/nodesets")
|
|
27
|
+
|
|
28
|
+
# Copy specified spec files over
|
|
29
|
+
@config.copy_spec_files(@repo)
|
|
30
|
+
|
|
31
|
+
# Create the Rakefile so that we can take advantage of the existing tasks
|
|
32
|
+
@config.write_rakefile(@repo.tempdir, "spec/classes/**/*_spec.rb")
|
|
33
|
+
|
|
34
|
+
# Create spec_helper.rb
|
|
35
|
+
@config.write_spec_helper("#{@repo.tempdir}/spec", @repo)
|
|
36
|
+
|
|
37
|
+
# Create spec_helper_accpetance.rb
|
|
38
|
+
@config.write_spec_helper_acceptance("#{@repo.tempdir}/spec", @repo)
|
|
39
|
+
|
|
40
|
+
if @mode.include?(:spec)
|
|
41
|
+
# Verify all of the spec tests
|
|
42
|
+
@config.spec_tests.each { |test| @config.verify_spec_test(@repo, test) }
|
|
43
|
+
|
|
44
|
+
# Deduplicate and write the tests (Spec and Acceptance)
|
|
45
|
+
@config.run_filters(PuppetlabsOnceover::Test.deduplicate(@config.spec_tests)).each do |test|
|
|
46
|
+
@config.write_spec_test("#{@repo.tempdir}/spec/classes", test)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
if @mode.include?(:acceptance)
|
|
51
|
+
# Verify all of the acceptance tests
|
|
52
|
+
@config.acceptance_tests.each { |test| @config.verify_acceptance_test(@repo, test) }
|
|
53
|
+
|
|
54
|
+
# Write them out
|
|
55
|
+
@config.write_acceptance_tests(
|
|
56
|
+
"#{@repo.tempdir}/spec/acceptance",
|
|
57
|
+
@config.run_filters(PuppetlabsOnceover::Test.deduplicate(@config.acceptance_tests))
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Parse the current hiera config, modify, and write it to the temp dir
|
|
62
|
+
unless @repo.hiera_config == nil
|
|
63
|
+
hiera_config = @repo.hiera_config
|
|
64
|
+
hiera_config.each do |setting, value|
|
|
65
|
+
if value.is_a?(Hash)
|
|
66
|
+
if value.has_key?(:datadir)
|
|
67
|
+
hiera_config[setting][:datadir] = "#{@repo.tempdir}/#{@repo.environmentpath}/production/#{value[:datadir]}"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
File.write("#{@repo.tempdir}/#{@repo.environmentpath}/production/hiera.yaml", hiera_config.to_yaml)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
@config.create_fixtures_symlinks(@repo)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def run_spec!
|
|
78
|
+
Dir.chdir(@repo.tempdir) do
|
|
79
|
+
# Disable warnings unless we are running in debug mode
|
|
80
|
+
unless logger.level.zero?
|
|
81
|
+
previous_rubyopt = ENV.fetch('RUBYOPT', nil)
|
|
82
|
+
ENV['RUBYOPT'] = ENV['RUBYOPT'].to_s + ' -W0'
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# NOTE: This is the way to provide options to rspec according to:
|
|
86
|
+
# https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/rake_tasks.rb#L51
|
|
87
|
+
ENV['CI_SPEC_OPTIONS'] = ENV['CI_SPEC_OPTIONS'].to_s + @config.filter_tags.map { |tag| " --tag #{tag}" }.join unless @config.filter_tags.nil?
|
|
88
|
+
ENV['CI_SPEC_OPTIONS'] = ENV['CI_SPEC_OPTIONS'].to_s + ' --fail-fast' if @config.fail_fast
|
|
89
|
+
|
|
90
|
+
if @config.opts[:parallel]
|
|
91
|
+
logger.debug "Running #{@command_prefix}rake parallel_spec from #{@repo.tempdir}"
|
|
92
|
+
result = run_command(@command_prefix.strip.split, 'rake', 'parallel_spec')
|
|
93
|
+
else
|
|
94
|
+
require 'io/console'
|
|
95
|
+
logger.debug "Running #{@command_prefix}rake spec:standalone from #{@repo.tempdir}"
|
|
96
|
+
result = run_command(@command_prefix.strip.split, 'rake', 'spec:standalone')
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Reset env to previous state if we modified it
|
|
100
|
+
unless logger.level.zero?
|
|
101
|
+
ENV['RUBYOPT'] = previous_rubyopt
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Print a summary if we were running in parallel
|
|
105
|
+
if @config.formatters.include? 'PuppetlabsOnceoverFormatterParallel'
|
|
106
|
+
require 'puppetlabs-onceover/rspec/formatters'
|
|
107
|
+
formatter = PuppetlabsOnceoverFormatterParallel.new(STDOUT)
|
|
108
|
+
formatter.output_results("#{repo.tempdir}/parallel")
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Finally exit and preserve the exit code
|
|
112
|
+
exit result.status.exitstatus
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def run_acceptance!
|
|
117
|
+
warn "[DEPRECATION] #{__method__} is deprecated due to the removal of Beaker"
|
|
118
|
+
|
|
119
|
+
Dir.chdir(@repo.tempdir) do
|
|
120
|
+
#`bundle install --binstubs`
|
|
121
|
+
#`bin/rake spec:standalone`
|
|
122
|
+
logger.debug "Running #{@command_prefix}rake acceptance from #{@repo.tempdir}"
|
|
123
|
+
result = run_command(@command_prefix.strip.split, 'rake', 'acceptance')
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Finally exit and preserve the exit code
|
|
127
|
+
exit result.status.exitstatus
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def run_command(*args)
|
|
131
|
+
begin
|
|
132
|
+
STDERR.raw! if STDERR.isatty
|
|
133
|
+
result = Backticks::Runner.new(interactive: true).run(args.flatten).join
|
|
134
|
+
ensure
|
|
135
|
+
STDERR.cooked! if STDERR.isatty
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
class PuppetlabsOnceover
|
|
2
|
+
class Test
|
|
3
|
+
@@all =[]
|
|
4
|
+
|
|
5
|
+
attr_accessor :nodes
|
|
6
|
+
attr_accessor :classes
|
|
7
|
+
attr_accessor :test_config
|
|
8
|
+
attr_reader :default_test_config
|
|
9
|
+
attr_reader :tags
|
|
10
|
+
|
|
11
|
+
# This can accept a bunch of stuff. It can accept nodes, classes or groups anywhere
|
|
12
|
+
# it will then detect them and expand them out into their respective objects so that
|
|
13
|
+
# we just end up with a list of nodes and classes
|
|
14
|
+
def initialize(on_this, test_this, test_config)
|
|
15
|
+
@default_test_config = {
|
|
16
|
+
'check_idempotency' => true,
|
|
17
|
+
'runs_before_idempotency' => 1
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# Add defaults if they do not exist
|
|
21
|
+
test_config = @default_test_config.merge(test_config)
|
|
22
|
+
|
|
23
|
+
@nodes = []
|
|
24
|
+
@classes = []
|
|
25
|
+
@test_config = test_config
|
|
26
|
+
@test_config.delete('classes') # remove classes from the config
|
|
27
|
+
|
|
28
|
+
# Make sure that tags are an array
|
|
29
|
+
@test_config['tags'] ||= []
|
|
30
|
+
@test_config['tags'] = [@test_config['tags']].flatten
|
|
31
|
+
@tags = @test_config['tags']
|
|
32
|
+
|
|
33
|
+
# Get the nodes we are working on
|
|
34
|
+
if PuppetlabsOnceover::Group.find(on_this)
|
|
35
|
+
@nodes << PuppetlabsOnceover::Group.find(on_this).members
|
|
36
|
+
elsif PuppetlabsOnceover::Node.find(on_this)
|
|
37
|
+
@nodes << PuppetlabsOnceover::Node.find(on_this)
|
|
38
|
+
else
|
|
39
|
+
raise "#{on_this} was not found in the list of nodes or groups!"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
@nodes.flatten!
|
|
43
|
+
|
|
44
|
+
# Check that our nodes list contains only nodes
|
|
45
|
+
raise "#{@nodes} contained a non-node object." unless @nodes.all? { |item| item.is_a?(PuppetlabsOnceover::Node) }
|
|
46
|
+
|
|
47
|
+
if test_this.is_a?(String)
|
|
48
|
+
# If we have just given a string then grab all the classes it corresponds to
|
|
49
|
+
if PuppetlabsOnceover::Group.find(test_this)
|
|
50
|
+
@classes << PuppetlabsOnceover::Group.find(test_this).members
|
|
51
|
+
elsif PuppetlabsOnceover::Class.find(test_this)
|
|
52
|
+
@classes << PuppetlabsOnceover::Class.find(test_this)
|
|
53
|
+
else
|
|
54
|
+
raise "#{test_this} was not found in the list of classes or groups!"
|
|
55
|
+
end
|
|
56
|
+
@classes.flatten!
|
|
57
|
+
elsif test_this.is_a?(Hash)
|
|
58
|
+
@classes = PuppetlabsOnceover::TestConfig.subtractive_to_list(test_this)
|
|
59
|
+
elsif test_this.is_a?(PuppetlabsOnceover::Class)
|
|
60
|
+
@classes << test_this
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def eql?(other)
|
|
65
|
+
@nodes.sort.eql?(other.nodes.sort) and @classes.sort.eql?(other.classes.sort)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def to_s
|
|
69
|
+
class_msg = ""
|
|
70
|
+
node_msg = ""
|
|
71
|
+
if classes.count > 1
|
|
72
|
+
class_msg = "#{classes.count}_classes"
|
|
73
|
+
else
|
|
74
|
+
class_msg = classes[0].name.gsub("::",'__')
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
if nodes.count > 1
|
|
78
|
+
node_msg = "#{nodes.count}_nodes"
|
|
79
|
+
else
|
|
80
|
+
node_msg = nodes[0].name
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
"#{class_msg}_on_#{node_msg}"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def self.deduplicate(tests)
|
|
87
|
+
require 'deep_merge'
|
|
88
|
+
# This should take an array of tests and remove any duplicates from them
|
|
89
|
+
|
|
90
|
+
# this will be an array of arrays, or maybe hashes
|
|
91
|
+
combinations = []
|
|
92
|
+
new_tests = []
|
|
93
|
+
|
|
94
|
+
tests.each do |test|
|
|
95
|
+
test.nodes.each do |node|
|
|
96
|
+
test.classes.each do |cls|
|
|
97
|
+
combo = {node => cls}
|
|
98
|
+
if combinations.member?(combo)
|
|
99
|
+
|
|
100
|
+
# Find the right test object:
|
|
101
|
+
relevant_test = new_tests[new_tests.index do |a|
|
|
102
|
+
a.nodes[0] == node and a.classes[0] == cls
|
|
103
|
+
end]
|
|
104
|
+
|
|
105
|
+
# Delete all default values in the current options hash
|
|
106
|
+
test.test_config.delete_if do |key, value|
|
|
107
|
+
test.default_test_config[key] == value
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Merge the non-default options right on in there
|
|
111
|
+
relevant_test.test_config.deep_merge!(test.test_config)
|
|
112
|
+
else
|
|
113
|
+
combinations << combo
|
|
114
|
+
new_tests << PuppetlabsOnceover::Test.new(node, cls, test.test_config)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# The array that this returns should be ephemeral, it does not
|
|
121
|
+
# represent anything defined in a controlrepo and should just
|
|
122
|
+
# be passed into the thing doing the testing and then killed,
|
|
123
|
+
# we don't want too many copies of the same shit going around
|
|
124
|
+
#
|
|
125
|
+
# Actually based on the way things are written I don't think this
|
|
126
|
+
# will deduplicate node or class objects, just test objects,
|
|
127
|
+
# everything else is passed by reference
|
|
128
|
+
new_tests
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def self.all
|
|
132
|
+
@@all
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|