beaker 4.38.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +36 -11
- data/.rubocop.yml +75 -0
- data/.rubocop_todo.yml +239 -0
- data/CHANGELOG.md +88 -33
- data/Gemfile +16 -4
- data/HISTORY.md +103 -0
- data/Rakefile +101 -112
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Gemfile +1 -1
- data/acceptance/fixtures/module/Rakefile +3 -3
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +16 -23
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -2
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +7 -6
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +7 -8
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +9 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +15 -21
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +23 -30
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +21 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +7 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +30 -38
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +14 -18
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +8 -14
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +7 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +4 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +8 -8
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +4 -6
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +9 -21
- data/acceptance/tests/base/host/file_test.rb +8 -8
- data/acceptance/tests/base/host/group_test.rb +2 -3
- data/acceptance/tests/base/host/host_test.rb +69 -66
- data/acceptance/tests/base/host/packages.rb +27 -30
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +2 -3
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +3 -5
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +10 -14
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/concepts/style_guide.md +1 -1
- data/docs/how_to/debug_beaker_tests.md +13 -13
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +63 -74
- data/lib/beaker/command.rb +22 -30
- data/lib/beaker/command_factory.rb +4 -3
- data/lib/beaker/dsl/assertions.rb +7 -19
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +5 -9
- data/lib/beaker/dsl/helpers/host_helpers.rb +72 -133
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +20 -28
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +17 -19
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +18 -21
- data/lib/beaker/dsl/structure.rb +55 -67
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +3 -3
- data/lib/beaker/host/aix/user.rb +3 -3
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +36 -48
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +5 -5
- data/lib/beaker/host/mac/group.rb +13 -13
- data/lib/beaker/host/mac/pkg.rb +6 -109
- data/lib/beaker/host/mac/user.rb +7 -7
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +70 -74
- data/lib/beaker/host/pswindows/file.rb +4 -6
- data/lib/beaker/host/pswindows/group.rb +5 -5
- data/lib/beaker/host/pswindows/pkg.rb +17 -17
- data/lib/beaker/host/pswindows/user.rb +4 -4
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +86 -88
- data/lib/beaker/host/unix/file.rb +41 -47
- data/lib/beaker/host/unix/group.rb +3 -3
- data/lib/beaker/host/unix/pkg.rb +158 -421
- data/lib/beaker/host/unix/user.rb +4 -4
- data/lib/beaker/host/unix.rb +18 -20
- data/lib/beaker/host/windows/exec.rb +20 -20
- data/lib/beaker/host/windows/file.rb +5 -5
- data/lib/beaker/host/windows/group.rb +5 -5
- data/lib/beaker/host/windows/pkg.rb +6 -57
- data/lib/beaker/host/windows/user.rb +4 -4
- data/lib/beaker/host/windows.rb +13 -13
- data/lib/beaker/host.rb +82 -139
- data/lib/beaker/host_prebuilt_steps.rb +121 -233
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +46 -63
- data/lib/beaker/local_connection.rb +4 -6
- data/lib/beaker/logger.rb +71 -85
- data/lib/beaker/logger_junit.rb +22 -26
- data/lib/beaker/network_manager.rb +40 -43
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +34 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +3 -10
- data/lib/beaker/options/parser.rb +89 -105
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +29 -34
- data/lib/beaker/platform.rb +38 -46
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +40 -46
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +6 -8
- data/lib/beaker/shared/semvar.rb +39 -43
- data/lib/beaker/shared/timed.rb +2 -5
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +46 -55
- data/lib/beaker/subcommand.rb +23 -30
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +5 -10
- data/lib/beaker/tasks/rake_task.rb +26 -28
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +15 -27
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +52 -57
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +5 -6
- data/spec/beaker/cli_spec.rb +135 -153
- data/spec/beaker/command_spec.rb +64 -58
- data/spec/beaker/dsl/assertions_spec.rb +38 -47
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +114 -135
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +30 -36
- data/spec/beaker/dsl/outcomes_spec.rb +15 -14
- data/spec/beaker/dsl/roles_spec.rb +170 -132
- data/spec/beaker/dsl/structure_spec.rb +181 -163
- data/spec/beaker/dsl/test_tagging_spec.rb +94 -95
- data/spec/beaker/dsl/wrappers_spec.rb +39 -40
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +92 -102
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +5 -8
- data/spec/beaker/host/freebsd/pkg_spec.rb +29 -29
- data/spec/beaker/host/mac/exec_spec.rb +4 -5
- data/spec/beaker/host/mac/group_spec.rb +47 -56
- data/spec/beaker/host/mac/user_spec.rb +53 -62
- data/spec/beaker/host/pswindows/exec_spec.rb +36 -35
- data/spec/beaker/host/pswindows/file_spec.rb +21 -18
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +14 -14
- data/spec/beaker/host/unix/exec_spec.rb +87 -92
- data/spec/beaker/host/unix/file_spec.rb +76 -82
- data/spec/beaker/host/unix/pkg_spec.rb +165 -407
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +32 -34
- data/spec/beaker/host/windows/file_spec.rb +22 -23
- data/spec/beaker/host/windows/group_spec.rb +17 -19
- data/spec/beaker/host/windows/pkg_spec.rb +10 -13
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +193 -341
- data/spec/beaker/host_spec.rb +241 -312
- data/spec/beaker/hypervisor/hypervisor_spec.rb +38 -63
- data/spec/beaker/localhost_connection_spec.rb +14 -13
- data/spec/beaker/logger_junit_spec.rb +22 -34
- data/spec/beaker/logger_spec.rb +174 -155
- data/spec/beaker/network_manager_spec.rb +27 -27
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/data/hosts_preserved.yml +395 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +36 -31
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +7 -9
- data/spec/beaker/options/parser_spec.rb +187 -187
- data/spec/beaker/options/presets_spec.rb +8 -10
- data/spec/beaker/options/subcommand_options_parser_spec.rb +15 -15
- data/spec/beaker/options/validator_spec.rb +27 -28
- data/spec/beaker/perf_spec.rb +32 -34
- data/spec/beaker/platform_spec.rb +27 -37
- data/spec/beaker/shared/error_handler_spec.rb +8 -17
- data/spec/beaker/shared/fog_credentials_spec.rb +30 -30
- data/spec/beaker/shared/host_manager_spec.rb +55 -89
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +24 -31
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +85 -90
- data/spec/beaker/subcommand/subcommand_util_spec.rb +40 -37
- data/spec/beaker/subcommand_spec.rb +89 -89
- data/spec/beaker/test_case_spec.rb +33 -62
- data/spec/beaker/test_suite_spec.rb +153 -160
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +9 -8
- data/spec/mocks.rb +6 -11
- data/spec/spec_helper.rb +0 -4
- metadata +60 -85
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
- data/spec/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
data/HISTORY.md
CHANGED
@@ -1,3 +1,106 @@
|
|
1
|
+
## [4.38.1](https://github.com/voxpupuli/beaker/tree/4.38.1) (2022-09-21)
|
2
|
+
|
3
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.38.0...4.38.1)
|
4
|
+
|
5
|
+
**Fixed bugs:**
|
6
|
+
|
7
|
+
- Arch Linux: Ensure keyring is up2date [\#1755](https://github.com/voxpupuli/beaker/pull/1755) ([bastelfreak](https://github.com/bastelfreak))
|
8
|
+
|
9
|
+
## [4.38.0](https://github.com/voxpupuli/beaker/tree/4.38.0) (2022-08-11)
|
10
|
+
|
11
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.37.2...4.38.0)
|
12
|
+
|
13
|
+
**Implemented enhancements:**
|
14
|
+
|
15
|
+
- Drop pry dependency, allow using debug gem [\#1737](https://github.com/voxpupuli/beaker/pull/1737) ([ekohl](https://github.com/ekohl))
|
16
|
+
|
17
|
+
## [4.37.2](https://github.com/voxpupuli/beaker/tree/4.37.2) (2022-07-29)
|
18
|
+
|
19
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.37.1...4.37.2)
|
20
|
+
|
21
|
+
**Fixed bugs:**
|
22
|
+
|
23
|
+
- Use the new scheme for agent versions \>= 6.28 and \< 7 [\#1749](https://github.com/voxpupuli/beaker/pull/1749) ([joshcooper](https://github.com/joshcooper))
|
24
|
+
|
25
|
+
## [4.37.1](https://github.com/voxpupuli/beaker/tree/4.37.1) (2022-07-27)
|
26
|
+
|
27
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.37.0...4.37.1)
|
28
|
+
|
29
|
+
**Fixed bugs:**
|
30
|
+
|
31
|
+
- macOS PE tarballs include arch now [\#1747](https://github.com/voxpupuli/beaker/pull/1747) ([joshcooper](https://github.com/joshcooper))
|
32
|
+
|
33
|
+
## [4.37.0](https://github.com/voxpupuli/beaker/tree/4.37.0) (2022-06-28)
|
34
|
+
|
35
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.36.1...4.37.0)
|
36
|
+
|
37
|
+
**Implemented enhancements:**
|
38
|
+
|
39
|
+
- Add support for Win32-OpenSSH [\#1744](https://github.com/voxpupuli/beaker/pull/1744) ([joshcooper](https://github.com/joshcooper))
|
40
|
+
|
41
|
+
**Fixed bugs:**
|
42
|
+
|
43
|
+
- Create ~/.ssh on Windows if it doesn't exist [\#1745](https://github.com/voxpupuli/beaker/pull/1745) ([joshcooper](https://github.com/joshcooper))
|
44
|
+
|
45
|
+
## [4.36.1](https://github.com/voxpupuli/beaker/tree/4.36.1) (2022-06-16)
|
46
|
+
|
47
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.36.0...4.36.1)
|
48
|
+
|
49
|
+
**Implemented enhancements:**
|
50
|
+
|
51
|
+
- \(maint\) Remove /etc/environment file for ubuntu2204 [\#1742](https://github.com/voxpupuli/beaker/pull/1742) ([cthorn42](https://github.com/cthorn42))
|
52
|
+
|
53
|
+
## [4.36.0](https://github.com/voxpupuli/beaker/tree/4.36.0) (2022-05-30)
|
54
|
+
|
55
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.35.0...4.36.0)
|
56
|
+
|
57
|
+
**Implemented enhancements:**
|
58
|
+
|
59
|
+
- \(PE-33493\) Add Ubuntu 2204 codename [\#1740](https://github.com/voxpupuli/beaker/pull/1740) ([cthorn42](https://github.com/cthorn42))
|
60
|
+
|
61
|
+
## [4.35.0](https://github.com/voxpupuli/beaker/tree/4.35.0) (2022-05-13)
|
62
|
+
|
63
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.34.0...4.35.0)
|
64
|
+
|
65
|
+
**Implemented enhancements:**
|
66
|
+
|
67
|
+
- Build gem during CI runs [\#1738](https://github.com/voxpupuli/beaker/pull/1738) ([bastelfreak](https://github.com/bastelfreak))
|
68
|
+
- Add Ruby 3.1 support [\#1736](https://github.com/voxpupuli/beaker/pull/1736) ([ekohl](https://github.com/ekohl))
|
69
|
+
|
70
|
+
## [4.34.0](https://github.com/voxpupuli/beaker/tree/4.34.0) (2022-01-27)
|
71
|
+
|
72
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.33.0...4.34.0)
|
73
|
+
|
74
|
+
**Implemented enhancements:**
|
75
|
+
|
76
|
+
- Extract a host\_packages method from validate\_host [\#1729](https://github.com/voxpupuli/beaker/pull/1729) ([ekohl](https://github.com/ekohl))
|
77
|
+
- Reduce duplication in ssh\_permit\_user\_environment [\#1728](https://github.com/voxpupuli/beaker/pull/1728) ([ekohl](https://github.com/ekohl))
|
78
|
+
|
79
|
+
**Fixed bugs:**
|
80
|
+
|
81
|
+
- Do not install curl on EL9 [\#1732](https://github.com/voxpupuli/beaker/pull/1732) ([ekohl](https://github.com/ekohl))
|
82
|
+
- Drop old Ruby 1.8 compatibility code [\#1730](https://github.com/voxpupuli/beaker/pull/1730) ([ekohl](https://github.com/ekohl))
|
83
|
+
|
84
|
+
## [4.33.0](https://github.com/voxpupuli/beaker/tree/4.33.0) (2022-01-21)
|
85
|
+
|
86
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.32.0...4.33.0)
|
87
|
+
|
88
|
+
**Implemented enhancements:**
|
89
|
+
|
90
|
+
- Add ed25519 as runtime dependency [\#1726](https://github.com/voxpupuli/beaker/pull/1726) ([bastelfreak](https://github.com/bastelfreak))
|
91
|
+
|
92
|
+
## [4.32.0](https://github.com/voxpupuli/beaker/tree/4.32.0) (2021-12-06)
|
93
|
+
|
94
|
+
[Full Changelog](https://github.com/voxpupuli/beaker/compare/4.31.0...4.32.0)
|
95
|
+
|
96
|
+
**Implemented enhancements:**
|
97
|
+
|
98
|
+
- Initial EL9 support [\#1719](https://github.com/voxpupuli/beaker/pull/1719) ([ekohl](https://github.com/ekohl))
|
99
|
+
|
100
|
+
**Fixed bugs:**
|
101
|
+
|
102
|
+
- Arch Linux: install net-tools and openssh [\#1722](https://github.com/voxpupuli/beaker/pull/1722) ([bastelfreak](https://github.com/bastelfreak))
|
103
|
+
|
1
104
|
## [4.31.0](https://github.com/voxpupuli/beaker/tree/4.31.0) (2021-11-02)
|
2
105
|
|
3
106
|
### Fixed
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'beaker-hostgenerator'
|
|
4
4
|
require 'beaker'
|
5
5
|
HOSTS_PRESERVED = 'log/latest/hosts_preserved.yml'
|
6
6
|
|
7
|
-
task :default => [
|
7
|
+
task :default => ['test:spec']
|
8
8
|
|
9
9
|
task :test do
|
10
10
|
Rake::Task['test:spec'].invoke
|
@@ -14,9 +14,7 @@ task :spec do
|
|
14
14
|
Rake::Task['test:spec'].invoke
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
task :acceptance => ['test:base', 'test:puppetgit', 'test:hypervisor']
|
19
|
-
|
17
|
+
task :acceptance => ['test:base', 'test:hypervisor']
|
20
18
|
|
21
19
|
task :yard do
|
22
20
|
Rake::Task['docs:gen'].invoke
|
@@ -28,16 +26,16 @@ end
|
|
28
26
|
|
29
27
|
module HarnessOptions
|
30
28
|
defaults = {
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
:tests => ['tests'],
|
30
|
+
:log_level => 'debug',
|
31
|
+
:preserve_hosts => 'onfail',
|
34
32
|
}
|
35
33
|
|
36
34
|
DEFAULTS = defaults
|
37
35
|
|
38
36
|
def self.get_options(file_path)
|
39
37
|
puts "Attempting to merge config file: #{file_path}"
|
40
|
-
if File.
|
38
|
+
if File.exist? file_path
|
41
39
|
options = eval(File.read(file_path), binding)
|
42
40
|
else
|
43
41
|
puts "No options file found at #{File.expand_path(file_path)}... skipping"
|
@@ -60,31 +58,28 @@ module HarnessOptions
|
|
60
58
|
final_options.merge!(intermediary_options)
|
61
59
|
final_options.merge!(local_overrides)
|
62
60
|
end
|
63
|
-
|
64
61
|
end
|
65
62
|
|
66
63
|
def hosts_file_env
|
67
|
-
ENV
|
64
|
+
ENV.fetch('BEAKER_HOSTS', nil)
|
68
65
|
end
|
69
66
|
|
70
|
-
def hosts_opt(use_preserved_hosts=false)
|
67
|
+
def hosts_opt(use_preserved_hosts = false)
|
71
68
|
if use_preserved_hosts
|
72
69
|
"--hosts=#{HOSTS_PRESERVED}"
|
70
|
+
elsif hosts_file_env
|
71
|
+
"--hosts=#{hosts_file_env}"
|
73
72
|
else
|
74
|
-
|
75
|
-
"--hosts=#{hosts_file_env}"
|
76
|
-
else
|
77
|
-
"--hosts=tmp/#{HOSTS_FILE}"
|
78
|
-
end
|
73
|
+
"--hosts=tmp/#{HOSTS_FILE}"
|
79
74
|
end
|
80
75
|
end
|
81
76
|
|
82
77
|
def agent_target
|
83
|
-
ENV['TEST_TARGET'] || '
|
78
|
+
ENV['TEST_TARGET'] || 'centos7-64af'
|
84
79
|
end
|
85
80
|
|
86
81
|
def master_target
|
87
|
-
ENV['MASTER_TEST_TARGET'] || '
|
82
|
+
ENV['MASTER_TEST_TARGET'] || 'centos7-64default.mdcal'
|
88
83
|
end
|
89
84
|
|
90
85
|
def test_targets
|
@@ -94,11 +89,10 @@ end
|
|
94
89
|
HOSTS_FILE = "#{test_targets}-#{SecureRandom.uuid}.yaml"
|
95
90
|
|
96
91
|
def beaker_test(mode = :base, options = {})
|
97
|
-
|
98
92
|
preserved_hosts_mode = options[:hosts] == HOSTS_PRESERVED
|
99
93
|
final_options = HarnessOptions.final_options(mode, options)
|
100
94
|
|
101
|
-
options_opt
|
95
|
+
options_opt = ""
|
102
96
|
# preserved hosts can not be used with an options file (BKR-670)
|
103
97
|
# one can still use OPTIONS
|
104
98
|
|
@@ -106,94 +100,88 @@ def beaker_test(mode = :base, options = {})
|
|
106
100
|
options_file = 'merged_options.rb'
|
107
101
|
options_opt = "--options-file=#{options_file}"
|
108
102
|
File.open(options_file, 'w') do |merged|
|
109
|
-
merged.puts
|
110
|
-
# Copy this file to local_options.rb and adjust as needed if you wish to run
|
111
|
-
# with some local overrides.
|
103
|
+
merged.puts <<~EOS
|
104
|
+
# Copy this file to local_options.rb and adjust as needed if you wish to run
|
105
|
+
# with some local overrides.
|
112
106
|
EOS
|
113
107
|
merged.puts(final_options)
|
114
108
|
end
|
115
109
|
end
|
116
110
|
|
117
|
-
tests = ENV['TESTS'] || ENV
|
111
|
+
tests = ENV['TESTS'] || ENV.fetch('TEST', nil)
|
118
112
|
tests_opt = ""
|
119
113
|
tests_opt = "--tests=#{tests}" if tests
|
120
114
|
|
121
115
|
overriding_options = ENV['OPTIONS'].to_s
|
122
116
|
|
123
|
-
args = [options_opt, hosts_opt(preserved_hosts_mode), tests_opt,
|
124
|
-
*overriding_options.split(' ')].compact
|
117
|
+
args = [options_opt, hosts_opt(preserved_hosts_mode), tests_opt, *overriding_options.split(' ')].compact
|
125
118
|
|
126
119
|
sh("beaker", *args)
|
127
120
|
end
|
128
121
|
|
129
|
-
|
130
122
|
namespace :test do
|
131
|
-
USAGE =
|
132
|
-
You may set BEAKER_HOSTS=config/nodes/foo.yaml or include it in an acceptance-options.rb for Beaker,
|
133
|
-
or specify TEST_TARGET in a form beaker-hostgenerator accepts, e.g. ubuntu1504-64a.
|
134
|
-
You may override the default master test target by specifying MASTER_TEST_TARGET.
|
135
|
-
You may set TESTS=path/to/test,and/more/tests.
|
136
|
-
You may set additional Beaker OPTIONS='--more --options'
|
137
|
-
If there is a Beaker options hash in a ./acceptance/local_options.rb, it will be included.
|
138
|
-
Commandline options set through the above environment variables will override settings in this file.
|
123
|
+
USAGE = <<~EOS
|
124
|
+
You may set BEAKER_HOSTS=config/nodes/foo.yaml or include it in an acceptance-options.rb for Beaker,
|
125
|
+
or specify TEST_TARGET in a form beaker-hostgenerator accepts, e.g. ubuntu1504-64a.
|
126
|
+
You may override the default master test target by specifying MASTER_TEST_TARGET.
|
127
|
+
You may set TESTS=path/to/test,and/more/tests.
|
128
|
+
You may set additional Beaker OPTIONS='--more --options'
|
129
|
+
If there is a Beaker options hash in a ./acceptance/local_options.rb, it will be included.
|
130
|
+
Commandline options set through the above environment variables will override settings in this file.
|
139
131
|
EOS
|
140
132
|
|
141
133
|
desc 'Run specs and check for deprecation warnings'
|
142
134
|
task :spec do
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
135
|
+
Dir.chdir(__dir__) do
|
136
|
+
exit_status = 1
|
137
|
+
output = ''
|
138
|
+
Open3.popen3("bundle exec rspec") do |_stdin, stdout, _stderr, wait_thr|
|
139
|
+
while (line = stdout.gets)
|
140
|
+
puts line
|
141
|
+
end
|
142
|
+
output = stdout.to_s
|
143
|
+
fail "Failed to 'bundle exec rspec' (exit status: #{wait_thr.value})" if not wait_thr.value.success?
|
144
|
+
|
145
|
+
exit_status = wait_thr.value
|
154
146
|
end
|
155
|
-
exit_status
|
156
|
-
|
157
|
-
|
158
|
-
#check for deprecation warnings
|
159
|
-
if output =~ /Deprecation Warnings/
|
160
|
-
fail "DEPRECATION WARNINGS in spec generation, please fix!"
|
147
|
+
if exit_status != /0/
|
148
|
+
# check for deprecation warnings
|
149
|
+
fail "DEPRECATION WARNINGS in spec generation, please fix!" if output.include?('Deprecation Warnings')
|
161
150
|
end
|
162
151
|
end
|
163
|
-
Dir.chdir( original_dir )
|
164
152
|
end
|
165
153
|
|
166
|
-
desc
|
167
|
-
Run the base beaker acceptance tests
|
168
|
-
#{USAGE}
|
154
|
+
desc <<~EOS
|
155
|
+
Run the base beaker acceptance tests
|
156
|
+
#{USAGE}
|
169
157
|
EOS
|
170
|
-
task :base
|
158
|
+
task :base => 'gen_hosts' do
|
171
159
|
beaker_test(:base)
|
172
160
|
end
|
173
161
|
|
174
|
-
desc
|
175
|
-
Run the subcommand beaker acceptance tests
|
176
|
-
#{USAGE}
|
162
|
+
desc <<~EOS
|
163
|
+
Run the subcommand beaker acceptance tests
|
164
|
+
#{USAGE}
|
177
165
|
EOS
|
178
166
|
task :subcommands => 'gen_hosts' do
|
179
167
|
beaker_test(:subcommands)
|
180
168
|
end
|
181
169
|
|
182
|
-
desc
|
183
|
-
Run the hypervisor beaker acceptance tests
|
184
|
-
#{USAGE}
|
170
|
+
desc <<~EOS
|
171
|
+
Run the hypervisor beaker acceptance tests
|
172
|
+
#{USAGE}
|
185
173
|
EOS
|
186
|
-
task :hypervisor
|
174
|
+
task :hypervisor => 'gen_hosts' do
|
187
175
|
beaker_test(:hypervisor)
|
188
176
|
end
|
189
177
|
|
190
|
-
|
191
178
|
desc 'Generate Beaker Host Config File'
|
192
179
|
task :gen_hosts do
|
193
|
-
if hosts_file_env
|
194
|
-
|
195
|
-
|
196
|
-
|
180
|
+
next if hosts_file_env
|
181
|
+
|
182
|
+
arguments = [test_targets]
|
183
|
+
arguments += ['--hypervisor', ENV['BEAKER_HYPERVISOR']] if ENV['BEAKER_HYPERVISOR']
|
184
|
+
cli = BeakerHostGenerator::CLI.new(arguments)
|
197
185
|
FileUtils.mkdir_p('tmp') # -p ignores when dir already exists
|
198
186
|
File.open("tmp/#{HOSTS_FILE}", 'w') do |fh|
|
199
187
|
fh.print(cli.execute)
|
@@ -201,7 +189,6 @@ Run the hypervisor beaker acceptance tests
|
|
201
189
|
end
|
202
190
|
end
|
203
191
|
|
204
|
-
|
205
192
|
###########################################################
|
206
193
|
#
|
207
194
|
# History Tasks
|
@@ -210,16 +197,12 @@ end
|
|
210
197
|
namespace :history do
|
211
198
|
desc 'Generate HISTORY.md'
|
212
199
|
task :gen do
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
if output !~ /success/
|
218
|
-
raise "History generation failed"
|
200
|
+
Dir.chdir(__dir__) do
|
201
|
+
output = `bundle exec ruby history.rb .`
|
202
|
+
puts output
|
203
|
+
raise "History generation failed" if !output.include?('success')
|
219
204
|
end
|
220
|
-
Dir.chdir( original_dir )
|
221
205
|
end
|
222
|
-
|
223
206
|
end
|
224
207
|
|
225
208
|
###########################################################
|
@@ -231,62 +214,53 @@ DOCS_DIR = 'yard_docs'
|
|
231
214
|
DOCS_DAEMON = "yard server --reload --daemon --docroot #{DOCS_DIR}"
|
232
215
|
FOREGROUND_SERVER = "bundle exec yard server --reload --verbose lib/beaker --docroot #{DOCS_DIR}"
|
233
216
|
|
234
|
-
def running?(
|
217
|
+
def running?(cmdline)
|
235
218
|
ps = `ps -ef`
|
236
|
-
found = ps.lines.grep(
|
237
|
-
if found.length > 1
|
238
|
-
raise StandardError, "Found multiple YARD Servers. Don't know what to do."
|
239
|
-
end
|
219
|
+
found = ps.lines.grep(/#{Regexp.quote(cmdline)}/)
|
220
|
+
raise StandardError, "Found multiple YARD Servers. Don't know what to do." if found.length > 1
|
240
221
|
|
241
222
|
yes = found.empty? ? false : true
|
242
223
|
return yes, found.first
|
243
224
|
end
|
244
225
|
|
245
|
-
def pid_from(
|
226
|
+
def pid_from(output)
|
246
227
|
output.squeeze(' ').strip.split(' ')[1]
|
247
228
|
end
|
248
229
|
|
249
230
|
desc 'Start the documentation server in the foreground'
|
250
231
|
task :docs => 'docs:clear' do
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
Dir.chdir( original_dir )
|
232
|
+
Dir.chdir(__dir__) do
|
233
|
+
sh FOREGROUND_SERVER
|
234
|
+
end
|
255
235
|
end
|
256
236
|
|
257
237
|
namespace :docs do
|
258
|
-
|
259
238
|
desc 'Clear the generated documentation cache'
|
260
239
|
task :clear do
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
Dir.chdir( original_dir )
|
240
|
+
Dir.chdir(__dir__) do
|
241
|
+
sh "rm -rf #{DOCS_DIR}"
|
242
|
+
end
|
265
243
|
end
|
266
244
|
|
267
245
|
desc 'Generate static documentation'
|
268
246
|
task :gen => 'docs:clear' do
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
if output =~ /\[warn\]|\[error\]/
|
274
|
-
fail "Errors/Warnings during yard documentation generation"
|
247
|
+
Dir.chdir(__dir__) do
|
248
|
+
output = `bundle exec yard doc -o #{DOCS_DIR}`
|
249
|
+
puts output
|
250
|
+
fail "Errors/Warnings during yard documentation generation" if /\[warn\]|\[error\]/.match?(output)
|
275
251
|
end
|
276
|
-
Dir.chdir( original_dir )
|
277
252
|
end
|
278
253
|
|
279
254
|
desc 'Run the documentation server in the background, alias `bg`'
|
280
255
|
task :background => 'docs:clear' do
|
281
|
-
yes, output = running?(
|
256
|
+
yes, output = running?(DOCS_DAEMON)
|
282
257
|
if yes
|
283
258
|
puts "Not starting a new YARD Server..."
|
284
|
-
puts "Found one running with pid #{pid_from(
|
259
|
+
puts "Found one running with pid #{pid_from(output)}."
|
285
260
|
else
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
Dir.chdir( original_dir )
|
261
|
+
Dir.chdir(__dir__) do
|
262
|
+
sh "bundle exec #{DOCS_DAEMON}"
|
263
|
+
end
|
290
264
|
end
|
291
265
|
end
|
292
266
|
|
@@ -294,9 +268,9 @@ namespace :docs do
|
|
294
268
|
|
295
269
|
desc 'Check the status of the documentation server'
|
296
270
|
task :status do
|
297
|
-
yes, output = running?(
|
271
|
+
yes, output = running?(DOCS_DAEMON)
|
298
272
|
if yes
|
299
|
-
pid = pid_from(
|
273
|
+
pid = pid_from(output)
|
300
274
|
puts "Found a YARD Server running with pid #{pid}"
|
301
275
|
else
|
302
276
|
puts "Could not find a running YARD Server."
|
@@ -305,16 +279,16 @@ namespace :docs do
|
|
305
279
|
|
306
280
|
desc "Stop a running YARD Server"
|
307
281
|
task :stop do
|
308
|
-
yes, output = running?(
|
282
|
+
yes, output = running?(DOCS_DAEMON)
|
309
283
|
if yes
|
310
|
-
pid = pid_from(
|
284
|
+
pid = pid_from(output)
|
311
285
|
puts "Found a YARD Server running with pid #{pid}"
|
312
286
|
`kill #{pid}`
|
313
287
|
puts "Stopping..."
|
314
|
-
yes,
|
288
|
+
yes, _output = running?(DOCS_DAEMON)
|
315
289
|
if yes
|
316
290
|
`kill -9 #{pid}`
|
317
|
-
yes,
|
291
|
+
yes, _output = running?(DOCS_DAEMON)
|
318
292
|
if yes
|
319
293
|
puts "Could not Stop Server!"
|
320
294
|
else
|
@@ -341,4 +315,19 @@ begin
|
|
341
315
|
config.future_release = gem_version
|
342
316
|
end
|
343
317
|
rescue LoadError
|
318
|
+
# Optional group in bundler
|
319
|
+
end
|
320
|
+
|
321
|
+
begin
|
322
|
+
require 'rubocop/rake_task'
|
323
|
+
rescue LoadError
|
324
|
+
# RuboCop is an optional group
|
325
|
+
else
|
326
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
327
|
+
# These make the rubocop experience maybe slightly less terrible
|
328
|
+
task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
|
329
|
+
|
330
|
+
# Use Rubocop's Github Actions formatter if possible
|
331
|
+
task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true'
|
332
|
+
end
|
344
333
|
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
}.merge(eval File.read('acceptance/config/acceptance-options.rb'))
|
2
|
+
:tests => 'acceptance/tests/base',
|
3
|
+
}.merge(eval File.read('acceptance/config/acceptance-options.rb'))
|
@@ -1,3 +1,3 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
}.merge(eval File.read('acceptance/config/acceptance-options.rb'))
|
2
|
+
:tests => 'acceptance/tests/hypervisor',
|
3
|
+
}.merge(eval File.read('acceptance/config/acceptance-options.rb'))
|
@@ -1,10 +1,10 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
|
4
|
+
gem 'facter', '>= 1.7.0'
|
4
5
|
gem 'puppet', puppetversion
|
5
6
|
gem 'puppetlabs_spec_helper', '>= 0.1.0'
|
6
7
|
gem 'puppet-lint', '>= 0.3.2'
|
7
|
-
gem 'facter', '>= 1.7.0'
|
8
8
|
|
9
9
|
group :system_tests do
|
10
10
|
gem 'beaker-rspec', :require => false
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'puppetlabs_spec_helper/rake_tasks'
|
3
3
|
require 'puppet-lint/tasks/puppet-lint'
|
4
|
-
PuppetLint.configuration.send(
|
4
|
+
PuppetLint.configuration.send(:disable_80chars)
|
5
5
|
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
|
6
6
|
|
7
7
|
desc "Validate manifests, templates, and ruby files"
|
@@ -9,8 +9,8 @@ task :validate do
|
|
9
9
|
Dir['manifests/**/*.pp'].each do |manifest|
|
10
10
|
sh "puppet parser validate --noop #{manifest}"
|
11
11
|
end
|
12
|
-
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
|
13
|
-
sh "ruby -c #{ruby_file}" unless ruby_file
|
12
|
+
Dir['spec/**/*.rb', 'lib/**/*.rb'].each do |ruby_file|
|
13
|
+
sh "ruby -c #{ruby_file}" unless ruby_file.include?('spec/fixtures')
|
14
14
|
end
|
15
15
|
Dir['templates/**/*.erb'].each do |template|
|
16
16
|
sh "erb -P -x -T '-' #{template} | ruby -c"
|
@@ -1,55 +1,53 @@
|
|
1
1
|
require 'spec_helper_acceptance'
|
2
2
|
|
3
3
|
describe "my tests" do
|
4
|
-
|
5
4
|
# an example using the beaker DSL
|
6
5
|
# use http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL
|
7
|
-
it "
|
8
|
-
result = shell(
|
6
|
+
it "says hello!" do
|
7
|
+
result = shell('echo hello')
|
9
8
|
expect(result.stdout).to match(/hello/)
|
10
9
|
end
|
11
10
|
|
12
11
|
# an example using Serverspec
|
13
12
|
# use http://serverspec.org/resource_types.html
|
14
13
|
describe package('puppet') do
|
15
|
-
it {
|
14
|
+
it { is_expected.to be_installed }
|
16
15
|
end
|
17
16
|
|
18
17
|
it "can create and confirm a file" do
|
19
|
-
shell(
|
18
|
+
shell('rm -f demo.txt')
|
20
19
|
create_remote_file(default, 'demo.txt', 'foo\nfoo\nfoo\n')
|
21
|
-
shell(
|
22
|
-
shell(
|
20
|
+
shell('grep foo demo.txt')
|
21
|
+
shell('grep bar demo.txt', :acceptable_exit_codes => [1])
|
23
22
|
end
|
24
23
|
|
25
|
-
it "
|
24
|
+
it "is able to apply manifests" do
|
26
25
|
manifest_1 = "user {'foo':
|
27
26
|
ensure => present,}"
|
28
27
|
manifest_2 = "user {'foo':
|
29
28
|
ensure => absent,}"
|
30
29
|
manifest_3 = "user {'root':
|
31
30
|
ensure => present,}"
|
32
|
-
apply_manifest(
|
33
|
-
apply_manifest(
|
34
|
-
apply_manifest(
|
31
|
+
apply_manifest(manifest_1, :expect_changes => true)
|
32
|
+
apply_manifest(manifest_2, :expect_changes => true)
|
33
|
+
apply_manifest(manifest_3)
|
35
34
|
end
|
36
35
|
|
37
36
|
describe service('sshd') do
|
38
|
-
it {
|
37
|
+
it { is_expected.to be_running }
|
39
38
|
end
|
40
39
|
|
41
40
|
describe user('root') do
|
42
|
-
it {
|
41
|
+
it { is_expected.to exist }
|
43
42
|
end
|
44
43
|
|
45
44
|
describe user('foo') do
|
46
|
-
it {
|
45
|
+
it { is_expected.not_to exist }
|
47
46
|
end
|
48
47
|
|
49
48
|
context "can use both serverspec and Beaker DSL" do
|
50
|
-
|
51
49
|
it "can create a file" do
|
52
|
-
shell(
|
50
|
+
shell('rm -f /tmp/demo.txt')
|
53
51
|
manifest = "file {'demofile':
|
54
52
|
path => '/tmp/demo.txt',
|
55
53
|
ensure => present,
|
@@ -60,13 +58,8 @@ describe "my tests" do
|
|
60
58
|
end
|
61
59
|
|
62
60
|
describe file('/tmp/demo.txt') do
|
63
|
-
it {
|
64
|
-
|
65
|
-
|
66
|
-
describe file('/tmp/demo.txt') do
|
67
|
-
it { should contain 'this is my file.' }
|
61
|
+
it { is_expected.to be_file }
|
62
|
+
it { is_expected.to contain 'this is my file.' }
|
68
63
|
end
|
69
64
|
end
|
70
|
-
|
71
|
-
|
72
65
|
end
|