In some bad thread scheduling situations, the API service request
in the testing thread may be executed before the corresponding
event being received on the MDS thread. This will lead to the
unexpected behavior of the service request and cause the failure
in this test case.

This patch helps avoid the above issue by waiting for the expected
event being received on MDS thread before invoking the testing
service request.
---
 src/mds/apitest/mdstipc_api.c  | 427 +++++++++++++++++++++++++++++------------
 src/mds/apitest/mdstipc_conf.c |   2 -
 2 files changed, 304 insertions(+), 125 deletions(-)

diff --git a/src/mds/apitest/mdstipc_api.c b/src/mds/apitest/mdstipc_api.c
index 090af99..4890a8f 100644
--- a/src/mds/apitest/mdstipc_api.c
+++ b/src/mds/apitest/mdstipc_api.c
@@ -27,11 +27,13 @@
 #include "base/ncs_main_papi.h"
 #include "mdstipc.h"
 #include "base/ncssysf_tmr.h"
+#include "base/osaf_time.h"
 
 #define MSG_SIZE MDS_DIRECT_BUF_MAXSIZE
 static MDS_CLIENT_MSG_FORMAT_VER gl_set_msg_fmt_ver;
 
 MDS_SVC_ID svc_ids[3] = {2006, 2007, 2008};
+const uint64_t kWaitTime = 10*1000; // Wait for 10 seconds timeout.
 
 pthread_mutex_t safe_printf_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t gl_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -1658,8 +1660,12 @@ void tet_svc_subscr_VDEST_10()
        SaUint32T rc;
        int id;
        MDS_SVC_ID svcids[] = {600, 700};
-       printf(
-           "\nTest Case 10: Cross check whether i_rem_svc_pvt_ver returned in 
service event callback, matches the service private sub-part version of the 
remote service (subscribee)\n");
+       struct timespec timeout_time;
+
+       printf("\nTest Case 10: Cross check whether i_rem_svc_pvt_ver returned "
+                       "in service event callback, matches the service "
+                       "private sub-part version of the remote service "
+                       "(subscribed)\n");
        // Creating a N-way VDEST with id =1001
        rc = create_vdest(NCS_VDEST_TYPE_N_WAY_ROUND_ROBIN, 1001);
        if (rc != NCSCC_RC_SUCCESS) {
@@ -1711,39 +1717,61 @@ void tet_svc_subscr_VDEST_10()
                FAIL = 1;
        }
        // Retrieving the events
-       if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
-                                SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
-               printf("\nRetrieve servive 500 Fail\n");
-               FAIL = 1;
-       }
+       osaf_set_millis_timeout(kWaitTime, &timeout_time);
+       while (!osaf_is_timeout(&timeout_time)) {
+               osaf_nanosleep(&kHundredMilliseconds);
+               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
+                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+                       printf("\nRetrieve servive 500 Fail\n");
+                       FAIL = 1;
+                       break;
+               }
 
-       // Verifying for the versions for UP event
-       if ((tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 1,
-                               NCSMDS_UP)) != 1 ||
-           (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 700, 2,
-                               NCSMDS_UP) != 1)) {
-               printf("\nFail to verifying for the versions for UP event\n");
+               // Verify the MDS svc private sub part ver of UP events.
+               if ((tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 1,
+                               NCSMDS_UP)) == 1 &&
+                               (tet_verify_version(gl_tet_adest.mds_pwe1_hdl,
+                                               500, 700, 2, NCSMDS_UP) == 1)) {
+                       printf("\nRetrieved UP events");
+                       break;
+               }
+       }
+       // The NCSMDS_UP events were not received within reasonable time.
+       if (osaf_is_timeout(&timeout_time)) {
+               printf("\nFail to verify svc_pvt_ver of UP events\n");
                FAIL = 1;
        }
+
        // Changing the role of vdest role to quiesced
        if (vdest_change_role(1001, V_DEST_RL_QUIESCED) != NCSCC_RC_SUCCESS) {
                printf("\nFail to change the role of vdest role to quiesced\n");
                FAIL = 1;
        }
        // Retrieving the events
