beaker 3.35.0 → 4.0.0

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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +32 -9
  3. data/CHANGELOG.md +56 -1
  4. data/CONTRIBUTING.md +82 -32
  5. data/DOCUMENTING.md +68 -44
  6. data/README.md +14 -31
  7. data/acceptance/lib/helpers/test_helper.rb +0 -28
  8. data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -1
  9. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
  10. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +106 -103
  11. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +5 -5
  12. data/acceptance/tests/base/dsl/helpers/host_helpers/install_package_test.rb +1 -50
  13. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
  14. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +71 -27
  15. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +3 -3
  16. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -3
  17. data/acceptance/tests/base/host/file_test.rb +81 -0
  18. data/beaker.gemspec +7 -15
  19. data/docs/README.md +5 -12
  20. data/docs/concepts/beaker_libraries.md +2 -2
  21. data/docs/concepts/glossary.md +11 -0
  22. data/docs/concepts/style_guide.md +24 -91
  23. data/docs/concepts/test_tagging.md +3 -10
  24. data/docs/concepts/testing_beaker_itself.md +3 -2
  25. data/docs/concepts/ticket_process.md +17 -45
  26. data/docs/how_to/archive_sut_files.md +7 -33
  27. data/docs/how_to/change_terminal_output_coloring.md +7 -4
  28. data/docs/how_to/confine.md +5 -16
  29. data/docs/how_to/debug_beaker_tests.md +14 -6
  30. data/docs/how_to/hosts/README.md +2 -5
  31. data/docs/how_to/hosts/archlinux.md +4 -2
  32. data/docs/how_to/hosts/cisco.md +9 -30
  33. data/docs/how_to/hosts/eos.md +5 -14
  34. data/docs/how_to/hypervisors/README.md +18 -36
  35. data/docs/how_to/install_puppet.md +18 -51
  36. data/docs/how_to/platform_specific_tag_confines.md +11 -31
  37. data/docs/how_to/preserve_hosts.md +13 -54
  38. data/docs/how_to/rake_tasks.md +1 -4
  39. data/docs/how_to/recipes.md +9 -2
  40. data/docs/how_to/run_in_parallel.md +10 -10
  41. data/docs/how_to/ssh_agent_forwarding.md +8 -13
  42. data/docs/how_to/ssh_connection_preference.md +10 -10
  43. data/docs/how_to/test_arbitrary_beaker_versions.md +5 -12
  44. data/docs/how_to/the_beaker_dsl.md +207 -184
  45. data/docs/how_to/upgrade_from_2_to_3.md +13 -53
  46. data/docs/how_to/upgrade_from_3_to_4.md +52 -0
  47. data/docs/how_to/use_hocon_helpers.md +10 -28
  48. data/docs/how_to/use_user_password_authentication.md +13 -10
  49. data/docs/how_to/write_a_beaker_test_for_a_module.md +6 -2
  50. data/docs/tutorials/README.md +14 -55
  51. data/docs/tutorials/creating_a_test_environment.md +47 -52
  52. data/docs/tutorials/installation.md +57 -21
  53. data/docs/tutorials/lets_write_a_test.md +8 -1
  54. data/docs/tutorials/quick_start_rake_tasks.md +63 -62
  55. data/docs/tutorials/subcommands.md +19 -32
  56. data/docs/tutorials/test_run.md +14 -16
  57. data/docs/tutorials/test_suites.md +14 -43
  58. data/docs/tutorials/the_command_line.md +14 -2
  59. data/lib/beaker/cli.rb +11 -24
  60. data/lib/beaker/dsl/helpers/host_helpers.rb +10 -34
  61. data/lib/beaker/dsl/helpers.rb +4 -6
  62. data/lib/beaker/dsl/install_utils.rb +0 -5
  63. data/lib/beaker/dsl/roles.rb +1 -1
  64. data/lib/beaker/dsl.rb +7 -0
  65. data/lib/beaker/host/aix/file.rb +2 -2
  66. data/lib/beaker/host/aix/group.rb +1 -0
  67. data/lib/beaker/host/aix/user.rb +1 -0
  68. data/lib/beaker/host/freebsd/pkg.rb +9 -0
  69. data/lib/beaker/host/mac/group.rb +1 -0
  70. data/lib/beaker/host/mac/user.rb +8 -13
  71. data/lib/beaker/host/pswindows/file.rb +2 -2
  72. data/lib/beaker/host/pswindows/group.rb +1 -0
  73. data/lib/beaker/host/pswindows/user.rb +1 -0
  74. data/lib/beaker/host/unix/exec.rb +5 -5
  75. data/lib/beaker/host/unix/file.rb +43 -2
  76. data/lib/beaker/host/unix/group.rb +1 -0
  77. data/lib/beaker/host/unix/pkg.rb +9 -2
  78. data/lib/beaker/host/unix/user.rb +1 -0
  79. data/lib/beaker/host/windows/file.rb +32 -2
  80. data/lib/beaker/host/windows/group.rb +1 -0
  81. data/lib/beaker/host/windows/user.rb +1 -0
  82. data/lib/beaker/host.rb +12 -11
  83. data/lib/beaker/host_prebuilt_steps.rb +1 -5
  84. data/lib/beaker/hypervisor.rb +1 -5
  85. data/lib/beaker/logger.rb +1 -1
  86. data/lib/beaker/result.rb +4 -0
  87. data/lib/beaker/shared/fog_credentials.rb +61 -0
  88. data/lib/beaker/shared/host_manager.rb +6 -3
  89. data/lib/beaker/shared.rb +2 -1
  90. data/lib/beaker/subcommand.rb +5 -3
  91. data/lib/beaker/version.rb +1 -1
  92. data/lib/beaker.rb +0 -10
  93. data/spec/beaker/cli_spec.rb +21 -0
  94. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +14 -51
  95. data/spec/beaker/dsl/wrappers_spec.rb +0 -46
  96. data/spec/beaker/host/mac/user_spec.rb +5 -8
  97. data/spec/beaker/host/unix/exec_spec.rb +1 -1
  98. data/spec/beaker/host/unix/file_spec.rb +39 -0
  99. data/spec/beaker/host/unix/pkg_spec.rb +66 -17
  100. data/spec/beaker/host/unix_spec.rb +4 -4
  101. data/spec/beaker/host/windows/file_spec.rb +55 -0
  102. data/spec/beaker/host_prebuilt_steps_spec.rb +26 -73
  103. data/spec/beaker/host_spec.rb +10 -14
  104. data/spec/beaker/hypervisor/hypervisor_spec.rb +3 -3
  105. data/spec/beaker/logger_spec.rb +4 -0
  106. data/spec/beaker/shared/fog_credentials_spec.rb +100 -0
  107. data/spec/beaker/shared/host_manager_spec.rb +8 -0
  108. data/spec/beaker/subcommand_spec.rb +1 -0
  109. metadata +56 -165
  110. data/acceptance/lib/beaker/acceptance/install_utils.rb +0 -58
  111. data/acceptance/tests/base/dsl/helpers/host_helpers/create_tmpdir_on_test.rb +0 -68
  112. data/acceptance/tests/base/dsl/install_utils/clone_git_repo_on_test.rb +0 -49
  113. data/lib/beaker/dsl/helpers/facter_helpers.rb +0 -57
  114. data/lib/beaker/dsl/install_utils/pe_defaults.rb +0 -143
  115. data/lib/beaker/dsl/install_utils/windows_utils.rb +0 -223
  116. data/spec/beaker/dsl/ezbake_utils_spec.rb +0 -279
  117. data/spec/beaker/dsl/install_utils/pe_defaults_spec.rb +0 -61
  118. data/spec/beaker/dsl/install_utils/windows_utils_spec.rb +0 -263
