Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a Simple Unit testsuite

Summary: We have used to at facebook for code sanity checking
  • Loading branch information...
commit 778a7277975b9dde40c20b035ced0f9136ca2a30 1 parent ad12eea
groys authored
View
102 test/basictest.php
@@ -0,0 +1,102 @@
+<?php
+// Copyright (c) 2007-2008 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+include_once 'tests.php';
+include_once 'testutil.php';
+
+$success = true;
+
+$pid = scribe_start('basictest', $GLOBALS['SCRIBE_BIN'],
+ $GLOBALS['SCRIBE_PORT'], 'scribe.conf.basictest');
+
+// write 10k messages to category test (handled by default store)
+print("test writing 10k messages to category test\n");
+stress_test('test', 'client1', 1000, 10000, 20, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/test', 'test-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+// write another 10k messages to category test (should see 1 out of order)
+print("test writing another 10k messages (will see 1 out of order)\n");
+stress_test('test', 'client1', 1000, 10000, 20, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/test', 'test-', 'client1');
+
+if ($results["count"] != 20000 || $results["out_of_order"] != 1) {
+ $success = false;
+}
+
+// write 200k messages to category test using different client name
+print("test writing 200k more messages to category test\n");
+stress_test('test', 'client2', 10000, 200000, 50, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/test', 'test-', 'client2');
+
+if ($results["count"] != 200000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+// write 10k messages to category tps (handled by named store)
+print("test writing 10k messages to category tps\n");
+stress_test('tps', 'client1', 1000, 10000, 200, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/tps', 'tps-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+// write 10k messages to category foodoo (handled by prefix store)
+print("test writing 10k messages to category foodoo\n");
+stress_test('foodoo', 'client1', 10000, 10000, 20, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/foodoo', 'foodoo-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+// write 10k messages to category rock (handled by categories prefix store)
+print("test writing 100k messages to category rock\n");
+stress_test('rock', 'client1', 100, 10000, 20, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/rock', 'rock-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+// write 10k messages to category paper (handled by categories store)
+print("test writing 10k messages to category paper\n");
+stress_test('paper', 'client1', 1000, 10000, 20, 500, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/paper', 'paper-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+if (!scribe_stop($GLOBALS['SCRIBE_CTRL'], $GLOBALS['SCRIBE_PORT'], $pid)) {
+ print("ERROR: could not stop scribe\n");
+ $success = false;
+}
+
+return $success;
View
106 test/basictest2.php
@@ -0,0 +1,106 @@
+<?php
+// Copyright (c) 2007-2008 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+include_once 'tests.php';
+include_once 'testutil.php';
+
+// basictest2 is similar to simpletest, except it turns off
+// new_thread_per_category and sets num_thrift_server_threads
+
+$success = true;
+
+$pid = scribe_start('basictest2', $GLOBALS['SCRIBE_BIN'],
+ $GLOBALS['SCRIBE_PORT'], 'scribe.conf.basictest2');
+
+// write 10k messages to category test (handled by default store)
+print("test writing 10k messages to category test\n");
+stress_test('test', 'client1', 1000, 10000, 20, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/default', 'default-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+// write another 10k messages to category test (should see 1 out of order)
+print("test writing another 10k messages (will see 1 out of order)\n");
+stress_test('test', 'client1', 1000, 10000, 20, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/default', 'default-', 'client1');
+
+if ($results["count"] != 20000 || $results["out_of_order"] != 1) {
+ $success = false;
+}
+
+// write 200k messages to category test using different client name
+print("test writing 200k more messages to category test\n");
+stress_test('test', 'client2', 10000, 200000, 50, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/default', 'default-', 'client2');
+
+if ($results["count"] != 200000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+// write 10k messages to category tps (handled by named store)
+print("test writing 10k messages to category tps\n");
+stress_test('tps', 'client1', 1000, 10000, 200, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/tps', 'tps-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+// write 10k messages to category foodoo (handled by prefix store)
+print("test writing 10k messages to category foodoo\n");
+stress_test('foodoo', 'client1', 10000, 10000, 20, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/foo', 'foo-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+// write 10k messages to category rock (handled by categories prefix store)
+print("test writing 100k messages to category rock\n");
+stress_test('rock', 'client1', 100, 10000, 20, 100, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/rockpaper', 'rockpaper-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+// write 10k messages to category paper (handled by categories store)
+print("test writing 10k messages to category paper\n");
+stress_test('paper', 'client2', 1000, 10000, 20, 500, 1);
+sleep(5);
+$results = resultChecker('/tmp/scribetest_/rockpaper', 'rockpaper-', 'client2');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+
+if (!scribe_stop($GLOBALS['SCRIBE_CTRL'], $GLOBALS['SCRIBE_PORT'], $pid)) {
+ print("ERROR: could not stop scribe\n");
+ return false;
+}
+
+return $success;
View
23 test/bucket_test.php
@@ -0,0 +1,23 @@
+<?php
+// Copyright (c) 2007-2008 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+include_once 'tests.php';
+
+bucket_test();
+
+?>
View
210 test/buckettest.conf
@@ -0,0 +1,210 @@
+## Copyright (c) 2007-2008 Facebook
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+## See accompanying file LICENSE or visit the Scribe site at:
+## http://developers.facebook.com/scribe/
+
+
+##
+## Test configuration listens on a different port and writes data to
+## /tmp/scribetest
+##
+
+
+# scribe configuration
+#
+# This file specifies global key-value pairs as well as store
+# objects, which are surrounded by xml-like tags <store></store>
+#
+# Each store has a category and a type. The category must match the
+# category string used by the client code, and the type must be one of:
+# file, network, bucket, buffer. The remainder of the store
+# configuration depends on the type.
+#
+# Some types of stores include other stores, which are specified by
+# nested xml-like tags. These have specific names that depend on type.
+# For example a buffer store has a <primary> store and a <secondary>
+# store, which can be of any type, and are configured the same way
+# they would be in a top-level <store>. Note that nested stores don't
+# have a configured category, it is inherited from the top-level store.
+#
+# The category "default" is a special case. Any category not configured
+# here will be handled using the default configuration, except with
+# filenames overwritten with the category name.
+#
+# The parser isn't great, so add whitespace at your own risk.
+
+port=1463
+max_msg_per_second=2000000
+check_interval=3
+num_thrift_server_threads=3
+
+# DEFAULT
+<store>
+category=default
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=30
+retry_interval_range=10
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest
+base_filename=thisisoverwritten
+max_size=1000000
+chunk_size=1024
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp
+base_filename=thisisoverwritten
+max_size=3000000
+</secondary>
+</store>
+
+# BUCKETIZER TEST
+<store>
+category=buckettest
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=30
+retry_interval_range=10
+
+<primary>
+type=bucket
+num_buckets=6
+bucket_subdir=bucket
+bucket_type=key_hash
+delimiter=1
+
+<bucket>
+type=file
+fs_type=std
+file_path=/tmp/scribetest
+base_filename=buckettest
+max_size=1000000
+rotate_period=hourly
+rotate_hour=0
+rotate_minute=30
+write_meta=yes
+</bucket>
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp
+base_filename=buckettest
+max_size=30000
+</secondary>
+</store>
+
+
+# BUCKETIZER TEST 2
+<store>
+category=buckettest2
+type=bucket
+
+num_buckets=2
+bucket_type=key_hash
+delimiter=1
+
+<bucket0>
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=30
+retry_interval_range=10
+
+<primary>
+type=file
+file_path=/tmp/scribetest/bucktest2_bucket0
+base_filename=buckettest2
+max_size=1000000
+</primary>
+
+<secondary>
+type=file
+file_path=/tmp/scribe_test/buckettest2_bucket0
+base_filename=buckettest2
+max_size=1000000
+</secondary>
+</bucket0>
+
+<bucket1>
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=30
+retry_interval_range=10
+
+<primary>
+type=file
+file_path=/tmp/scribetest/bucktest2_bucket1
+base_filename=buckettest2
+max_size=1000000
+</primary>
+
+<secondary>
+type=file
+file_path=/tmp/scribe_test/buckettest2_bucket1
+base_filename=buckettest2
+max_size=1000000
+</secondary>
+</bucket1>
+
+<bucket2>
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=30
+retry_interval_range=10
+
+<primary>
+type=file
+file_path=/tmp/scribetest/bucktest2_bucket2
+base_filename=buckettest2
+max_size=1000000
+</primary>
+
+<secondary>
+type=file
+file_path=/tmp/scribe_test/buckettest2_bucket2
+base_filename=buckettest2
+max_size=1000000
+</secondary>
+</bucket2>
+
+</store>
+
+
View
99 test/buffertest.php
@@ -0,0 +1,99 @@
+<?php
+// Copyright (c) 2007-2008 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+include_once 'tests.php';
+include_once 'testutil.php';
+
+$success = true;
+
+$pid = scribe_start('buffertest', $GLOBALS['SCRIBE_BIN'],
+ $GLOBALS['SCRIBE_PORT'], 'scribe.conf.buffertest');
+
+// delete scribetest_ directory, and try to log messages there.
+// Then recreate directory and verify that buffers get written
+system("rm -rf /tmp/scribetest_", $error);
+if ($error) {
+ print("ERROR: unable to delete /tmp/scribetest_\n");
+}
+
+
+// write 10k messages to category test (handled by default store)
+print("test writing 10k messages to category test\n");
+stress_test('test', 'client1', 1000, 10000, 20, 100, 1);
+
+// write another 10k messages to category test (should see 1 out of order)
+sleep(2);
+print("test writing another 10k messages (will see 1 out of order)\n");
+stress_test('test', 'client1', 1000, 10000, 20, 100, 1);
+
+// write 200k messages to category test using different client name
+print("test writing 200k more messages to category test\n");
+stress_test('test', 'client2', 10000, 200000, 50, 100, 1);
+
+// write 10k messages to category foodoo (handled by prefix store)
+print("test writing 10k messages to category foodoo\n");
+stress_test('foodoo', 'client1', 10000, 10000, 20, 100, 1);
+
+
+// write 10k messages to category rock (handled by categories prefix store)
+print("test writing 100k messages to category rock\n");
+stress_test('rock', 'client1', 100, 10000, 20, 100, 1);
+
+// re-create primary store path
+system("mkdir /tmp/scribetest_", $error);
+if ($error) {
+ print("ERROR: unable to recreate /tmp/scribetest_\n");
+}
+
+
+// sleep for a while to wait for buffers to flush
+print("Waiting for buffers to flush...\n");
+sleep(120);
+
+// verify all messages got logged
+$results = resultChecker('/tmp/scribetest_/test', 'test-', 'client1');
+
+if ($results["count"] != 20000 || $results["out_of_order"] != 1) {
+ $success = false;
+}
+
+$results = resultChecker('/tmp/scribetest_/test', 'test-', 'client2');
+
+if ($results["count"] != 200000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+$results = resultChecker('/tmp/scribetest_/foodoo', 'foodoo-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+$results = resultChecker('/tmp/scribetest_/rock', 'rock-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+
+if (!scribe_stop($GLOBALS['SCRIBE_CTRL'], $GLOBALS['SCRIBE_PORT'], $pid)) {
+ print("ERROR: could not stop scribe\n");
+ return false;
+}
+
+return $success;
View
122 test/buffertest2.php
@@ -0,0 +1,122 @@
+<?php
+// Copyright (c) 2007-2008 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+include_once 'tests.php';
+include_once 'testutil.php';
+
+// Simpletest2 is similar to simpletest, except it turns off
+// new_thread_per_category and sets num_thrift_server_threads
+
+$success = true;
+
+// delete scribetest_ directory, and try to log messages there.
+// Then recreate directory and verify that buffers get written
+system("rm -rf /tmp/scribetest_", $error);
+if ($error) {
+ print("ERROR: unable to delete /tmp/scribetest_\n");
+}
+
+$pid = scribe_start('buffertest2', $GLOBALS['SCRIBE_BIN'],
+ $GLOBALS['SCRIBE_PORT'], 'scribe.conf.buffertest2');
+sleep(2);
+
+// write 10k messages to category test (handled by default store)
+print("test writing 10k messages to category test\n");
+stress_test('test', 'client1', 1000, 10000, 20, 100, 1);
+
+// write another 10k messages to category test (should see 1 out of order)
+print("test writing another 10k messages (will see 1 out of order)\n");
+sleep(2);
+stress_test('test', 'client1', 1000, 10000, 20, 100, 1);
+
+// write 200k messages to category test using different client name
+print("test writing 200k more messages to category test\n");
+stress_test('test', 'client2', 10000, 200000, 50, 100, 1);
+
+// write 10k messages to category tps (handled by named store)
+print("test writing 10k messages to category tps\n");
+stress_test('tps', 'client1', 1000, 10000, 200, 100, 1);
+
+// write 10k messages to category foodoo (handled by prefix store)
+print("test writing 10k messages to category foodoo\n");
+stress_test('foodoo', 'client1', 10000, 10000, 20, 100, 1);
+
+// write 10k messages to category rock (handled by categories prefix store)
+print("test writing 100k messages to category rock\n");
+stress_test('rock', 'client1', 100, 10000, 20, 100, 1);
+
+// write 10k messages to category paper (handled by categories store)
+print("test writing 10k messages to category paper\n");
+stress_test('paper', 'client2', 1000, 10000, 20, 500, 1);
+
+
+// re-create primary store path
+system("mkdir /tmp/scribetest_", $error);
+if ($error) {
+ print("ERROR: unable to recreate /tmp/scribetest_\n");
+}
+
+
+// sleep for a while to wait for buffers to flush
+print("Waiting for buffers to flush...\n");
+sleep(120);
+
+// verify all messages got logged
+$results = resultChecker('/tmp/scribetest_/default', 'default-', 'client1');
+
+if ($results["count"] != 20000 || $results["out_of_order"] != 1) {
+ $success = false;
+}
+
+$results = resultChecker('/tmp/scribetest_/default', 'default-', 'client2');
+
+if ($results["count"] != 200000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+$results = resultChecker('/tmp/scribetest_/tps', 'tps-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+$results = resultChecker('/tmp/scribetest_/foo', 'foo-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+$results = resultChecker('/tmp/scribetest_/rockpaper', 'rockpaper-', 'client1');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+$results = resultChecker('/tmp/scribetest_/rockpaper', 'rockpaper-', 'client2');
+
+if ($results["count"] != 10000 || $results["out_of_order"] != 0) {
+ $success = false;
+}
+
+
+if (!scribe_stop($GLOBALS['SCRIBE_CTRL'], $GLOBALS['SCRIBE_PORT'], $pid)) {
+ print("ERROR: could not stop scribe\n");
+ return false;
+}
+
+return $success;
View
57 test/categoriestest.php
@@ -0,0 +1,57 @@
+<?php
+// Copyright (c) 2007-2008 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+include_once 'tests.php';
+include_once 'testutil.php';
+
+$success = true;
+
+$pid = scribe_start('categoriestest', $GLOBALS['SCRIBE_BIN'],
+ $GLOBALS['SCRIBE_PORT'], 'scribe.conf.categoriestest');
+
+// write 10k messages to many different categories
+$categories = array("hello", "foo", "food", "rock", "rockstar", "paper",
+ "scissors", "apple", "banana");
+$client = "client1";
+
+print("Testing writing 100k messages to multiple categories.\n");
+super_stress_test($categories, $client, 1000, 100000, 20, 100, 1);
+
+sleep(10);
+
+// verify all messages got written
+foreach ($categories as $category) {
+ $path = "/tmp/scribetest_/$category";
+ $prefix = $category . '-';
+
+ print("Verifying messages for category $category.\n");
+ $results = resultChecker($path, $prefix, $client);
+
+ if ($results["count"] != 100000 || $results["out_of_order"] != 0) {
+ print("Error:Bad results for category $category\n");
+ $success = false;
+ }
+}
+
+
+if (!scribe_stop($GLOBALS['SCRIBE_CTRL'], $GLOBALS['SCRIBE_PORT'], $pid)) {
+ print("ERROR: could not stop scribe\n");
+ $success = false;
+}
+
+return $success;
View
23 test/reinit.php
@@ -0,0 +1,23 @@
+<?php
+// Copyright (c) 2007-2008 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+include_once 'tests.php';
+
+scribe_reinitialize();
+
+?>
View
179 test/scribe.conf.basictest
@@ -0,0 +1,179 @@
+## Copyright (c) 2007-2008 Facebook
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+## See accompanying file LICENSE or visit the Scribe site at:
+## http://developers.facebook.com/scribe/
+
+
+##
+## Test configuration listens on a different port and writes data to
+## /tmp/scribetest
+##
+
+
+# scribe configuration
+#
+# This file specifies global key-value pairs as well as store
+# objects, which are surrounded by xml-like tags <store></store>
+#
+# Each store has a category and a type. The category must match the
+# category string used by the client code, and the type must be one of:
+# file, network, bucket, buffer. The remainder of the store
+# configuration depends on the type.
+#
+# Some types of stores include other stores, which are specified by
+# nested xml-like tags. These have specific names that depend on type.
+# For example a buffer store has a <primary> store and a <secondary>
+# store, which can be of any type, and are configured the same way
+# they would be in a top-level <store>. Note that nested stores don't
+# have a configured category, it is inherited from the top-level store.
+#
+# The category "default" is a special case. Any category not configured
+# here will be handled using the default configuration, except with
+# filenames overwritten with the category name.
+#
+# The parser isn't great, so add whitespace at your own risk.
+
+max_msg_per_second=2000000
+check_interval=1
+
+# DEFAULT
+<store>
+category=default
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=thisisoverwritten
+max_size=2000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=thisisoverwritten
+max_size=3000000
+</secondary>
+</store>
+
+<store>
+category=tps
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_/tps
+base_filename=tps
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_/tps
+base_filename=tps
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+category=foo*
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=foooverwritten
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=foooverwritten
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+categories=rock* paper
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=rockoverwritten
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=rockoverwritten
+max_size=3000000
+</secondary>
+</store>
+
+
View
181 test/scribe.conf.basictest2
@@ -0,0 +1,181 @@
+## Copyright (c) 2007-2008 Facebook
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+## See accompanying file LICENSE or visit the Scribe site at:
+## http://developers.facebook.com/scribe/
+
+
+##
+## Test configuration listens on a different port and writes data to
+## /tmp/scribetest
+##
+
+
+# scribe configuration
+#
+# This file specifies global key-value pairs as well as store
+# objects, which are surrounded by xml-like tags <store></store>
+#
+# Each store has a category and a type. The category must match the
+# category string used by the client code, and the type must be one of:
+# file, network, bucket, buffer. The remainder of the store
+# configuration depends on the type.
+#
+# Some types of stores include other stores, which are specified by
+# nested xml-like tags. These have specific names that depend on type.
+# For example a buffer store has a <primary> store and a <secondary>
+# store, which can be of any type, and are configured the same way
+# they would be in a top-level <store>. Note that nested stores don't
+# have a configured category, it is inherited from the top-level store.
+#
+# The category "default" is a special case. Any category not configured
+# here will be handled using the default configuration, except with
+# filenames overwritten with the category name.
+#
+# The parser isn't great, so add whitespace at your own risk.
+
+max_msg_per_second=2000000
+check_interval=1
+num_thrift_server_threads=4
+new_thread_per_category=no
+
+# DEFAULT
+<store>
+category=default
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_/default
+base_filename=default
+max_size=2000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_/default
+base_filename=default
+max_size=3000000
+</secondary>
+</store>
+
+<store>
+category=tps
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_/tps
+base_filename=tps
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_/tps
+base_filename=tps
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+category=foo*
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_/foo
+base_filename=foo
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_/foo
+base_filename=foo
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+categories=rock* paper
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_/rockpaper
+base_filename=rockpaper
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_/rockpaper
+base_filename=rockpaper
+max_size=3000000
+</secondary>
+</store>
+
+
View
179 test/scribe.conf.buffertest
@@ -0,0 +1,179 @@
+## Copyright (c) 2007-2008 Facebook
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+## See accompanying file LICENSE or visit the Scribe site at:
+## http://developers.facebook.com/scribe/
+
+
+##
+## Test configuration listens on a different port and writes data to
+## /tmp/scribetest
+##
+
+
+# scribe configuration
+#
+# This file specifies global key-value pairs as well as store
+# objects, which are surrounded by xml-like tags <store></store>
+#
+# Each store has a category and a type. The category must match the
+# category string used by the client code, and the type must be one of:
+# file, network, bucket, buffer. The remainder of the store
+# configuration depends on the type.
+#
+# Some types of stores include other stores, which are specified by
+# nested xml-like tags. These have specific names that depend on type.
+# For example a buffer store has a <primary> store and a <secondary>
+# store, which can be of any type, and are configured the same way
+# they would be in a top-level <store>. Note that nested stores don't
+# have a configured category, it is inherited from the top-level store.
+#
+# The category "default" is a special case. Any category not configured
+# here will be handled using the default configuration, except with
+# filenames overwritten with the category name.
+#
+# The parser isn't great, so add whitespace at your own risk.
+
+max_msg_per_second=2000000
+check_interval=1
+
+# DEFAULT
+<store>
+category=default
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=thisisoverwritten
+max_size=2000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=thisisoverwritten
+max_size=3000000
+</secondary>
+</store>
+
+<store>
+category=tps
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_/tps
+base_filename=tps
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_/tps
+base_filename=tps
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+category=foo*
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=foooverwritten
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=foooverwritten
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+categories=rock* paper
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=rockoverwritten
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=rockoverwritten
+max_size=3000000
+</secondary>
+</store>
+
+
View
181 test/scribe.conf.buffertest2
@@ -0,0 +1,181 @@
+## Copyright (c) 2007-2008 Facebook
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+## See accompanying file LICENSE or visit the Scribe site at:
+## http://developers.facebook.com/scribe/
+
+
+##
+## Test configuration listens on a different port and writes data to
+## /tmp/scribetest
+##
+
+
+# scribe configuration
+#
+# This file specifies global key-value pairs as well as store
+# objects, which are surrounded by xml-like tags <store></store>
+#
+# Each store has a category and a type. The category must match the
+# category string used by the client code, and the type must be one of:
+# file, network, bucket, buffer. The remainder of the store
+# configuration depends on the type.
+#
+# Some types of stores include other stores, which are specified by
+# nested xml-like tags. These have specific names that depend on type.
+# For example a buffer store has a <primary> store and a <secondary>
+# store, which can be of any type, and are configured the same way
+# they would be in a top-level <store>. Note that nested stores don't
+# have a configured category, it is inherited from the top-level store.
+#
+# The category "default" is a special case. Any category not configured
+# here will be handled using the default configuration, except with
+# filenames overwritten with the category name.
+#
+# The parser isn't great, so add whitespace at your own risk.
+
+max_msg_per_second=2000000
+check_interval=1
+num_thrift_server_threads=4
+new_thread_per_category=no
+
+# DEFAULT
+<store>
+category=default
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_/default
+base_filename=default
+max_size=2000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_/default
+base_filename=default
+max_size=3000000
+</secondary>
+</store>
+
+<store>
+category=tps
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_/tps
+base_filename=tps
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_/tps
+base_filename=tps
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+category=foo*
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_/foo
+base_filename=foo
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_/foo
+base_filename=foo
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+categories=rock* paper
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_/rockpaper
+base_filename=rockpaper
+max_size=10000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_/rockpaper
+base_filename=rockpaper
+max_size=3000000
+</secondary>
+</store>
+
+
View
211 test/scribe.conf.categoriestest
@@ -0,0 +1,211 @@
+## Copyright (c) 2007-2008 Facebook
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+## See accompanying file LICENSE or visit the Scribe site at:
+## http://developers.facebook.com/scribe/
+
+
+##
+## Test configuration listens on a different port and writes data to
+## /tmp/scribetest
+##
+
+
+# scribe configuration
+#
+# This file specifies global key-value pairs as well as store
+# objects, which are surrounded by xml-like tags <store></store>
+#
+# Each store has a category and a type. The category must match the
+# category string used by the client code, and the type must be one of:
+# file, network, bucket, buffer. The remainder of the store
+# configuration depends on the type.
+#
+# Some types of stores include other stores, which are specified by
+# nested xml-like tags. These have specific names that depend on type.
+# For example a buffer store has a <primary> store and a <secondary>
+# store, which can be of any type, and are configured the same way
+# they would be in a top-level <store>. Note that nested stores don't
+# have a configured category, it is inherited from the top-level store.
+#
+# The category "default" is a special case. Any category not configured
+# here will be handled using the default configuration, except with
+# filenames overwritten with the category name.
+#
+# The parser isn't great, so add whitespace at your own risk.
+
+max_msg_per_second=2000000
+check_interval=1
+
+# DEFAULT
+<store>
+category=default
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=thisisoverwritten
+max_size=1000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=thisisoverwritten
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+categories=foo*
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=foooverwritten
+max_size=1000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=foooverwritten
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+categories= paper rock*
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=paperoverwritten
+max_size=1000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=paperoverwritten
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+categories=scissors
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=scissorsoverwritten
+max_size=1000000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=scissorsoverwritten
+max_size=3000000
+</secondary>
+</store>
+
+
+<store>
+categories=apple pear banana
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=appleoverwritten
+max_size=100000
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=appleoverwritten
+max_size=3000000
+</secondary>
+</store>
+
View
127 test/scribe.conf.simpletest
@@ -0,0 +1,127 @@
+## Copyright (c) 2007-2008 Facebook
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+## See accompanying file LICENSE or visit the Scribe site at:
+## http://developers.facebook.com/scribe/
+
+
+##
+## Test configuration listens on a different port and writes data to
+## /tmp/scribetest
+##
+
+
+# scribe configuration
+#
+# This file specifies global key-value pairs as well as store
+# objects, which are surrounded by xml-like tags <store></store>
+#
+# Each store has a category and a type. The category must match the
+# category string used by the client code, and the type must be one of:
+# file, network, bucket, buffer. The remainder of the store
+# configuration depends on the type.
+#
+# Some types of stores include other stores, which are specified by
+# nested xml-like tags. These have specific names that depend on type.
+# For example a buffer store has a <primary> store and a <secondary>
+# store, which can be of any type, and are configured the same way
+# they would be in a top-level <store>. Note that nested stores don't
+# have a configured category, it is inherited from the top-level store.
+#
+# The category "default" is a special case. Any category not configured
+# here will be handled using the default configuration, except with
+# filenames overwritten with the category name.
+#
+# The parser isn't great, so add whitespace at your own risk.
+
+port=1463
+max_msg_per_second=2000000
+check_interval=1
+num_thrift_server_threads=4
+
+
+# DEFAULT
+<store>
+category=default
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=3
+retry_interval_range=1
+
+send_buffer=no
+
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=thisisoverwritten
+max_size=10000000
+chunk_size=1024
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=thisisoverwritten
+max_size=3000000
+</secondary>
+</store>
+
+# BUCKETIZER TEST
+<store>
+category=buckettest
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=30
+retry_interval_range=10
+
+<primary>
+type=bucket
+num_buckets=6
+bucket_subdir=bucket
+bucket_type=key_hash
+delimiter=1
+
+<bucket>
+type=file
+fs_type=std
+file_path=/tmp/scribetest_
+base_filename=buckettest
+max_size=1000000
+rotate_period=hourly
+rotate_hour=0
+rotate_minute=30
+write_meta=yes
+</bucket>
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp/scribe_test_
+base_filename=buckettest
+max_size=30000
+</secondary>
+</store>
+
View
128 test/scribe.conf.test
@@ -13,7 +13,7 @@
## limitations under the License.
##
## See accompanying file LICENSE or visit the Scribe site at:
-## http://developers.facebook.com/scribe/
+## http://developers.facebook.com/scribe/
##
@@ -29,18 +29,18 @@
#
# Each store has a category and a type. The category must match the
# category string used by the client code, and the type must be one of:
-# file, network, bucket, buffer. The remainder of the store
+# file, network, bucket, buffer. The remainder of the store
# configuration depends on the type.
#
-# Some types of stores include other stores, which are specified by
-# nested xml-like tags. These have specific names that depend on type.
+# Some types of stores include other stores, which are specified by
+# nested xml-like tags. These have specific names that depend on type.
# For example a buffer store has a <primary> store and a <secondary>
# store, which can be of any type, and are configured the same way
# they would be in a top-level <store>. Note that nested stores don't
# have a configured category, it is inherited from the top-level store.
#
# The category "default" is a special case. Any category not configured
-# here will be handled using the default configuration, except with
+# here will be handled using the default configuration, except with
# filenames overwritten with the category name.
#
# The parser isn't great, so add whitespace at your own risk.
@@ -51,76 +51,74 @@ check_interval=3
# DEFAULT
<store>
- category=default
- type=buffer
- must_succeed=yes
+category=default
+type=buffer
- target_write_size=20480
- max_write_interval=1
- buffer_send_rate=2
- retry_interval=30
- retry_interval_range=10
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=30
+retry_interval_range=10
- <primary>
- type=file
- fs_type=std
- file_path=/tmp/scribetest
- base_filename=thisisoverwritten
- max_size=1000000
- chunk_size=1024
- rotate_period=daily
- rotate_hour=0
- rotate_minute=5
- add_newlines=1
- </primary>
+<primary>
+type=file
+fs_type=std
+file_path=/tmp/scribetest
+base_filename=thisisoverwritten
+max_size=1000000
+chunk_size=1024
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
- <secondary>
- type=file
- fs_type=std
- file_path=/tmp
- base_filename=thisisoverwritten
- max_size=3000000
- </secondary>
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp
+base_filename=thisisoverwritten
+max_size=3000000
+</secondary>
</store>
# BUCKETIZER TEST
<store>
- category=buckettest
- type=buffer
+category=buckettest
+type=buffer
- target_write_size=20480
- max_write_interval=1
- buffer_send_rate=2
- retry_interval=30
- retry_interval_range=10
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=30
+retry_interval_range=10
- <primary>
- type=bucket
- num_buckets=6
- bucket_subdir=bucket
- bucket_type=key_hash
-#use space for delimter
- delimiter=9
+<primary>
+type=bucket
+num_buckets=6
+bucket_subdir=bucket
+bucket_type=key_hash
+delimiter=1
- <bucket>
- type=file
- fs_type=std
- file_path=/tmp/scribetest
- base_filename=buckettest
- max_size=1000000
- rotate_period=hourly
- rotate_hour=0
- rotate_minute=30
- write_meta=yes
- </bucket>
- </primary>
+<bucket>
+type=file
+fs_type=std
+file_path=/tmp/scribetest
+base_filename=buckettest
+max_size=1000000
+rotate_period=hourly
+rotate_hour=0
+rotate_minute=30
+write_meta=yes
+</bucket>
+</primary>
- <secondary>
- type=file
- fs_type=std
- file_path=/tmp
- base_filename=buckettest
- max_size=30000
- </secondary>
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp
+base_filename=buckettest
+max_size=30000
+</secondary>
</store>
View
84 test/scribe.conf.test.hdfs
@@ -0,0 +1,84 @@
+## Copyright (c) 2007-2008 Facebook
+##
+## Licensed under the Apache License, Version 2.0 (the "License");
+## you may not use this file except in compliance with the License.
+## You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+##
+## See accompanying file LICENSE or visit the Scribe site at:
+## http://developers.facebook.com/scribe/
+
+
+##
+## Test configuration listens on a different port and writes data to
+## /tmp/scribetest
+##
+
+
+# scribe configuration
+#
+# This file specifies global key-value pairs as well as store
+# objects, which are surrounded by xml-like tags <store></store>
+#
+# Each store has a category and a type. The category must match the
+# category string used by the client code, and the type must be one of:
+# file, hdfs, network, bucket, buffer. The remainder of the store
+# configuration depends on the type.
+#
+# Some types of stores include other stores, which are specified by
+# nested xml-like tags. These have specific names that depend on type.
+# For example a buffer store has a <primary> store and a <secondary>
+# store, which can be of any type, and are configured the same way
+# they would be in a top-level <store>. Note that nested stores don't
+# have a configured category, it is inherited from the top-level store.
+#
+# The category "default" is a special case. Any category not configured
+# here will be handled using the default configuration, except with
+# filenames overwritten with the category name.
+#
+# The parser isn't great, so add whitespace at your own risk.
+
+port=1463
+max_msg_per_second=2000000
+check_interval=3
+
+# DEFAULT
+<store>
+category=default
+type=buffer
+
+target_write_size=20480
+max_write_interval=1
+buffer_send_rate=2
+retry_interval=30
+retry_interval_range=10
+
+<primary>
+type=file
+fs_type=hdfs
+file_path=hdfs://hadoopnode.mydomain.com:9000/tmp/scribetest.hdfs
+create_symlink=yes
+base_filename=thisisoverwritten
+max_size=100000000
+chunk_size=1024
+rotate_period=daily
+rotate_hour=0
+rotate_minute=5
+add_newlines=1
+</primary>
+
+<secondary>
+type=file
+fs_type=std
+file_path=/tmp
+base_filename=thisisoverwritten
+max_size=3000000
+</secondary>
+</store>
View
81 test/simpletest.php
@@ -0,0 +1,81 @@
+<?php
+// Copyright (c) 2007-2008 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+include_once 'tests.php';
+include_once 'testutil.php';
+
+// run some simpletests
+// -verify that we can send a message
+// -send a message with non-printable characters
+// -send some strange input messages
+
+$success = true;
+
+$pid = scribe_start('simpletest', $GLOBALS['SCRIBE_BIN'],
+ $GLOBALS['SCRIBE_PORT'], 'scribe.conf.simpletest');
+
+print("running strange input test\n");
+strange_input_test();
+sleep(2);
+
+print("running some simple tests\n");
+simple_test();
+
+// wait for messages to arrive
+sleep(5);
+
+// check results
+$file = fopen("/tmp/scribetest_/scribe_test/scribe_test_current", 'r');
+
+if ($file) {
+
+ // strange_input_test should end up writing '\n'
+ $line = fgets($file, 3);
+
+ if ($line != '\n') {
+ print("ERROR: Did not find first message\n");
+ $success = false;
+ }
+
+ // simple_test should have written 2 more lines
+ $line = fgets($file);
+
+ if ($line != "this is a message\n") {
+ print("ERROR: Did not find first simple_test line\n");
+ $success = false;
+ }
+
+ $line = fgets($file);
+
+ if ($line != ("and a binary" . chr(0) . chr(1) . " message\n")) {
+ print("ERROR: Did not find second simpe_test line\n");
+ $success = false;
+ }
+
+} else {
+ print("ERROR: could not open result file: $file\n");
+ $success = false;
+}
+
+
+if (!scribe_stop($GLOBALS['SCRIBE_CTRL'], $GLOBALS['SCRIBE_PORT'], $pid)) {
+ print("ERROR: could not stop scribe\n");
+ return false;
+}
+
+return $success;
View
43 test/superstress.php
@@ -0,0 +1,43 @@
+<?php
+// Copyright (c) 2007-2008 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+include_once 'tests.php';
+
+if ($argc > 1) {
+ $client = $argv[1];
+} else {
+ $client = 'client1';
+}
+
+if ($argc > 2) {
+
+ for($i = 0; $i < $argc - 2; ++$i) {
+ $categories[$i] = $argv[$i+2];
+ }
+
+} else {
+ $categories = array("rock", "paper", "scissors");
+}
+
+print "starting test...\n";
+
+super_stress_test($categories, $client, 10000, 200000, 20, 100, 1);
+
+print "done\n";
+
+?>
View
8 test/tests.php
@@ -15,7 +15,7 @@
//
// See accompanying file LICENSE or visit the Scribe site at:
// http://developers.facebook.com/scribe/
-
+// put your thrift and scribe php root here
$GLOBALS['THRIFT_ROOT'] = '/usr/local/thrift/php/thrift';
$GLOBALS['SCRIBE_ROOT'] = '/usr/local/thrift/php/thrift/packages';
@@ -36,15 +36,15 @@ function simple_test() {
$messages []= $msg2;
$msg3 = new LogEntry;
$msg3->category = 'buckettest';
- $msg3->message = '99 a key-value message with a non-printable delimiter\n';
+ $msg3->message = '99' . chr(1) . 'a key-value message with a non-printable delimiter\n';
$messages []= $msg3;
$msg4 = new LogEntry;
$msg4->category = 'buckettest';
- $msg4->message = '99 a different message in the same bucket\n';
+ $msg4->message = '99' . chr(1) . 'a different message in the same bucket\n';
$messages []= $msg4;
$msg5 = new LogEntry;
$msg5->category = 'buckettest';
- $msg5->message = '98 a different bucket\n';
+ $msg5->message = '98' . chr(1) . 'a different bucket\n';
$messages []= $msg5;
$scribe_client = create_scribe_client();
View
157 test/testsuite.php
@@ -0,0 +1,157 @@
+<?php
+// Copyright (c) 2007-2008 Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+include_once 'tests.php';
+include_once 'testutil.php';
+
+// This script writes to /tmp/scribetest_/ and /tmp/scribe_test_/
+//TODO: warning!
+
+///////////////////////////////////////////////////////////////////////////////
+// Change these paths to the location of your scribed binary and
+// scribe_ctrl script
+$GLOBALS['SCRIBE_BIN'] = '../src';
+$GLOBALS['SCRIBE_CTRL'] = '../examples';
+//
+///////////////////////////////////////////////////////////////////////////////
+
+
+// In order to change these port number, you would also need to edit
+// the scribe.conf.* configs
+$GLOBALS['SCRIBE_PORT'] = 1463;
+$GLOBALS['SCRIBE_PORT2'] = 1466;
+
+$ALL_TESTS = array(
+ 'simpletest',
+ 'basictest',
+ 'basictest2',
+ 'buffertest',
+ 'buffertest2',
+// 'categoriestest',
+);
+
+$output_file = null;
+
+function usage() {
+ print("Usage (must be run as root):
+
+ DO NOT RUN ON ANY MACHINE THAT IS ALREADY RUNNING SCRIBE!
+
+ Run all tests:
+ php testsuite.php
+ Run specific test:
+ php testsuite.php [test name]*
+ ");
+}
+
+function write_callback($buffer) {
+ global $output_file;
+
+ $success = fwrite($output_file, $buffer);
+
+ if (!$success) {
+ return "ERROR: could not write test output\n";
+ }
+}
+
+function clean_test_dirs() {
+ system("rm -rf /tmp/scribetest_ /tmp/scribe_test_");
+ system("mkdir /tmp/scribetest_ /tmp/scribe_test_", $error);
+
+ if ($error) {
+ print("ERROR: Could not mkdir /tmp/scribetest_ /tmp/scribe_test_\n");
+ }
+}
+
+function run_test($testname) {
+ global $output_file;
+
+ print("Running test $testname ... ");
+
+ try {
+ clean_test_dirs();
+
+ // redirect output for each test to its own file
+ $filename = "scribe.test." . $testname;
+ $output_file = fopen($filename, 'w');
+
+ if (!$output_file) {
+ print("ERROR: could not open test output file: $output_file \n");
+ return false;
+ }
+
+ ob_start("write_callback");
+
+ //run test
+ $success = include($testname . ".php");
+
+ ob_end_flush();
+ fclose($output_file);
+ $output_file = null;
+
+ if ($success) {
+ print("succeeded.\n");
+ } else {
+ print("FAILED. see test output.\n");
+ }
+
+ } catch (Exception $e) {
+ print("EXCEPTION: " . $e->getMessage() . "\n");
+ $success = false;
+ }
+
+ return $success;
+}
+
+$succeeded = 0;
+$failed = 0;
+
+if ($argc > 1) {
+ if ($argv[1] == "-h" || $argv[1] == "help") {
+ usage();
+ return false;
+ }
+
+ // run only tests specified
+ $tests = array_splice($argv, 1);
+ foreach ($tests as $testname) {
+ if (run_test($testname)) {
+ $succeeded++;
+ } else {
+ $failed++;
+ }
+ }
+} else {
+ foreach ($ALL_TESTS as $testname) {
+ if (run_test($testname)) {
+ $succeeded++;
+ } else {
+ $failed++;
+ }
+ }
+}
+
+print("$succeeded tests passed, $failed tests failed.\n");
+
+if ($succeeded && !$failed) {
+ print("SUCCESS\n");
+ return true;
+} else {
+ print("FAILED\n");
+ return false;
+}
View
214 test/testutil.php
@@ -0,0 +1,214 @@
+<?php
+// Copyright (c) 2009- Facebook
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+// See accompanying file LICENSE or visit the Scribe site at:
+// http://developers.facebook.com/scribe/
+
+
+/**
+ * Starts scribe in a new process using the config file for the given test.
+ * stdout/err is redirected to scribed.out.test<test_num>
+ *
+ * @param string $test_name name of test being run
+ * @param string $scribed_path scribed binary full path
+ * @param int $port port
+ * @param string $config name of config file to use
+ *
+ * @return int returns process id on success, 0 on failure
+ * @author agiardullo
+ */
+function scribe_start($test_name, $scribed_path, $port, $config) {
+ $scribed = "$scribed_path/scribed";
+ $command = "$scribed -p $port $config &> scribed.out.$test_name &";
+
+ print("Starting Scribed...\n");
+
+ $pid = system($command, $error);
+
+ if ($error) {
+ print("ERROR: Could not start scribed.\n");
+ return 0;
+ }
+
+ // give scribe a chance to startup
+ sleep(2);
+ return $pid;
+}
+
+
+/**
+ * Stops scribe. Will check for termination if $pid is provided.
+ *
+ * @param string $scribe_ctrl_path scribe_ctrl path
+ * @param int $port port
+ * @param int $pid scribed process (optional)
+ *
+ * @return bool returns true on success
+ * @author agiardullo
+ */
+function scribe_stop($scribe_ctrl_path, $port, $pid = 0) {
+ $wait = 5; //seconds
+ $scribe_ctrl = "$scribe_ctrl_path/scribe_ctrl";
+ $command = "$scribe_ctrl stop $port ";
+
+ print("Stopping Scribed...\n");
+
+ // send stop command to scribe
+ system($command, $error);
+
+ if ($error) {
+ print("ERROR: Could not stop scribed.\n");
+ return false;
+ }
+
+ sleep($wait);
+
+ if ($pid) {
+ // kill if scribe process has not yet terminated
+ system('kill -9 ' . $pid, $success);
+
+ if ($success) {
+ print("ERROR: scribed did not stop after $wait seconds.\n");
+ return false;
+ }
+