auxesis-cucumber-nagios 0.2.8 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -15
- data/lib/generators/project/bin/cucumber +1 -2
- data/lib/generators/project/bin/cucumber-nagios +22 -21
- data/lib/generators/project/bin/cucumber-nagios-gen +20 -13
- data/lib/generators/project/features/steps/result_steps.rb +4 -0
- data/lib/generators/project/lib/generators/feature/%feature_name%.feature +7 -0
- data/lib/generators/project/lib/generators/feature/%feature_name%_steps.rb +1 -0
- metadata +4 -2
data/README.md
CHANGED
@@ -16,20 +16,20 @@ As Bradley Taylor [put it](http://bradley.is/post/82649218/testing-dash-metrics-
|
|
16
16
|
Setting up a project
|
17
17
|
====================
|
18
18
|
|
19
|
-
To set up a standalone cucumber-nagios project, run:
|
19
|
+
To set up a standalone `cucumber-nagios` project, run:
|
20
20
|
|
21
21
|
cucumber-nagios-gen project <project-name>
|
22
22
|
|
23
|
-
This will spit out a bunch of files in the directory specified as
|
23
|
+
This will spit out a bunch of files in the directory specified as `<project-name>`.
|
24
24
|
|
25
|
-
Check the README within this directory for specific instructions for managing
|
25
|
+
Check the `README` within this directory for specific instructions for managing
|
26
26
|
the project.
|
27
27
|
|
28
28
|
|
29
29
|
Writing Features
|
30
30
|
================
|
31
31
|
|
32
|
-
Within your project, I suggest you put your features under under features/$fqdn/$name.feature
|
32
|
+
Within your project, I suggest you put your features under under `features/$fqdn/$name.feature`.
|
33
33
|
|
34
34
|
You'll want to have a read of the Cucumber documentation, however
|
35
35
|
your tests will look something like this:
|
@@ -45,10 +45,10 @@ your tests will look something like this:
|
|
45
45
|
Then I should see "www.wikipedia.org"
|
46
46
|
|
47
47
|
There's a collection of steps that will cover most of the things you'll be
|
48
|
-
testing for in features/steps/webrat_steps.rb
|
48
|
+
testing for in `features/steps/webrat_steps.rb`.
|
49
49
|
|
50
50
|
You can write custom steps for testing specific output and behaviour, e.g.
|
51
|
-
in features/smh.com.au/smh.feature
|
51
|
+
in `features/smh.com.au/smh.feature`:
|
52
52
|
|
53
53
|
Feature: smh.com.au
|
54
54
|
It should be up
|
@@ -60,7 +60,7 @@ in features/smh.com.au/smh.feature:
|
|
60
60
|
And there should be a section named "Opinion"
|
61
61
|
|
62
62
|
There aren't steps for "Then I should see site navigation", so you have to
|
63
|
-
write one yourself. :-) In features/smh.com.au/steps/smh_steps.rb
|
63
|
+
write one yourself. :-) In `features/smh.com.au/steps/smh_steps.rb`:
|
64
64
|
|
65
65
|
Then /^I should see site navigation$/ do
|
66
66
|
doc = Nokogiri::HTML(response.body.to_s)
|
@@ -70,7 +70,7 @@ write one yourself. :-) In features/smh.com.au/steps/smh_steps.rb:
|
|
70
70
|
You can use Nokogiri for testing responses with XPath matchers and CSS
|
71
71
|
selectors.
|
72
72
|
|
73
|
-
I suggest you use bin/cucumber directly so you can get better feedback when
|
73
|
+
I suggest you use `bin/cucumber` directly so you can get better feedback when
|
74
74
|
writing your tests:
|
75
75
|
|
76
76
|
bin/cucumber --require bin/common.rb \
|
@@ -81,17 +81,17 @@ writing your tests:
|
|
81
81
|
Running
|
82
82
|
=======
|
83
83
|
|
84
|
-
Invoke the
|
84
|
+
Invoke the Cucumber feature with the `cucumber-nagios` script:
|
85
85
|
|
86
86
|
bin/cucumber-nagios features/smh.com.au/smh.feature
|
87
87
|
|
88
|
-
cucumber-nagios can be run from anywhere:
|
88
|
+
`cucumber-nagios` can be run from anywhere:
|
89
89
|
|
90
90
|
/path/to/bin/cucumber-nagios /path/to/features/smh/smh.feature
|
91
91
|
|
92
92
|
It should return a standard Nagios-formatted response string:
|
93
93
|
|
94
|
-
Critical: 0, Warning: 0, 2 okay | passed=2, failed=0
|
94
|
+
Critical: 0, Warning: 0, 2 okay | passed=2, failed=0, total=2
|
95
95
|
|
96
96
|
Steps that fail will show up in the "Critical" total, and steps that pass
|
97
97
|
show up in the "okay" total.
|
@@ -106,11 +106,11 @@ Caveats
|
|
106
106
|
You may want to think about keeping to one scenario to a file, otherwise
|
107
107
|
you'll get multiple lines of output for a test:
|
108
108
|
|
109
|
-
Critical: 1, Warning: 0, 2 okay |
|
110
|
-
Critical: 1, Warning: 0, 4 okay |
|
109
|
+
Critical: 1, Warning: 0, 2 okay | passed=2, failed=1, total=3
|
110
|
+
Critical: 1, Warning: 0, 4 okay | passed=4, failed=1, total=5
|
111
111
|
|
112
|
-
|
113
|
-
when you want to test for an aggregate of failures across a site.
|
112
|
+
That said, Nagios should only read the last line, so this might be an ok
|
113
|
+
behaviour when you want to test for an aggregate of failures across a site.
|
114
114
|
|
115
115
|
|
116
116
|
|
@@ -1,26 +1,27 @@
|
|
1
|
-
#!/bin/
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
unless ARGV[0]
|
4
|
+
puts "Usage: #{__FILE__} <feature>"
|
5
|
+
exit 99
|
6
|
+
end
|
7
7
|
|
8
|
-
dirname
|
9
|
-
feature=$1
|
8
|
+
__DIR__ = File.expand_path(File.dirname(__FILE__))
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
feature = ARGV[0]
|
11
|
+
unless File.exists?(feature)
|
12
|
+
feature = File.join(__DIR__, '..', 'features', ARGV[0])
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
unless File.exist?(feature)
|
16
|
+
puts "Error: feature file doesn't exist!"
|
17
|
+
exit 98
|
18
|
+
end
|
19
|
+
|
20
|
+
command = "#{__DIR__}/cucumber"
|
21
|
+
command += " --require #{__DIR__}/common.rb"
|
22
|
+
command += " --require features/"
|
23
|
+
command += " --format Nagios::NagiosFormatter"
|
24
|
+
command += " #{feature}"
|
25
|
+
|
26
|
+
system(command) ? exit(0) : exit(2)
|
21
27
|
|
22
|
-
if [ "$retval" -eq "1" ]; then
|
23
|
-
exit 2
|
24
|
-
else
|
25
|
-
exit $retval
|
26
|
-
fi
|
@@ -7,28 +7,35 @@ module CucumberNagiosGenerators
|
|
7
7
|
|
8
8
|
extend Templater::Manifold
|
9
9
|
|
10
|
-
|
10
|
+
# feature generator
|
11
|
+
class FeatureGenerator < Templater::Generator
|
11
12
|
def self.source_root
|
12
|
-
File.join(File.dirname(__FILE__), '..', 'lib', 'generators', '
|
13
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'generators', 'feature')
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
desc <<-DESC
|
17
|
+
Generate a cucumber feature. Takes a two arguments:
|
18
|
+
bin/cucumber-nagios-gen feature <site-name> <feature-name>
|
19
|
+
DESC
|
19
20
|
|
20
|
-
|
21
|
-
|
21
|
+
first_argument :site, :required => true, :desc => "Site name"
|
22
|
+
second_argument :feature, :required => true, :desc => "Feature name"
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
template :feature do |template|
|
25
|
+
template.source = "%feature_name%.feature"
|
26
|
+
template.destination = "features/#{site}/#{feature}.feature"
|
27
|
+
end
|
28
|
+
|
29
|
+
template :step do |template|
|
30
|
+
template.source = "%feature_name%_steps.rb"
|
31
|
+
template.destination = "features/#{site}/steps/#{feature}_steps.rb"
|
32
|
+
end
|
25
33
|
|
26
34
|
end
|
27
35
|
|
28
|
-
desc "
|
29
|
-
add :
|
36
|
+
desc "Generators for a cucumber-nagios project"
|
37
|
+
add :feature, FeatureGenerator
|
30
38
|
|
31
39
|
end
|
32
40
|
|
33
|
-
|
34
41
|
CucumberNagiosGenerators.run_cli Dir.pwd, 'cucumber-nagios-gen', '0.1', ARGV
|
@@ -10,6 +10,10 @@ Then /^I should see an? (\w+) message$/ do |message_type|
|
|
10
10
|
response.should have_xpath("//*[@class='#{message_type}']")
|
11
11
|
end
|
12
12
|
|
13
|
+
Then /^the (.*) ?request should succeed/ do |_|
|
14
|
+
response.should be_successful
|
15
|
+
end
|
16
|
+
|
13
17
|
Then /^the (.*) ?request should fail/ do |_|
|
14
18
|
response.should_not be_successful
|
15
19
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# steps go here!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auxesis-cucumber-nagios
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lindsay Holmwood
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-05 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -61,6 +61,8 @@ files:
|
|
61
61
|
- LICENSE
|
62
62
|
- README.md
|
63
63
|
- Rakefile
|
64
|
+
- lib/generators/project/lib/generators/feature/%feature_name%.feature
|
65
|
+
- lib/generators/project/lib/generators/feature/%feature_name%_steps.rb
|
64
66
|
has_rdoc: false
|
65
67
|
homepage: http://holmwood.id.au/~lindsay/2009/02/23/web-app-integration-testing-for-sysadmins-with-cucumber-nagios/
|
66
68
|
post_install_message:
|