LAGUREN.NET
  • HOME
  • About Me

Nouvola Gem

3/27/2017

 
Nouvola, an upcoming cloud based performance testing platform, did not have a ruby gem. With a comprehensive api, this was the perfect candidate for my first open source project. The api allows me to run a test plan and collect the data from the test run. One of their newest features which is not yet documented is the ability to add a webhook to a test plan. Without this new feature, my script would have to poll every X minutes for test results.

Even though Nouvola offers a jenkins plugin to do what this gem does, sometimes it is nice to have if you don't want to set up a Jenkins server to do performance testing. Additionally, you can get the test results and run your own analysis. Assuming you have a test plan, this is all that you would need to use the gem (and are familiar with ruby).  Information about the gem can be found at the github repository.

First and foremost, get your api key. After logging into DiveCloud, go to you account and select API & Keys.  The next thing you would need is the plan id. If you don't have a test plan, you can create one by following this tutorial.
​
​INSTALLING THE GEM
To start using the gem, install it by using the command 'gem install nouvola'. 
gem install nouvola
As of this writing, the current version is 1.0.1.
​
SETTING THE WEBHOOK
For this example, I'll use requestb.in to provide me a url for testing the webhook. Opening the console, I'll enter the following:
irb(main):001:0> require 'nouvola'
=> true
irb(main):002:0> key = 'myapikey'
=> "myapikey"
irb(main):003:0> plan_id = 4431
=> 4431
irb(main):004:0> url = 'http://requestb.in/1e74o3t1'
=> "http://requestb.in/1e74o3t1"
irb(main):005:0> callback = Nouvola::Divecloud.new(key)
=> #<Nouvola::Divecloud:0x007fc21883eed8 @key="myapikey", @cred=nil>
irb(main):006:0> response = callback.hook(plan_id, url)
=> #<Net::HTTPOK 200 OK readbody=true>
If it is successful, simply type
irb(main):007:0> response.body
and you'll receive the following: 
=> "{\"result\":\"success\"}"
​RUN A TEST PLAN
Assuming you haven't exited the console, type the following lines code replacing with your api key and plan id:
irb(main):008:0> test = Nouvola::Divecloud.new(key)
=> #<Nouvola::Divecloud:0x007fc21981b388 @key="myapikey", @cred=nil>

irb(main):009:0> response = test.run(plan_id)
=> #<Net::HTTPOK 200 OK readbody=true>
If successful, response.body should return the following: 
irb(main):010:0> response.body
=> "{\"msg\":\"Test Plan is enqueued.\",\"test_id\":5056}"
GET RESULTS
From the response, you'll be given a test_id. This value is what we'll need to get the results from our test plan's latest run. Assuming the time has elapsed for your test, you can refresh the requestb.in page that you used. The following should appear on the page: 
Picture
If successful, you can enter the following to get the results. 
irb(main):011:0> test_id = 5056
=> 5056
irb(main):012:0> results = test.results(test_id)

=> #<Net::HTTPOK 200 OK readbody=true>​
Type response.body and the results for your test is provided to you in JSON format. Now, you have data that you can parse through and investigate what is going on.  Of course, you can always use the reporting features that are already provided by Nouvola.

You can view the gem on ruby gems,  https://rubygems.org/gems/nouvola, or the source code on github,  https://github.com/mlaguren/nouvola-gem.

Comments are closed.

    RSS Feed

    Categories

    All
    Advice
    Agile
    Android
    Automation
    BDD
    C9D9
    Capybara
    Career
    Continuous Delivery
    Continuous Integration
    Cucumber
    Database
    Ebates
    Firefox
    Fiverr
    GIT
    Groupon
    Interview
    Investing
    Jenkins
    JIRA
    Jmeter
    Jobs
    Meetup
    Melvinisms
    Metaprogramming
    Mobile
    Ruby
    Stockpile
    Training

© COPYRIGHT 2018. ALL RIGHTS RESERVED.
  • HOME
  • About Me