@@ -3,14 +3,14 @@ require "helpers/test_helper"
3
3
  test_name "dsl::helpers::host_helpers #backup_the_file" do
4
4
  step "#backup_the_file CURRENTLY will return nil if the file does not exist in the source directory" do
5
5
  # NOTE: would expect this to fail with Beaker::Host::CommandFailure
6
- remote_source = tmpdir_on default
7
- remote_destination = tmpdir_on default
6
+ remote_source = default.tmpdir()
7
+ remote_destination = default.tmpdir()
8
8
  result = backup_the_file default, remote_source, remote_destination
9
9
  assert_nil result
10
10
  end
11
11
 
12
12
  step "#backup_the_file will fail if the destination directory does not exist" do
13
- remote_source = tmpdir_on default
13
+ remote_source = default.tmpdir()
14
14
  remote_source_filename = File.join(remote_source, "puppet.conf")
15
15
  remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")
16
16
 
@@ -20,11 +20,11 @@ test_name "dsl::helpers::host_helpers #backup_the_file" do
20
20
  end
21
21
 
22
22
  step "#backup_the_file copies `puppet.conf` from the source to the destination directory" do
23
- remote_source = tmpdir_on default
23
+ remote_source = default.tmpdir()
24
24
  remote_source_filename = File.join(remote_source, "puppet.conf")
25
25
  remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")
26
26
 
27
- remote_destination = tmpdir_on default
27
+ remote_destination = default.tmpdir()
28
28
  remote_destination_filename = File.join(remote_destination, "puppet.conf.bak")
29
29
 
30
30
  result = backup_the_file default, remote_source, remote_destination
@@ -35,11 +35,11 @@ test_name "dsl::helpers::host_helpers #backup_the_file" do
35
35
  end
36
36
 
37
37
  step "#backup_the_file copies a named file from the source to the destination directory" do
