Check if cynara terminates, when no data are sent 40/30740/3
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Mon, 24 Nov 2014 11:37:10 +0000 (12:37 +0100)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Mon, 8 Dec 2014 10:41:44 +0000 (11:41 +0100)
Test case tca12 covers bug found in cynara. Cynara terminates,
when connection is closed and no data were sent.

Change-Id: I0859cc9db1b252cb5d8ea786183d80334de8725a

tests/cynara-tests/test_cases_async.cpp

index 65cd4e6..fbb6079 100644 (file)
@@ -31,6 +31,7 @@
 #include <cynara-client-async.h>
 
 #include <cstdint>
+#include <unistd.h>
 
 using namespace CynaraTestClientAsync;
 using namespace CynaraTestAdmin;
@@ -406,6 +407,43 @@ void tca11_double_request_with_restart_func()
     client.process(CYNARA_API_SUCCESS, Client::IGNORE_TIMEOUT);
 }
 
+void tca12_multiple_connections_without_requests_func()
+{
+    std::string testNo("12");
+
+    cynara_check_id id;
+    RequestEntity callbackData = {RequestFunction(),
+                                  CYNARA_API_ACCESS_DENIED,
+                                  CYNARA_CALL_CAUSE_FINISH};
+
+    DBusAccess dbusAccess(CynaraTestConsts::SERVICE.c_str());
+    pid_t before = dbusAccess.getServicePid();
+    timeval beforeTimestamp = dbusAccess.getServiceStartTimestamp();
+
+    for (int i = 0; i < 10; ++i)
+    {
+        Client client;
+        client.createRequest({testNo}, id, callbackData);
+        client.assertStatus(READWRITE);
+    }
+
+//wait until cynara possibly restarts
+    sleep(3);
+
+    pid_t after = dbusAccess.getServicePid();
+    timeval afterTimestamp = dbusAccess.getServiceStartTimestamp();
+    RUNNER_ASSERT_MSG(after != 0,
+                         "cynara service not running. After = " << after << ".");
+    RUNNER_ASSERT_MSG(before == after
+                      && beforeTimestamp.tv_sec == afterTimestamp.tv_sec
+                      && beforeTimestamp.tv_usec == afterTimestamp.tv_usec,
+                         "cynara service was restarted during the test. Before pid / timestamp = "
+                             << before << " / " << beforeTimestamp.tv_sec << "."
+                             << beforeTimestamp.tv_usec << " and after pid / timestamp = "
+                             << after << " / " << afterTimestamp.tv_sec << "."
+                             << afterTimestamp.tv_usec);
+}
+
 RUNNER_TEST_GROUP_INIT(cynara_async_tests)
 
 RUN_CYNARA_TEST(tca01_initialize)
@@ -424,3 +462,4 @@ RUN_CYNARA_TEST(tca09_disconnect_and_cancel1)
 RUN_CYNARA_TEST(tca09_disconnect_and_cancel2)
 RUN_CYNARA_TEST(tca10_double_request)
 RUN_CYNARA_TEST(tca11_double_request_with_restart)
+RUN_CYNARA_TEST(tca12_multiple_connections_without_requests)