Page 1 of 1

Nagios Integration with Selenium Issues.

Posted: Thu Jul 16, 2015 5:34 am
by njain213
Hi Team,

While Integrating Nagios XI with selenium, I am following installation guide as given in the link below:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

During Test-WWW-Selenium-1.36.tar.gz installation I am facing issues as shown below.

Issues are coing after "make test" command.

Code: Select all

make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-compile.t ........... ok   
t/01_load.t .............. ok   
t/interweb.t ............. skipped: not running live interweb tests
t/selenium-compat.t ...... 1/27 
#   Failed test at t/WWW/Selenium.pm line 40.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fexample.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Fexample.com'
# Looks like you failed 1 test of 27.
t/selenium-compat.t ...... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/27 subtests 
t/selenium-core.t ........ 1/? 
#   Failed test at t/WWW/Selenium.pm line 40.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fexample.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Fexample.com'
# Looks like you failed 1 test of 151.
t/selenium-core.t ........ Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/151 subtests 
t/selenium-dwim.t ........ 1/30 
#   Failed test at t/WWW/Selenium.pm line 40.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fexample.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Fexample.com'

#   Failed test at t/WWW/Selenium.pm line 40.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fexample.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Fexample.com'

#   Failed test at t/WWW/Selenium.pm line 40.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fexample.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Fexample.com'

#   Failed test at t/WWW/Selenium.pm line 40.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fexample.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Fexample.com'

#   Failed test at t/WWW/Selenium.pm line 40.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fexample.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Fexample.com'

#   Failed test at t/WWW/Selenium.pm line 40.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fexample.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Fexample.com'

#   Failed test at t/WWW/Selenium.pm line 40.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fexample.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Fexample.com'
# Looks like you failed 7 tests of 30.
t/selenium-dwim.t ........ Dubious, test returned 7 (wstat 1792, 0x700)
Failed 7/30 subtests 
t/selenium-rc.t .......... 1/50 
#   Failed test at t/selenium-rc.t line 151.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Ffoo.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Ffoo.com'
# Looks like you failed 1 test of 50.
t/selenium-rc.t .......... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/50 subtests 
t/test-selenium.t ........ ok     
t/test_default_server.t .. skipped: No selenium server found!
t/test_google.t .......... skipped: No selenium server found!
t/test_i18n.t ............ skipped: No selenium server found!
t/timeouts.t ............. 1/5 
#   Failed test at t/WWW/Selenium.pm line 40.
#          got: 'cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fexample.com'
#     expected: 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Fexample.com'
# Looks like you failed 1 test of 5.
t/timeouts.t ............. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/5 subtests 

Test Summary Report
-------------------
t/selenium-compat.t    (Wstat: 256 Tests: 27 Failed: 1)
  Failed test:  4
  Non-zero exit status: 1
t/selenium-core.t      (Wstat: 256 Tests: 151 Failed: 1)
  Failed test:  5
  Non-zero exit status: 1
t/selenium-dwim.t      (Wstat: 1792 Tests: 30 Failed: 7)
  Failed tests:  4, 8, 13, 17, 21, 25, 29
  Non-zero exit status: 7
t/selenium-rc.t        (Wstat: 256 Tests: 50 Failed: 1)
  Failed test:  13
  Non-zero exit status: 1
t/timeouts.t           (Wstat: 256 Tests: 5 Failed: 1)
  Failed test:  4
  Non-zero exit status: 1
Files=12, Tests=332,  1 wallclock secs ( 0.07 usr  0.03 sys +  0.52 cusr  0.11 csys =  0.73 CPU)
Result: FAIL
Failed 5/12 test programs. 11/332 subtests failed.
make: *** [test_dynamic] Error 1
Thanks
Naman

Re: Nagios Integration with Selenium Issues.

Posted: Thu Jul 16, 2015 2:15 pm
by tmcdonald
You might actually be able to continue. The make test command just runs some checks to see if the expected output is received, and in this case it seems like it isn't handling certain characters properly in the URL. For example, a space is usually represented as %2F and it seems not to like that. However being tests these might not represent perfectly a running environment.

