Permalink
Browse files

Fix testsuite scribe_stop

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
1 parent 0318e80 commit b07d15eacd6327ca331518ad697820fd1fbe5b00 groys committed with groys May 21, 2010
Showing with 86 additions and 4 deletions.
  1. +9 −1 examples/scribe_ctrl
  2. +73 −0 test/tests.php
  3. +1 −1 test/testsuite.php
  4. +3 −2 test/testutil.php
View
@@ -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
View
@@ -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.
View
@@ -45,7 +45,7 @@
// 'categoriestest',
'bucketupdater',
'paramtest',
- 'reloadtest',
+ //'reloadtest',
);
$output_file = null;
View
@@ -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;
}
@@ -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;
}

0 comments on commit b07d15e

Please sign in to comment.