mirror of
https://github.com/wassname/ray.git
synced 2026-08-08 11:25:28 +08:00
Change type naming convention. (#315)
* Rename object_id -> ObjectID. * Rename ray_logger -> RayLogger. * rename task_id -> TaskID, actor_id -> ActorID, function_id -> FunctionID * Rename plasma_store_info -> PlasmaStoreInfo. * Rename plasma_store_state -> PlasmaStoreState. * Rename plasma_object -> PlasmaObject. * Rename object_request -> ObjectRequests. * Rename eviction_state -> EvictionState. * Bug fix. * rename db_handle -> DBHandle * Rename local_scheduler_state -> LocalSchedulerState. * rename db_client_id -> DBClientID * rename task -> Task * make redis.c C++ compatible * Rename scheduling_algorithm_state -> SchedulingAlgorithmState. * Rename plasma_connection -> PlasmaConnection. * Rename client_connection -> ClientConnection. * Fixes from rebase. * Rename local_scheduler_client -> LocalSchedulerClient. * Rename object_buffer -> ObjectBuffer. * Rename client -> Client. * Rename notification_queue -> NotificationQueue. * Rename object_get_requests -> ObjectGetRequests. * Rename get_request -> GetRequest. * Rename object_info -> ObjectInfo. * Rename scheduler_object_info -> SchedulerObjectInfo. * Rename local_scheduler -> LocalScheduler and some fixes. * Rename local_scheduler_info -> LocalSchedulerInfo. * Rename global_scheduler_state -> GlobalSchedulerState. * Rename global_scheduler_policy_state -> GlobalSchedulerPolicyState. * Rename object_size_entry -> ObjectSizeEntry. * Rename aux_address_entry -> AuxAddressEntry. * Rename various ID helper methods. * Rename Task helper methods. * Rename db_client_cache_entry -> DBClientCacheEntry. * Rename local_actor_info -> LocalActorInfo. * Rename actor_info -> ActorInfo. * Rename retry_info -> RetryInfo. * Rename actor_notification_table_subscribe_data -> ActorNotificationTableSubscribeData. * Rename local_scheduler_table_send_info_data -> LocalSchedulerTableSendInfoData. * Rename table_callback_data -> TableCallbackData. * Rename object_info_subscribe_data -> ObjectInfoSubscribeData. * Rename local_scheduler_table_subscribe_data -> LocalSchedulerTableSubscribeData. * Rename more redis call data structures. * Rename photon_conn PhotonConnection. * Rename photon_mock -> PhotonMock. * Fix formatting errors.
This commit is contained in:
committed by
Robert Nishihara
parent
be1618f041
commit
a30eed452e
@@ -6,8 +6,8 @@ SUITE(common_tests);
|
||||
|
||||
TEST sha1_test(void) {
|
||||
static char hex[ID_STRING_SIZE];
|
||||
unique_id uid = globally_unique_id();
|
||||
object_id_to_string((object_id) uid, &hex[0], ID_STRING_SIZE);
|
||||
UniqueID uid = globally_unique_id();
|
||||
ObjectID_to_string((ObjectID) uid, &hex[0], ID_STRING_SIZE);
|
||||
PASS();
|
||||
}
|
||||
|
||||
|
||||
+31
-31
@@ -34,7 +34,7 @@ const int TEST_NUMBER = 10;
|
||||
|
||||
/* Test if entries have been written to the database. */
|
||||
|
||||
void lookup_done_callback(object_id object_id,
|
||||
void lookup_done_callback(ObjectID object_id,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
void *user_context) {
|
||||
@@ -52,10 +52,10 @@ void lookup_done_callback(object_id object_id,
|
||||
}
|
||||
|
||||
/* Entry added to database successfully. */
|
||||
void add_done_callback(object_id object_id, void *user_context) {}
|
||||
void add_done_callback(ObjectID object_id, void *user_context) {}
|
||||
|
||||
/* Test if we got a timeout callback if we couldn't connect database. */
|
||||
void timeout_callback(object_id object_id, void *context, void *user_data) {
|
||||
void timeout_callback(ObjectID object_id, void *context, void *user_data) {
|
||||
user_context *uc = (user_context *) context;
|
||||
CHECK(uc->test_number == TEST_NUMBER)
|
||||
}
|
||||
@@ -69,16 +69,16 @@ TEST object_table_lookup_test(void) {
|
||||
event_loop *loop = event_loop_create();
|
||||
/* This uses manager_port1. */
|
||||
const char *db_connect_args1[] = {"address", "127.0.0.1:12345"};
|
||||
db_handle *db1 = db_connect("127.0.0.1", 6379, "plasma_manager", manager_addr,
|
||||
2, db_connect_args1);
|
||||
DBHandle *db1 = db_connect("127.0.0.1", 6379, "plasma_manager", manager_addr,
|
||||
2, db_connect_args1);
|
||||
/* This uses manager_port2. */
|
||||
const char *db_connect_args2[] = {"address", "127.0.0.1:12346"};
|
||||
db_handle *db2 = db_connect("127.0.0.1", 6379, "plasma_manager", manager_addr,
|
||||
2, db_connect_args2);
|
||||
DBHandle *db2 = db_connect("127.0.0.1", 6379, "plasma_manager", manager_addr,
|
||||
2, db_connect_args2);
|
||||
db_attach(db1, loop, false);
|
||||
db_attach(db2, loop, false);
|
||||
unique_id id = globally_unique_id();
|
||||
retry_info retry = {
|
||||
UniqueID id = globally_unique_id();
|
||||
RetryInfo retry = {
|
||||
.num_retries = NUM_RETRIES,
|
||||
.timeout = TIMEOUT,
|
||||
.fail_callback = timeout_callback,
|
||||
@@ -109,9 +109,9 @@ TEST object_table_lookup_test(void) {
|
||||
}
|
||||
|
||||
int task_table_test_callback_called = 0;
|
||||
task *task_table_test_task;
|
||||
Task *task_table_test_task;
|
||||
|
||||
void task_table_test_fail_callback(unique_id id,
|
||||
void task_table_test_fail_callback(UniqueID id,
|
||||
void *context,
|
||||
void *user_data) {
|
||||
event_loop *loop = user_data;
|
||||
@@ -121,22 +121,22 @@ void task_table_test_fail_callback(unique_id id,
|
||||
int64_t task_table_delayed_add_task(event_loop *loop,
|
||||
int64_t id,
|
||||
void *context) {
|
||||
db_handle *db = context;
|
||||
retry_info retry = {
|
||||
DBHandle *db = context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = NUM_RETRIES,
|
||||
.timeout = TIMEOUT,
|
||||
.fail_callback = task_table_test_fail_callback,
|
||||
};
|
||||
task_table_add_task(db, copy_task(task_table_test_task), &retry, NULL,
|
||||
task_table_add_task(db, Task_copy(task_table_test_task), &retry, NULL,
|
||||
(void *) loop);
|
||||
return EVENT_LOOP_TIMER_DONE;
|
||||
}
|
||||
|
||||
void task_table_test_callback(task *callback_task, void *user_data) {
|
||||
void task_table_test_callback(Task *callback_task, void *user_data) {
|
||||
task_table_test_callback_called = 1;
|
||||
CHECK(task_state(callback_task) == TASK_STATUS_SCHEDULED);
|
||||
CHECK(task_size(callback_task) == task_size(task_table_test_task));
|
||||
CHECK(memcmp(callback_task, task_table_test_task, task_size(callback_task)) ==
|
||||
CHECK(Task_state(callback_task) == TASK_STATUS_SCHEDULED);
|
||||
CHECK(Task_size(callback_task) == Task_size(task_table_test_task));
|
||||
CHECK(memcmp(callback_task, task_table_test_task, Task_size(callback_task)) ==
|
||||
0);
|
||||
event_loop *loop = user_data;
|
||||
event_loop_stop(loop);
|
||||
@@ -145,15 +145,15 @@ void task_table_test_callback(task *callback_task, void *user_data) {
|
||||
TEST task_table_test(void) {
|
||||
task_table_test_callback_called = 0;
|
||||
event_loop *loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "local_scheduler", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, loop, false);
|
||||
db_client_id local_scheduler_id = globally_unique_id();
|
||||
DBClientID local_scheduler_id = globally_unique_id();
|
||||
task_spec *spec = example_task_spec(1, 1);
|
||||
task_table_test_task =
|
||||
alloc_task(spec, TASK_STATUS_SCHEDULED, local_scheduler_id);
|
||||
Task_alloc(spec, TASK_STATUS_SCHEDULED, local_scheduler_id);
|
||||
free_task_spec(spec);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = NUM_RETRIES,
|
||||
.timeout = TIMEOUT,
|
||||
.fail_callback = task_table_test_fail_callback,
|
||||
@@ -164,7 +164,7 @@ TEST task_table_test(void) {
|
||||
event_loop_add_timer(
|
||||
loop, 200, (event_loop_timer_handler) task_table_delayed_add_task, db);
|
||||
event_loop_run(loop);
|
||||
free_task(task_table_test_task);
|
||||
Task_free(task_table_test_task);
|
||||
db_disconnect(db);
|
||||
destroy_outstanding_callbacks(loop);
|
||||
event_loop_destroy(loop);
|
||||
@@ -174,20 +174,20 @@ TEST task_table_test(void) {
|
||||
|
||||
int num_test_callback_called = 0;
|
||||
|
||||
void task_table_all_test_callback(task *task, void *user_data) {
|
||||
void task_table_all_test_callback(Task *task, void *user_data) {
|
||||
num_test_callback_called += 1;
|
||||
}
|
||||
|
||||
TEST task_table_all_test(void) {
|
||||
event_loop *loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "local_scheduler", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, loop, false);
|
||||
task_spec *spec = example_task_spec(1, 1);
|
||||
/* Schedule two tasks on different local local schedulers. */
|
||||
task *task1 = alloc_task(spec, TASK_STATUS_SCHEDULED, globally_unique_id());
|
||||
task *task2 = alloc_task(spec, TASK_STATUS_SCHEDULED, globally_unique_id());
|
||||
retry_info retry = {
|
||||
Task *task1 = Task_alloc(spec, TASK_STATUS_SCHEDULED, globally_unique_id());
|
||||
Task *task2 = Task_alloc(spec, TASK_STATUS_SCHEDULED, globally_unique_id());
|
||||
RetryInfo retry = {
|
||||
.num_retries = NUM_RETRIES, .timeout = TIMEOUT, .fail_callback = NULL,
|
||||
};
|
||||
task_table_subscribe(db, NIL_ID, TASK_STATUS_SCHEDULED,
|
||||
@@ -212,8 +212,8 @@ TEST task_table_all_test(void) {
|
||||
TEST unique_client_id_test(void) {
|
||||
enum { num_conns = 100 };
|
||||
|
||||
db_client_id ids[num_conns];
|
||||
db_handle *db;
|
||||
DBClientID ids[num_conns];
|
||||
DBHandle *db;
|
||||
for (int i = 0; i < num_conns; ++i) {
|
||||
db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
ids[i] = get_db_client_id(db);
|
||||
@@ -221,7 +221,7 @@ TEST unique_client_id_test(void) {
|
||||
}
|
||||
for (int i = 0; i < num_conns; ++i) {
|
||||
for (int j = 0; j < i; ++j) {
|
||||
ASSERT(!db_client_ids_equal(ids[i], ids[j]));
|
||||
ASSERT(!DBClientID_equal(ids[i], ids[j]));
|
||||
}
|
||||
}
|
||||
PASS();
|
||||
|
||||
@@ -16,12 +16,12 @@ static event_loop *g_loop;
|
||||
|
||||
int new_object_failed = 0;
|
||||
int new_object_succeeded = 0;
|
||||
object_id new_object_id;
|
||||
task *new_object_task;
|
||||
ObjectID new_object_id;
|
||||
Task *new_object_task;
|
||||
task_spec *new_object_task_spec;
|
||||
task_id new_object_task_id;
|
||||
TaskID new_object_task_id;
|
||||
|
||||
void new_object_fail_callback(unique_id id,
|
||||
void new_object_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
new_object_failed = 1;
|
||||
@@ -30,34 +30,34 @@ void new_object_fail_callback(unique_id id,
|
||||
|
||||
/* === Test adding an object with an associated task === */
|
||||
|
||||
void new_object_done_callback(object_id object_id,
|
||||
task_id task_id,
|
||||
void new_object_done_callback(ObjectID object_id,
|
||||
TaskID task_id,
|
||||
void *user_context) {
|
||||
new_object_succeeded = 1;
|
||||
CHECK(object_ids_equal(object_id, new_object_id));
|
||||
CHECK(task_ids_equal(task_id, new_object_task_id));
|
||||
CHECK(ObjectID_equal(object_id, new_object_id));
|
||||
CHECK(TaskID_equal(task_id, new_object_task_id));
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
void new_object_lookup_callback(object_id object_id, void *user_context) {
|
||||
CHECK(object_ids_equal(object_id, new_object_id));
|
||||
retry_info retry = {
|
||||
void new_object_lookup_callback(ObjectID object_id, void *user_context) {
|
||||
CHECK(ObjectID_equal(object_id, new_object_id));
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = new_object_fail_callback,
|
||||
};
|
||||
db_handle *db = user_context;
|
||||
DBHandle *db = user_context;
|
||||
result_table_lookup(db, new_object_id, &retry, new_object_done_callback,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void new_object_task_callback(task_id task_id, void *user_context) {
|
||||
retry_info retry = {
|
||||
void new_object_task_callback(TaskID task_id, void *user_context) {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = new_object_fail_callback,
|
||||
};
|
||||
db_handle *db = user_context;
|
||||
DBHandle *db = user_context;
|
||||
result_table_add(db, new_object_id, new_object_task_id, &retry,
|
||||
new_object_lookup_callback, (void *) db);
|
||||
}
|
||||
@@ -67,18 +67,18 @@ TEST new_object_test(void) {
|
||||
new_object_succeeded = 0;
|
||||
new_object_id = globally_unique_id();
|
||||
new_object_task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
new_object_task_spec = task_task_spec(new_object_task);
|
||||
new_object_task_spec = Task_task_spec(new_object_task);
|
||||
new_object_task_id = task_spec_id(new_object_task_spec);
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = new_object_fail_callback,
|
||||
};
|
||||
task_table_add_task(db, copy_task(new_object_task), &retry,
|
||||
task_table_add_task(db, Task_copy(new_object_task), &retry,
|
||||
new_object_task_callback, db);
|
||||
event_loop_run(g_loop);
|
||||
db_disconnect(db);
|
||||
@@ -91,8 +91,8 @@ TEST new_object_test(void) {
|
||||
|
||||
/* === Test adding an object without an associated task === */
|
||||
|
||||
void new_object_no_task_callback(object_id object_id,
|
||||
task_id task_id,
|
||||
void new_object_no_task_callback(ObjectID object_id,
|
||||
TaskID task_id,
|
||||
void *user_context) {
|
||||
new_object_succeeded = 1;
|
||||
CHECK(IS_NIL_ID(task_id));
|
||||
@@ -105,10 +105,10 @@ TEST new_object_no_task_test(void) {
|
||||
new_object_id = globally_unique_id();
|
||||
new_object_task_id = globally_unique_id();
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = new_object_fail_callback,
|
||||
@@ -131,7 +131,7 @@ TEST new_object_no_task_test(void) {
|
||||
const char *lookup_timeout_context = "lookup_timeout";
|
||||
int lookup_failed = 0;
|
||||
|
||||
void lookup_done_callback(object_id object_id,
|
||||
void lookup_done_callback(ObjectID object_id,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
void *context) {
|
||||
@@ -139,7 +139,7 @@ void lookup_done_callback(object_id object_id,
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
void lookup_fail_callback(unique_id id, void *user_context, void *user_data) {
|
||||
void lookup_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
lookup_failed = 1;
|
||||
CHECK(user_context == (void *) lookup_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
@@ -147,10 +147,10 @@ void lookup_fail_callback(unique_id id, void *user_context, void *user_data) {
|
||||
|
||||
TEST lookup_timeout_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5, .timeout = 100, .fail_callback = lookup_fail_callback,
|
||||
};
|
||||
object_table_lookup(db, NIL_ID, &retry, lookup_done_callback,
|
||||
@@ -170,12 +170,12 @@ TEST lookup_timeout_test(void) {
|
||||
const char *add_timeout_context = "add_timeout";
|
||||
int add_failed = 0;
|
||||
|
||||
void add_done_callback(object_id object_id, void *user_context) {
|
||||
void add_done_callback(ObjectID object_id, void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
void add_fail_callback(unique_id id, void *user_context, void *user_data) {
|
||||
void add_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
add_failed = 1;
|
||||
CHECK(user_context == (void *) add_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
@@ -183,10 +183,10 @@ void add_fail_callback(unique_id id, void *user_context, void *user_data) {
|
||||
|
||||
TEST add_timeout_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5, .timeout = 100, .fail_callback = add_fail_callback,
|
||||
};
|
||||
object_table_add(db, NIL_ID, 0, (unsigned char *) NIL_DIGEST, &retry,
|
||||
@@ -205,7 +205,7 @@ TEST add_timeout_test(void) {
|
||||
|
||||
int subscribe_failed = 0;
|
||||
|
||||
void subscribe_done_callback(object_id object_id,
|
||||
void subscribe_done_callback(ObjectID object_id,
|
||||
int64_t data_size,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
@@ -214,19 +214,17 @@ void subscribe_done_callback(object_id object_id,
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
void subscribe_fail_callback(unique_id id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
void subscribe_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
subscribe_failed = 1;
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
TEST subscribe_timeout_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = subscribe_fail_callback,
|
||||
@@ -248,7 +246,7 @@ TEST subscribe_timeout_test(void) {
|
||||
int64_t reconnect_context_callback(event_loop *loop,
|
||||
int64_t timer_id,
|
||||
void *context) {
|
||||
db_handle *db = context;
|
||||
DBHandle *db = context;
|
||||
/* Reconnect to redis. This is not reconnecting the pub/sub channel. */
|
||||
redisAsyncFree(db->context);
|
||||
redisFree(db->sync_context);
|
||||
@@ -273,7 +271,7 @@ int64_t terminate_event_loop_callback(event_loop *loop,
|
||||
const char *lookup_retry_context = "lookup_retry";
|
||||
int lookup_retry_succeeded = 0;
|
||||
|
||||
void lookup_retry_done_callback(object_id object_id,
|
||||
void lookup_retry_done_callback(ObjectID object_id,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
void *context) {
|
||||
@@ -281,7 +279,7 @@ void lookup_retry_done_callback(object_id object_id,
|
||||
lookup_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
void lookup_retry_fail_callback(unique_id id,
|
||||
void lookup_retry_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
@@ -295,7 +293,7 @@ int add_retry_succeeded = 0;
|
||||
|
||||
/* === Test add then lookup retry === */
|
||||
|
||||
void add_lookup_done_callback(object_id object_id,
|
||||
void add_lookup_done_callback(ObjectID object_id,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
void *context) {
|
||||
@@ -305,9 +303,9 @@ void add_lookup_done_callback(object_id object_id,
|
||||
lookup_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
void add_lookup_callback(object_id object_id, void *user_context) {
|
||||
db_handle *db = user_context;
|
||||
retry_info retry = {
|
||||
void add_lookup_callback(ObjectID object_id, void *user_context) {
|
||||
DBHandle *db = user_context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = lookup_retry_fail_callback,
|
||||
@@ -321,10 +319,10 @@ TEST add_lookup_test(void) {
|
||||
lookup_retry_succeeded = 0;
|
||||
/* Construct the arguments to db_connect. */
|
||||
const char *db_connect_args[] = {"address", "127.0.0.1:11235"};
|
||||
db_handle *db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1",
|
||||
2, db_connect_args);
|
||||
DBHandle *db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 2,
|
||||
db_connect_args);
|
||||
db_attach(db, g_loop, true);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = lookup_retry_fail_callback,
|
||||
@@ -344,7 +342,7 @@ TEST add_lookup_test(void) {
|
||||
}
|
||||
|
||||
/* === Test add, remove, then lookup === */
|
||||
void add_remove_lookup_done_callback(object_id object_id,
|
||||
void add_remove_lookup_done_callback(ObjectID object_id,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
void *context) {
|
||||
@@ -353,9 +351,9 @@ void add_remove_lookup_done_callback(object_id object_id,
|
||||
lookup_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
void add_remove_lookup_callback(object_id object_id, void *user_context) {
|
||||
db_handle *db = user_context;
|
||||
retry_info retry = {
|
||||
void add_remove_lookup_callback(ObjectID object_id, void *user_context) {
|
||||
DBHandle *db = user_context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = lookup_retry_fail_callback,
|
||||
@@ -364,9 +362,9 @@ void add_remove_lookup_callback(object_id object_id, void *user_context) {
|
||||
(void *) lookup_retry_context);
|
||||
}
|
||||
|
||||
void add_remove_callback(object_id object_id, void *user_context) {
|
||||
db_handle *db = user_context;
|
||||
retry_info retry = {
|
||||
void add_remove_callback(ObjectID object_id, void *user_context) {
|
||||
DBHandle *db = user_context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = lookup_retry_fail_callback,
|
||||
@@ -378,10 +376,10 @@ void add_remove_callback(object_id object_id, void *user_context) {
|
||||
TEST add_remove_lookup_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
lookup_retry_succeeded = 0;
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, true);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = lookup_retry_fail_callback,
|
||||
@@ -408,7 +406,7 @@ int subscribe_retry_succeeded = 0;
|
||||
int64_t reconnect_sub_context_callback(event_loop *loop,
|
||||
int64_t timer_id,
|
||||
void *context) {
|
||||
db_handle *db = context;
|
||||
DBHandle *db = context;
|
||||
/* Reconnect to redis. This is not reconnecting the pub/sub channel. */
|
||||
redisAsyncFree(db->sub_context);
|
||||
redisAsyncFree(db->context);
|
||||
@@ -430,14 +428,14 @@ int64_t reconnect_sub_context_callback(event_loop *loop,
|
||||
const char *lookup_late_context = "lookup_late";
|
||||
int lookup_late_failed = 0;
|
||||
|
||||
void lookup_late_fail_callback(unique_id id,
|
||||
void lookup_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) lookup_late_context);
|
||||
lookup_late_failed = 1;
|
||||
}
|
||||
|
||||
void lookup_late_done_callback(object_id object_id,
|
||||
void lookup_late_done_callback(ObjectID object_id,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
void *context) {
|
||||
@@ -447,10 +445,10 @@ void lookup_late_done_callback(object_id object_id,
|
||||
|
||||
TEST lookup_late_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0,
|
||||
.timeout = 0,
|
||||
.fail_callback = lookup_late_fail_callback,
|
||||
@@ -477,22 +475,22 @@ TEST lookup_late_test(void) {
|
||||
const char *add_late_context = "add_late";
|
||||
int add_late_failed = 0;
|
||||
|
||||
void add_late_fail_callback(unique_id id, void *user_context, void *user_data) {
|
||||
void add_late_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
CHECK(user_context == (void *) add_late_context);
|
||||
add_late_failed = 1;
|
||||
}
|
||||
|
||||
void add_late_done_callback(object_id object_id, void *user_context) {
|
||||
void add_late_done_callback(ObjectID object_id, void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
TEST add_late_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0, .timeout = 0, .fail_callback = add_late_fail_callback,
|
||||
};
|
||||
object_table_add(db, NIL_ID, 0, (unsigned char *) NIL_DIGEST, &retry,
|
||||
@@ -517,14 +515,14 @@ TEST add_late_test(void) {
|
||||
const char *subscribe_late_context = "subscribe_late";
|
||||
int subscribe_late_failed = 0;
|
||||
|
||||
void subscribe_late_fail_callback(unique_id id,
|
||||
void subscribe_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) subscribe_late_context);
|
||||
subscribe_late_failed = 1;
|
||||
}
|
||||
|
||||
void subscribe_late_done_callback(object_id object_id,
|
||||
void subscribe_late_done_callback(ObjectID object_id,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
void *user_context) {
|
||||
@@ -534,10 +532,10 @@ void subscribe_late_done_callback(object_id object_id,
|
||||
|
||||
TEST subscribe_late_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0,
|
||||
.timeout = 0,
|
||||
.fail_callback = subscribe_late_fail_callback,
|
||||
@@ -565,34 +563,34 @@ TEST subscribe_late_test(void) {
|
||||
const char *subscribe_success_context = "subscribe_success";
|
||||
int subscribe_success_done = 0;
|
||||
int subscribe_success_succeeded = 0;
|
||||
object_id subscribe_id;
|
||||
ObjectID subscribe_id;
|
||||
|
||||
void subscribe_success_fail_callback(unique_id id,
|
||||
void subscribe_success_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
void subscribe_success_done_callback(object_id object_id,
|
||||
void subscribe_success_done_callback(ObjectID object_id,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
void *user_context) {
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0, .timeout = 750, .fail_callback = NULL,
|
||||
};
|
||||
object_table_add((db_handle *) user_context, subscribe_id, 0,
|
||||
object_table_add((DBHandle *) user_context, subscribe_id, 0,
|
||||
(unsigned char *) NIL_DIGEST, &retry, NULL, NULL);
|
||||
subscribe_success_done = 1;
|
||||
}
|
||||
|
||||
void subscribe_success_object_available_callback(object_id object_id,
|
||||
void subscribe_success_object_available_callback(ObjectID object_id,
|
||||
int64_t data_size,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
void *user_context) {
|
||||
CHECK(user_context == (void *) subscribe_success_context);
|
||||
CHECK(object_ids_equal(object_id, subscribe_id));
|
||||
CHECK(ObjectID_equal(object_id, subscribe_id));
|
||||
CHECK(manager_count == 1);
|
||||
subscribe_success_succeeded = 1;
|
||||
}
|
||||
@@ -602,12 +600,12 @@ TEST subscribe_success_test(void) {
|
||||
|
||||
/* Construct the arguments to db_connect. */
|
||||
const char *db_connect_args[] = {"address", "127.0.0.1:11236"};
|
||||
db_handle *db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1",
|
||||
2, db_connect_args);
|
||||
DBHandle *db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 2,
|
||||
db_connect_args);
|
||||
db_attach(db, g_loop, false);
|
||||
subscribe_id = globally_unique_id();
|
||||
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0,
|
||||
.timeout = 100,
|
||||
.fail_callback = subscribe_success_fail_callback,
|
||||
@@ -617,7 +615,7 @@ TEST subscribe_success_test(void) {
|
||||
(void *) subscribe_success_context, &retry,
|
||||
subscribe_success_done_callback, (void *) db);
|
||||
|
||||
object_id object_ids[1] = {subscribe_id};
|
||||
ObjectID object_ids[1] = {subscribe_id};
|
||||
object_table_request_notifications(db, 1, object_ids, &retry);
|
||||
|
||||
/* Install handler for terminating the event loop. */
|
||||
@@ -645,7 +643,7 @@ const char *subscribe_object_present_str = "subscribe_object_present";
|
||||
int subscribe_object_present_succeeded = 0;
|
||||
|
||||
void subscribe_object_present_object_available_callback(
|
||||
object_id object_id,
|
||||
ObjectID object_id,
|
||||
int64_t data_size,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
@@ -658,7 +656,7 @@ void subscribe_object_present_object_available_callback(
|
||||
CHECK(manager_count == 1);
|
||||
}
|
||||
|
||||
void fatal_fail_callback(unique_id id, void *user_context, void *user_data) {
|
||||
void fatal_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
}
|
||||
@@ -671,11 +669,11 @@ TEST subscribe_object_present_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
/* Construct the arguments to db_connect. */
|
||||
const char *db_connect_args[] = {"address", "127.0.0.1:11236"};
|
||||
db_handle *db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1",
|
||||
2, db_connect_args);
|
||||
DBHandle *db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 2,
|
||||
db_connect_args);
|
||||
db_attach(db, g_loop, false);
|
||||
unique_id id = globally_unique_id();
|
||||
retry_info retry = {
|
||||
UniqueID id = globally_unique_id();
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0, .timeout = 100, .fail_callback = fatal_fail_callback,
|
||||
};
|
||||
object_table_add(db, id, data_size, (unsigned char *) NIL_DIGEST, &retry,
|
||||
@@ -690,7 +688,7 @@ TEST subscribe_object_present_test(void) {
|
||||
/* Run the event loop to create do the add and subscribe. */
|
||||
event_loop_run(g_loop);
|
||||
|
||||
object_id object_ids[1] = {id};
|
||||
ObjectID object_ids[1] = {id};
|
||||
object_table_request_notifications(db, 1, object_ids, &retry);
|
||||
/* Install handler for terminating the event loop. */
|
||||
event_loop_add_timer(g_loop, 750,
|
||||
@@ -712,7 +710,7 @@ const char *subscribe_object_not_present_context =
|
||||
"subscribe_object_not_present";
|
||||
|
||||
void subscribe_object_not_present_object_available_callback(
|
||||
object_id object_id,
|
||||
ObjectID object_id,
|
||||
int64_t data_size,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
@@ -723,11 +721,11 @@ void subscribe_object_not_present_object_available_callback(
|
||||
|
||||
TEST subscribe_object_not_present_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
unique_id id = globally_unique_id();
|
||||
retry_info retry = {
|
||||
UniqueID id = globally_unique_id();
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0, .timeout = 100, .fail_callback = NULL,
|
||||
};
|
||||
object_table_subscribe_to_notifications(
|
||||
@@ -740,7 +738,7 @@ TEST subscribe_object_not_present_test(void) {
|
||||
/* Run the event loop to do the subscribe. */
|
||||
event_loop_run(g_loop);
|
||||
|
||||
object_id object_ids[1] = {id};
|
||||
ObjectID object_ids[1] = {id};
|
||||
object_table_request_notifications(db, 1, object_ids, &retry);
|
||||
/* Install handler for terminating the event loop. */
|
||||
event_loop_add_timer(g_loop, 750,
|
||||
@@ -762,7 +760,7 @@ const char *subscribe_object_available_later_context =
|
||||
int subscribe_object_available_later_succeeded = 0;
|
||||
|
||||
void subscribe_object_available_later_object_available_callback(
|
||||
object_id object_id,
|
||||
ObjectID object_id,
|
||||
int64_t data_size,
|
||||
int manager_count,
|
||||
const char *manager_vector[],
|
||||
@@ -786,11 +784,11 @@ TEST subscribe_object_available_later_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
/* Construct the arguments to db_connect. */
|
||||
const char *db_connect_args[] = {"address", "127.0.0.1:11236"};
|
||||
db_handle *db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1",
|
||||
2, db_connect_args);
|
||||
DBHandle *db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 2,
|
||||
db_connect_args);
|
||||
db_attach(db, g_loop, false);
|
||||
unique_id id = globally_unique_id();
|
||||
retry_info retry = {
|
||||
UniqueID id = globally_unique_id();
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0, .timeout = 100, .fail_callback = NULL,
|
||||
};
|
||||
object_table_subscribe_to_notifications(
|
||||
@@ -803,7 +801,7 @@ TEST subscribe_object_available_later_test(void) {
|
||||
/* Run the event loop to do the subscribe. */
|
||||
event_loop_run(g_loop);
|
||||
|
||||
object_id object_ids[1] = {id};
|
||||
ObjectID object_ids[1] = {id};
|
||||
object_table_request_notifications(db, 1, object_ids, &retry);
|
||||
/* Install handler for terminating the event loop. */
|
||||
event_loop_add_timer(g_loop, 750,
|
||||
@@ -839,11 +837,11 @@ TEST subscribe_object_available_subscribe_all(void) {
|
||||
g_loop = event_loop_create();
|
||||
/* Construct the arguments to db_connect. */
|
||||
const char *db_connect_args[] = {"address", "127.0.0.1:11236"};
|
||||
db_handle *db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1",
|
||||
2, db_connect_args);
|
||||
DBHandle *db = db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 2,
|
||||
db_connect_args);
|
||||
db_attach(db, g_loop, false);
|
||||
unique_id id = globally_unique_id();
|
||||
retry_info retry = {
|
||||
UniqueID id = globally_unique_id();
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0, .timeout = 100, .fail_callback = NULL,
|
||||
};
|
||||
object_table_subscribe_to_notifications(
|
||||
|
||||
@@ -69,7 +69,7 @@ TEST redis_socket_test(void) {
|
||||
}
|
||||
|
||||
void redis_read_callback(event_loop *loop, int fd, void *context, int events) {
|
||||
db_handle *db = context;
|
||||
DBHandle *db = context;
|
||||
char *cmd = read_log_message(fd);
|
||||
redisAsyncCommand(db->context, async_redis_socket_test_callback, NULL, cmd);
|
||||
free(cmd);
|
||||
@@ -102,7 +102,7 @@ TEST async_redis_socket_test(void) {
|
||||
utarray_push_back(connections, &socket_fd);
|
||||
|
||||
/* Start connection to Redis. */
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "test_process", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, loop, false);
|
||||
|
||||
@@ -148,7 +148,7 @@ void logging_read_callback(event_loop *loop,
|
||||
int fd,
|
||||
void *context,
|
||||
int events) {
|
||||
db_handle *conn = context;
|
||||
DBHandle *conn = context;
|
||||
char *cmd = read_log_message(fd);
|
||||
redisAsyncCommand(conn->context, logging_test_callback, NULL, cmd,
|
||||
(char *) conn->client.id, sizeof(conn->client.id));
|
||||
@@ -177,7 +177,7 @@ TEST logging_test(void) {
|
||||
utarray_push_back(connections, &socket_fd);
|
||||
|
||||
/* Start connection to Redis. */
|
||||
db_handle *conn =
|
||||
DBHandle *conn =
|
||||
db_connect("127.0.0.1", 6379, "test_process", "127.0.0.1", 0, NULL);
|
||||
db_attach(conn, loop, false);
|
||||
|
||||
@@ -185,8 +185,8 @@ TEST logging_test(void) {
|
||||
int client_fd = connect_ipc_sock(socket_pathname);
|
||||
ASSERT(client_fd >= 0);
|
||||
utarray_push_back(connections, &client_fd);
|
||||
ray_logger *logger = init_ray_logger("worker", RAY_INFO, 0, &client_fd);
|
||||
ray_log(logger, RAY_INFO, "TEST", "Message");
|
||||
RayLogger *logger = RayLogger_init("worker", RAY_INFO, 0, &client_fd);
|
||||
RayLogger_log(logger, RAY_INFO, "TEST", "Message");
|
||||
|
||||
event_loop_add_file(loop, socket_fd, EVENT_LOOP_READ, logging_accept_callback,
|
||||
conn);
|
||||
@@ -197,7 +197,7 @@ TEST logging_test(void) {
|
||||
|
||||
ASSERT(logging_test_callback_called);
|
||||
|
||||
free_ray_logger(logger);
|
||||
RayLogger_free(logger);
|
||||
db_disconnect(conn);
|
||||
event_loop_destroy(loop);
|
||||
for (int *p = (int *) utarray_front(connections); p != NULL;
|
||||
|
||||
@@ -17,18 +17,18 @@ event_loop *g_loop;
|
||||
|
||||
/* === A lookup of a task not in the table === */
|
||||
|
||||
task_id lookup_nil_id;
|
||||
TaskID lookup_nil_id;
|
||||
int lookup_nil_success = 0;
|
||||
const char *lookup_nil_context = "lookup_nil";
|
||||
|
||||
void lookup_nil_fail_callback(unique_id id,
|
||||
void lookup_nil_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
void lookup_nil_success_callback(task *task, void *context) {
|
||||
void lookup_nil_success_callback(Task *task, void *context) {
|
||||
lookup_nil_success = 1;
|
||||
CHECK(task == NULL);
|
||||
CHECK(context == (void *) lookup_nil_context);
|
||||
@@ -38,10 +38,10 @@ void lookup_nil_success_callback(task *task, void *context) {
|
||||
TEST lookup_nil_test(void) {
|
||||
lookup_nil_id = globally_unique_id();
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 1000,
|
||||
.fail_callback = lookup_nil_fail_callback,
|
||||
@@ -61,28 +61,28 @@ TEST lookup_nil_test(void) {
|
||||
|
||||
int add_success = 0;
|
||||
int lookup_success = 0;
|
||||
task *add_lookup_task;
|
||||
Task *add_lookup_task;
|
||||
const char *add_lookup_context = "add_lookup";
|
||||
|
||||
void add_lookup_fail_callback(unique_id id,
|
||||
void add_lookup_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
void lookup_success_callback(task *task, void *context) {
|
||||
void lookup_success_callback(Task *task, void *context) {
|
||||
lookup_success = 1;
|
||||
CHECK(memcmp(task, add_lookup_task, task_size(task)) == 0);
|
||||
CHECK(memcmp(task, add_lookup_task, Task_size(task)) == 0);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
void add_success_callback(task_id task_id, void *context) {
|
||||
void add_success_callback(TaskID task_id, void *context) {
|
||||
add_success = 1;
|
||||
CHECK(task_ids_equal(task_id, task_task_id(add_lookup_task)));
|
||||
CHECK(TaskID_equal(task_id, Task_task_id(add_lookup_task)));
|
||||
|
||||
db_handle *db = context;
|
||||
retry_info retry = {
|
||||
DBHandle *db = context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 1000,
|
||||
.fail_callback = add_lookup_fail_callback,
|
||||
@@ -94,15 +94,15 @@ void add_success_callback(task_id task_id, void *context) {
|
||||
TEST add_lookup_test(void) {
|
||||
add_lookup_task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 1000,
|
||||
.fail_callback = add_lookup_fail_callback,
|
||||
};
|
||||
task_table_add_task(db, copy_task(add_lookup_task), &retry,
|
||||
task_table_add_task(db, Task_copy(add_lookup_task), &retry,
|
||||
add_success_callback, (void *) db);
|
||||
/* Disconnect the database to see if the lookup times out. */
|
||||
event_loop_run(g_loop);
|
||||
@@ -121,14 +121,12 @@ TEST add_lookup_test(void) {
|
||||
const char *subscribe_timeout_context = "subscribe_timeout";
|
||||
int subscribe_failed = 0;
|
||||
|
||||
void subscribe_done_callback(task_id task_id, void *user_context) {
|
||||
void subscribe_done_callback(TaskID task_id, void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
void subscribe_fail_callback(unique_id id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
void subscribe_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
subscribe_failed = 1;
|
||||
CHECK(user_context == (void *) subscribe_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
@@ -136,10 +134,10 @@ void subscribe_fail_callback(unique_id id,
|
||||
|
||||
TEST subscribe_timeout_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = subscribe_fail_callback,
|
||||
@@ -164,12 +162,12 @@ const char *publish_timeout_context = "publish_timeout";
|
||||
const int publish_test_number = 272;
|
||||
int publish_failed = 0;
|
||||
|
||||
void publish_done_callback(task_id task_id, void *user_context) {
|
||||
void publish_done_callback(TaskID task_id, void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
void publish_fail_callback(unique_id id, void *user_context, void *user_data) {
|
||||
void publish_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
publish_failed = 1;
|
||||
CHECK(user_context == (void *) publish_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
@@ -177,11 +175,11 @@ void publish_fail_callback(unique_id id, void *user_context, void *user_data) {
|
||||
|
||||
TEST publish_timeout_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
retry_info retry = {
|
||||
Task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5, .timeout = 100, .fail_callback = publish_fail_callback,
|
||||
};
|
||||
task_table_add_task(db, task, &retry, publish_done_callback,
|
||||
@@ -202,7 +200,7 @@ TEST publish_timeout_test(void) {
|
||||
int64_t reconnect_db_callback(event_loop *loop,
|
||||
int64_t timer_id,
|
||||
void *context) {
|
||||
db_handle *db = context;
|
||||
DBHandle *db = context;
|
||||
/* Reconnect to redis. */
|
||||
redisAsyncFree(db->sub_context);
|
||||
db->sub_context = redisAsyncConnect("127.0.0.1", 6379);
|
||||
@@ -225,12 +223,12 @@ const char *subscribe_retry_context = "subscribe_retry";
|
||||
const int subscribe_retry_test_number = 273;
|
||||
int subscribe_retry_succeeded = 0;
|
||||
|
||||
void subscribe_retry_done_callback(object_id object_id, void *user_context) {
|
||||
void subscribe_retry_done_callback(ObjectID object_id, void *user_context) {
|
||||
CHECK(user_context == (void *) subscribe_retry_context);
|
||||
subscribe_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
void subscribe_retry_fail_callback(unique_id id,
|
||||
void subscribe_retry_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
@@ -239,10 +237,10 @@ void subscribe_retry_fail_callback(unique_id id,
|
||||
|
||||
TEST subscribe_retry_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = subscribe_retry_fail_callback,
|
||||
@@ -272,12 +270,12 @@ TEST subscribe_retry_test(void) {
|
||||
const char *publish_retry_context = "publish_retry";
|
||||
int publish_retry_succeeded = 0;
|
||||
|
||||
void publish_retry_done_callback(object_id object_id, void *user_context) {
|
||||
void publish_retry_done_callback(ObjectID object_id, void *user_context) {
|
||||
CHECK(user_context == (void *) publish_retry_context);
|
||||
publish_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
void publish_retry_fail_callback(unique_id id,
|
||||
void publish_retry_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
@@ -286,11 +284,11 @@ void publish_retry_fail_callback(unique_id id,
|
||||
|
||||
TEST publish_retry_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
retry_info retry = {
|
||||
Task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = publish_retry_fail_callback,
|
||||
@@ -321,24 +319,24 @@ TEST publish_retry_test(void) {
|
||||
const char *subscribe_late_context = "subscribe_late";
|
||||
int subscribe_late_failed = 0;
|
||||
|
||||
void subscribe_late_fail_callback(unique_id id,
|
||||
void subscribe_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) subscribe_late_context);
|
||||
subscribe_late_failed = 1;
|
||||
}
|
||||
|
||||
void subscribe_late_done_callback(task_id task_id, void *user_context) {
|
||||
void subscribe_late_done_callback(TaskID task_id, void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_late_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
retry_info retry = {
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0,
|
||||
.timeout = 0,
|
||||
.fail_callback = subscribe_late_fail_callback,
|
||||
@@ -366,25 +364,25 @@ TEST subscribe_late_test(void) {
|
||||
const char *publish_late_context = "publish_late";
|
||||
int publish_late_failed = 0;
|
||||
|
||||
void publish_late_fail_callback(unique_id id,
|
||||
void publish_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) publish_late_context);
|
||||
publish_late_failed = 1;
|
||||
}
|
||||
|
||||
void publish_late_done_callback(task_id task_id, void *user_context) {
|
||||
void publish_late_done_callback(TaskID task_id, void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
}
|
||||
|
||||
TEST publish_late_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
DBHandle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 0, NULL);
|
||||
db_attach(db, g_loop, false);
|
||||
task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
retry_info retry = {
|
||||
Task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0,
|
||||
.timeout = 0,
|
||||
.fail_callback = publish_late_fail_callback,
|
||||
|
||||
@@ -12,17 +12,17 @@
|
||||
SUITE(task_tests);
|
||||
|
||||
TEST task_test(void) {
|
||||
task_id parent_task_id = globally_unique_id();
|
||||
function_id func_id = globally_unique_id();
|
||||
TaskID parent_task_id = globally_unique_id();
|
||||
FunctionID func_id = globally_unique_id();
|
||||
task_spec *spec = start_construct_task_spec(
|
||||
NIL_ID, parent_task_id, 0, NIL_ACTOR_ID, 0, func_id, 4, 2, 10);
|
||||
ASSERT(task_num_args(spec) == 4);
|
||||
ASSERT(task_num_returns(spec) == 2);
|
||||
|
||||
unique_id arg1 = globally_unique_id();
|
||||
UniqueID arg1 = globally_unique_id();
|
||||
ASSERT(task_args_add_ref(spec, arg1) == 0);
|
||||
ASSERT(task_args_add_val(spec, (uint8_t *) "hello", 5) == 1);
|
||||
unique_id arg2 = globally_unique_id();
|
||||
UniqueID arg2 = globally_unique_id();
|
||||
ASSERT(task_args_add_ref(spec, arg2) == 2);
|
||||
ASSERT(task_args_add_val(spec, (uint8_t *) "world", 5) == 3);
|
||||
/* Finish constructing the spec. This constructs the task ID and the
|
||||
@@ -32,11 +32,11 @@ TEST task_test(void) {
|
||||
/* Check that the spec was constructed as expected. */
|
||||
ASSERT(task_num_args(spec) == 4);
|
||||
ASSERT(task_num_returns(spec) == 2);
|
||||
ASSERT(function_ids_equal(task_function(spec), func_id));
|
||||
ASSERT(object_ids_equal(task_arg_id(spec, 0), arg1));
|
||||
ASSERT(FunctionID_equal(task_function(spec), func_id));
|
||||
ASSERT(ObjectID_equal(task_arg_id(spec, 0), arg1));
|
||||
ASSERT(memcmp(task_arg_val(spec, 1), (uint8_t *) "hello",
|
||||
task_arg_length(spec, 1)) == 0);
|
||||
ASSERT(object_ids_equal(task_arg_id(spec, 2), arg2));
|
||||
ASSERT(ObjectID_equal(task_arg_id(spec, 2), arg2));
|
||||
ASSERT(memcmp(task_arg_val(spec, 3), (uint8_t *) "world",
|
||||
task_arg_length(spec, 3)) == 0);
|
||||
|
||||
@@ -46,9 +46,9 @@ TEST task_test(void) {
|
||||
|
||||
TEST deterministic_ids_test(void) {
|
||||
/* Define the inputs to the task construction. */
|
||||
task_id parent_task_id = globally_unique_id();
|
||||
function_id func_id = globally_unique_id();
|
||||
unique_id arg1 = globally_unique_id();
|
||||
TaskID parent_task_id = globally_unique_id();
|
||||
FunctionID func_id = globally_unique_id();
|
||||
UniqueID arg1 = globally_unique_id();
|
||||
uint8_t *arg2 = (uint8_t *) "hello world";
|
||||
|
||||
/* Construct a first task. */
|
||||
@@ -66,14 +66,14 @@ TEST deterministic_ids_test(void) {
|
||||
finish_construct_task_spec(spec2);
|
||||
|
||||
/* Check that these tasks have the same task IDs and the same return IDs.*/
|
||||
ASSERT(task_ids_equal(task_spec_id(spec1), task_spec_id(spec2)));
|
||||
ASSERT(object_ids_equal(task_return(spec1, 0), task_return(spec2, 0)));
|
||||
ASSERT(object_ids_equal(task_return(spec1, 1), task_return(spec2, 1)));
|
||||
ASSERT(object_ids_equal(task_return(spec1, 2), task_return(spec2, 2)));
|
||||
ASSERT(TaskID_equal(task_spec_id(spec1), task_spec_id(spec2)));
|
||||
ASSERT(ObjectID_equal(task_return(spec1, 0), task_return(spec2, 0)));
|
||||
ASSERT(ObjectID_equal(task_return(spec1, 1), task_return(spec2, 1)));
|
||||
ASSERT(ObjectID_equal(task_return(spec1, 2), task_return(spec2, 2)));
|
||||
/* Check that the return IDs are all distinct. */
|
||||
ASSERT(!object_ids_equal(task_return(spec1, 0), task_return(spec2, 1)));
|
||||
ASSERT(!object_ids_equal(task_return(spec1, 0), task_return(spec2, 2)));
|
||||
ASSERT(!object_ids_equal(task_return(spec1, 1), task_return(spec2, 2)));
|
||||
ASSERT(!ObjectID_equal(task_return(spec1, 0), task_return(spec2, 1)));
|
||||
ASSERT(!ObjectID_equal(task_return(spec1, 0), task_return(spec2, 2)));
|
||||
ASSERT(!ObjectID_equal(task_return(spec1, 1), task_return(spec2, 2)));
|
||||
|
||||
/* Create more tasks that are only mildly different. */
|
||||
|
||||
@@ -114,11 +114,11 @@ TEST deterministic_ids_test(void) {
|
||||
finish_construct_task_spec(spec7);
|
||||
|
||||
/* Check that the task IDs are all distinct from the original. */
|
||||
ASSERT(!task_ids_equal(task_spec_id(spec1), task_spec_id(spec3)));
|
||||
ASSERT(!task_ids_equal(task_spec_id(spec1), task_spec_id(spec4)));
|
||||
ASSERT(!task_ids_equal(task_spec_id(spec1), task_spec_id(spec5)));
|
||||
ASSERT(!task_ids_equal(task_spec_id(spec1), task_spec_id(spec6)));
|
||||
ASSERT(!task_ids_equal(task_spec_id(spec1), task_spec_id(spec7)));
|
||||
ASSERT(!TaskID_equal(task_spec_id(spec1), task_spec_id(spec3)));
|
||||
ASSERT(!TaskID_equal(task_spec_id(spec1), task_spec_id(spec4)));
|
||||
ASSERT(!TaskID_equal(task_spec_id(spec1), task_spec_id(spec5)));
|
||||
ASSERT(!TaskID_equal(task_spec_id(spec1), task_spec_id(spec6)));
|
||||
ASSERT(!TaskID_equal(task_spec_id(spec1), task_spec_id(spec7)));
|
||||
|
||||
/* Check that the return object IDs are distinct from the originals. */
|
||||
task_spec *specs[6] = {spec1, spec3, spec4, spec5, spec6, spec7};
|
||||
@@ -127,7 +127,7 @@ TEST deterministic_ids_test(void) {
|
||||
for (int task_index2 = 0; task_index2 < 6; ++task_index2) {
|
||||
for (int return_index2 = 0; return_index2 < 3; ++return_index2) {
|
||||
if (task_index1 != task_index2 && return_index1 != return_index2) {
|
||||
ASSERT(!object_ids_equal(
|
||||
ASSERT(!ObjectID_equal(
|
||||
task_return(specs[task_index1], return_index1),
|
||||
task_return(specs[task_index2], return_index2)));
|
||||
}
|
||||
@@ -147,8 +147,8 @@ TEST deterministic_ids_test(void) {
|
||||
}
|
||||
|
||||
TEST send_task(void) {
|
||||
task_id parent_task_id = globally_unique_id();
|
||||
function_id func_id = globally_unique_id();
|
||||
TaskID parent_task_id = globally_unique_id();
|
||||
FunctionID func_id = globally_unique_id();
|
||||
task_spec *spec = start_construct_task_spec(
|
||||
NIL_ID, parent_task_id, 0, NIL_ACTOR_ID, 0, func_id, 4, 2, 10);
|
||||
task_args_add_ref(spec, globally_unique_id());
|
||||
|
||||
@@ -18,14 +18,14 @@ const int64_t arg_value_size = 1000;
|
||||
|
||||
static inline task_spec *example_task_spec_with_args(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
object_id arg_ids[]) {
|
||||
task_id parent_task_id = globally_unique_id();
|
||||
function_id func_id = globally_unique_id();
|
||||
ObjectID arg_ids[]) {
|
||||
TaskID parent_task_id = globally_unique_id();
|
||||
FunctionID func_id = globally_unique_id();
|
||||
task_spec *task =
|
||||
start_construct_task_spec(NIL_ID, parent_task_id, 0, NIL_ACTOR_ID, 0,
|
||||
func_id, num_args, num_returns, arg_value_size);
|
||||
for (int64_t i = 0; i < num_args; ++i) {
|
||||
object_id arg_id;
|
||||
ObjectID arg_id;
|
||||
if (arg_ids == NULL) {
|
||||
arg_id = globally_unique_id();
|
||||
} else {
|
||||
@@ -42,21 +42,21 @@ static inline task_spec *example_task_spec(int64_t num_args,
|
||||
return example_task_spec_with_args(num_args, num_returns, NULL);
|
||||
}
|
||||
|
||||
static inline task *example_task_with_args(int64_t num_args,
|
||||
static inline Task *example_task_with_args(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
int task_state,
|
||||
object_id arg_ids[]) {
|
||||
int Task_state,
|
||||
ObjectID arg_ids[]) {
|
||||
task_spec *spec = example_task_spec_with_args(num_args, num_returns, arg_ids);
|
||||
task *instance = alloc_task(spec, task_state, NIL_ID);
|
||||
Task *instance = Task_alloc(spec, Task_state, NIL_ID);
|
||||
free_task_spec(spec);
|
||||
return instance;
|
||||
}
|
||||
|
||||
static inline task *example_task(int64_t num_args,
|
||||
static inline Task *example_task(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
int task_state) {
|
||||
int Task_state) {
|
||||
task_spec *spec = example_task_spec(num_args, num_returns);
|
||||
task *instance = alloc_task(spec, task_state, NIL_ID);
|
||||
Task *instance = Task_alloc(spec, Task_state, NIL_ID);
|
||||
free_task_spec(spec);
|
||||
return instance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user