Remote Execution with Testlink 1.9.2

Discussion and information for XML-RPC interface.

Moderators: Amaradana, TurboPT, TL Developers

Post Reply
tom1
Advanced user
Posts: 23
Joined: Thu Nov 11, 2010 4:40 pm

Remote Execution with Testlink 1.9.2

Post by tom1 »

Hi,
I updated my Testlink version from 1.9.0 to 1.9.2. In 1.9.0 the remote execution only works with a "small" workaround like this: http://www.teamst.org/forum/viewtopic.php?f=11&t=3663

And now it works out of the box :D

Here a short description:
Activate API in config.inc.php: $tlCfg->api->enabled = TRUE
Enable XML-RPC calls in config.inc.php: $tlCfg->exec_cfg->enable_test_automation = ENABLED
Define a custom field e.g. on Testcase level: RE-XMLRPC_url_tcase
Set value to IP:PORT/PATH, eg: 192.168.1.63:8000/RPC2

And an example server in perl:

Code: Select all

#!/usr/bin/perl -w

use Frontier::Daemon;
use RPC::XML::Client;
use strict;

#============================================================================
# Init
#============================================================================

# Methods used by frontier daemon
my $methods = {'executeTestCase' => \&ExecuteTest};

# Get testlink devkey
my $devkey = "1234567890";

# Testlink api url
my $testlink_server = 'http://localhost/testlink/lib/api/xmlrpc.php';

#============================================================================
# Main
#============================================================================

# Start frontier daemon
print "Starting Frontier Daemon...\n";
Frontier::Daemon->new(LocalPort => 8000, methods => $methods) or die "ERROR: Couldnt't start HTTP server: $!";

#============================================================================
# Subs
#============================================================================

# ---------------------------------------------------------------------------
# Test execution
# ---------------------------------------------------------------------------
sub ExecuteTest {
  my ($testCaseName, $testCaseID, $testCaseVersionID, $testProjectID, $testPlanID, $platformID, $buildID, $executionMode);

  my $b = $_[0];

  foreach my $k (keys(%$b)){
    if ($k eq "testCaseName")      { $testCaseName      = $b->{$k} }
    if ($k eq "testCaseID")        { $testCaseID        = $b->{$k} }
    if ($k eq "testCaseVersionID") { $testCaseVersionID = $b->{$k} }
    if ($k eq "testProjectID")     { $testProjectID     = $b->{$k} }
    if ($k eq "testPlanID")        { $testPlanID        = $b->{$k} }
    if ($k eq "platformID")        { $platformID        = $b->{$k} }
    if ($k eq "buildID")           { $buildID           = $b->{$k} }
    if ($k eq "executionMode")     { $executionMode     = $b->{$k} }
  }

  # New XMLRPC client
  my $xmlrpc_testlink = RPC::XML::Client->new($testlink_server);

  # Check if testlink server is running
  my $sayHello = $xmlrpc_testlink->send_request('tl.sayHello');
  if ($$sayHello eq "Hello!") { 
    print "Testlink Server is running!\n";
  } else {
    print "ERROR: Testlink Server is down!\n";
    exit 1;
  }

  # Do some execution and set return values
  print "Execute $testCaseName!\n";
  my $status = "f";
  my $notes = "Testlink XMLRPC Server test";

  # Report test result to testlink
  my $reportTCResult = $xmlrpc_testlink->send_request('tl.reportTCResult', 
   { devKey=>$devkey,
     testcaseid=>$testCaseID,
     testplanid=>$testPlanID,
     buildid=>$buildID,
     status=>$status,
     notes=>$notes,
     guess=>'TRUE',
   });
  my $report_result;
  my @resp_array = @{$reportTCResult->value};
  $b  = $resp_array[0];
  foreach my $k (keys(%$b)){
    if ($k eq "message") { $report_result = $b->{$k} }
  }
  print "Report Result: $report_result\n";
}
Is it necessary to report the result via XMLRPC API or is there a possibility to return some values directly?

Cheers, Tom
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Re: Remote Execution with Testlink 1.9.2

Post by fman »

>> r is there a possibility to return some values directly?
what does this means ?
tom1
Advanced user
Posts: 23
Joined: Thu Nov 11, 2010 4:40 pm

Re: Remote Execution with Testlink 1.9.2

Post by tom1 »

Does the executeTestCase method provides a return value?
There appears a "Remote Execution Result Feedback" afterwards. Is it possible to provide some feedback to display?
mrayappa
TestLink user
Posts: 4
Joined: Wed Jun 08, 2011 5:48 pm

