|
@@ -506,6 +506,124 @@ START_TEST(Server_deleteMonitoredItems) {
|
|
}
|
|
}
|
|
END_TEST
|
|
END_TEST
|
|
|
|
|
|
|
|
+START_TEST(Server_lifeTimeCount) {
|
|
|
|
+ /* Create a subscription */
|
|
|
|
+ UA_CreateSubscriptionRequest request;
|
|
|
|
+ UA_CreateSubscriptionResponse response;
|
|
|
|
+
|
|
|
|
+ UA_CreateSubscriptionRequest_init(&request);
|
|
|
|
+ request.publishingEnabled = true;
|
|
|
|
+ request.requestedLifetimeCount = 3;
|
|
|
|
+ request.requestedMaxKeepAliveCount = 1;
|
|
|
|
+ UA_CreateSubscriptionResponse_init(&response);
|
|
|
|
+ Service_CreateSubscription(server, &adminSession, &request, &response);
|
|
|
|
+ ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
|
|
|
+ ck_assert_uint_eq(response.revisedMaxKeepAliveCount, 1);
|
|
|
|
+ ck_assert_uint_eq(response.revisedLifetimeCount, 3);
|
|
|
|
+ UA_CreateSubscriptionResponse_deleteMembers(&response);
|
|
|
|
+
|
|
|
|
+ /* Create a second subscription */
|
|
|
|
+ UA_CreateSubscriptionRequest_init(&request);
|
|
|
|
+ request.publishingEnabled = true;
|
|
|
|
+ request.requestedLifetimeCount = 4;
|
|
|
|
+ request.requestedMaxKeepAliveCount = 2;
|
|
|
|
+ UA_CreateSubscriptionResponse_init(&response);
|
|
|
|
+ Service_CreateSubscription(server, &adminSession, &request, &response);
|
|
|
|
+ ck_assert_uint_eq(response.responseHeader.serviceResult, UA_STATUSCODE_GOOD);
|
|
|
|
+ ck_assert_uint_eq(response.revisedMaxKeepAliveCount, 2);
|
|
|
|
+ /* revisedLifetimeCount is revised to 3*MaxKeepAliveCount */
|
|
|
|
+ ck_assert_uint_eq(response.revisedLifetimeCount, 6);
|
|
|
|
+ UA_Double publishingInterval = response.revisedPublishingInterval;
|
|
|
|
+ ck_assert(publishingInterval > 0.0f);
|
|
|
|
+ UA_CreateSubscriptionResponse_deleteMembers(&response);
|
|
|
|
+
|
|
|
|
+ UA_Server_run_iterate(server, false);
|
|
|
|
+
|
|
|
|
+ UA_UInt32 count = 0;
|
|
|
|
+ UA_Subscription *sub;
|
|
|
|
+ LIST_FOREACH(sub, &adminSession.serverSubscriptions, listEntry){
|
|
|
|
+ ck_assert_uint_eq(sub->currentLifetimeCount, 0);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_uint_eq(count, 2);
|
|
|
|
+
|
|
|
|
+ UA_fakeSleep((UA_UInt32)publishingInterval + 1);
|
|
|
|
+ UA_Server_run_iterate(server, false);
|
|
|
|
+
|
|
|
|
+ count = 0;
|
|
|
|
+ LIST_FOREACH(sub, &adminSession.serverSubscriptions, listEntry){
|
|
|
|
+ ck_assert_uint_eq(sub->currentLifetimeCount, 1);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_uint_eq(count, 2);
|
|
|
|
+
|
|
|
|
+ /* Sleep until the publishing interval times out */
|
|
|
|
+ UA_fakeSleep((UA_UInt32)publishingInterval + 1);
|
|
|
|
+ UA_Server_run_iterate(server, false);
|
|
|
|
+
|
|
|
|
+ count = 0;
|
|
|
|
+ LIST_FOREACH(sub, &adminSession.serverSubscriptions, listEntry){
|
|
|
|
+ ck_assert_uint_eq(sub->currentLifetimeCount, 2);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_uint_eq(count, 2);
|
|
|
|
+
|
|
|
|
+ /* Sleep until the publishing interval times out */
|
|
|
|
+ UA_fakeSleep((UA_UInt32)publishingInterval + 1);
|
|
|
|
+ UA_Server_run_iterate(server, false);
|
|
|
|
+
|
|
|
|
+ count = 0;
|
|
|
|
+ LIST_FOREACH(sub, &adminSession.serverSubscriptions, listEntry){
|
|
|
|
+ ck_assert_uint_eq(sub->currentLifetimeCount, 3);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_uint_eq(count, 2);
|
|
|
|
+
|
|
|
|
+ /* Sleep until the publishing interval times out */
|
|
|
|
+ UA_fakeSleep((UA_UInt32)publishingInterval + 1);
|
|
|
|
+ UA_Server_run_iterate(server, false);
|
|
|
|
+
|
|
|
|
+ count = 0;
|
|
|
|
+ LIST_FOREACH(sub, &adminSession.serverSubscriptions, listEntry){
|
|
|
|
+ ck_assert_uint_eq(sub->currentLifetimeCount, 4);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_uint_eq(count, 1);
|
|
|
|
+
|
|
|
|
+ /* Sleep until the publishing interval times out */
|
|
|
|
+ UA_fakeSleep((UA_UInt32)publishingInterval + 1);
|
|
|
|
+ UA_Server_run_iterate(server, false);
|
|
|
|
+
|
|
|
|
+ count = 0;
|
|
|
|
+ LIST_FOREACH(sub, &adminSession.serverSubscriptions, listEntry){
|
|
|
|
+ ck_assert_uint_eq(sub->currentLifetimeCount, 5);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_uint_eq(count, 1);
|
|
|
|
+
|
|
|
|
+ /* Sleep until the publishing interval times out */
|
|
|
|
+ UA_fakeSleep((UA_UInt32)publishingInterval + 1);
|
|
|
|
+ UA_Server_run_iterate(server, false);
|
|
|
|
+
|
|
|
|
+ count = 0;
|
|
|
|
+ LIST_FOREACH(sub, &adminSession.serverSubscriptions, listEntry){
|
|
|
|
+ ck_assert_uint_eq(sub->currentLifetimeCount, 6);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_uint_eq(count, 1);
|
|
|
|
+
|
|
|
|
+ /* Sleep until the publishing interval times out */
|
|
|
|
+ UA_fakeSleep((UA_UInt32)publishingInterval + 1);
|
|
|
|
+ UA_Server_run_iterate(server, false);
|
|
|
|
+
|
|
|
|
+ count = 0;
|
|
|
|
+ LIST_FOREACH(sub, &adminSession.serverSubscriptions, listEntry){
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+ ck_assert_uint_eq(count, 0);
|
|
|
|
+}
|
|
|
|
+END_TEST
|
|
|
|
+
|
|
#endif /* UA_ENABLE_SUBSCRIPTIONS */
|
|
#endif /* UA_ENABLE_SUBSCRIPTIONS */
|
|
|
|
|
|
static Suite* testSuite_Client(void) {
|
|
static Suite* testSuite_Client(void) {
|
|
@@ -525,6 +643,7 @@ static Suite* testSuite_Client(void) {
|
|
tcase_add_test(tc_server, Server_deleteSubscription);
|
|
tcase_add_test(tc_server, Server_deleteSubscription);
|
|
tcase_add_test(tc_server, Server_republish_invalid);
|
|
tcase_add_test(tc_server, Server_republish_invalid);
|
|
tcase_add_test(tc_server, Server_publishCallback);
|
|
tcase_add_test(tc_server, Server_publishCallback);
|
|
|
|
+ tcase_add_test(tc_server, Server_lifeTimeCount);
|
|
#endif /* UA_ENABLE_SUBSCRIPTIONS */
|
|
#endif /* UA_ENABLE_SUBSCRIPTIONS */
|
|
suite_add_tcase(s, tc_server);
|
|
suite_add_tcase(s, tc_server);
|
|
|
|
|