38
- remote_source = tmpdir_on default
38
+ remote_source = default.tmpdir()
39
39
  remote_source_filename = File.join(remote_source, "testfile.txt")
40
40
  remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "testfile.txt")
41
41
 
42
- remote_destination = tmpdir_on default
42
+ remote_destination = default.tmpdir()
43
43
  remote_destination_filename = File.join(remote_destination, "testfile.txt.bak")
44
44
 
45
45
  result = backup_the_file default, remote_source, remote_destination, "testfile.txt"
@@ -50,10 +50,10 @@ test_name "dsl::helpers::host_helpers #backup_the_file" do
50
50
  end
51
51
 
52
52
  step "#backup_the_file CURRENTLY will fail if given a hosts array" do
53
- remote_source = tmpdir_on default
53
+ remote_source = default.tmpdir()
54
54
  remote_source_filename = File.join(remote_source, "testfile.txt")
55
55
  remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "testfile.txt")
56
- remote_destination = tmpdir_on default
56
+ remote_destination = default.tmpdir()
57
57
 
58
58
  remote_destination_filename = File.join(remote_destination, "testfile.txt.bak")
59
59
 
@@ -2,14 +2,6 @@ require "helpers/test_helper"
2
2
 
3
3
  test_name "dsl::helpers::host_helpers #create_remote_file" do
4
4
 
5
- confine_block :to, :platform => /^centos|el-\d|fedora/ do
6
- step "installing `rsync` on #{default['platform']} for all later test steps" do
7
- hosts.each do |host|
8
- install_package host, "rsync"
9
- end
10
- end
11
- end
12
-
13
5
  if test_scp_error_on_close?
14
6
  step "#create_remote_file fails when the remote path does not exist" do
15
7
  assert_raises Beaker::Host::CommandFailure do
@@ -24,18 +16,8 @@ test_name "dsl::helpers::host_helpers #create_remote_file" do
24
16
  end
25
17
  end
26
18
 
27
- step "#create_remote_file CURRENTLY does not fail and does not create a remote file when the remote path does not exist, using rsync" do
28
- # NOTE: would expect this to fail with Beaker::Host::CommandFailure
29
-
30
- create_remote_file default, "/non/existent/testfile.txt", "contents\n", { :protocol => 'rsync' }
31
-
32
- assert_raises Beaker::Host::CommandFailure do
33
- on(default, "cat /non/existent/testfile.txt").exit_code
34
- end
35
- end
36
-
37
19
  step "#create_remote_file creates a remote file with the specified contents" do
38
- remote_tmpdir = tmpdir_on default
20
+ remote_tmpdir = default.tmpdir("beaker")
39
21
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
40
22
  contents = fixture_contents("simple_text_file")
41
23
 
@@ -46,7 +28,7 @@ test_name "dsl::helpers::host_helpers #create_remote_file" do
46
28
  end
47
29
 
48
30
  step "#create_remote_file creates a remote file with the specified contents, using scp" do
49
- remote_tmpdir = tmpdir_on default
31
+ remote_tmpdir = default.tmpdir("beaker")
50
32
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
51
33
  contents = fixture_contents("simple_text_file")
52
34
 
@@ -56,62 +38,15 @@ test_name "dsl::helpers::host_helpers #create_remote_file" do
56
38
  assert_equal contents, remote_contents
57
39
  end
58
40
 
59
- # NOTE: there does not seem to be a reliable way to confine to cygwin hosts.
60
- confine_block :to, :platform => /windows/ do
61
-
62
- # NOTE: rsync methods are not working currently on windows platforms
63
-
64
- step "#create_remote_file CURRENTLY fails on #{default['platform']}, using rsync" do
65
- remote_tmpdir = tmpdir_on default
66
- remote_filename = File.join(remote_tmpdir, "testfile.txt")
67
- contents = fixture_contents("simple_text_file")
68
-
69
- create_remote_file default, remote_filename, contents, { :protocol => "rsync" }
70
-
71
- assert_raises Beaker::Host::CommandFailure do
72
- remote_contents = on(default, "cat #{remote_filename}").stdout
73
- end
74
- end
75
- end
76
-
77
- confine_block :except, :platform => /windows/ do
78
-
79
- step "#create_remote_file creates a remote file with the specified contents, using rsync" do
80
- remote_tmpdir = tmpdir_on default
81
- remote_filename = File.join(remote_tmpdir, "testfile.txt")
82
- contents = fixture_contents("simple_text_file")
83
-
84
- result = create_remote_file default, remote_filename, contents, { :protocol => "rsync" }
85
-
86
- fails_intermittently("https://tickets.puppetlabs.com/browse/BKR-612",
87
- "default" => default,
88
- "remote_tmpdir" => remote_tmpdir,
89
- "remote_filename" => remote_filename,
90
- "contents" => contents,
91
- "result" => result
92
- ) do
93
- remote_contents = on(default, "cat #{remote_filename}").stdout
94
- assert_equal contents, remote_contents
95
- end
96
- end
97
- end
98
-
99
- step "#create_remote_file' does not create a remote file when an unknown protocol is specified" do
100
- remote_tmpdir = tmpdir_on default
101
- remote_filename = File.join(remote_tmpdir, "testfile.txt")
102
- contents = fixture_contents("simple_text_file")
103
-
104
- create_remote_file default, remote_filename, contents, { :protocol => 'unknown' }
105
-
106
- assert_raises Beaker::Host::CommandFailure do
107
- on(default, "cat #{remote_filename}").exit_code
41
+ step "#create_remote_file creates remote files on all remote hosts, when given an array" do
42
+ remote_dir = "/tmp/beaker_remote_file_test"
43
+ # ensure remote dir exists on all hosts
44
+ hosts.each do |host|
45
+ # we can't use tmpdir here, because some hosts may have different tmpdir behavior.
46
+ host.mkdir_p(remote_dir)
108
47
  end
109
- end
110
48
 
111
- step "#create_remote_file creates remote files on all remote hosts, when given an array" do
112
- remote_tmpdir = tmpdir_on default
113
- on hosts, "mkdir -p #{remote_tmpdir}"
114
- remote_filename = File.join(remote_tmpdir, "testfile.txt")
49
+ remote_filename = File.join(remote_dir, "testfile.txt")
115
50
  contents = fixture_contents("simple_text_file")
116
51
 
117
52
  create_remote_file hosts, remote_filename, contents
@@ -123,9 +58,14 @@ test_name "dsl::helpers::host_helpers #create_remote_file" do
123
58
  end
124
59
 
125
60
  step "#create_remote_file creates remote files on all remote hosts, when given an array, using scp" do
126
- remote_tmpdir = tmpdir_on default
127
- on hosts, "mkdir -p #{remote_tmpdir}"
128
- remote_filename = File.join(remote_tmpdir, "testfile.txt")
61
+ remote_dir = "/tmp/beaker_remote_file_test"
62
+ # ensure remote dir exists on all hosts
63
+ hosts.each do |host|
64
+ # we can't use tmpdir here, because some hosts may have different tmpdir behavior.
65
+ host.mkdir_p(remote_dir)
66
+ end
67
+
68
+ remote_filename = File.join(remote_dir, "testfile.txt")
129
69
  contents = fixture_contents("simple_text_file")
130
70
 
131
71
  create_remote_file hosts, remote_filename, contents, { :protocol => 'scp' }
@@ -136,35 +76,63 @@ test_name "dsl::helpers::host_helpers #create_remote_file" do
136
76
  end
137
77
  end
138
78
 
139
- # NOTE: there does not appear to be a way to confine just to cygwin hosts
140
- confine_block :to, :platform => /windows/ do
141
79
 
142
- # NOTE: rsync methods are not working currently on windows
143
- # platforms. Would expect this to be documented better.
80
+ confine_block :except, :platform => /windows/ do
81
+ # these tests exercise the rsync backend
82
+ # NOTE: rsync works fine on Windows as long as you use POSIX-style paths.
83
+ # However, these tests use Host#tmpdir which outputs mixed-style paths
84
+ # e.g. C:/cygwin64/tmp/beaker.Rp9G6L - Fix me with BKR-1503
85
+
86
+ confine_block :except, :platform => /osx/ do
87
+ # packages are unsupported on OSX
88
+ step "installing rsync on hosts if needed" do
89
+ hosts.each do |host|
90
+ if host.check_for_package('rsync')
91
+ host[:rsync_installed] = true
92
+ else
93
+ host[:rsync_installed] = false
94
+ host.install_package "rsync"
95
+ end
96
+ end
97
+ end
98
+ end
144
99
 
145
- step "#create_remote_file creates remote files on all remote hosts, when given an array, using rsync" do
146
- remote_tmpdir = tmpdir_on default
147
- on hosts, "mkdir -p #{remote_tmpdir}"
100
+ step "#create_remote_file fails and does not create a remote file when the remote path does not exist, using rsync" do
101
+ assert_raises Beaker::Host::CommandFailure do
102
+ create_remote_file default, "/non/existent/testfile.txt", "contents\n", { :protocol => 'rsync' }
103
+ end
104
+
105
+ assert_raises Beaker::Host::CommandFailure do
106
+ on(default, "cat /non/existent/testfile.txt").exit_code
107
+ end
108
+ end
109
+
110
+ step "#create_remote_file creates a remote file with the specified contents, using rsync" do
111
+ remote_tmpdir = default.tmpdir("beaker")
148
112
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
149
113
  contents = fixture_contents("simple_text_file")
150
114
 
