cucumber-nagios 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +53 -55
- metadata +2 -2
data/README.md
CHANGED
@@ -1,28 +1,26 @@
|
|
1
1
|
cucumber-nagios
|
2
2
|
===============
|
3
3
|
|
4
|
-
cucumber-nagios allows you to write high-level behavioural tests of web
|
5
|
-
application, and plug the results into Nagios.
|
4
|
+
cucumber-nagios allows you to write high-level behavioural tests of web
|
5
|
+
application, and plug the results into Nagios.
|
6
6
|
|
7
|
-
As Bradley Taylor [put it](http://bradley.is/post/82649218/testing-dash-metrics-with-cucumber):
|
7
|
+
As Bradley Taylor [put it](http://bradley.is/post/82649218/testing-dash-metrics-with-cucumber):
|
8
8
|
|
9
|
-
“Instead of writing boring monitoring plugins from scratch,
|
9
|
+
“Instead of writing boring monitoring plugins from scratch,
|
10
10
|
you can now do behavior driven ops!
|
11
11
|
|
12
|
-
Transform from a grumpy, misanthropic sysadmin to a hipster,
|
12
|
+
Transform from a grumpy, misanthropic sysadmin to a hipster,
|
13
13
|
agile developer instantly.”
|
14
14
|
|
15
15
|
|
16
16
|
Quickstart
|
17
17
|
==========
|
18
18
|
|
19
|
-
|
20
|
-
1. `gem tumble`
|
21
|
-
2. `gem install cucumber-nagios`
|
19
|
+
1. `gem install cucumber-nagios`
|
22
20
|
3. `cucumber-nagios-gen project bunch-o-tests`
|
23
21
|
4. `cd bunch-o-tests`
|
24
22
|
5. `gem bundle`
|
25
|
-
6. `
|
23
|
+
6. `cucumber-nagios-gen feature ebay.com.au bidding`
|
26
24
|
7. `bin/cucumber-nagios features/ebay.com.au/bidding.feature`
|
27
25
|
|
28
26
|
|
@@ -33,30 +31,30 @@ To set up a standalone `cucumber-nagios` project, run:
|
|
33
31
|
|
34
32
|
cucumber-nagios-gen project <project-name>
|
35
33
|
|
36
|
-
This will spit out a bunch of files in the directory specified as `<project-name>`.
|
34
|
+
This will spit out a bunch of files in the directory specified as `<project-name>`.
|
37
35
|
|
38
36
|
Check the `README` within this directory for specific instructions for managing
|
39
|
-
the project.
|
37
|
+
the project.
|
40
38
|
|
41
39
|
|
42
40
|
Bundling dependencies
|
43
41
|
=====================
|
44
42
|
|
45
|
-
Bundling cucumber-nagios's dependencies allows you to drop your cucumber-nagios
|
46
|
-
project to any machine and have it run. This can be useful if you want to
|
43
|
+
Bundling cucumber-nagios's dependencies allows you to drop your cucumber-nagios
|
44
|
+
project to any machine and have it run. This can be useful if you want to
|
47
45
|
develop your tests on one machine, and deploy them to another (like a production
|
48
|
-
Nagios server).
|
46
|
+
Nagios server).
|
49
47
|
|
50
|
-
You'll need to bundle your dependencies to use cucumber-nagios.
|
48
|
+
You'll need to bundle your dependencies to use cucumber-nagios.
|
51
49
|
|
52
|
-
First you need to make sure the following dependencies are installed:
|
50
|
+
First you need to make sure the following dependencies are installed:
|
53
51
|
|
54
52
|
- RubyGems
|
55
53
|
- bundler08 gem (automatically pulled in by the cucumber-nagios gem)
|
56
54
|
|
57
55
|
To bundle your dependencies, within your project directory run:
|
58
56
|
|
59
|
-
$ gem bundle
|
57
|
+
$ gem bundle
|
60
58
|
|
61
59
|
*Please note*: cucumber-nagios uses `bundler08`, **not** `bundler`. Until the
|
62
60
|
`bundler` guys sort their shit out, I refuse to release software that uses it.
|
@@ -65,31 +63,31 @@ To bundle your dependencies, within your project directory run:
|
|
65
63
|
Deploying to production
|
66
64
|
=======================
|
67
65
|
|
68
|
-
Once you've copied your project around, just run the bundler again:
|
66
|
+
Once you've copied your project around, just run the bundler again:
|
69
67
|
|
70
68
|
$ gem bundle
|
71
69
|
|
72
|
-
You'll need to have RubyGems and the bundler gem installed on the system
|
70
|
+
You'll need to have RubyGems and the bundler gem installed on the system
|
73
71
|
you're deploying too. I know, this is not optimal, but hopefully the bundler
|
74
|
-
gem will handle this better in the future.
|
72
|
+
gem will handle this better in the future.
|
75
73
|
|
76
74
|
|
77
75
|
Writing features
|
78
76
|
================
|
79
77
|
|
80
78
|
Once you've set up a project, you can use the `bin/cucumber-nagios-gen` command
|
81
|
-
to generate new features. It takes two arguments: the site you're testing, and
|
82
|
-
feature you're testing:
|
79
|
+
to generate new features. It takes two arguments: the site you're testing, and
|
80
|
+
feature you're testing:
|
83
81
|
|
84
82
|
bin/cucumber-nagios-gen feature gnome.org navigation
|
85
83
|
|
86
|
-
This will spit out two files:
|
84
|
+
This will spit out two files:
|
87
85
|
|
88
86
|
features/gnome.org/navigation.feature
|
89
87
|
features/gnome.org/steps/navigation_steps.rb
|
90
88
|
|
91
89
|
|
92
|
-
As for writing features, you'll want to have a read of the
|
90
|
+
As for writing features, you'll want to have a read of the
|
93
91
|
[Cucumber documentation](http://wiki.github.com/aslakhellesoy/cucumber), however
|
94
92
|
your tests will look something like this:
|
95
93
|
|
@@ -97,63 +95,63 @@ your tests will look something like this:
|
|
97
95
|
To broaden their knowledge
|
98
96
|
A user should be able
|
99
97
|
To search for things
|
100
|
-
|
98
|
+
|
101
99
|
Scenario: Searching for things
|
102
100
|
Given I visit "http://www.google.com"
|
103
101
|
When I fill in "q" with "wikipedia"
|
104
102
|
And I press "Google Search"
|
105
103
|
Then I should see "www.wikipedia.org"
|
106
104
|
|
107
|
-
There's a collection of steps that will cover most of the things you'll be
|
108
|
-
testing for in `features/steps/webrat_steps.rb`.
|
105
|
+
There's a collection of steps that will cover most of the things you'll be
|
106
|
+
testing for in `features/steps/webrat_steps.rb`.
|
109
107
|
|
110
108
|
You can write custom steps for testing specific output and behaviour, e.g.
|
111
|
-
in `features/smh.com.au/smh.feature`:
|
109
|
+
in `features/smh.com.au/smh.feature`:
|
112
110
|
|
113
111
|
Feature: smh.com.au
|
114
112
|
It should be up
|
115
113
|
And provide links to content
|
116
|
-
|
114
|
+
|
117
115
|
Scenario: Visiting home page
|
118
116
|
When I go to http://smh.com.au/
|
119
117
|
Then I should see site navigation
|
120
118
|
And there should be a section named "Opinion"
|
121
119
|
|
122
|
-
There aren't steps for "Then I should see site navigation", so you have to
|
123
|
-
write one yourself. :-) In `features/smh.com.au/steps/smh_steps.rb`:
|
120
|
+
There aren't steps for "Then I should see site navigation", so you have to
|
121
|
+
write one yourself. :-) In `features/smh.com.au/steps/smh_steps.rb`:
|
124
122
|
|
125
|
-
Then /^I should see site navigation$/ do
|
126
|
-
doc = Nokogiri::HTML(response.body.to_s)
|
127
|
-
doc.css("ul#nav li a").size.should > 5
|
123
|
+
Then /^I should see site navigation$/ do
|
124
|
+
doc = Nokogiri::HTML(response.body.to_s)
|
125
|
+
doc.css("ul#nav li a").size.should > 5
|
128
126
|
end
|
129
127
|
|
130
|
-
You can use Nokogiri for testing responses with XPath matchers and CSS
|
131
|
-
selectors.
|
128
|
+
You can use Nokogiri for testing responses with XPath matchers and CSS
|
129
|
+
selectors.
|
132
130
|
|
133
|
-
I suggest you use `bin/cucumber` directly so you can get better feedback when
|
131
|
+
I suggest you use `bin/cucumber` directly so you can get better feedback when
|
134
132
|
writing your tests:
|
135
133
|
|
136
134
|
bin/cucumber --require features/ features/smh/smh.feature
|
137
135
|
|
138
|
-
This will output using the default 'pretty' formatter.
|
136
|
+
This will output using the default 'pretty' formatter.
|
139
137
|
|
140
138
|
Running
|
141
139
|
=======
|
142
140
|
|
143
|
-
Invoke the Cucumber feature with the `cucumber-nagios` script:
|
141
|
+
Invoke the Cucumber feature with the `cucumber-nagios` script:
|
144
142
|
|
145
143
|
bin/cucumber-nagios features/smh.com.au/smh.feature
|
146
144
|
|
147
|
-
`cucumber-nagios` can be run from anywhere:
|
145
|
+
`cucumber-nagios` can be run from anywhere:
|
148
146
|
|
149
147
|
/path/to/bin/cucumber-nagios /path/to/features/smh/smh.feature
|
150
148
|
|
151
|
-
It should return a standard Nagios-formatted response string:
|
149
|
+
It should return a standard Nagios-formatted response string:
|
152
150
|
|
153
151
|
Critical: 0, Warning: 0, 2 okay | passed=2, failed=0, total=2
|
154
152
|
|
155
|
-
Steps that fail will show up in the "Critical" total, and steps that pass
|
156
|
-
show up in the "okay" total.
|
153
|
+
Steps that fail will show up in the "Critical" total, and steps that pass
|
154
|
+
show up in the "okay" total.
|
157
155
|
|
158
156
|
The value printed at the end is in Nagios's Performance Data format, so it
|
159
157
|
can be graphed and the like.
|
@@ -162,24 +160,24 @@ Benchmarking
|
|
162
160
|
============
|
163
161
|
|
164
162
|
You can benchmark your features if you need to test response times for a set of
|
165
|
-
site interactions:
|
163
|
+
site interactions:
|
166
164
|
|
167
165
|
Feature: slashdot.com
|
168
166
|
To keep the geek masses satisfied
|
169
167
|
Slashdot must be responsive
|
170
|
-
|
168
|
+
|
171
169
|
Scenario: Visiting a responsive front page
|
172
170
|
Given I am benchmarking
|
173
171
|
When I go to http://slashdot.org/
|
174
172
|
Then the elapsed time should be less than 5 seconds
|
175
173
|
|
176
174
|
The elapsed time step can be reused multiple times in the same scenario if you
|
177
|
-
need fine grained testing:
|
175
|
+
need fine grained testing:
|
178
176
|
|
179
177
|
Feature: slashdot.com
|
180
178
|
To keep the geek masses satisfied
|
181
179
|
Slashdot must be responsive
|
182
|
-
|
180
|
+
|
183
181
|
Scenario: Visiting news articles
|
184
182
|
Given I am benchmarking
|
185
183
|
When I go to http://slashdot.org/
|
@@ -204,7 +202,7 @@ You can test for various conditions on an AMQP message queue.
|
|
204
202
|
Then it should have less than 400 messages
|
205
203
|
Then it should have at least 5 consumers
|
206
204
|
Then it should have less than 50 messages per consumer
|
207
|
-
|
205
|
+
|
208
206
|
This has been tested using RabbitMQ but uses the amqp gem which should support
|
209
207
|
other backends. See features/amqp_steps.rb for all the available steps.
|
210
208
|
|
@@ -214,12 +212,12 @@ Quirks
|
|
214
212
|
Failure *is* an option (exceptions are good)
|
215
213
|
--------------------------------------------
|
216
214
|
|
217
|
-
Exceptions raised within your tests will appear in the failed totals, so you
|
218
|
-
don't need to worry about trying to catch them in your own custom steps.
|
215
|
+
Exceptions raised within your tests will appear in the failed totals, so you
|
216
|
+
don't need to worry about trying to catch them in your own custom steps.
|
219
217
|
|
220
|
-
i.e. if you try fetching a page on a server that is down, or the page returns
|
221
|
-
a 404, the exception raised by Mechanize just gets treated by Cucumber as a
|
222
|
-
test failure.
|
218
|
+
i.e. if you try fetching a page on a server that is down, or the page returns
|
219
|
+
a 404, the exception raised by Mechanize just gets treated by Cucumber as a
|
220
|
+
test failure.
|
223
221
|
|
224
222
|
Using the Steps in another Cucumber suite
|
225
223
|
=========================================
|
@@ -245,7 +243,7 @@ Version control
|
|
245
243
|
It's highly recommend that you store your cucumber-nagios projects in a version
|
246
244
|
control system!
|
247
245
|
|
248
|
-
To get up and running with git:
|
246
|
+
To get up and running with git:
|
249
247
|
|
250
248
|
$ git init
|
251
249
|
$ git add .
|
@@ -263,7 +261,7 @@ Testing
|
|
263
261
|
-------
|
264
262
|
|
265
263
|
The gem is thoroughly tested (with Cucumber, no less). The gem's Cucumber
|
266
|
-
features live in $gemroot/features/, and can be run with:
|
264
|
+
features live in $gemroot/features/, and can be run with:
|
267
265
|
|
268
266
|
$ cucumber --require features/ features/installing.feature
|
269
267
|
$ cucumber --require features/ features/creating.feature
|