Transport tests updated to changes in transport subsystem.

This commit is contained in:
tomas 2005-01-19 05:23:33 +00:00
parent b4d240a096
commit 90c3bee5e6
2 changed files with 280 additions and 26 deletions

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.3 $
Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/tests/transTest.php,v $
------------------------------------------------------------------------------*/
@ -39,43 +39,100 @@ PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$dbc = DB::connect($config['dsn'], TRUE);
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new LocStor(&$dbc, $config);
$tr = &new Transport(&$gb->dbc, &$gb, $gb->config);
@unlink("{$tr->transDir}/log");
$gunid = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
$gunid = 'a23456789abcdefa';
$mediaFile = '../tests/ex1.mp3';
$mdataFile = '../tests/mdata1.xml';
/* ========== UPLOAD ========== */
/*
*/
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
echo"# Store: ";
$r = $gb->storeAudioClip($sessid, $gunid, $mediaFile, $mdataFile);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
echo "$r\n";
echo"# Upload: "; $r = $gb->uploadFile('', $gunid, $sessid);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
echo join(', ',$r)."\n";
$parid = $gb->_getHomeDirId($sessid);
$oid = $gb->bsPutFile($parid, "xx1.mp3", $mediaFile, $mdataFile, $gunid, 'audioclip');
if(PEAR::isError($oid)){ echo "ERROR: ".$oid->getMessage()."\n"; exit(1); }
$comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
echo "$oid\n";
echo"# Cron: "; list($r1, $r2) = $gb->cronJob();
if(PEAR::isError($r1)){ echo "ERROR: ".$r1->getMessage()."\n"; exit(1); }
if(PEAR::isError($r2)){ echo "ERROR: ".$r2->getMessage()."\n"; exit(1); }
echo "$r1, $r2\n";
echo"# Delete: "; $r = $gb->deleteAudioClip($sessid, $gunid);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
echo "$r\n";
echo"# Download: "; $r = $gb->downloadFile($gunid, $sessid);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
echo join(', ',$r)."\n";
echo"# Cron: "; $r = $gb->cronJob();
if(PEAR::isError($r1)){ echo "ERROR: ".$r1->getMessage()."\n"; exit(1); }
if(PEAR::isError($r2)){ echo "ERROR: ".$r2->getMessage()."\n"; exit(1); }
echo "$r1, $r2\n";
echo"# Transport uploadToArchive: ";
$r = $tr->uploadToArchive($gunid, $sessid);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getUserInfo()."\n"; exit(1); }
var_dump($r);
echo"# logout: "; $r = $gb->logout($sessid);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
echo "$r\n";
foreach(array(1,2,3) as $nu){
echo"# Transport: uploadCron: "; $r = $tr->uploadCron();
if(PEAR::isError($r)){
echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1);
}
var_dump($r);
}
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
echo"# Delete: "; $r = $gb->deleteAudioClip($sessid, $gunid);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
echo "$r\n";
echo"# logout: "; $r = $gb->logout($sessid);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
echo "$r\n";
$comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
#echo `tail -n 20 ../trans/log`; exit;
/* === DOWNLOAD === */
/*
*/
echo"# Login: ".($sessid = $gb->login('root', 'q'))."\n";
echo"# Transport downloadFromArchive: ";
$r = $tr->downloadFromArchive($gunid, $sessid);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getUserInfo()."\n"; exit(1); }
var_dump($r);
echo"# logout: "; $r = $gb->logout($sessid);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
echo "$r\n";
foreach(array(1,2,3) as $nu){
echo"# Transport: downloadCron: "; $r = $tr->downloadCron();
if(PEAR::isError($r)){
echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1);
}
var_dump($r);
}
$comm = "ls -l {$gb->storageDir}/a23"; echo `$comm`;
echo `tail -n 20 ../trans/log`; exit;
/*
*/
/*
echo"# Transport loginToArchive: "; $r = $tr->loginToArchive();
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
var_dump($r['sessid']);
echo"# Transport logoutFromArchive: "; $r = $tr->logoutFromArchive($r['sessid']);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
var_dump($r['status']);
echo"# Ping: ";
$r = $tr->pingToArchive();
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
var_dump($r);
echo"# Delete: "; $r = $gb->deleteAudioClip($sessid, $gunid);
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
echo "$r\n";
*/
echo "#Transport test: OK.\n\n"
?>

View File

@ -0,0 +1,197 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# 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/tests/transTest.sh,v $
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script call locstor.resetStorage XMLRPC method
#-------------------------------------------------------------------------------
reldir=`dirname $0`/../..
WWW_ROOT=`cd $reldir/var/install; php -q getWwwRoot.php` || exit $?
echo "#Transport test: URL: $WWW_ROOT"
#$reldir/var/xmlrpc/xr_cli_test.py -s $WWW_ROOT/xmlrpc/xrLocStor.php \
# resetStorage || exit $?
cd $reldir/var/xmlrpc
XR_CLI="php -q xr_cli_test.php -s $WWW_ROOT/xmlrpc/xrLocStor.php"
login() {
echo -n "# login: "
SESSID=`$XR_CLI login root q` || \
{ ERN=$?; echo $SESSID; exit $ERN; }
echo "sessid: $SESSID"
}
storeOpen() {
echo "# store: "
METADATA="<?xml version=\"1.0\"?>
<audioClip><metadata xmlns=\"http://www.streamonthefly.org/\"
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
xmlns:dcterms=\"http://purl.org/dc/terms/\">
<dcterms:extent>00:00:11</dcterms:extent></metadata></audioClip>"
MEDIA=../tests/ex1.mp3
MD5=`md5sum $MEDIA`; for i in $MD5; do MD5=$i; break; done
RES=`$XR_CLI storeAudioClipOpen "$SESSID" "$GUNID" "$METADATA" "stored_file.mp3" "$MD5"` || \
{ ERN=$?; echo $RES; exit $ERN; }
unset URL
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
echo " URL = $URL"
echo " TOKEN = $TOKEN"
}
storeClose() {
echo -n "# curl (PUT): "
curl -C 0 -T $MEDIA $URL || exit $?
echo "status: $?"
echo -n "# storeAudioClipClose: "
GUNID=`$XR_CLI storeAudioClipClose "$SESSID" "$TOKEN"` || \
{ ERN=$?; echo $GUNID; exit $ERN; }
echo $GUNID
}
deleteAudioClip() {
echo -n "# deleteAudioClip: "
$XR_CLI deleteAudioClip $SESSID $GUNID || exit $?
}
uploadToArchive() {
echo -n "# uploadToArchive: "
TRTOK=`$XR_CLI uploadToArchive $SESSID $GUNID` || \
{ ERN=$?; echo $TRTOK; exit $ERN; }
echo $TRTOK
}
downloadFromArchive() {
echo -n "# downloadFromArchive: "
TRTOK=`$XR_CLI downloadFromArchive $SESSID $GUNID` || \
{ ERN=$?; echo $TRTOK; exit $ERN; }
echo $TRTOK
}
getTransportInfo() {
echo "# getTransportInfo:"
$XR_CLI getTransportInfo $SESSID $TRTOK
echo "# status: $?"
}
transportCron() {
echo -n "# transportCron: "
../cron/transportCron.php
echo $?
}
logout() {
echo -n "# logout: "
$XR_CLI logout $SESSID || exit $?
}
PLID="123456789abcdef8"
createPlaylist() {
echo -n "# createPlaylist: "
$XR_CLI createPlaylist $SESSID $PLID "newPlaylist.xml" || exit $?
}
editPlaylist() {
DATE=`date '+%H:%M:%S'`
PLAYLIST="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<smil><head><metadata>
<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:dc=\"http://purl.org/metadata/dublin_core#\">
<dc:title>XY $DATE</dc:title>
</rdf:RDF>
</metadata></head><body><seq>
<audio src=\"123456789abcdefa\"/>
<audio src=\"123456789abcdefb\"/>
</seq></body></smil>"
echo -n "# editPlaylist: "
RES=`$XR_CLI editPlaylist $SESSID $PLID` || \
{ ERN=$?; echo $RES; exit $ERN; }
unset URL
for i in $RES; do if [ -z $URL ] ; then URL=$i; else TOKEN=$i; fi; done
echo $TOKEN
# deletePlaylist
if [ $DEBUG_I ]; then echo $URL; fi
if [ $DEBUG_I ]; then echo -n "Press enter ..."; read KEY; fi
if [ $DEBUG_I ]; then echo " Playlist:"; echo $PLAYLIST; fi
echo -n "# savePlaylist: "
$XR_CLI savePlaylist $SESSID $TOKEN "$PLAYLIST" || exit $?
}
deletePlaylist() {
echo -n "# deletePlaylist (${PLID}): "
$XR_CLI deletePlaylist $SESSID $PLID
# || exit $?
echo "# status: $?"
}
testPrint(){
ls -l ../stor/a23
md5sum ../stor/a23/a23456789abcdef2
}
#PLID="a23456789abcdef3"
#GUNID=$PLID
#GUNID="a23456789abcdef2"
login
storeOpen
storeClose
#createPlaylist
#editPlaylist
#testPrint
uploadToArchive
#TRTOK="99ce8d099fc10ac5"
getTransportInfo
transportCron
getTransportInfo
transportCron
getTransportInfo
deleteAudioClip
#deletePlaylist
#testPrint
downloadFromArchive
#TRTOK="72bbe5eaa3ce7165"
getTransportInfo
transportCron
getTransportInfo
transportCron
getTransportInfo
#testPrint
logout
echo "#Transport test: OK"
exit 0