-       if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
-                                SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
-               printf("\nFail to retreive events\n");
-               FAIL = 1;
+       osaf_set_millis_timeout(kWaitTime, &timeout_time);
+       while (!osaf_is_timeout(&timeout_time)) {
+               osaf_nanosleep(&kHundredMilliseconds);
+               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
+                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+                       printf("\nFail to retreive events\n");
+                       FAIL = 1;
+                       break;
+               }
+               // Verify the MDS svc private sub part ver of NO ACTIVE events.
+               if ((tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 1,
+                                       NCSMDS_NO_ACTIVE)) == 1 &&
+                   (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 700, 2,
+                                       NCSMDS_NO_ACTIVE) == 1)) {
+                       printf("\nRetrieved NO_ACTIVE events");
+                       break;
+               }
        }
-       if ((tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 1,
-                               NCSMDS_NO_ACTIVE)) != 1 ||
-           (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 700, 2,
-                               NCSMDS_NO_ACTIVE) != 1)) {
-               printf(
-                   "\nFail to verifying for the versions for NO_ACTIVE 
event\n");
+       // The NO_ACTIVE events were not received within reasonable time.
+       if (osaf_is_timeout(&timeout_time)) {
+               printf("\nFail to verify svc_pvt_ver of NO_ACTIVE events\n");
                FAIL = 1;
        }
+
        // Changing the role of vdest role to standby
        if (vdest_change_role(1001, V_DEST_RL_STANDBY) != NCSCC_RC_SUCCESS) {
                printf("\nFail to change the role of vdest role to standby\n");
@@ -1939,6 +1967,8 @@ void tet_svc_subscr_VDEST_12()
        SaUint32T rc;
        int i;
        MDS_SVC_ID svc_id_sixhd[] = {600};
+       struct timespec timeout_time;
+
        // Creating a N-way VDEST with id =1001
        rc = create_vdest(NCS_VDEST_TYPE_N_WAY_ROUND_ROBIN, 1001);
        if (rc != NCSCC_RC_SUCCESS) {
@@ -1946,8 +1976,9 @@ void tet_svc_subscr_VDEST_12()
                FAIL = 1;
        }
 
-       printf(
-           "\nTest case 12: In the NO_ACTIVE event notification, the remote 
service subpart version is set to the last active instance.s remote-service 
sub-part version\n");
+       printf("\nTest case 12: In the NO_ACTIVE event notification, the "
+                       "remote service subpart version is set to the last "
+                       "active instance.s remote-service sub-part version\n");
        printf("\nGetting an ADEST handle\n");
        if (adest_get_handle() != NCSCC_RC_SUCCESS) {
                printf("\nFail\n");
@@ -1995,20 +2026,27 @@ void tet_svc_subscr_VDEST_12()
                printf("\nFail\n");
                FAIL = 1;
        }
-
        printf("\nAction: Retrieving the events\n");
-       if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
-                                SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
-               printf("Retrieve Fail\n");
-               FAIL = 1;
-       }
-
-       printf("\nAction: Verifying for the versions for UP event\n");
-       if (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 1,
-                              NCSMDS_UP) != 1)
+       osaf_set_millis_timeout(kWaitTime, &timeout_time);
+       while (!osaf_is_timeout(&timeout_time)) {
+               osaf_nanosleep(&kHundredMilliseconds);
+               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
+                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+                       printf("Retrieve Fail\n");
+                       FAIL = 1;
+                       break;
+               }
 
-       {
-               printf("\nFail\n");
+               // Verify the MDS svc private sub part version of UP event
+               if (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 1,
+                               NCSMDS_UP) == 1) {
+                       printf("\nRetrieved UP event");
+                       break;
+               }
+       }
+       // The UP event were not received within reasonable time.
+       if (osaf_is_timeout(&timeout_time)) {
+               printf("\nFail to verify svc_pvt_ver of UP event\n");
                FAIL = 1;
        }
 
@@ -2029,19 +2067,26 @@ void tet_svc_subscr_VDEST_12()
                printf("\nFail\n");
                FAIL = 1;
        }
-
-       sleep(1);
-       if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
-                                SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
-               printf("Retrieve Fail\n");
-               FAIL = 1;
+       printf("\nAction: Retrieving the events\n");
+       osaf_set_millis_timeout(kWaitTime, &timeout_time);
+       while (!osaf_is_timeout(&timeout_time)) {
+               osaf_nanosleep(&kHundredMilliseconds);
+               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
+                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+                       printf("Retrieve Fail\n");
+                       FAIL = 1;
+                       break;
+               }
+               // Verify the MDS svc private sub part ver of NO ACTIVE event
+               if (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 2,
+                               NCSMDS_NO_ACTIVE) == 1) {
+                       printf("\nRetrieved NO ACTIVE event");
+                       break;
+               }
        }
