features/step_definitions/json_steps.rb in visage-app-2.0.5 vs features/step_definitions/json_steps.rb in visage-app-2.1.0
- old
+ new
@@ -101,11 +101,11 @@
end
When /^I visit "([^"]*)" on the first available host$/ do |glob|
host = @response["hosts"].first
url = "/data/#{host}/#{glob}"
- When "I go to #{url}"
+ step "I go to #{url}"
end
When /^I visit the first available host$/ do
step 'I go to /data'
@@ -113,22 +113,22 @@
step 'I should receive valid JSON'
step 'the JSON should have a list of hosts'
host = @response["hosts"].first
url = "/data/#{host}"
- When "I go to #{url}"
+ step "I go to #{url}"
end
When /^I visit the first two available hosts$/ do
step 'I go to /data'
step 'the request should succeed'
step 'I should receive valid JSON'
step 'the JSON should have a list of hosts'
host = @response["hosts"][0..1].join(',')
url = "/data/#{host}"
- When "I go to #{url}"
+ step "I go to #{url}"
end
Then /^the JSON should have a list of plugins$/ do
host = @response.keys.first
plugins = @response[host]
@@ -148,10 +148,18 @@
When /^I visit "([^"]*)" on the first available host with the following query parameters:$/ do |glob, table|
host = @response["hosts"].first
url = "/data/#{host}/#{glob}"
params = Hash[table.hashes.map { |hash| [hash["parameter"], hash["value"]] }]
+ params.each do |key, value|
+ if value == "1 hour ago"
+ params[key] = (Time.now() - 3600).to_i.to_s
+ end
+ if value == "now"
+ params[key] = Time.now().to_i.to_s
+ end
+ end
query = params.map{|k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}"}.join("&")
url += "?#{query}"
step "I go to #{url}"
end
@@ -166,9 +174,24 @@
metric.each_pair do |k, series|
series.each_pair do |k, data|
params.each do |key, value|
data[key].should == value.to_i
end
+ end
+ end
+ end
+ end
+
+end
+
+Then /^I should see a 95th percentile value for each plugin instance$/ do
+ @response.should_not be_nil
+
+ @response.each_pair do |host, plugin|
+ plugin.each_pair do |instance, metric|
+ metric.each_pair do |k, series|
+ series.each_pair do |k, data|
+ data['percentile_95'].should >= 0
end
end
end
end