Try continuing on to the make install step and go from there. If you run into more issues please post back.

Re: Nagios Integration with Selenium Issues.

Posted: Thu Jul 16, 2015 10:36 pm
by njain213
One more thing I want to know that in the step “Customize The Simpletest Script”, it is pointing to which Simpletest Script?

Please elaborate below lines:
Once downloaded to the /tmp directory be sure to move the Selenium test that we recorded at the beginning of this document, to the
same directory you placed the clean_selenium_script in, then run the following:

perl clean_selenium_script --filename=simpletest –o=simpletest

If you placed your simpletest script in another directory simply change the command like so:

perl clean_selenium_script –filename=/path/to/simpletest –o=simpletest

This will edit and format the file named simpletest and rename the output as simpletest once again.
Now, we must set the values inside the Perl script to those of
our Selenium server. Use the text editor of your choice and
edit the simpletest file. Edit following lines:

Code: Select all

new(host => “<selenium.server.ip.here>”,
 port => <port here>
 browser => “*firefox”,
Thanks
Naman

Re: Nagios Integration with Selenium Issues.

Posted: Fri Jul 17, 2015 1:37 pm
by tmcdonald
I think there is a typo on page 2 when we say to save the file as "sampletest". This should be "simpletest" and would explain where that file is supposed to have come from. I will see about getting this fixed.

Re: Nagios Integration with Selenium Issues.

Posted: Mon Jul 20, 2015 1:12 am
by njain213
Hi,

I have done with the Simpletest script part.

Simpletest Script:

Code: Select all

Use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;
use TimePerf2;

my $time= TimePerf2->new(60,90,120);


my $sel = Test::WWW::Selenium->new( host => "10.0.2.15",
                                    port => 80,
                                    browser => "*firefox",
                                    browser_url => "https://www.google.com" );

pass;
elsif ( !$time->endTime("ALL") ) { }

else { $time->getTimes(); }
$sel->stop();
Now, I have moved Simpletest script to the path /usr/local/nagios/libexec and after running the command "perl Simpletest",it gives the below error.

root@localhost libexec]# perl Simpletest
syntax error at Simpletest line 18, near "elsif"
Execution of Simpletest aborted due to compilation errors.
# Looks like your test exited with 255 before it could output anything.



When I have commented out below lines:

elsif ( !$time->endTime("ALL") ) { }

else { $time->getTimes(); }
$sel->stop();

it gives me the below error:

[root@localhost libexec]# perl Simpletest
Error requesting http://10.0.2.15:80/selenium-server/driver/:
404 Not Found
# Looks like your test exited with 255 before it could output anything.


Can you please help me out in this?

Thanks
Naman

Re: Nagios Integration with Selenium Issues.

Posted: Mon Jul 20, 2015 2:53 pm
by tmcdonald
That elsif line and the others that you commented out need to remain, but the elsif part needs to just be if. Not sure why it is like that. Try making that change and running it.

Re: Nagios Integration with Selenium Issues.

Posted: Mon Jul 20, 2015 2:59 pm
by lmiltchev
Are you sure that port 80 is the correct port for the selenium server?

I am able to recreate the issue if I use port 80, however the simpletest runs fine if I use the "default" port 4444.

I would recommend repeating the steps from the "Recording A Test Case" section in the document, saving the "simpletest", modifying it by adding the selenium server's IP and leaving the default port 4444 unchanged.

Code: Select all

my $sel = Test::WWW::Selenium->new( host => "10.0.2.15",
                                    port => 4444,
                                    browser => "*firefox",
                                    browser_url => "https://www.google.com" );
Move the "simpletest" to your Nagios XI server, and run:

Code: Select all

perl simpletest
to test it. Let me know if this helped.

Re: Nagios Integration with Selenium Issues.

Posted: Tue Jul 21, 2015 10:07 pm
by njain213
Thanks for your help.

Its working now.

Re: Nagios Integration with Selenium Issues.

Posted: Wed Jul 22, 2015 9:14 am
by tmcdonald
I'll be closing this thread now, but feel free to open another if you need anything in the future!