Verify the service events before and after conflict. --- src/mds/apitest/mdstipc_api.c | 481 ++++++++++++++++++++++++++++++++++ 1 file changed, 481 insertions(+)
diff --git a/src/mds/apitest/mdstipc_api.c b/src/mds/apitest/mdstipc_api.c index 030a638a3..b2ef3465c 100644 --- a/src/mds/apitest/mdstipc_api.c +++ b/src/mds/apitest/mdstipc_api.c @@ -2107,6 +2107,481 @@ void tet_svc_subscr_VDEST_12() test_validate(FAIL, 0); } +void tet_svc_subscr_VDEST_13() { + int FAIL = 0; + SaUint32T rc; + MDS_SVC_ID svc_id_sixhd[] = {600}; + + mds_shutdown(); + pid_t pid = fork(); + if (pid < 0) { + printf("\nFailed to fork process\n"); + FAIL = 1; + test_validate(FAIL, 0); + } else if (pid > 0) { + // Parent process + mds_startup(); + printf("\nTest case 13: conflict mxn active vdests\n"); + printf("\nGet an adest handle\n"); + if (adest_get_handle() != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + // Create a vdest with id = 1001 + rc = create_vdest(NCS_VDEST_TYPE_MxN, 1001); + if (rc != NCSCC_RC_SUCCESS) { + printf("\nFailed to create a vdest with id =1001\n"); + FAIL = 1; + } + + printf("\nAction: Install the service 600\n"); + if (mds_service_install(gl_tet_vdest[0].mds_pwe1_hdl, 600, 1, + NCSMDS_SCOPE_INTRACHASSIS, true, + false) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + printf("\nAction: Change the role of vdest 1001 to active\n"); + if (vdest_change_role(1001, V_DEST_RL_ACTIVE) + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Install the service 500\n"); + if (mds_service_install(gl_tet_adest.mds_pwe1_hdl, 500, 1, + NCSMDS_SCOPE_INTRACHASSIS, true, + false) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Subscribe for the services\n"); + if (mds_service_subscribe(gl_tet_adest.mds_pwe1_hdl, 500, + NCSMDS_SCOPE_INTRACHASSIS, 1, + svc_id_sixhd) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Retrieve the event\n"); + if (wait_adest_sel_obj(500, 10)) { + printf("\nFail\n"); + FAIL = 1; + } + if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500, + SA_DISPATCH_ONE) != NCSCC_RC_SUCCESS) { + printf("\nRetrieve fail\n"); + FAIL = 1; + } + + printf("\nAction: Verify for the version for UP event\n"); + if (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 1, + NCSMDS_UP) != 1) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Sleep to wait for the service in the child" + " process to change role to active\n"); + sleep(5); + + printf("\nAction: Uninstall 600 in vdest 1001\n"); + if (mds_service_uninstall(gl_tet_vdest[0].mds_pwe1_hdl, 600) + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Retrieve the event\n"); + if (wait_adest_sel_obj(500, 10)) { + printf("\nFail\n"); + FAIL = 1; + } + if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500, + SA_DISPATCH_ONE) != NCSCC_RC_SUCCESS) { + printf("\nRetrieve fail\n"); + FAIL = 1; + } + + printf("\nAction: Verify for the versions for NO_ACTIVE" + " event\n"); + if (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 1, + NCSMDS_NO_ACTIVE) != 1) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Retrieve the event\n"); + if (wait_adest_sel_obj(500, 10)) { + printf("\nFail\n"); + FAIL = 1; + } + if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500, + SA_DISPATCH_ONE) != NCSCC_RC_SUCCESS) { + printf("\nRetrieve fail\n"); + FAIL = 1; + } + + printf("\nAction: Verify for the versions for NEW_ACTIVE" + " event\n"); + if (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 1, + NCSMDS_NEW_ACTIVE) != 1) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Cancel the subscription\n"); + if (mds_service_cancel_subscription( + gl_tet_adest.mds_pwe1_hdl, 500, 1, + svc_id_sixhd) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Uninstall the service 500\n"); + if (mds_service_uninstall(gl_tet_adest.mds_pwe1_hdl, 500) + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + // Destroy a vdest with id = 1001 + printf("\nAction: Destroy the vdest 1001\n"); + rc = destroy_vdest(1001); + if (rc != NCSCC_RC_SUCCESS) { + printf("\nFail to destroy a vdest with id = 1001\n"); + FAIL = 1; + } + + test_validate(FAIL, 0); + } else { + // Child process + MDS_SVC_ID svc_id_fivehd[] = {500}; + mds_startup(); + printf("\nChild: Get an adest handle\n"); + if (adest_get_handle() != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Create a vdest with id =1001\n"); + if (create_vdest(NCS_VDEST_TYPE_MxN, 1001) != + NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Install the service\n"); + if (mds_service_install(gl_tet_vdest[0].mds_pwe1_hdl, 600, 1, + NCSMDS_SCOPE_INTRACHASSIS, true, + false) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Subscribe for the services\n"); + if (mds_service_subscribe(gl_tet_vdest[0].mds_pwe1_hdl, 600, + NCSMDS_SCOPE_INTRACHASSIS, 1, + svc_id_fivehd) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Retrieve the event\n"); + if (wait_vdest_sel_obj(&gl_tet_vdest[0], 600, 10)) { + printf("\nFail\n"); + FAIL = 1; + } + if (mds_service_retrieve( + gl_tet_vdest[0].mds_pwe1_hdl, 600, + SA_DISPATCH_ONE) != NCSCC_RC_SUCCESS) { + printf("\nRetrieve fail\n"); + FAIL = 1; + } + + printf("\nChild: Verify for the versions for UP event\n"); + if (tet_verify_version(gl_tet_vdest[0].mds_pwe1_hdl, 600, 500, + 1, NCSMDS_UP) != 1) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Sleep to wait for up event of other vdest\n"); + sleep(1); + + printf("\nChild: Change the role of vdest 1001 to active\n"); + if (vdest_change_role(1001, V_DEST_RL_ACTIVE) + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Retrieve the events\n"); + if (wait_vdest_sel_obj(&gl_tet_vdest[0], 600, 10)) { + printf("\nFail\n"); + FAIL = 1; + } + if (mds_service_retrieve(gl_tet_vdest[0].mds_pwe1_hdl, 600, + SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) { + printf("\nRetrieve fail\n"); + FAIL = 1; + } + + printf("\nChild: Verify for the versions for DOWN event\n"); + if (tet_verify_version(gl_tet_vdest[0].mds_pwe1_hdl, 600, 500, + 1, NCSMDS_DOWN) != 1) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Cancel the subscription\n"); + if (mds_service_cancel_subscription( + gl_tet_vdest[0].mds_pwe1_hdl, 600, 1, + svc_id_fivehd) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Uninstall the service\n"); + if (mds_service_uninstall(gl_tet_vdest[0].mds_pwe1_hdl, 600) + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Destroy the vdest 1001\n"); + if (destroy_vdest(1001) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + test_validate(FAIL, 0); + } +} + +void tet_svc_subscr_VDEST_14() { + int FAIL = 0; + SaUint32T rc; + MDS_SVC_ID svc_id_sixhd[] = {600}; + + mds_shutdown(); + pid_t pid = fork(); + if (pid < 0) { + printf("\nFailed to fork process\n"); + FAIL = 1; + test_validate(FAIL, 0); + } else if (pid > 0) { + // Parent process + mds_startup(); + printf("\nTest case 14: conflict nway active vdests\n"); + printf("\nGet an adest handle\n"); + if (adest_get_handle() != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + // Creating a vdest with id = 1001 + rc = create_vdest(NCS_VDEST_TYPE_N_WAY_ROUND_ROBIN, 1001); + if (rc != NCSCC_RC_SUCCESS) { + printf("\nFailed to create a vdest with id =" + " 1001\n"); + FAIL = 1; + } + + printf("\nAction: Install the service 600\n"); + if (mds_service_install(gl_tet_vdest[0].mds_pwe1_hdl, 600, 1, + NCSMDS_SCOPE_INTRACHASSIS, true, + false) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Change the role of vdest 1001 to active\n"); + if (vdest_change_role(1001, V_DEST_RL_ACTIVE) + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Install the service 500\n"); + if (mds_service_install(gl_tet_adest.mds_pwe1_hdl, 500, 1, + NCSMDS_SCOPE_INTRACHASSIS, true, + false) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Subscribe for the services\n"); + if (mds_service_subscribe(gl_tet_adest.mds_pwe1_hdl, 500, + NCSMDS_SCOPE_INTRACHASSIS, 1, + svc_id_sixhd) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Retrieve the event\n"); + if (wait_adest_sel_obj(500, 10)) { + printf("\nFail\n"); + FAIL = 1; + } + if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500, + SA_DISPATCH_ONE) != NCSCC_RC_SUCCESS) { + printf("\nRetrieve fail\n"); + FAIL = 1; + } + + printf("\nAction: Verify for the versions for UP event\n"); + if (tet_verify_version(gl_tet_adest.mds_pwe1_hdl, 500, 600, 1, + NCSMDS_UP) != 1) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Sleep to wait for the service in the child" + " process to change role to active\n"); + sleep(5); + + printf("\nAction: Uninstall 600 in vdest 1001\n"); + if (mds_service_uninstall(gl_tet_vdest[0].mds_pwe1_hdl, 600) + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Sleep to wait for changing active vdest\n"); + sleep(1); + + printf("\nAction: Cancel the subscription\n"); + if (mds_service_cancel_subscription( + gl_tet_adest.mds_pwe1_hdl, 500, 1, + svc_id_sixhd) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nAction: Uninstall the service 500\n"); + if (mds_service_uninstall(gl_tet_adest.mds_pwe1_hdl, 500) != + NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + // Destroy a vdest with id = 1001 + printf("\nAction: Destroy the vdest 1001\n"); + rc = destroy_vdest(1001); + if (rc != NCSCC_RC_SUCCESS) { + printf("\nFail to destroy a vdest with id = 1001\n"); + FAIL = 1; + } + + test_validate(FAIL, 0); + } else { + // Child process + MDS_SVC_ID svc_id_fivehd[] = {500}; + mds_startup(); + printf("\nChild: Get an adest handle\n"); + if (adest_get_handle() != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Create a nway vdest with id = 1001\n"); + if (create_vdest(NCS_VDEST_TYPE_N_WAY_ROUND_ROBIN, 1001) != + NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Install the service\n"); + if (mds_service_install(gl_tet_vdest[0].mds_pwe1_hdl, 600, 1, + NCSMDS_SCOPE_INTRACHASSIS, true, + false) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Subscribe for the services\n"); + if (mds_service_subscribe(gl_tet_vdest[0].mds_pwe1_hdl, 600, + NCSMDS_SCOPE_INTRACHASSIS, 1, + svc_id_fivehd) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Retrieve the events\n"); + if (wait_vdest_sel_obj(&gl_tet_vdest[0], 600, 10)) { + printf("\nFail\n"); + FAIL = 1; + } + if (mds_service_retrieve( + gl_tet_vdest[0].mds_pwe1_hdl, 600, + SA_DISPATCH_ONE) != NCSCC_RC_SUCCESS) { + printf("\nRetrieve fail\n"); + FAIL = 1; + } + + printf("\nChild: Verify for the versions for UP event\n"); + if (tet_verify_version(gl_tet_vdest[0].mds_pwe1_hdl, 600, 500, + 1, NCSMDS_UP) != 1) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Sleep to wait for up event of other vdest\n"); + sleep(1); + + printf("\nChild: Change the role of vdest 1001 to active\n"); + if (vdest_change_role(1001, V_DEST_RL_ACTIVE) + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Retrieve the events\n"); + if (wait_vdest_sel_obj(&gl_tet_vdest[0], 600, 10)) { + printf("\nFail\n"); + FAIL = 1; + } + if (mds_service_retrieve(gl_tet_vdest[0].mds_pwe1_hdl, 600, + SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS) { + printf("\nRetrieve fail\n"); + FAIL = 1; + } + + printf("\nChild: Verify for the versions for DOWN event\n"); + if (tet_verify_version(gl_tet_vdest[0].mds_pwe1_hdl, 600, 500, + 1, NCSMDS_DOWN) != 1) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Cancel the subscription\n"); + if (mds_service_cancel_subscription( + gl_tet_vdest[0].mds_pwe1_hdl, 600, 1, + svc_id_fivehd) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Uninstall the service\n"); + if (mds_service_uninstall(gl_tet_vdest[0].mds_pwe1_hdl, 600) + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + printf("\nChild: Destroy the vdest 1001\n"); + if (destroy_vdest(1001) != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + + test_validate(FAIL, 0); + } +} + void tet_adest_cancel_thread() { MDS_SVC_ID svcids[] = {600, 700}; @@ -14370,6 +14845,12 @@ __attribute__((constructor)) static void mdsTipcAPI_constructor(void) test_case_add( 4, tet_svc_subscr_VDEST_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"); + test_case_add( + 4, tet_svc_subscr_VDEST_13, + "Conflict mxn active vdests"); + test_case_add( + 4, tet_svc_subscr_VDEST_14, + "Conflict nway active vdests"); test_suite_add(5, "Subscribe ADEST"); test_case_add( -- 2.25.1 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel