|
1 | | -# Busser::RunnerPlugin::Serverspec |
| 1 | +# busser-serverspec |
2 | 2 |
|
| 3 | +[](https://badge.fury.io/rb/busser-serverspec) |
3 | 4 |
|
4 | | -A Busser runner plugin for Serverspec |
| 5 | +A [Busser](https://github.com/test-kitchen/busser) runner plugin that runs |
| 6 | +[Serverspec](https://serverspec.org) tests as integration tests. |
| 7 | + |
| 8 | +Busser installs Serverspec on the machine under test the first time a suite |
| 9 | +runs, then executes the suite's `serverspec` directory against it. Because the |
| 10 | +tests run on the machine itself, they use Serverspec's `exec` backend rather |
| 11 | +than SSH. |
5 | 12 |
|
6 | 13 | ## Status |
7 | 14 |
|
8 | | -This Gem has now been archived. No active maintainers have come forward in the past 5 years and the original maintainer has since pulled the plugin. |
| 15 | +This gem has been archived. No active maintainers have come forward in the past |
| 16 | +five years and the original maintainer has since pulled the plugin. |
| 17 | + |
| 18 | +We recommend moving to a maintained project for similar functionality, or |
| 19 | +building and running the gem yourself. In particular, |
| 20 | +[kitchen-verifier-shell](https://github.com/higanworks/kitchen-verifier-shell) |
| 21 | +with Serverspec covers the same ground and is configured directly in your |
| 22 | +`kitchen.yml`. |
| 23 | + |
| 24 | +## Requirements |
9 | 25 |
|
10 | | -We recommend moving to a maintained project for similar functionality or building and running the Gem yourself. |
| 26 | +Ruby 3.2 or newer, and busser 0.9.0 or newer. |
11 | 27 |
|
12 | | -## Installation and Setup |
| 28 | +## Installation |
13 | 29 |
|
14 | | -Put this into your `kitchen.yml`: |
| 30 | +Select the Busser verifier in your `kitchen.yml`: |
15 | 31 |
|
16 | 32 | ```yaml |
17 | 33 | verifier: |
18 | 34 | name: busser |
19 | 35 | ``` |
20 | 36 |
|
21 | | -You may also look at the Busser [plugin usage][plugin_usage] page. |
| 37 | +Busser then installs the plugin for you when the suite runs. To install it by |
| 38 | +hand: |
| 39 | +
|
| 40 | +```bash |
| 41 | +busser plugin install busser-serverspec |
| 42 | +``` |
22 | 43 |
|
23 | 44 | ## Usage |
24 | 45 |
|
25 | | -Please put test files into [COOKBOOK]/test/integration/[SUITES]/serverspec/ |
26 | | -
|
27 | | -```cookbook |
28 | | -`-- test |
29 | | - `-- integration |
30 | | - `-- default |
31 | | - `-- serverspec |
32 | | - |-- Gemfile |
33 | | - |-- localhost |
34 | | - | `-- httpd_spec.rb |
35 | | - `-- spec_helper.rb |
| 46 | +Put your specs in a subdirectory of the suite's `serverspec` directory: |
| 47 | + |
| 48 | +```text |
| 49 | +test |
| 50 | +`-- integration |
| 51 | + `-- default # suite name |
| 52 | + `-- serverspec |
| 53 | + |-- Gemfile # optional |
| 54 | + |-- spec_helper.rb |
| 55 | + `-- localhost |
| 56 | + `-- httpd_spec.rb |
36 | 57 | ``` |
37 | 58 |
|
38 | | -`Gemfile` is optional. You can specify installing Serverspec version and install the gems you need. |
39 | | - |
40 | | -## Note |
| 59 | +Specs are collected recursively as `**/*_spec.rb`, so any depth works; the |
| 60 | +`localhost/` directory above is convention, not a requirement. The separator is |
| 61 | +an underscore — `_spec.rb`, not `-spec.rb`. The suite directory is also added to |
| 62 | +the load path and set as RSpec's default path, so `require "spec_helper"` works |
| 63 | +without a relative path. |
41 | 64 |
|
42 | | -### File Matching |
| 65 | +```ruby |
| 66 | +require "spec_helper" |
43 | 67 |
|
44 | | -The globbing pattern to match files is `"serverspec/*/*_spec.rb"`. |
45 | | -You need to use `"_spec.rb"` (underscore), not `"-spec.rb"` (minus). |
| 68 | +describe command("echo hello") do |
| 69 | + its(:exit_status) { should eq 0 } |
| 70 | + its(:stdout) { should eq "hello\n" } |
| 71 | +end |
| 72 | +``` |
46 | 73 |
|
47 | | -### Specify Serverspec version |
| 74 | +### Backend |
48 | 75 |
|
49 | | -If you have to specify the Serverspec version, you can use Gemfile. Example Gemfile: |
| 76 | +The tests run on the machine under test, after Test Kitchen has logged in, so |
| 77 | +the `exec` backend is the right one: |
50 | 78 |
|
51 | | -```Gemfile |
52 | | -source 'https://rubygems.org' |
53 | | -gem 'serverspec', '< 2.0' |
| 79 | +```ruby |
| 80 | +require "serverspec" |
| 81 | +set :backend, :exec |
54 | 82 | ``` |
55 | 83 |
|
56 | | -### Serverspec backend |
| 84 | +Do not use `set :backend, :ssh` — that would have Serverspec connect back out |
| 85 | +over the network from a machine that is already the target. |
| 86 | + |
| 87 | +### Pinning Serverspec |
| 88 | + |
| 89 | +A `Gemfile` in the suite directory is `bundle install`ed before the run, which |
| 90 | +is how you pin a particular Serverspec version: |
| 91 | + |
| 92 | +```ruby |
| 93 | +source "https://rubygems.org" |
| 94 | + |
| 95 | +gem "serverspec", "~> 2.43" |
| 96 | +``` |
57 | 97 |
|
58 | | -It runs on a target server for testing after ssh log in it. |
59 | | -So you need to specify `set :backend, :exec` not `set :backend, :ssh` (Serverspec v2). |
60 | | -If you use Serverspec v1, you must specify `include SpecInfra::Helper::Exec` not `include SpecInfra::Helper::Ssh`. |
| 98 | +Without one, the plugin installs Serverspec 2.43 or newer. |
61 | 99 |
|
62 | | -## Authors |
| 100 | +## Contributing |
63 | 101 |
|
64 | | -Created and maintained by [HIGUCHI Daisuke][author] (<d-higuchi@creationline.com>) |
| 102 | +Bug reports and pull requests are welcome. See |
| 103 | +[CONTRIBUTING.md](CONTRIBUTING.md) for how to set up the project, run the test |
| 104 | +suite, and format your commits. |
65 | 105 |
|
66 | 106 | ## License |
67 | 107 |
|
68 | | -Apache 2.0 (see [LICENSE][license]) |
| 108 | +Apache License 2.0. See [LICENSE](LICENSE). |
69 | 109 |
|
70 | | -[author]: https://github.com/cl-lab-k |
71 | | -[license]: https://github.com/test-kitchen/busser-serverspec/blob/master/LICENSE |
72 | | -[plugin_usage]: https://kitchen.ci/docs/verifiers/serverspec/ |
| 110 | +Originally created by [HIGUCHI Daisuke](https://github.com/cl-lab-k). |
0 commit comments