151
- create_remote_file hosts, remote_filename, contents, { :protocol => 'rsync' }
115
+ result = create_remote_file default, remote_filename, contents, { :protocol => "rsync" }
152
116
 
153
- hosts.each do |host|
154
- assert_raises Beaker::Host::CommandFailure do
155
- remote_contents = on(host, "cat #{remote_filename}").stdout
156
- end
117
+ fails_intermittently("https://tickets.puppetlabs.com/browse/BKR-612",
118
+ "default" => default,
119
+ "remote_tmpdir" => remote_tmpdir,
120
+ "remote_filename" => remote_filename,
121
+ "contents" => contents,
122
+ "result" => result
123
+ ) do
124
+ remote_contents = on(default, "cat #{remote_filename}").stdout
125
+ assert_equal contents, remote_contents
157
126
  end
158
127
  end
159
- end
160
-
161
- confine_block :except, :platform => /windows|fedora/ do
162
128
 
163
129
  step "#create_remote_file creates remote files on all remote hosts, when given an array, using rsync" do
164
- remote_tmpdir = tmpdir_on default
165
-
166
- # NOTE: we do not do this step in the non-hosts-array version of the test, not sure why
167
- on hosts, "mkdir -p #{remote_tmpdir}"
130
+ remote_tmpdir = "/tmp/beaker_remote_file_test"
131
+ # ensure remote dir exists on all hosts
132
+ hosts.each do |host|
133
+ # we can't use tmpdir here, because some hosts may have different tmpdir behavior.
134
+ host.mkdir_p(remote_tmpdir)
135
+ end
168
136
 
169
137
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
170
138
  contents = fixture_contents("simple_text_file")
@@ -184,17 +152,52 @@ test_name "dsl::helpers::host_helpers #create_remote_file" do
184
152
  end
185
153
  end
186
154
  end
155
+
156
+ confine_block :except, :platform => /osx/ do
157
+ # packages are unsupported on OSX
158
+ step "uninstalling rsync on hosts if needed" do
159
+ hosts.each do |host|
160
+ if !host[:rsync_installed]
161
+ # rsync wasn't installed on #{host} when we started, so we should clean up after ourselves
162
+ rsync_package = "rsync"
163
+ # solaris-10 uses OpenCSW pkgutil, which prepends "CSW" to its provided packages
164
+ # TODO: fix this with BKR-1502
165
+ rsync_package = "CSWrsync" if host['platform'] =~ /solaris-10/
166
+ host.uninstall_package rsync_package
167
+ end
168
+ host.delete(:rsync_installed)
169
+ end
170
+ end
171
+ end
187
172
  end
188
173
 
189
- confine_block :to, :platform => /centos|el-\d|fedora/ do
174
+ step "#create_remote_file' does not create a remote file when an unknown protocol is specified" do
175
+ remote_tmpdir = default.tmpdir("beaker")
176
+ remote_filename = File.join(remote_tmpdir, "testfile.txt")
177
+ contents = fixture_contents("simple_text_file")
190
178
 
191
- step "uninstall rsync package on #{default['platform']} for later test runs" do
192
- # NOTE: this is basically a #teardown section for test isolation
193
- # Could we reorganize tests into different files to make this
194
- # clearer?
179
+ create_remote_file default, remote_filename, contents, { :protocol => 'unknown' }
195
180
 
196
- hosts.each do |host|
197
- on host, "yum -y remove rsync"
181
+ assert_raises Beaker::Host::CommandFailure do
182
+ on(default, "cat #{remote_filename}").exit_code
183
+ end
184
+ end
185
+
186
+ # NOTE: there does not appear to be a way to confine just to cygwin hosts
187
+ confine_block :to, :platform => /windows/ do
188
+ # NOTE: rsync works fine on Windows as long as you use POSIX-style paths.
189
+ # Fix me with BKR-1503
190
+ step "#create_remote_file CURRENTLY fails on #{default['platform']}, using rsync" do
191
+ remote_tmpdir = default.tmpdir("beaker")
192
+ remote_filename = File.join(remote_tmpdir, "testfile.txt")
193
+ contents = fixture_contents("simple_text_file")
194
+
195
+ assert_raises Beaker::Host::CommandFailure do
196
+ create_remote_file default, remote_filename, contents, { :protocol => "rsync" }
197
+ end
198
+
199
+ assert_raises Beaker::Host::CommandFailure do
200
+ remote_contents = on(default, "cat #{remote_filename}").stdout
198
201
  end
199
202
  end
200
203
  end
@@ -3,10 +3,10 @@ require "helpers/test_helper"
3
3
  # construct an appropriate local file URL for curl testing
4
4
  def host_local_url(host, path)
5
5
  if host.is_cygwin?