Re: Remote Execution with Testlink 1.9.2

Post by mrayappa »

Can someone please post a python example analogous to the perl example?
aostad
Member of TestLink Community
Posts: 183
Joined: Wed Apr 01, 2009 8:32 pm

Re: Remote Execution with Testlink 1.9.2

Post by aostad »

After reading many posts in this forum, I'm trying to setup a remote execution with testlink, however, get following error in userlog1.log:

[11/Oct/23 00:24:25][WARNING][6hc7h2af4d6veem2lrbs66kgt6][GUI]
E_NOTICE
Trying to get property of non-object - in C:\Accounts\testlink\third_party\xml-rpc\class-IXR.php - Line 554
[<<][4ea35eb9c9af0031883594][DEFAULT][/lib/execute/execSetResults.php][11/Oct/23 00:24:25][11/Oct/23 00:24:26][took 0.241177 secs]
[<<][4ea35eba4f446490219684][DEFAULT][/lib/execute/execNavigator.php][11/Oct/23 00:24:26][11/Oct/23 00:24:26][took 0.072278 secs]
[>>][4ea35eba6351d914818023][DEFAULT][/lib/execute/execNavigator.php][11/Oct/23 00:24:26]
[<<][4ea35eba6351d914818023][DEFAULT][/lib/execute/execNavigator.php][11/Oct/23 00:24:26][11/Oct/23 00:24:26][took 0.112722 secs]
[<<][4ea35ebd160bb704468040][DEFAULT][/lib/execute/execSetResults.php][11/Oct/23 00:24:29][11/Oct/23 00:24:29][took 0.085088 secs]
[>>][4ea35ebd2d065973562078][DEFAULT][/lib/execute/execSetResults.php][11/Oct/23 00:24:29]
[<<][4ea35ebd2d065973562078][DEFAULT][/lib/execute/execSetResults.php][11/Oct/23 00:24:29][11/Oct/23 00:24:29][took 0.197765 secs]

It looks like the error comes from here:
552 function getResponse() {
553 // methodResponses can only have one param - return that
554 return $this->message->params[0];


I first run the server:
C:\RPC2>perl server_001.pl
Starting HTTP Daemon...

C:\RPC2>


Then click on the "Execute and Save Result" button in execution page of a test case.

Is there any configuration that I'm missing? Do I need to change the code to make it work?

I appreciate your help.
aostad
Member of TestLink Community
Posts: 183
Joined: Wed Apr 01, 2009 8:32 pm

Re: Remote Execution with Testlink 1.9.2

Post by aostad »

BTW, I get this in execution page:
Remote execution connection failure - check you config
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Re: Remote Execution with Testlink 1.9.2

Post by fman »

you need to have a client to test that you can connect to your server
aostad
Member of TestLink Community
Posts: 183
Joined: Wed Apr 01, 2009 8:32 pm

Re: Remote Execution with Testlink 1.9.2

Post by aostad »

Sorry, I'm not good at this. Could you please let me know how I can implement a client. Any example?
Thanks.
aostad
Member of TestLink Community
Posts: 183
Joined: Wed Apr 01, 2009 8:32 pm

Re: Remote Execution with Testlink 1.9.2

Post by aostad »

It looks like a connection can noy be stablidh.
[>>][4ea4c5ac4036c742001453][DEFAULT][/lib/execute/execSetResults.php][11/Oct/24 01:55:56]
[11/Oct/24 01:55:57][WARNING][87eeihjdks4bpe03l0vehejg52][GUI]
E_WARNING
fsockopen(): unable to connect to 127.0.0.1:8000 (No connection could be made because the target machine actively refused it.
) - in C:\Accounts\testlink\third_party\xml-rpc\class-IXR.php - Line 507
[11/Oct/24 01:55:57][WARNING][87eeihjdks4bpe03l0vehejg52][GUI]
E_NOTICE
Trying to get property of non-object - in C:\Accounts\testlink\third_party\xml-rpc\class-IXR.php - Line 554


Can somebody please comment and let me know what configuration is missing?

Thanks a lot.
fman
Member of TestLink Community
Posts: 3123
Joined: Tue Nov 15, 2005 7:19 am

Re: Remote Execution with Testlink 1.9.2

Post by fman »

only think I can do is give you a complete PHP example, that you can find on the new FAQ forum
Post Reply