none
Integration Tests for WCF Service with MSMQ RRS feed

  • Question

  • Hi,

    We have a WCF service and hosted with private MSMQ endpoint. We written integration tests for WCF service. After completing each test, We are checking DB records for assert conditions. The problem we are facing is, When we run integration tests one by one then every thing is running. But If we run all tests at a times then 1 or 2 are failing out of 15 tests with inconsistency manner. 

    I understand that this issue is coming because of MSMQ delay to hit the service. Even I used thread.sleep before checking database, still we are facing the same issue.

    Could you please suggest any solution.

    Regards,

    Venkat.



    Wednesday, July 31, 2013 3:05 PM

Answers

  • Hi Munaga,

    My understanding is that you're performing some test on a MSMQ based WCF service. The service will write some data into database after operation call finishes. And you're looking for some reliable ways to programmtically check the database records after the operation call finishes, correct?

    As for the operation call test, if you start them together, are you using multi-threading or asynchronous operation invoking? Since your service will write some database records after the call finishes, it is possible that your main test code (for each operation call) use a loop to constantly check the database until a certain flag data field is filled. Or maybe we can consider adding a store-procedure at database side which can help detect whether a certain record is at finished or ready status (which can be called by the testing code to determine if it is ok to perform the database record checking).

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 1, 2013 5:07 AM
    Moderator
  • It is resolved. I am checking queue journal count for successful message delivery. We are using transnational queues. I followed below steps.

    1. Read message queue journal count.

    2. Call service.

    3. Read again message queue journal count. If message is not delivered successfully, then repeat step 3 for 2 or 3 times. Use Thread.Sleep(2000) time before repeating step. Still not success then make integration test fail by using Assert.Fail with proper message.

    Regards,

    Venkat.

    • Marked as answer by Munaga Venkat Saturday, September 14, 2013 4:28 AM
    Saturday, September 14, 2013 4:28 AM

All replies

  • Hi Munaga,

    My understanding is that you're performing some test on a MSMQ based WCF service. The service will write some data into database after operation call finishes. And you're looking for some reliable ways to programmtically check the database records after the operation call finishes, correct?

    As for the operation call test, if you start them together, are you using multi-threading or asynchronous operation invoking? Since your service will write some database records after the call finishes, it is possible that your main test code (for each operation call) use a loop to constantly check the database until a certain flag data field is filled. Or maybe we can consider adding a store-procedure at database side which can help detect whether a certain record is at finished or ready status (which can be called by the testing code to determine if it is ok to perform the database record checking).

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 1, 2013 5:07 AM
    Moderator
  • Thanks Steven for reply.

    Sorry for the late respond. Still it is an open issue for me.

    You understood the problem correctly. All operations are one way WCF operations, just fire & forget.

    I will check these steps.

    Regards,
    Venkat.


    Tuesday, September 3, 2013 11:10 PM
  • It is resolved. I am checking queue journal count for successful message delivery. We are using transnational queues. I followed below steps.

    1. Read message queue journal count.

    2. Call service.

    3. Read again message queue journal count. If message is not delivered successfully, then repeat step 3 for 2 or 3 times. Use Thread.Sleep(2000) time before repeating step. Still not success then make integration test fail by using Assert.Fail with proper message.

    Regards,

    Venkat.

    • Marked as answer by Munaga Venkat Saturday, September 14, 2013 4:28 AM
    Saturday, September 14, 2013 4:28 AM