diff --git a/runtime/src/store/object.c b/runtime/src/store/object.c index 20ebd01f..0070704c 100644 --- a/runtime/src/store/object.c +++ b/runtime/src/store/object.c @@ -3995,8 +3995,6 @@ corto_int16 corto_unlock( return corto_unlock_intern(object); } - - /* Obtain function name from signature */ corto_int32 corto_signatureName(corto_string signature, corto_id buffer) { corto_char ch, *srcptr, *bptr; diff --git a/runtime/test/vstore/src/ReplicatorEvent.c b/runtime/test/vstore/src/ReplicatorEvent.c index ca54db60..ce1bd873 100644 --- a/runtime/test/vstore/src/ReplicatorEvent.c +++ b/runtime/test/vstore/src/ReplicatorEvent.c @@ -1,10 +1,7 @@ /* This is a managed file. Do not delete this comment. */ #include - - #include - void test_ReplicatorEvent_tc_event( test_ReplicatorEvent this) { @@ -14,42 +11,34 @@ void test_ReplicatorEvent_tc_event( test_assert(parent != NULL); corto_query q = {.select = "/", .from = corto_fullpath(NULL, parent)}; - test_EventReplicatorCreate_auto(mount, &q, NULL); test_assert(mount != NULL); - corto_int32DeclareChild_auto(parent, a); test_assert(a != NULL); test_assert(corto_checkAttr(a, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - ret = corto_define(a); test_assert(ret == 0); test_assert(corto_ownerof(a) == NULL); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - ret = corto_int32Update(a, 20); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - ret = corto_delete(a); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 1); - ret = corto_delete(mount); test_assert(ret == 0); - ret = corto_delete(parent); test_assert(ret == 0); - } void test_ReplicatorEvent_tc_eventDefineWithUpdate( @@ -63,31 +52,25 @@ void test_ReplicatorEvent_tc_eventDefineWithUpdate( corto_query q = {.select = "/", .from = corto_fullpath(NULL, parent)}; test_EventReplicatorCreate_auto(mount, &q, NULL); test_assert(mount != NULL); - corto_int32DeclareChild_auto(parent, a); test_assert(a != NULL); test_assertint(mount->declareCount, 0); test_assert(mount->updateCount == 0); test_assert(mount->deleteCount == 0); - ret = corto_int32Update(a, 20); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assert(mount->updateCount == 1); test_assert(mount->deleteCount == 0); - ret = corto_delete(a); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assert(mount->updateCount == 1); test_assert(mount->deleteCount == 1); - ret = corto_delete(mount); test_assert(ret == 0); - ret = corto_delete(parent); test_assert(ret == 0); - } void test_ReplicatorEvent_tc_eventTree( @@ -101,59 +84,49 @@ void test_ReplicatorEvent_tc_eventTree( corto_query q = {.select = "/", .from = corto_fullpath(NULL, parent)}; test_EventReplicatorCreate_auto(mount, &q, NULL); test_assert(mount != NULL); - corto_int32DeclareChild_auto(parent, a); test_assert(a != NULL); test_assert(corto_checkAttr(a, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - corto_int32DeclareChild_auto(a, a_a); test_assert(a_a != NULL); test_assert(corto_checkAttr(a_a, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - ret = corto_define(a); test_assert(ret == 0); test_assert(corto_ownerof(a) == NULL); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - ret = corto_define(a_a); test_assert(corto_ownerof(a_a) == NULL); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - ret = corto_int32Update(a, 20); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - ret = corto_int32Update(a_a, 20); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - ret = corto_delete(a); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 1); - ret = corto_delete(mount); test_assert(ret == 0); - ret = corto_delete(parent); test_assert(ret == 0); - } void test_ReplicatorEvent_tc_eventTreeWithTree( @@ -167,59 +140,49 @@ void test_ReplicatorEvent_tc_eventTreeWithTree( corto_query q = {.select = "//", .from = corto_fullpath(NULL, parent)}; test_EventReplicatorCreate_auto(mount, &q, NULL); test_assert(mount != NULL); - corto_int32DeclareChild_auto(parent, a); test_assert(a != NULL); test_assert(corto_checkAttr(a, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - corto_int32DeclareChild_auto(a, a_a); test_assert(a_a != NULL); test_assert(corto_checkAttr(a_a, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - ret = corto_define(a); test_assert(corto_ownerof(a) == NULL); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - ret = corto_define(a_a); test_assert(corto_ownerof(a_a) == NULL); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - ret = corto_int32Update(a, 20); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 3); test_assertint(mount->deleteCount, 0); - ret = corto_int32Update(a_a, 20); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 4); test_assertint(mount->deleteCount, 0); - ret = corto_delete(a); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 4); test_assertint(mount->deleteCount, 2); - ret = corto_delete(mount); test_assert(ret == 0); - ret = corto_delete(parent); test_assert(ret == 0); - } void test_ReplicatorEvent_tc_eventWithTree( @@ -233,39 +196,32 @@ void test_ReplicatorEvent_tc_eventWithTree( corto_query q = {.select = "//", .from = corto_fullpath(NULL, parent)}; test_EventReplicatorCreate_auto(mount, &q, NULL); test_assert(mount != NULL); - corto_int32DeclareChild_auto(parent, a); test_assert(a != NULL); test_assert(corto_checkAttr(a, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - ret = corto_define(a); test_assert(corto_ownerof(a) == NULL); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - ret = corto_int32Update(a, 20); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - ret = corto_delete(a); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 1); - ret = corto_delete(mount); test_assert(ret == 0); - ret = corto_delete(parent); test_assert(ret == 0); - } void test_ReplicatorEvent_tc_matchingType( @@ -279,65 +235,54 @@ void test_ReplicatorEvent_tc_matchingType( corto_query q = {.select = "/", .from = corto_fullpath(NULL, parent), .type = "int32"}; test_EventReplicatorCreate_auto(mount, &q, NULL); test_assert(mount != NULL); - corto_int32DeclareChild_auto(parent, a); test_assert(a != NULL); test_assert(corto_checkAttr(a, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - corto_float32DeclareChild_auto(parent, b); test_assert(a != NULL); test_assert(corto_checkAttr(b, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - ret = corto_define(a); test_assert(corto_ownerof(a) == NULL); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - ret = corto_define(b); test_assert(corto_ownerof(b) == NULL); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - ret = corto_int32Update(a, 20); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - ret = corto_float32Update(b, 10.5); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - ret = corto_delete(a); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 1); - ret = corto_delete(b); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 1); - ret = corto_delete(mount); test_assert(ret == 0); - ret = corto_delete(parent); test_assert(ret == 0); - } void test_ReplicatorEvent_tc_nonPersistent( @@ -351,14 +296,12 @@ void test_ReplicatorEvent_tc_nonPersistent( corto_query q = {.select = "/", .from = corto_fullpath(NULL, parent)}; test_EventReplicatorCreate_auto(mount, &q, NULL); test_assert(mount != NULL); - corto_int32DeclareChild_auto(parent, a); test_assert(a != NULL); test_assert(corto_checkAttr(a, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - corto_attr prev = corto_setAttr(CORTO_ATTR_WRITABLE); corto_float32DeclareChild_auto(parent, b); corto_setAttr(prev); @@ -367,51 +310,42 @@ void test_ReplicatorEvent_tc_nonPersistent( test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - ret = corto_define(a); test_assert(corto_ownerof(a) == NULL); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - ret = corto_define(b); test_assert(corto_ownerof(b) == NULL); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - ret = corto_int32Update(a, 20); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - ret = corto_float32Update(b, 10.5); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - ret = corto_delete(a); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 1); - ret = corto_delete(b); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 1); - ret = corto_delete(mount); test_assert(ret == 0); - ret = corto_delete(parent); test_assert(ret == 0); - } void test_ReplicatorEvent_tc_ownedByMount( @@ -425,28 +359,24 @@ void test_ReplicatorEvent_tc_ownedByMount( corto_query q = {.select = "/", .from = corto_fullpath(NULL, parent)}; test_EventReplicatorCreate_auto(mount, &q, NULL); test_assert(mount != NULL); - corto_int32DeclareChild_auto(parent, a); test_assert(a != NULL); test_assert(corto_checkAttr(a, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - corto_float32DeclareChild_auto(parent, b); test_assert(a != NULL); test_assert(corto_checkAttr(b, CORTO_ATTR_PERSISTENT)); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 0); test_assertint(mount->deleteCount, 0); - ret = corto_define(a); test_assert(ret == 0); test_assert(corto_ownerof(a) == NULL); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - corto_setOwner(mount); ret = corto_define(b); corto_setOwner(NULL); @@ -455,13 +385,11 @@ void test_ReplicatorEvent_tc_ownedByMount( test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 1); test_assertint(mount->deleteCount, 0); - ret = corto_int32Update(a, 20); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - corto_setOwner(mount); ret = corto_float32Update(b, 10.5); corto_setOwner(NULL); @@ -469,13 +397,11 @@ void test_ReplicatorEvent_tc_ownedByMount( test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 0); - ret = corto_delete(a); test_assert(ret == 0); test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 1); - corto_setOwner(mount); ret = corto_delete(b); corto_setOwner(NULL); @@ -483,13 +409,10 @@ void test_ReplicatorEvent_tc_ownedByMount( test_assertint(mount->declareCount, 0); test_assertint(mount->updateCount, 2); test_assertint(mount->deleteCount, 1); - ret = corto_delete(mount); test_assert(ret == 0); - ret = corto_delete(parent); test_assert(ret == 0); - } void test_ReplicatorEvent_tc_rateLimitOneObject( @@ -497,26 +420,22 @@ void test_ReplicatorEvent_tc_rateLimitOneObject( { corto_int16 ret; int cycles = 50000; - + corto_time timeout = {60, 0}; test_setTimeout(&timeout); - if (test_runslow()) { cycles = 100; } corto_voidCreateChild_auto(root_o, parent); test_assert(parent != NULL); - corto_mountPolicy policy = {.sampleRate = 5}; corto_query q = {.select = "/", .from = corto_fullpath(NULL, parent)}; test_EventReplicatorCreate_auto(mount, &q, &policy); test_assert(mount != NULL); - corto_int32DeclareChild_auto(parent, a); test_assert(a != NULL); test_assert(corto_checkAttr(a, CORTO_ATTR_PERSISTENT)); - /* Send 100K updates */ corto_time start, stop; corto_timeGet(&start); @@ -524,23 +443,19 @@ void test_ReplicatorEvent_tc_rateLimitOneObject( ret = corto_int32Update(a, 20); test_assert(ret == 0); } - corto_timeGet(&stop); + corto_timeGet(&stop); // Wait 2/frequency to ensure mount has processed all data corto_sleep(0, 400000000); corto_float64 t = corto_timeToDouble(corto_timeSub(stop, start)); test_assert(mount->updateCount <= ceil(t * 5.0 + 1.0)); test_assert(mount->updateCount >= floor(t * 5.0 - 1.0)); - ret = corto_delete(a); test_assert(ret == 0); - ret = corto_delete(mount); test_assert(ret == 0); - ret = corto_delete(parent); test_assert(ret == 0); - } void test_ReplicatorEvent_tc_rateLimitThreeObjects( @@ -550,19 +465,16 @@ void test_ReplicatorEvent_tc_rateLimitThreeObjects( int cycles = 50000; corto_time timeout = {60, 0}; test_setTimeout(&timeout); - if (test_runslow()) { cycles = 100; } corto_voidCreateChild_auto(root_o, parent); test_assert(parent != NULL); - corto_mountPolicy policy = {.sampleRate = 5}; corto_query q = {.select = "/", .from = corto_fullpath(NULL, parent)}; test_EventReplicatorCreate_auto(mount, &q, &policy); test_assert(mount != NULL); - corto_int32DeclareChild_auto(parent, a); test_assert(a != NULL); test_assert(corto_checkAttr(a, CORTO_ATTR_PERSISTENT)); @@ -572,7 +484,6 @@ void test_ReplicatorEvent_tc_rateLimitThreeObjects( corto_int32DeclareChild_auto(parent, c); test_assert(a != NULL); test_assert(corto_checkAttr(a, CORTO_ATTR_PERSISTENT)); - /* Send 100K updates */ corto_time start, stop; corto_timeGet(&start); @@ -582,22 +493,35 @@ void test_ReplicatorEvent_tc_rateLimitThreeObjects( ret = corto_int32Update(c, 20); test_assert(ret == 0); } - corto_timeGet(&stop); + corto_timeGet(&stop); // Wait 2/frequency to ensure mount has processed all data corto_sleep(0, 400000000); corto_float64 t = corto_timeToDouble(corto_timeSub(stop, start)); test_assert(mount->updateCount <= 3.0 * ceil(t * 5.0 + 1.0)); test_assert(mount->updateCount >= 3.0 * floor(t * 5.0 - 1.0)); - ret = corto_delete(a); test_assert(ret == 0); - ret = corto_delete(mount); test_assert(ret == 0); - ret = corto_delete(parent); test_assert(ret == 0); - } +void test_ReplicatorEvent_tc_rateLimitAlign( + test_ReplicatorEvent this) +{ + /* Test issue #634 */ + test_assert(corto_createChild(root_o, "data/obj", corto_void_o) != NULL); + corto_mount mnt = corto_declareChild(root_o, "config/influx", corto_mount_o); + test_assert(mnt != NULL); + mnt->super.query = (corto_query){ + .select = "/", + .from = "data" + }; + mnt->policy = (corto_mountPolicy){ + .mask = CORTO_MOUNT_HISTORY_BATCH_NOTIFY, + .sampleRate = 20.0, + }; + test_assert(corto_define(mnt) == 0); +} diff --git a/runtime/test/vstore/test.cx b/runtime/test/vstore/test.cx index 36bae930..3b7a4751 100644 --- a/runtime/test/vstore/test.cx +++ b/runtime/test/vstore/test.cx @@ -413,6 +413,7 @@ test/Suite ReplicatorEvent:/ void tc_ownedByMount() void tc_rateLimitOneObject() void tc_rateLimitThreeObjects() + void tc_rateLimitAlign() test/Suite MountSubscription:/ void tc_subscribeSingle()