XMLRPC test client have been rewritten into PHP (from Python => Python is not
required now)
This commit is contained in:
parent
85c44e8a72
commit
4c0f884085
3 changed files with 214 additions and 8 deletions
|
@ -22,7 +22,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: tomas $
|
||||
# Version : $Revision: 1.1 $
|
||||
# Version : $Revision: 1.2 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/resetStorage.sh,v $
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -34,7 +34,11 @@ reldir=`dirname $0`/..
|
|||
WWW_ROOT=`cd $reldir/var/install; php -q getWwwRoot.php` || exit $?
|
||||
echo "# storageServer root URL: $WWW_ROOT"
|
||||
|
||||
$reldir/var/xmlrpc/xr_cli_test.py -s $WWW_ROOT/xmlrpc/xrLocStor.php \
|
||||
#$reldir/var/xmlrpc/xr_cli_test.py -s $WWW_ROOT/xmlrpc/xrLocStor.php \
|
||||
# resetStorage || exit $?
|
||||
|
||||
cd $reldir/var/xmlrpc
|
||||
php -q xr_cli_test.php -s $WWW_ROOT/xmlrpc/xrLocStor.php \
|
||||
resetStorage || exit $?
|
||||
|
||||
echo "# resetStorage: OK"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#
|
||||
#
|
||||
# Author : $Author: tomas $
|
||||
# Version : $Revision: 1.15 $
|
||||
# Version : $Revision: 1.16 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/testRunner.sh,v $
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -43,15 +43,18 @@ METADATA="<?xml version=\"1.0\"?>
|
|||
<dcterms:extent>00:00:11</dcterms:extent></metadata></audioClip>"
|
||||
|
||||
echo ""
|
||||
XRDIR=`dirname $0`
|
||||
XMLRPC=`cd var/install; php -q getXrUrl.php` || exit $?
|
||||
echo "# storageServer XMLRPC URL: $XMLRPC"
|
||||
|
||||
TESTDIR=`dirname $0`
|
||||
XR_CLI="$TESTDIR/xr_cli_test.py -s ${XMLRPC}"
|
||||
cd $XRDIR
|
||||
#XR_CLI="./xr_cli_test.py -s ${XMLRPC}"
|
||||
XR_CLI="php -q xr_cli_test.php -s ${XMLRPC}"
|
||||
|
||||
login() {
|
||||
echo -n "# login: "
|
||||
SESSID=`$XR_CLI login root q` || exit $?
|
||||
SESSID=`$XR_CLI login root q` || \
|
||||
{ ERN=$?; echo $SESSID; exit $ERN; }
|
||||
echo "sessid: $SESSID"
|
||||
}
|
||||
|
||||
|
@ -66,7 +69,7 @@ existsAudioClip() {
|
|||
}
|
||||
|
||||
storeAudioClip() {
|
||||
MEDIA=var/tests/ex1.mp3
|
||||
MEDIA=../tests/ex1.mp3
|
||||
MD5=`md5sum $MEDIA`; for i in $MD5; do MD5=$i; break; done
|
||||
if [ $DEBUG_I ]; then echo "md5=$MD5"; fi
|
||||
echo -n "# storeAudioClipOpen: "
|
||||
|
@ -300,10 +303,11 @@ storageTest(){
|
|||
}
|
||||
|
||||
usage(){
|
||||
echo "Usage: $0 <command> [args]"
|
||||
echo "Usage: $0 [<command>] [args]"
|
||||
echo -e "commands:\n test\n existsAudioClip\n accessRawAudioData"
|
||||
echo -e " storeAudioClip\n deleteAudioClip\n updateAudioClipMetadata"
|
||||
echo -e " getAudioClip\n searchMetadata\n"
|
||||
echo -e " preferences\n playlists\n storage\n"
|
||||
}
|
||||
|
||||
if [ "$COMM" == "test" ]; then
|
||||
|
|
198
livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.php
Normal file
198
livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.php
Normal file
|
@ -0,0 +1,198 @@
|
|||
<?php
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2004 Media Development Loan Fund
|
||||
|
||||
This file is part of the LiveSupport project.
|
||||
http://livesupport.campware.org/
|
||||
To report bugs, send an e-mail to bugs@campware.org
|
||||
|
||||
LiveSupport is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
LiveSupport is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with LiveSupport; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: tomas $
|
||||
Version : $Revision: 1.1 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/xmlrpc/xr_cli_test.php,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
include_once "../xmlrpc/XML/RPC.php";
|
||||
|
||||
$pars = $argv;
|
||||
array_shift($pars);
|
||||
$verbose = FALSE;
|
||||
if($pars[0] == '-v'){ $verbose = TRUE; array_shift($pars); }
|
||||
if($pars[0] == '-s'){
|
||||
array_shift($pars);
|
||||
$serverPath = array_shift($pars);
|
||||
}else $serverPath = 'http://localhost:80/livesupportStorageServer/xmlrpc/xrLocStor.php';
|
||||
|
||||
#$serverPath = "http://localhost:80/livesupportStorageServerCVS/xmlrpc/xrLocStor.php";
|
||||
|
||||
$url = parse_url($serverPath);
|
||||
$client = new XML_RPC_Client($url['path'], $url['host']);
|
||||
$method = array_shift($pars);
|
||||
|
||||
if($verbose){
|
||||
echo "serverPath: $serverPath\n";
|
||||
echo "host: {$url['host']}, path: {$url['path']}\n";
|
||||
echo "method: $method\n";
|
||||
echo "pars:\n";
|
||||
var_dump($pars);
|
||||
}
|
||||
|
||||
$infos = array(
|
||||
"listMethods" => array('m'=>"system.listMethods", 'p'=>NULL),
|
||||
"methodHelp" => array('m'=>"system.methodHelp", 'p'=>0),
|
||||
"methodSignature" => array('m'=>"system.methodSignature", 'p'=>0),
|
||||
"test" =>
|
||||
array('m'=>"locstor.test", 'p'=>array('sessid', 'teststring')),
|
||||
"authenticate" => array('m'=>"locstor.authenticate",
|
||||
'p'=>array('login', 'pass'), 'r'=>'authenticate'),
|
||||
"login" => array('m'=>"locstor.login",
|
||||
'p'=>array('login', 'pass'), 'r'=>'sessid'),
|
||||
"logout" => array('m'=>"locstor.logout",
|
||||
'p'=>array('sessid'), 'r'=>'status'),
|
||||
|
||||
"storeAudioClipOpen" => array('m'=>"locstor.storeAudioClipOpen",
|
||||
'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'chsum'),
|
||||
'r'=>array('url', 'token')
|
||||
),
|
||||
"storeAudioClipClose" => array('m'=>"locstor.storeAudioClipClose",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
|
||||
"accessRawAudioData" => array('m'=>"locstor.accessRawAudioData",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
|
||||
"releaseRawAudioData" => array('m'=>"locstor.releaseRawAudioData",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'status'),
|
||||
"downloadRawAudioDataOpen" =>
|
||||
array('m'=>"locstor.downloadRawAudioDataOpen",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
|
||||
"downloadRawAudioDataClose" =>
|
||||
array('m'=>"locstor.downloadRawAudioDataClose",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
|
||||
"downloadMetadataOpen" => array('m'=>"locstor.downloadMetadataOpen",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>array('url', 'token')),
|
||||
"downloadMetadataClose" => array('m'=>"locstor.downloadMetadataClose",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'gunid'),
|
||||
|
||||
"deleteAudioClip" =>
|
||||
array('m'=>"locstor.deleteAudioClip",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'status'),
|
||||
"existsAudioClip" => array('m'=>"locstor.existsAudioClip",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'exists'),
|
||||
"getAudioClip" => array('m'=>"locstor.getAudioClip",
|
||||
'p'=>array('sessid', 'gunid'), 'r'=>'metadata'),
|
||||
"updateAudioClipMetadata" => array('m'=>"locstor.updateAudioClipMetadata",
|
||||
'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'),
|
||||
"searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL),
|
||||
"resetStorage" => array('m'=>"locstor.resetStorage", 'p'=>array()),
|
||||
|
||||
"createPlaylist" => array('m'=>"locstor.createPlaylist",
|
||||
'p'=>array('sessid', 'plid', 'fname'), 'r'=>'plid'),
|
||||
"editPlaylist" => array('m'=>"locstor.editPlaylist",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')),
|
||||
"savePlaylist" => array('m'=>"locstor.savePlaylist",
|
||||
'p'=>array('sessid', 'token', 'newPlaylist'), 'r'=>'plid'),
|
||||
"deletePlaylist" => array('m'=>"locstor.deletePlaylist",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>'status'),
|
||||
"accessPlaylist" => array('m'=>"locstor.accessPlaylist",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>array('url', 'token')),
|
||||
"releasePlaylist" => array('m'=>"locstor.releasePlaylist",
|
||||
'p'=>array('sessid', 'token'), 'r'=>'plid'),
|
||||
"existsPlaylist" => array('m'=>"locstor.existsPlaylist",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>'exists'),
|
||||
"playlistIsAvailable" => array('m'=>"locstor.playlistIsAvailable",
|
||||
'p'=>array('sessid', 'plid'), 'r'=>'available'),
|
||||
|
||||
"loadPref" => array('m'=>"locstor.loadPref",
|
||||
'p'=>array('sessid', 'key'), 'r'=>'value'),
|
||||
"savePref" => array('m'=>"locstor.savePref",
|
||||
'p'=>array('sessid', 'key', 'value'), 'r'=>'status'),
|
||||
"delPref" => array('m'=>"locstor.delPref",
|
||||
'p'=>array('sessid', 'key'), 'r'=>'status'),
|
||||
"openPut" => array('m'=>"locstor.openPut", 'p'=>array()),
|
||||
"closePut" => array('m'=>"locstor.closePut", 'p'=>array()),
|
||||
);
|
||||
|
||||
|
||||
$fullmethod = $infos[$method]['m'];
|
||||
$pinfo = $infos[$method]['p'];
|
||||
if(is_null($pinfo)){
|
||||
$parr = NULL;
|
||||
}elseif(!is_array($pinfo)){
|
||||
$parr = $pars[0];
|
||||
#echo "pinfo not null and not array.\n"; exit;
|
||||
}elseif(count($pinfo) == 0){
|
||||
$parr = array();
|
||||
}else{
|
||||
$parr = array(); $i=0;
|
||||
foreach($pinfo as $it){
|
||||
$parr[$it] = $pars[$i++];
|
||||
}
|
||||
}
|
||||
if($method == 'searchMetadata'){
|
||||
$parr = array(
|
||||
'sessid'=>$pars[0],
|
||||
'criteria'=>array(
|
||||
'filetype'=>'audioclip',
|
||||
'operator'=>'and',
|
||||
'limit'=> 0,
|
||||
'offset'=> 0,
|
||||
'conditions'=>array(
|
||||
array('cat'=>$pars[1], 'op'=>'partial', 'val'=>$pars[2])
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
$msg = new XML_RPC_Message($fullmethod, array(XML_RPC_encode($parr)));
|
||||
|
||||
if($verbose){
|
||||
echo "parr:\n";
|
||||
var_dump($parr);
|
||||
echo "message:\n";
|
||||
echo $msg->serialize()."\n";
|
||||
}
|
||||
|
||||
$res = $client->send($msg);
|
||||
if($res->faultCode() > 0) {
|
||||
echo "xr_cli_test.php: ".$res->faultString()." ".$res->faultCode()."\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if($verbose){
|
||||
echo "result:\n";
|
||||
echo $res->serialize();
|
||||
}
|
||||
|
||||
$resp = XML_RPC_decode($res->value());
|
||||
if(isset($infos[$method]['r'])){
|
||||
$pom = $infos[$method]['r'];
|
||||
if(is_array($pom)){
|
||||
foreach($pom as $k=>$it) $pom[$k] = $resp[$it];
|
||||
echo join(' ', $pom)."\n";
|
||||
}else switch($pom){
|
||||
case"status":
|
||||
case"exists":
|
||||
echo ($resp[$pom]=='1' ? "TRUE" : "FALSE" )."\n";
|
||||
break;
|
||||
default:
|
||||
echo "{$resp[$pom]}\n";
|
||||
}
|
||||
}else{
|
||||
print_r($resp);
|
||||
# echo"\n";
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue