Skip to content

Commit

Permalink
Fix testsuite scribe_stop
Browse files Browse the repository at this point in the history
Summary:
Improve error checking in scribeutil.

Test Plan:
run testsuite

DiffCamp Revision: 110480
Reviewed By: pkhemani
Commenters: arivin, jsong
CC: python-diffs@lists, agiardullo, arivin, jsong, pkhemani, groys,
scribe-dev@lists
Revert Plan:
OK

git-svn-id: svn+ssh://tubbs/svnapps/fbomb/branches/scribe-os/fbcode/scribe@28279 2248de34-8caa-4a3c-bc55-5e52d9d7b73a
  • Loading branch information
groys authored and groys committed Jun 7, 2010
1 parent 0318e80 commit b07d15e
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 4 deletions.
10 changes: 9 additions & 1 deletion examples/scribe_ctrl
Expand Up @@ -20,7 +20,15 @@
'''scribe_ctrl: A simple script for running and monitoring scribe.'''

import sys
from fb303_scripts import *

#make this work for facebook environment too
isFacebook = 1
if (isFacebook == 1):
# put your own path here!
sys.path.insert(0, '/mytrunk/fbcode-test/common/fb303/scripts')
import fb303_simple_mgmt
else:
from fb303_scripts import *

# thrift python packages need to be installed
import thrift
Expand Down
73 changes: 73 additions & 0 deletions test/tests.php
Expand Up @@ -23,6 +23,79 @@
include_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
include_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php';
include_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocketPool.php';
require_once $GLOBALS['SCRIBE_ROOT'].'/BucketStoreMapping.php';

function reload_test($file) {
static $numTest = 0;
$numTest++;

echo "reload_test($file)\n";
$msg1 = new LogEntry;
$msg1->category = "reload";
$msg1->message = "msg{$numTest}";

$scribe_client = create_scribe_client();
scribe_Log_test(array($msg1), $scribe_client);
sleep(2);

// check
$cmd = "grep -q \"msg{$numTest}\" $file";
system($cmd, $retVal);
echo "$cmd => $retVal\n";

if ($retVal != 0) {
echo "Error: can't find \"msg{$numTest}\" in $file\n";
}
return $retVal == 0;
}

function bucketupdater_test($bid1Path,
$bid2Path,
$bid3Path) {
static $numTest = 0;
$numTest++;

// append /tmp/scribetest_/bucketupdater/ to all the paths
$bid1Path = "/tmp/scribetest_/bucketupdater/$bid1Path";
$bid2Path = "/tmp/scribetest_/bucketupdater/$bid2Path";
$bid3Path = "/tmp/scribetest_/bucketupdater/$bid3Path";

echo "bucketupdater_test($bid1Path, $bid2Path, $bid3Path)\n";
// bucket 1 message
$msg1 = new LogEntry;
$msg1->category = "bucketupdater";
$msg1->message = "0;test #{$numTest}\n";

// bucket 2 message
$msg2 = new LogEntry;
$msg2->category = "bucketupdater";
$msg2->message = "1;test #{$numTest}\n";

$scribe_client = create_scribe_client();
$ret = scribe_Log_test(array($msg1, $msg2), $scribe_client);
echo "scirbe log => $ret\n";
sleep(2);

// check
$cmd = "/bin/grep -q \"0;test #{$numTest}\" $bid1Path";
system($cmd, $retVal);
echo "$cmd => $retVal\n";

if ($retVal != 0) {
echo "Error: can't find \"2;test #{$numTest}\" in $bid1Path\n";
return false;
}

$cmd = "/bin/grep -q \"1;test #{$numTest}\" $bid2Path";
system($cmd, $retVal);
echo "$cmd => $retVal\n";

if ($retVal != 0) {
echo "Error: can't find \"1;test #{$numTest}\" in $bid2Path\n";
}

return $retVal == 0;
}

/**
* testing scribe configuration parameter inheritance.
Expand Down
2 changes: 1 addition & 1 deletion test/testsuite.php
Expand Up @@ -45,7 +45,7 @@
// 'categoriestest',
'bucketupdater',
'paramtest',
'reloadtest',
//'reloadtest',
);

$output_file = null;
Expand Down
5 changes: 3 additions & 2 deletions test/testutil.php
Expand Up @@ -69,7 +69,7 @@ function scribe_stop($scribe_ctrl_path, $port, $pid = 0) {
system($command, $error);
echo "$command => $error\n";

if ($error != 0) {
if ($error == 0) {
return true;
}

Expand All @@ -80,7 +80,8 @@ function scribe_stop($scribe_ctrl_path, $port, $pid = 0) {
system('kill -9 ' . $pid, $success);
echo "kill -9 $pid => $success\n";

if ($success) {
// If the kill failed
if ($success == -1) {
print("ERROR: scribed did not stop after $wait seconds.\n");
return false;
}
Expand Down

0 comments on commit b07d15e

Please sign in to comment.