cucumber-newrelic 0.0.1
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.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +58 -0
- data/Rakefile +33 -0
- data/config/newrelic.yml.example +4 -0
- data/cucumber-newrelic.gemspec +56 -0
- data/features/cucumber.feature +26 -0
- data/features/steps/config_steps.rb +13 -0
- data/features/support/env.rb +1 -0
- data/lib/cucumber/newrelic/steps.rb +28 -0
- data/lib/cucumber/newrelic/version.rb +5 -0
- data/lib/cucumber/newrelic.rb +44 -0
- metadata +102 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jesse Newland
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
= cucumber-newrelic
|
2
|
+
|
3
|
+
Cucumber steps for verifying New Relic Application Metrics.
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
In your <tt>features/support/env.rb</tt>:
|
8
|
+
|
9
|
+
require 'cucumber/nagios/steps'
|
10
|
+
|
11
|
+
You can now write crazy features like this:
|
12
|
+
|
13
|
+
Feature: Response Time
|
14
|
+
As a impatient user
|
15
|
+
Our app should be super fast
|
16
|
+
|
17
|
+
Background:
|
18
|
+
Given my NewRelic license key is 'sekret'
|
19
|
+
|
20
|
+
Scenario: Average Response time
|
21
|
+
Given that my application is being monitored by New Relic
|
22
|
+
Then my application's 'response time' should be less than 500 milliseconds
|
23
|
+
|
24
|
+
Scenario: Apdex
|
25
|
+
Given that my application is being monitored by New Relic
|
26
|
+
Then my application's 'apdex' should be 1
|
27
|
+
|
28
|
+
== Available Metrics
|
29
|
+
|
30
|
+
["Apdex", "Application Busy", "CPU", "Memory", "Errors", "Error Rate", "Response Time", "Throughput", "DB"]
|
31
|
+
|
32
|
+
== Available Operators
|
33
|
+
|
34
|
+
* be greater than
|
35
|
+
* be less than
|
36
|
+
* equal OR be
|
37
|
+
* not equal OR not be
|
38
|
+
|
39
|
+
== Running Cucumber Features
|
40
|
+
|
41
|
+
Drop your license key into config/newrelic.yml, then run 'em like so:
|
42
|
+
|
43
|
+
cucumber features
|
44
|
+
|
45
|
+
== Note on Patches/Pull Requests
|
46
|
+
|
47
|
+
* Fork the project.
|
48
|
+
* Make your feature addition or bug fix.
|
49
|
+
* Add cucumber features for it. This is important so I don't break it in a
|
50
|
+
future version unintentionally.
|
51
|
+
* Commit, do not mess with rakefile, version, or history.
|
52
|
+
(if you want to have your own version, that is fine but bump version in a
|
53
|
+
commit by itself I can ignore when I pull)
|
54
|
+
* Send me a pull request. Bonus points for topic branches.
|
55
|
+
|
56
|
+
== Copyright
|
57
|
+
|
58
|
+
Copyright (c) 2010 Jesse Newland. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
$LOAD_PATH.unshift 'lib'
|
4
|
+
require 'cucumber/newrelic/version'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.version = Cucumber::Newrelic::VERSION
|
10
|
+
gem.name = "cucumber-newrelic"
|
11
|
+
gem.summary = %Q{Cucumber steps for verifing metrics from NewRelic's API}
|
12
|
+
gem.description = %Q{Cucumber steps for verifing metrics from NewRelic's API}
|
13
|
+
gem.email = "jnewland@gmail.com"
|
14
|
+
gem.homepage = "http://github.com/jnewland/cucumber-newrelic"
|
15
|
+
gem.authors = ["Jesse Newland"]
|
16
|
+
gem.add_dependency "newrelic_rpm", "~> 2.10.6"
|
17
|
+
gem.add_dependency "activeresource", "~> 2.3.8"
|
18
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
19
|
+
end
|
20
|
+
Jeweler::GemcutterTasks.new
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'rake/rdoctask'
|
26
|
+
Rake::RDocTask.new do |rdoc|
|
27
|
+
version = Cucumber::Newrelic::VERSION
|
28
|
+
|
29
|
+
rdoc.rdoc_dir = 'rdoc'
|
30
|
+
rdoc.title = "cucumber-newrelic #{version}"
|
31
|
+
rdoc.rdoc_files.include('README*')
|
32
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
33
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{cucumber-newrelic}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Jesse Newland"]
|
12
|
+
s.date = %q{2010-06-08}
|
13
|
+
s.description = %q{Cucumber steps for verifing metrics from NewRelic's API}
|
14
|
+
s.email = %q{jnewland@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"config/newrelic.yml.example",
|
26
|
+
"cucumber-newrelic.gemspec",
|
27
|
+
"features/cucumber.feature",
|
28
|
+
"features/steps/config_steps.rb",
|
29
|
+
"features/support/env.rb",
|
30
|
+
"lib/cucumber/newrelic.rb",
|
31
|
+
"lib/cucumber/newrelic/steps.rb",
|
32
|
+
"lib/cucumber/newrelic/version.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/jnewland/cucumber-newrelic}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.6}
|
38
|
+
s.summary = %q{Cucumber steps for verifing metrics from NewRelic's API}
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<newrelic_rpm>, ["~> 2.10.6"])
|
46
|
+
s.add_runtime_dependency(%q<activeresource>, ["~> 2.3.8"])
|
47
|
+
else
|
48
|
+
s.add_dependency(%q<newrelic_rpm>, ["~> 2.10.6"])
|
49
|
+
s.add_dependency(%q<activeresource>, ["~> 2.3.8"])
|
50
|
+
end
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<newrelic_rpm>, ["~> 2.10.6"])
|
53
|
+
s.add_dependency(%q<activeresource>, ["~> 2.3.8"])
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Feature: Setup
|
2
|
+
As a dev wanting to verify New Relic API
|
3
|
+
You should be able to initialize auth details in the background
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given your we load our NewRelic license key from the config file
|
7
|
+
|
8
|
+
Scenario: Installing the gem
|
9
|
+
When a scenario runs
|
10
|
+
Then the NewRelic API is responsive
|
11
|
+
|
12
|
+
Scenario: Less than
|
13
|
+
Given that my application is being monitored by New Relic
|
14
|
+
Then my application's 'response time' should be less than 500 milliseconds
|
15
|
+
|
16
|
+
Scenario: Equal
|
17
|
+
Given that my application is being monitored by New Relic
|
18
|
+
Then my application's 'apdex' should be 1
|
19
|
+
|
20
|
+
Scenario: Greater than
|
21
|
+
Given that my application is being monitored by New Relic
|
22
|
+
Then my application's 'apdex' should be greater than 0.5
|
23
|
+
|
24
|
+
Scenario: Not equal
|
25
|
+
Given that my application is being monitored by New Relic
|
26
|
+
Then my application's 'apdex' should not be 0
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
Given /^your we load our NewRelic license key from the config file$/ do
|
3
|
+
key = YAML.load_file(File.join(Dir.pwd, 'config', 'newrelic.yml'))['production']['license_key']
|
4
|
+
Given "our NewRelic license key is '"+key+"'"
|
5
|
+
end
|
6
|
+
|
7
|
+
When /^a scenario runs$/ do
|
8
|
+
# noop
|
9
|
+
end
|
10
|
+
|
11
|
+
Then /^the NewRelic API is responsive$/ do
|
12
|
+
Then 'that my application is being monitored by New Relic'
|
13
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(Dir.pwd, 'lib', 'cucumber', 'newrelic', 'steps.rb')
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'cucumber/newrelic'
|
2
|
+
|
3
|
+
Given /^(my|our) NewRelic license key is '([^\"]*)'$/ do |junk, key|
|
4
|
+
Cucumber::Newrelic.new_relic_license_key = key
|
5
|
+
end
|
6
|
+
|
7
|
+
When /^I get the '([^\"]*)' from New Relic$/ do |metric|
|
8
|
+
Cucumber::Newrelic.new_relic_metric(metric)
|
9
|
+
end
|
10
|
+
|
11
|
+
Given 'that my application is being monitored by New Relic' do
|
12
|
+
Cucumber::Newrelic.new_relic_application.should_not be_nil
|
13
|
+
end
|
14
|
+
|
15
|
+
Then /^my application's '([^\"]*)' should (be|be less than|be greater than|equal|not equal|not be) ([\d\.]+)( milliseconds| percent|)$/ do |metric, operator, intended_value, unit|
|
16
|
+
real_value = Cucumber::Newrelic.new_relic_metric(metric)
|
17
|
+
intended_value = intended_value.to_f
|
18
|
+
case operator
|
19
|
+
when 'be less than'
|
20
|
+
real_value.should < intended_value
|
21
|
+
when 'be greater than'
|
22
|
+
real_value.should > intended_value
|
23
|
+
when 'be', 'equal'
|
24
|
+
real_value.should == intended_value
|
25
|
+
when 'not be', 'not equal'
|
26
|
+
real_value.should_not == intended_value
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'active_resource'
|
2
|
+
require 'newrelic_rpm'
|
3
|
+
require 'new_relic_api'
|
4
|
+
|
5
|
+
module Cucumber
|
6
|
+
module Newrelic
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :new_relic_application_id
|
10
|
+
end
|
11
|
+
|
12
|
+
def included
|
13
|
+
#kludge to use the NewRelic API outside of rails
|
14
|
+
NewRelicApi.host = "rpm.newrelic.com"
|
15
|
+
NewRelicApi.port = 80
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.new_relic_license_key=(key)
|
19
|
+
NewRelicApi.license_key = key
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.new_relic_metric(name)
|
23
|
+
new_relic_values.find { |v| v.name.downcase == name.to_s.downcase }.metric_value
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.new_relic_application
|
27
|
+
if self.new_relic_application_id
|
28
|
+
@application ||= NewRelicApi::Account.find(:first).applications.find { |a| a.id = self.new_relic_application_id }
|
29
|
+
else
|
30
|
+
@application ||= NewRelicApi::Account.find(:first).applications.first
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def self.new_relic_values
|
37
|
+
@values ||= new_relic_application.threshold_values
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
World(Cucumber::Newrelic)
|
44
|
+
require 'cucumber/nagios/steps'
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cucumber-newrelic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jesse Newland
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-06-08 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: newrelic_rpm
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 10
|
30
|
+
- 6
|
31
|
+
version: 2.10.6
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: activeresource
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 2
|
43
|
+
- 3
|
44
|
+
- 8
|
45
|
+
version: 2.3.8
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
description: Cucumber steps for verifing metrics from NewRelic's API
|
49
|
+
email: jnewland@gmail.com
|
50
|
+
executables: []
|
51
|
+
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files:
|
55
|
+
- LICENSE
|
56
|
+
- README.rdoc
|
57
|
+
files:
|
58
|
+
- .document
|
59
|
+
- .gitignore
|
60
|
+
- LICENSE
|
61
|
+
- README.rdoc
|
62
|
+
- Rakefile
|
63
|
+
- config/newrelic.yml.example
|
64
|
+
- cucumber-newrelic.gemspec
|
65
|
+
- features/cucumber.feature
|
66
|
+
- features/steps/config_steps.rb
|
67
|
+
- features/support/env.rb
|
68
|
+
- lib/cucumber/newrelic.rb
|
69
|
+
- lib/cucumber/newrelic/steps.rb
|
70
|
+
- lib/cucumber/newrelic/version.rb
|
71
|
+
has_rdoc: true
|
72
|
+
homepage: http://github.com/jnewland/cucumber-newrelic
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options:
|
77
|
+
- --charset=UTF-8
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
94
|
+
requirements: []
|
95
|
+
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.3.6
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: Cucumber steps for verifing metrics from NewRelic's API
|
101
|
+
test_files: []
|
102
|
+
|