-       printf("\nAction: Verifying for the versions for NO ACTIVE event\n");
-       if (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 2,
-                              NCSMDS_NO_ACTIVE) != 1)
-
-       {
-               printf("\nFail\n");
+       // The NCSMDS_NO_ACTIVE event were not received within reasonable time.
+       if (osaf_is_timeout(&timeout_time)) {
+               printf("\nFail to verify svc_pvt_ver of NO_ACTIVE event\n");
                FAIL = 1;
        }
 
@@ -2147,9 +2192,9 @@ void tet_svc_subscr_ADEST_1()
 {
        int FAIL = 0;
        MDS_SVC_ID svcids[] = {600, 700};
-
-       printf(
-           "Test Case 1: 500 Subscription to:600,700 where Install scope = 
Subscription scope\n");
+       struct timespec timeout_time;
+       printf("Test Case 1: 500 Subscription to:600,700 where Install "
+                       "scope = Subscription scope\n");
        if (prepare_ADEST_tc() == false)
                FAIL = 1;
 
@@ -2161,13 +2206,22 @@ void tet_svc_subscr_ADEST_1()
                FAIL = 1;
        } else {
                printf("\nAction: Retrieve only ONE event\n");
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
-                                        SA_DISPATCH_ONE) != NCSCC_RC_SUCCESS) {
-                       printf("Fail, retrieve ONE\n");
+               osaf_set_millis_timeout(kWaitTime, &timeout_time);
+               while (!osaf_is_timeout(&timeout_time)) {
+                       osaf_nanosleep(&kHundredMilliseconds);
+                       if (mds_service_retrieve(
+                                       gl_tet_adest.mds_pwe1_hdl, 500,
+                                       SA_DISPATCH_ONE) == NCSCC_RC_SUCCESS) {
+                               printf("\nSuccess\n");
+                               break;
+                       }
+               }
+               // Fail to retrieve ONE.
+               if (osaf_is_timeout(&timeout_time)) {
+                       printf("\nFail to retrieve ONE within reasonable "
+                                       "time\n");
                        FAIL = 1;
-               } else
-                       printf("\nSuccess\n");
-
+               }
                printf("\nAction: Retrieve ALL event\n");
                if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
                                         SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
@@ -2467,12 +2521,14 @@ void tet_svc_subscr_ADEST_9()
        MDS_SVC_ID one[] = {600};
        MDS_SVC_ID two[] = {700};
        MDS_SVC_ID svcids[] = {600, 700};
+       struct timespec timeout_time;
 
        if (prepare_ADEST_tc() == false)
                FAIL = 1;
 
-       printf(
-           "\nTest Case 9: 500 Subscription to:600,700 in two seperate 
Subscription calls but Cancels both in a single cancellation call\n");
+       printf("\nTest Case 9: 500 Subscription to:600,700 in two seperate "
+                       "Subscription calls but Cancels both in a single "
+                       "cancellation call\n");
        printf("\nAction: Subscribe 500 to 600\n");
        if (mds_service_subscribe(gl_tet_adest.mds_pwe1_hdl, 500,
                                  NCSMDS_SCOPE_INTRACHASSIS, 1,
@@ -2488,15 +2544,37 @@ void tet_svc_subscr_ADEST_9()
                FAIL = 1;
        } else {
                printf("\nAction: Retreive three times, third shall fail\n");
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
-                                        SA_DISPATCH_ONE) != NCSCC_RC_SUCCESS) {
-                       printf("\nFail mds_service_retrieve\n");
+               osaf_set_millis_timeout(kWaitTime, &timeout_time);
+               while (!osaf_is_timeout(&timeout_time)) {
+                       osaf_nanosleep(&kHundredMilliseconds);
+                       if (mds_service_retrieve(
+                                       gl_tet_adest.mds_pwe1_hdl, 500,
+                                       SA_DISPATCH_ONE) == NCSCC_RC_SUCCESS) {
+                               printf("\nSuccess\n");
+                               break;
+                       }
+               }
+               // Fail to retrieve ONE (first) within reasonable time.
+               if (osaf_is_timeout(&timeout_time)) {
+                       printf("\nFail to retrieve ONE (first) within "
+                                       "reasonable time.\n");
                        FAIL = 1;
                }
 
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
-                                        SA_DISPATCH_ONE) != NCSCC_RC_SUCCESS) {
-                       printf("\nFail mds_service_retrieve\n");
+               osaf_set_millis_timeout(kWaitTime, &timeout_time);
+               while (!osaf_is_timeout(&timeout_time)) {
+                       osaf_nanosleep(&kHundredMilliseconds);
+                       if (mds_service_retrieve(
+                                       gl_tet_adest.mds_pwe1_hdl, 500,
+                                       SA_DISPATCH_ONE) == NCSCC_RC_SUCCESS) {
+                               printf("\nSuccess\n");
+                               break;
+                       }
+               }
+               // Fail to retrieve ONE (second) within reasonable time.
+               if (osaf_is_timeout(&timeout_time)) {
+                       printf("\nFail to retrieve ONE (second) within "
+                                       "reasonable time.\n");
                        FAIL = 1;
                }
 
@@ -6053,6 +6131,60 @@ void tet_adest_all_rcvr_thread()
        free(mesg);
 }
 
+
+/*****************************************************************************
+
+  Function NAME: tet_mds_retrieve_for_change
+
+  DESCRIPTION: This routine calls mds_service_retrieve function until
+  successfully retrieving the given service subscription state change event.
+  It returns NCSCC_RC_FAILURE if the expected event cannot be retrieved within
+  predefined kWaitTime timeout period or when the mds_service_retrieve call
+  results in NCSCC_RC_FAILURE.
+
+  ARGUMENTS:
+    mds_hdl:       MDS_HDL related to the subscribing service.
+    your_scv_id:   MDS_SVC_ID of the subscribing service.
+    dispatchFlags: SaDispatchFlagsT
+    req_svc_id:    NCSMDS_SVC_ID of the subscribed service.
+    svc_pvt_ver:   MDS svc private sub part version of the subscribed service.
+    change:        Expected NCSMDS_CHG of the subscribed service.
+
+  RETURNS:  1 - NCSCC_RC_SUCCESS
+           2 - NCSCC_RC_FAILURE
+
+*****************************************************************************/
+
+uint32_t tet_mds_retrieve_for_change(MDS_HDL mds_hdl, MDS_SVC_ID your_scv_id,
+               SaDispatchFlagsT dispatchFlags, NCSMDS_SVC_ID req_svc_id,
+               MDS_SVC_PVT_SUB_PART_VER svc_pvt_ver, NCSMDS_CHG change)
+{
+       uint32_t rc = NCSCC_RC_FAILURE;
+       struct timespec timeout_time;
+
+       osaf_set_millis_timeout(kWaitTime, &timeout_time);
+       while (!osaf_is_timeout(&timeout_time)) {
+               osaf_nanosleep(&kHundredMilliseconds);
+               if (mds_service_retrieve(mds_hdl, your_scv_id,
+                               dispatchFlags) != NCSCC_RC_SUCCESS) {
+                       printf("\nFail mds_service_retrieve\n");
+                       break;
+               }
+               // Verify if the correct service event was retrieved.
+               if (tet_verify_version(mds_hdl, your_scv_id, req_svc_id,
+                               svc_pvt_ver, change) == 1) {
+                       rc = NCSCC_RC_SUCCESS;
+                       break;
+               }
+       }
+       // The expected event was not retrieved within reasonable time.
+       if (osaf_is_timeout(&timeout_time)) {
+               printf("\nFail to retrieve the expected event\n");
+       }
+
+       return rc;
+}
+
 void tet_send_all_tp_1()
 {
        int FAIL = 0;
@@ -6069,8 +6201,9 @@ void tet_send_all_tp_1()
 
        /*--------------------------------------------------------------------*/
 
-       printf(
-           "\nTest Case 1: Sender service installed with 
i_fail_no_active_sends = true and there is no-active instance of the receiver 
service\n");
+       printf("\nTest Case 1: Sender service installed with "
+                       "i_fail_no_active_sends = true and there is "
+                       "no-active instance of the receiver service\n");
 
        printf("\tSetting up the setup\n");
        if (tet_initialise_setup(true)) {
@@ -6085,17 +6218,27 @@ void tet_send_all_tp_1()
                FAIL = 1;
        }
 
+       if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                       NCSMDS_UP) != NCSCC_RC_SUCCESS) {
+               printf("\nFail\n");
+               FAIL = 1;
+       }
+
        if (vdest_change_role(200, V_DEST_RL_STANDBY) != NCSCC_RC_SUCCESS) {
                printf("\nFail\n");
                FAIL = 1;
        }
 
-       if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+       if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                       NCSMDS_NO_ACTIVE) != NCSCC_RC_SUCCESS) {
                printf("\nFail\n");
                FAIL = 1;
        }
