November 2015 Archives

Easy nginx monitoring with sparrow

Hi, this is very simple and short example, but quite expository.

install sparrow

$ sudo apt-get install curl
$ sudo cpanm Sparrow

installs nginx sparrow plugin

$ sparrow index update
$ sparrow plg install swat-nginx

setup monitored host

$ sparrow project foo create
$ sparrow check add foo nginx-server
$ sparrow check set foo nginx-server -p swat-nginx -u 127.0.0.1

and finally ... run test suite

    $ sparrow check run foo nginx-server

    # sparrow environment initialzed at /home/vagrant/sparrow
    /home/vagrant/.swat/.cache/20277/prove/00.GET.t ..
    ok 1 - GET 127.0.0.1/ succeeded
    # response saved to /home/vagrant/.swat/.cache/20277/prove/jgxseRgqg2
    ok 2 - output match '200 OK'
    ok 3 - output match /Server: nginx\/(\S+)/
    ok 4 - valid nginx version: 1.6.2
    1..4
    ok
    All tests successful.
    Files=1, Tests=4,  0 wallclock secs ( 0.03 usr  0.00 sys +  0.05 cusr  0.00 csys =   0.08 CPU)
    Result: PASS

PS

Visit https://github.com/melezhik/sparrow to know more.

sparrow - tiny web monitoring tool

Tiny but quick sparrow

Let me introduce you a sparrow - a tiny web monitoring / test tool . Tiny as project is in very alpha stage, but I hope it will grow and get mature and get used by others.

Sparrow is a console client to setup tests/monitoring infrastructure and run swat tests suites. Swat - is web test application automation framework. Sparrow provides some glue to run sparrow plugins - shareable swat tests suites.

Here is the list of some sparrow plugins created by me - https://github.com/melezhik/sparrow-hub

Swat was initially designed to radically increase and simplify web tests development. Another idea behind swat philosophy - is to create shareable tests suites could be reused by someone else with different context ( monitoring, QA, development, devops ) but in easy manner.

Recently I have posted a informal swat introduction paper with the list of swat test suites could be base for such a sparrow plugins.

If you are inspired in test automation development on perl we probably could go one direction. So swat/sparrow contributors are needed!

Possible impact:

  • start using swat,sparrow and sparrow plugins
  • create new sparrow plugins ( swat test suites ) - it's really easy
  • contribute to sparrow - there is some TODOs here - implementing REST API, clear up documentation and my documentations typos, (--; , etc
  • contribute to swat - the api is going to be stable, but I am open to new ideas as Russians say two heads are better then one (-;

--- Thanks, Alexey Melezhik ( the author of swat and sparrow )

Doing testing in a swat way

Hi I wrote an informal introduction into swat, trying to highlights some benefits one could gain using swat in web test development. Feedback is appreciated. Thanks.

Bootstraping test infrastructure for mojo application using swat

Install swat mojo command

You need a swat mojo command to generate swat tests scaffolding for mojo application.

cpanm Mojolicious::Command::swat

Bootstrap mojo application

Then you need to bootstrap mojo application or choose existed one.

mkdir myapp
cd myapp
mojo generate lite_app myapp.pl

Define http resources ( mojo routes )

As well as define your routes.

$ nano myapp.pl

#!/usr/bin/env perl
use Mojolicious::Lite;

get '/' => sub {
  my $c = shift;
  $c->render(text => 'ROOT');
};


post '/hello' => sub {
  my $c = shift;
  $c->render(text => 'HELLO');
};

get '/hello/world' => sub {
  my $c = shift;
  $c->render(text => 'HELLO WORLD');
};

app->start;


$ ./myapp.pl routes
/             GET
/hello        POST  hello
/hello/world  GET   helloworld

Bootstrap swat tests

And then create a swat tests for every route exists.

$ ./myapp.pl swat
generate swat route for / ...
generate swat data for GET / ...
generate swat route for /hello ...
generate swat data for POST /hello ...
generate swat route for /hello/world ...
generate swat data for GET /hello/world ...

Specify additional swat check lists

This phase might be skipped as preliminary 200 OK checks are already added on bootstrap phase.

But you may define more.

For complete documentation on how to write swat tests please visit https://github.com/melezhik/swat.

$ echo ROOT >> swat/get.txt
$ echo HELLO >> swat/hello/post.txt
$ echo HELLO WORLD >> swat/hello/world/get.txt

Start mojo application

$ morbo ./myapp.pl
Server available at http://127.0.0.1:3000

Run swat tests

vagrant@Debian-jessie-amd64-netboot:~/projects/myapp$ swat swat/
/home/vagrant/.swat/.cache/26576/prove/hello/world/00.GET.t ..
ok 1 - GET http://127.0.0.1:3000/hello/world succeeded
# response saved to /home/vagrant/.swat/.cache/26576/prove/an7LtP99Ju
ok 2 - output match '200 OK'
ok 3 - output match 'HELLO WORLD'
1..3
ok
/home/vagrant/.swat/.cache/26576/prove/foo/bar/00.PUT.t ......
ok 1 - PUT http://127.0.0.1:3000/foo/bar succeeded
# response saved to /home/vagrant/.swat/.cache/26576/prove/L1JTyul6W5
ok 2 - output match '200 OK'
1..2
ok
/home/vagrant/.swat/.cache/26576/prove/00.GET.t ..............
ok 1 - GET http://127.0.0.1:3000/ succeeded
# response saved to /home/vagrant/.swat/.cache/26576/prove/YPnyXfYPXz
ok 2 - output match '200 OK'
ok 3 - output match 'ROOT'
1..3
ok
/home/vagrant/.swat/.cache/26576/prove/hello/00.POST.t .......
ok 1 - POST http://127.0.0.1:3000/hello succeeded
# response saved to /home/vagrant/.swat/.cache/26576/prove/baZKYm1hGD
ok 2 - output match '200 OK'
ok 3 - output match 'HELLO'
1..3
ok
All tests successful.
Files=4, Tests=12,  0 wallclock secs ( 0.03 usr  0.00 sys +  0.20 cusr  0.01 csys =  0.24 CPU)
Result: PASS

That's it.

Enjoy your testing with swat! ;--)

Outthentic latest releases

Hi! I am very glad to announce of outthentic stuff latest releases:

  • Outthentic::DSL - a core component for all outthentic test clients
  • Outthentic client - a general purposes test tool ( based on Outthentic::DSL )
  • Swat client - a web application test tool ( based on Outthentic::DSL )

So. Follow metacpan/github docs, find your proper tool and enjoy your testing with Outthentic!/users/melezhik/2015/11/index.html

About melezhik

user-pic Dev & Devops --- Then I beheld all the work of God, that a man cannot find out the work that is done under the sun: because though a man labour to seek it out, yet he shall not find it; yea further; though a wise man think to know it, yet shall he not be able to find it. (Ecclesiastes 8:17)