6
- "file://#{path.gsub('/', '\\\\\\\\')}"
7
- else
8
- "file://#{path}"
6
+ path_result = on(host, "cygpath #{path}")
7
+ path = path_result.raw_output.chomp
9
8
  end
9
+ "file://#{path}"
10
10
  end
11
11
 
12
12
  test_name "dsl::helpers::host_helpers #curl_on" do
@@ -17,7 +17,7 @@ test_name "dsl::helpers::host_helpers #curl_on" do
17
17
  end
18
18
 
19
19
  step "#curl_on can retrieve the contents of a URL, using standard curl options" do
20
- remote_tmpdir = tmpdir_on default
20
+ remote_tmpdir = default.tmpdir()
21
21
  remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")
22
22
  remote_targetfilename = File.join remote_tmpdir, "outfile.txt"
23
23
 
@@ -29,7 +29,7 @@ test_name "dsl::helpers::host_helpers #curl_on" do
29
29
  end
30
30
 
31
31
  step "#curl_on can retrieve the contents of a URL, when given a hosts array" do
32
- remote_tmpdir = tmpdir_on default
32
+ remote_tmpdir = default.tmpdir()
33
33
  on hosts, "mkdir -p #{remote_tmpdir}"
34
34
 
35
35
  remote_filename = contents = nil
@@ -1,54 +1,5 @@
1
1
  require "helpers/test_helper"
2
2
 
3
3
  test_name "dsl::helpers::host_helpers #install_package" do
4
-
5
- # NOTE: there does not appear to be a way to confine just to cygwin hosts
6
- confine_block :to, :platform => /windows/ do
7
-
8
- # NOTE: install_package on windows currently fails as follows:
9
- #
10
- # ArgumentError: wrong number of arguments (3 for 1..2)
11
- #
12
- # Would expect this to be documented better, and to fail with Beaker::Host::CommandFailure
13
-
14
- step "#install_package CURRENTLY fails on windows platforms" do
15
- assert_raises ArgumentError do
16
- install_package default, "rsync"
17
- end
18
- end
19
- end
20
-
21
- confine_block :to, :platform => /osx/ do
22
- # TODO: install_package on OSX installs via a .dmg file -- how to test this?
23
- end
24
-
25
- confine_block :except, :platform => /windows|osx/ do
26
-
27
- step "#install_package fails if package is not known on the OS" do
28
- assert_raises Beaker::Host::CommandFailure do
29
- install_package default, "non-existent-package-name"
30
- end
31
- end
32
-
33
- step "#install_package installs a known package successfully" do
34
- result = install_package default, "rsync"
35
- assert check_for_package(default, "rsync"), "package was not successfully installed"
36
- end
37
-
38
- step "#install_package succeeds when installing an already-installed package" do
39
- result = install_package default, "rsync"
40
- result = install_package default, "rsync"
41
- assert check_for_package(default, "rsync"), "package was not successfully installed"
42
- end
43
-
44
- step "#install_package CURRENTLY fails if given a host array" do
45
- # NOTE: would expect this to work across hosts, or to be better
46
- # documented. If not supported, should raise
47
- # Beaker::Host::CommandFailure
48
-
49
- assert_raises NoMethodError do
50
- install_package hosts, "rsync"
51
- end
52
- end
53
- end
4
+ step "#install_package is just a wrapper for Host#install_package, see acceptance/tests/base/host/packages.rb"
54
5
  end
@@ -4,7 +4,7 @@ test_name "dsl::helpers::host_helpers #retry_on" do
4
4
  step "#retry_on CURRENTLY fails with a RuntimeError if command does not pass after all retries" do
5
5
  # NOTE: would have expected this to fail with Beaker::Hosts::CommandFailure
6
6
 
7
- remote_tmpdir = tmpdir_on default
7
+ remote_tmpdir = default.tmpdir()
8
8
  remote_script_file = File.join(remote_tmpdir, "test.sh")
9
9
  remote_filename, contents = create_remote_file_from_fixture("retry_script", default, remote_tmpdir, "test.sh")
10
10
 
@@ -14,7 +14,7 @@ test_name "dsl::helpers::host_helpers #retry_on" do
14
14
  end
15
15
 
16
16
  step "#retry_on succeeds if command passes before retries are exhausted" do
17
- remote_tmpdir = tmpdir_on default
17
+ remote_tmpdir = default.tmpdir()
18
18
  remote_script_file = File.join(remote_tmpdir, "test.sh")
19
19
  remote_filename, contents = create_remote_file_from_fixture("retry_script", default, remote_tmpdir, "test.sh")
20
20
 
@@ -27,7 +27,7 @@ test_name "dsl::helpers::host_helpers #retry_on" do
27
27
  # NOTE: would expect this to work across hosts, or be better documented and
28
28
  # to raise Beaker::Host::CommandFailure
29
29
 
