Re: [PATCH 1/1] UNITTEST: Middleware Subscription Failure


Damian Maguire
 

Running the tests in a loop in isolation doesn't display the same behaviour, nor does running the set of MiddlewareSubscriptionTests (run with --gtest_filter=MiddlewareSubscriptionTests.* --gtest_repeat=100), so I suspect the root cause is something not being cleaned up elsewhere in the full series of tests. I'll have to dig in a bit more to track down exactly where the problem is. This fix looks like the right thing to do for now anyway, and does allow the tests to pass correctly. 

There is an open question around some of these tests because in order to test the bridge calls we have to basically double call the same underlying subscription bridge create functions. Not sure how we can resolve this though, since the rest of the setup is required to provide the context for the bridge calls to operate. 

Looks good anyway, cheers for the fix Phil. 

D


On 24 January 2014 19:53, Philip Preston <philippreston@...> wrote:
Yeah - same here.  They seemed to fail every time with my build on Ubuntu, and failed more often than not on the Mac - only ever saw it pass about 1 in every 10 runs.  

On 24 Jan 2014, at 19:50, Frank Quinn <fquinn.ni@...> wrote:

Thanks Phil - it's an interesting one because for some reason, this test doesn't fail every time in our CI environment - it fails about half of the time... fix looks good to me. I recommend we merge it into next and hopefully see after a few days if it it solves this phantom failure!

Cheers,
Frank

Philip Preston <philippreston@...> wrote:
Currently UnitTestMamaMiddlewareC is failing two tests:

[  FAILED  ] MiddlewareSubscriptionTests.createInvalidSymbol
[  FAILED  ] MiddlewareSubscriptionTests.createInvalidQueue

Subscription Allocate is not being called prior to the create so the qpid bridge checks for null on the MamaSubscription and fails.

Fixed by moving all subscription allocations to Setup and deallocate in TearDown.  Tests are passing.  Checked on Linux.

[----------] Global test environment tear-down
[==========] 228 tests from 9 test cases ran. (385 ms total)
[  PASSED  ] 228 tests.

Signed off by: Philip Preston <philippreston@...>

---

diff --git a/mama/c_cpp/src/gunittest/c/middleware/middlewareSubscriptionTests.cpp b/mama/c_cpp/src/gunittest/c/middleware/middlewareSubscriptionTests.cpp
index a2ac06b..c48f68e 100644
--- a/mama/c_cpp/src/gunittest/c/middleware/middlewareSubscriptionTests.cpp
+++ b/mama/c_cpp/src/gunittest/c/middleware/middlewareSubscriptionTests.cpp
@@ -104,6 +104,8 @@ void MiddlewareSubscriptionTests::SetUp(void)
     mamaSource_setId(source, "SRC");
     mamaSource_setTransport(source, tport);
     mamaSource_setSymbolNamespace(source, "NASDAQ");
+    
+    mamaSubscription_allocate(&parent);
 
     callbacks.onCreate          = onCreate; 
     callbacks.onError           = onError; 
@@ -117,6 +119,7 @@ void MiddlewareSubscriptionTests::SetUp(void)
 void MiddlewareSubscriptionTests::TearDown(void)
 {
     mamaTransport_destroy (tport);
+    mamaSubscription_deallocate(parent);
 }
 
 static void onCreate (mamaSubscription subscription,
@@ -318,7 +321,6 @@ TEST_F (MiddlewareSubscriptionTests, createWildCardInvalidCallbacks)
 
 TEST_F (MiddlewareSubscriptionTests, mute)
 {
-    mamaSubscription_allocate(&parent);
     ASSERT_EQ(MAMA_STATUS_OK,
               mamaSubscription_create(parent, queue, &callbacks, source, sourceName, closure));
 
@@ -349,7 +351,6 @@ TEST_F (MiddlewareSubscriptionTests, destroyInvalid)
 TEST_F (MiddlewareSubscriptionTests, isValid)
 {
     int res = NULL;
-    mamaSubscription_allocate(&parent);
     ASSERT_EQ(MAMA_STATUS_OK,
               mamaSubscription_create(parent, queue, &callbacks, source, sourceName, closure));
 
@@ -386,7 +387,6 @@ TEST_F (MiddlewareSubscriptionTests, getPlatformError)
 {
     void* error = NOT_NULL;
     mama_status status = MAMA_STATUS_OK;
-    mamaSubscription_allocate(&parent);
     ASSERT_EQ(MAMA_STATUS_OK,
               mamaSubscription_create(parent, queue, &callbacks, source, sourceName, closure));
 
@@ -428,7 +428,6 @@ TEST_F (MiddlewareSubscriptionTests, getPlatformErrorInvalidSubBridge)
 TEST_F (MiddlewareSubscriptionTests, isTportDisconnected)
 {
     int res = NULL;
-    mamaSubscription_allocate(&parent);
     ASSERT_EQ(MAMA_STATUS_OK,
               mamaSubscription_create(parent, queue, &callbacks, source, sourceName, closure));
 
@@ -454,7 +453,6 @@ TEST_F (MiddlewareSubscriptionTests, setTopicClosure)
 {
     void* newClosure = NOT_NULL;
     mama_status status = MAMA_STATUS_OK;
-    mamaSubscription_allocate(&parent);
     ASSERT_EQ(MAMA_STATUS_OK,
               mamaSubscription_create(parent, queue, &callbacks, source, sourceName, closure));
 
@@ -489,7 +487,6 @@ TEST_F (MiddlewareSubscriptionTests, setTopicClosureInvalidSubBridge)
 
 TEST_F (MiddlewareSubscriptionTests, muteCurrentTopic)
 {
-    mamaSubscription_allocate(&parent);
     ASSERT_EQ(MAMA_STATUS_OK,
               mamaSubscription_create(parent, queue, &callbacks, source, sourceName, closure));
 






Openmama-dev mailing list
Openmama-dev@...
https://lists.openmama.org/mailman/listinfo/openmama-dev

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.


_______________________________________________
Openmama-dev mailing list
Openmama-dev@...
https://lists.openmama.org/mailman/listinfo/openmama-dev


Join Openmama-dev@lists.openmama.org to automatically receive all group messages.