+
        /*SND*/
        printf("\t Sending the message to no active instance\n");
        if ((mds_just_send(
@@ -6132,9 +6275,11 @@ void tet_send_all_tp_1()
                printf("\nFail\n");
                FAIL = 1;
        }
-       if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+
+       if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                       NCSMDS_NEW_ACTIVE) != NCSCC_RC_SUCCESS) {
                printf("\nFail\n");
                FAIL = 1;
        }
@@ -6239,8 +6384,9 @@ void tet_send_all_tp_2()
 
        /*--------------------------------------------------------------------*/
 
-       printf(
-           "\nTest Case 2: Sender service installed with 
i_fail_no_active_sends = false and there is no-active instance of the receiver 
service\n");
+       printf("\nTest Case 2: Sender service installed with "
+                       "i_fail_no_active_sends = false and there is "
+                       "no-active instance of the receiver service\n");
 
        if (tet_initialise_setup(false)) {
                printf("\n Setup Initialisation has Failed \n");
@@ -6253,17 +6399,27 @@ void tet_send_all_tp_2()
                FAIL = 1;
        }
 
+       if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                       NCSMDS_UP) != NCSCC_RC_SUCCESS) {
+               printf("\nFail\n");
+               FAIL = 1;
+       }
+
        if (vdest_change_role(200, V_DEST_RL_STANDBY) != NCSCC_RC_SUCCESS) {
                printf("\nFail\n");
                FAIL = 1;
        }
 
-       if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+       if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                       NCSMDS_NO_ACTIVE) != NCSCC_RC_SUCCESS) {
                printf("\nFail\n");
                FAIL = 1;
        }
+
        printf("\n Sending the message to no active instance\n");
        if ((mds_just_send(gl_tet_adest.mds_pwe1_hdl,
                           NCSMDS_SVC_ID_EXTERNAL_MIN,
@@ -6279,25 +6435,29 @@ void tet_send_all_tp_2()
                printf("\nFail\n");
                FAIL = 1;
        }
-       if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
-               printf("\nFail mds_service_retrieve\n");
+
+       if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                       NCSMDS_NEW_ACTIVE) != NCSCC_RC_SUCCESS) {
+               printf("\nFail\n");
                FAIL = 1;
        }
+
        /*SNDACK*/
        printf("\nChange role to standby\n");
        if (vdest_change_role(200, V_DEST_RL_STANDBY) != NCSCC_RC_SUCCESS) {
                printf("\nFail\n");
                FAIL = 1;
        }
-       if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+
+       if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                       NCSMDS_NO_ACTIVE) != NCSCC_RC_SUCCESS) {
                printf("\nFail\n");
                FAIL = 1;
        }
-
        else
                printf("\nSuccess\n");
        /*Create thread to change role*/
@@ -6334,15 +6494,16 @@ void tet_send_all_tp_2()
                printf("\nFail\n");
                FAIL = 1;
        }
-       if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+       if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                       NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                       NCSMDS_NO_ACTIVE) != NCSCC_RC_SUCCESS) {
                printf("\nFail\n");
                FAIL = 1;
        }
-
        else
                printf("\nSuccess\n");
+
        if (tet_create_task((NCS_OS_CB)tet_vdest_all_rcvr_thread,
                            gl_tet_vdest[1].svc[1].task.t_handle) ==
            NCSCC_RC_SUCCESS) {
@@ -9088,28 +9249,34 @@ void tet_direct_send_all_tp_5()
                        printf("\nFail");
                        FAIL = 1;
                }
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                        NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+
+               if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                               NCSMDS_UP) != NCSCC_RC_SUCCESS) {
                        printf("\nFail");
                        FAIL = 1;
                }
 
                gl_set_msg_fmt_ver = 1;
-               printf(
-                   "\nTest Case 5 : Direct send when Sender service installed 
with i_fail_no_active_sends = false and there is no-active instance of the 
receiver service\n");
+               printf("\nTest Case 5 : Direct send when Sender service "
+                               "installed with i_fail_no_active_sends = false "
+                               "and there is no-active instance of the "
+                               "receiver service\n");
                if (vdest_change_role(200, V_DEST_RL_STANDBY) !=
                    NCSCC_RC_SUCCESS) {
                        printf("\nFail\n");
                        FAIL = 1;
                }
 
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                        NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+               if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                               NCSMDS_NO_ACTIVE) != NCSCC_RC_SUCCESS) {
                        printf("\nFail\n");
                        FAIL = 1;
                }
+
                printf("\n Sending the message to no active instance\n");
                if (mds_direct_send_message(
                        gl_tet_adest.mds_pwe1_hdl, NCSMDS_SVC_ID_EXTERNAL_MIN,
@@ -9126,12 +9293,15 @@ void tet_direct_send_all_tp_5()
                        printf("\nFail\n");
                        FAIL = 1;
                }
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                        NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+
+               if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                               NCSMDS_NEW_ACTIVE) != NCSCC_RC_SUCCESS) {
                        printf("\nFail\n");
                        FAIL = 1;
                }
+
                /*SNDACK*/
                printf("\nChange role to standby\n");
                if (vdest_change_role(200, V_DEST_RL_STANDBY) !=
@@ -9139,9 +9309,11 @@ void tet_direct_send_all_tp_5()
                        printf("\nFail\n");
                        FAIL = 1;
                }
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                        NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+
+               if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                               NCSMDS_NO_ACTIVE) != NCSCC_RC_SUCCESS) {
                        printf("\nFail\n");
                        FAIL = 1;
                }
@@ -9184,13 +9356,14 @@ void tet_direct_send_all_tp_5()
                        printf("\nFail\n");
                        FAIL = 1;
                }
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                        NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+
+               if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                               NCSMDS_NO_ACTIVE) != NCSCC_RC_SUCCESS) {
                        printf("\nFail\n");
                        FAIL = 1;
                }
-
                else
                        printf("\nSuccess\n");
 
@@ -9337,16 +9510,19 @@ void tet_direct_send_all_tp_6()
                        printf("\nFail");
                        FAIL = 1;
                }
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                        NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+               if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                               NCSMDS_UP) != NCSCC_RC_SUCCESS) {
                        printf("\nFail");
                        FAIL = 1;
                }
 
                gl_set_msg_fmt_ver = 1;
-               printf(
-                   "\nTest Case 6: Direct send when Sender service installed 
with i_fail_no_active_sends = true and there is no-active instance of the 
receiver service\n");
+               printf("\nTest Case 6: Direct send when Sender service "
+                               "installed with i_fail_no_active_sends = true "
+                               "and there is no-active instance of the "
+                               "receiver service\n");
                if (mds_service_cancel_subscription(
                        gl_tet_adest.mds_pwe1_hdl, NCSMDS_SVC_ID_EXTERNAL_MIN,
                        1, svcids) != NCSCC_RC_SUCCESS) {
@@ -9369,9 +9545,11 @@ void tet_direct_send_all_tp_6()
                        printf("\nFail\n");
                        FAIL = 1;
                }
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                        NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+
+               if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                               NCSMDS_UP) != NCSCC_RC_SUCCESS) {
                        printf("\nFail\n");
                        FAIL = 1;
                }
@@ -9382,9 +9560,10 @@ void tet_direct_send_all_tp_6()
                        FAIL = 1;
                }
 
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                        NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+               if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                               NCSMDS_NO_ACTIVE) != NCSCC_RC_SUCCESS) {
                        printf("\nFail\n");
                        FAIL = 1;
                }
@@ -9440,9 +9619,11 @@ void tet_direct_send_all_tp_6()
                        printf("\nFail\n");
                        FAIL = 1;
                }
-               if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
-                                        NCSMDS_SVC_ID_EXTERNAL_MIN,
-                                        SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) {
+
+               if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ALL,
+                               NCSMDS_SVC_ID_EXTERNAL_MIN, 1,
+                               NCSMDS_NEW_ACTIVE) != NCSCC_RC_SUCCESS) {
                        printf("\nFail\n");
                        FAIL = 1;
                }
diff --git a/src/mds/apitest/mdstipc_conf.c b/src/mds/apitest/mdstipc_conf.c
index 61bf27f..eb22f0a 100644
--- a/src/mds/apitest/mdstipc_conf.c
+++ b/src/mds/apitest/mdstipc_conf.c
@@ -1740,8 +1740,6 @@ uint32_t mds_service_retrieve(MDS_HDL mds_hdl, MDS_SVC_ID 
svc_id,
        }
 
        if (ncsmds_api(&svc_to_mds_info) == NCSCC_RC_SUCCESS) {
-               printf("\n MDS RETRIEVE is SUCCESSFULL");
-
                return NCSCC_RC_SUCCESS;
        } else {
                printf("\nRequest to ncsmds_api: MDS RETRIEVE has FAILED\n");
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to