30
- remote_tmpdir = tmpdir_on default
30
+ remote_tmpdir = default.tmpdir()
31
31
  remote_script_file = File.join(remote_tmpdir, "test.sh")
32
32
 
33
33
  hosts.each do |host|
@@ -2,26 +2,21 @@ require "helpers/test_helper"
2
2
 
3
3
  test_name "dsl::helpers::host_helpers #rsync_to" do
4
4
 
5
- confine_block :to, :platform => /^centos|el-\d|fedora/ do
6
- step "installing `rsync` on #{default['platform']} for all later test steps" do
7
- hosts.each do |host|
8
- install_package host, "rsync"
9
- end
10
- end
11
- end
12
-
13
5
  # NOTE: there does not seem to be a reliable way to confine to cygwin hosts.
14
6
  confine_block :to, :platform => /windows/ do
15
7
 
16
- # NOTE: rsync methods are not working currently on windows platforms. Would
17
- # expect this to be documented better.
8
+ # NOTE: rsync works fine on Windows as long as you use POSIX-style paths.
9
+ # However, these tests use Host#tmpdir which outputs mixed-style paths
10
+ # e.g. C:/cygwin64/tmp/beaker.Rp9G6L - Fix me with BKR-1503
18
11
 
19
12
  step "#rsync_to CURRENTLY fails on windows systems" do
20
13
  Dir.mktmpdir do |local_dir|
21
14
  local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
22
- remote_tmpdir = tmpdir_on default
15
+ remote_tmpdir = default.tmpdir()
23
16
 
24
- rsync_to default, local_filename, remote_tmpdir
17
+ assert_raises Beaker::Host::CommandFailure do
18
+ rsync_to default, local_filename, remote_tmpdir
19
+ end
25
20
 
26
21
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
27
22
  assert_raises Beaker::Host::CommandFailure do
@@ -32,21 +27,65 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
32
27
  end
33
28
 
34
29
  confine_block :except, :platform => /windows/ do
30
+ # NOTE: rsync works fine on Windows as long as you use POSIX-style paths.
31
+ # However, these tests use Host#tmpdir which outputs mixed-style paths
32
+ # e.g. C:/cygwin64/tmp/beaker.Rp9G6L - Fix me with BKR-1503
35
33
 
36
34
  step "#rsync_to fails if the local file cannot be found" do
37
- remote_tmpdir = tmpdir_on default
35
+ remote_tmpdir = default.tmpdir()
38
36
  assert_raises IOError do
39
37
  rsync_to default, "/non/existent/file.txt", remote_tmpdir
40
38
  end
41
39
  end
42
40
 
43
- step "#rsync_to CURRENTLY does not fail, but does not copy the file if the remote path cannot be found" do
44
- # NOTE: would expect this to fail with Beaker::Host::CommandFailure
41
+ confine_block :except, :platform => /osx/ do
42
+ # packages are unsupported on OSX
45
43
 
44
+ step "uninstalling rsync on hosts if needed" do
45
+ hosts.each do |host|
46
+ if host.check_for_package('rsync')
47
+ host[:rsync_installed] = true
48
+ rsync_package = "rsync"
49
+ # solaris-10 uses OpenCSW pkgutil, which prepends "CSW" to its provided packages
50
+ # TODO: fix this with BKR-1502
51
+ rsync_package = "CSWrsync" if host['platform'] =~ /solaris-10/
52
+ host.uninstall_package rsync_package
53
+ else
54
+ host[:rsync_installed] = false
55
+ end
56
+ end
57
+ end
58
+
59
+ # rsync is preinstalled on OSX
60
+ step "#rsync_to fails if rsync is not installed on the remote host" do
61
+ Dir.mktmpdir do |local_dir|
62
+ local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
63
+
64
+ hosts.each do |host|
65
+ remote_tmpdir = host.tmpdir("beaker")
66
+ remote_filename = File.join(remote_tmpdir, "testfile.txt")
67
+
68
+ assert_raises Beaker::Host::CommandFailure do
69
+ rsync_to default, local_filename, remote_tmpdir
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ step "installing rsync on hosts" do
76
+ hosts.each do |host|
77
+ host.install_package "rsync"
78
+ end
79
+ end
80
+ end
81
+
82
+ step "#rsync_to fails if the remote path cannot be found" do
46
83
  Dir.mktmpdir do |local_dir|
47
84
  local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
48
85
 
49
- rsync_to default, local_filename, "/non/existent/testfile.txt"
86
+ assert_raises Beaker::Host::CommandFailure do
87
+ rsync_to default, local_filename, "/non/existent/testfile.txt"
88
+ end
50
89
  assert_raises Beaker::Host::CommandFailure do
51
90
  on(default, "cat /non/existent/testfile.txt").exit_code
52
91
  end
@@ -56,7 +95,7 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
56
95
  step "#rsync_to creates the file on the remote system" do
57
96
  Dir.mktmpdir do |local_dir|
58
97
  local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
59
- remote_tmpdir = tmpdir_on default
98
+ remote_tmpdir = default.tmpdir()
60
99
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
61
100
 
62
101
  result = rsync_to default, local_filename, remote_tmpdir
@@ -80,7 +119,7 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
80
119
  step "#rsync_to creates the file on all remote systems when a host array is provided" do
81
120
  Dir.mktmpdir do |local_dir|
82
121
  local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
83
- remote_tmpdir = tmpdir_on default
122
+ remote_tmpdir = default.tmpdir()
84
123
  on hosts, "mkdir -p #{remote_tmpdir}"
85
124
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
86
125
 
@@ -103,17 +142,22 @@ test_name "dsl::helpers::host_helpers #rsync_to" do
103
142
  end
104
143
  end
105
144
  end
106
- end
107
-
108
- confine_block :to, :platform => /centos|el-\d|fedora/ do
109
145
 
110
- step "uninstall rsync package on #{default['platform']} for later test runs" do
111
- # NOTE: this is basically a #teardown section for test isolation
112
- # Could we reorganize tests into different files to make this
113
- # clearer?
146
+ confine_block :except, :platform => /osx/ do
147
+ # packages are unsupported on OSX
114
148
 
115
- hosts.each do |host|
116
- on host, "yum -y remove rsync"
149
+ step "uninstalling rsync on hosts if needed" do
150
+ hosts.each do |host|
151
+ if !host[:rsync_installed]
152
+ # rsync wasn't installed on #{host} when we started, so we should clean up after ourselves
153
+ rsync_package = "rsync"
154
+ # solaris-10 uses OpenCSW pkgutil, which prepends "CSW" to its provided packages
155
+ # TODO: fix this with BKR-1502
156
+ rsync_package = "CSWrsync" if host['platform'] =~ /solaris-10/
157
+ host.uninstall_package rsync_package
158
+ end
159
+ host.delete(:rsync_installed)
160
+ end
117
161
  end
118
162
  end
119
163
  end
@@ -3,7 +3,7 @@ require "helpers/test_helper"
3
3
  test_name "dsl::helpers::host_helpers #scp_from" do
4
4
  if test_scp_error_on_close?
5
5
  step "#scp_from fails if the local path cannot be found" do
6
- remote_tmpdir = tmpdir_on default
6
+ remote_tmpdir = default.tmpdir()
7
7
  remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")
8
8
 
9
9
  assert_raises Beaker::Host::CommandFailure do
@@ -22,7 +22,7 @@ test_name "dsl::helpers::host_helpers #scp_from" do
22
22
 
23
23
  step "#scp_from creates the file on the local system" do
24
24
  Dir.mktmpdir do |local_dir|
25
- remote_tmpdir = tmpdir_on default
25
+ remote_tmpdir = default.tmpdir()
26
26
  remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")
27
27
 
28
28
  scp_from default, remote_filename, local_dir
@@ -37,7 +37,7 @@ test_name "dsl::helpers::host_helpers #scp_from" do
37
37
  # file repeatedly to generate an error
38
38
 
39
39
  Dir.mktmpdir do |local_dir|
40
- remote_tmpdir = tmpdir_on default
40
+ remote_tmpdir = default.tmpdir()
41
41
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
42
42
  on hosts, "mkdir -p #{remote_tmpdir}"
43
43
  results = on hosts, %Q{echo "${RANDOM}:${RANDOM}:${RANDOM}" > #{remote_filename}}
@@ -2,7 +2,7 @@ require "helpers/test_helper"
2
2
 
3
3
  test_name "dsl::helpers::host_helpers #scp_to" do
4
4
  step "#scp_to fails if the local file cannot be found" do
5
- remote_tmpdir = tmpdir_on default
5
+ remote_tmpdir = default.tmpdir()
6
6
  assert_raises IOError do
7
7
  scp_to default, "/non/existent/file.txt", remote_tmpdir
8
8
  end
@@ -24,7 +24,7 @@ test_name "dsl::helpers::host_helpers #scp_to" do
24
24
  step "#scp_to creates the file on the remote system" do
25
25
  Dir.mktmpdir do |local_dir|
26
26
  local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
27
- remote_tmpdir = tmpdir_on default
27
+ remote_tmpdir = default.tmpdir()
28
28
 
29
29
  scp_to default, local_filename, remote_tmpdir
30
30
 
@@ -38,7 +38,7 @@ test_name "dsl::helpers::host_helpers #scp_to" do
38
38
  Dir.mktmpdir do |local_dir|
39
39
  local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
40
40
 
41
- remote_tmpdir = tmpdir_on default
41
+ remote_tmpdir = default.tmpdir()
42
42
  on hosts, "mkdir -p #{remote_tmpdir}"
43
43
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
44
44