|
From: Thien H. <thi...@en...> - 2026-04-23 04:02:26
|
---
src/mds/apitest/mdstipc.h | 3 +
src/mds/apitest/mdstipc_api.c | 361 ++++++++++++++++++++++++++++++----
2 files changed, 331 insertions(+), 33 deletions(-)
diff --git a/src/mds/apitest/mdstipc.h b/src/mds/apitest/mdstipc.h
index a8628d707..c03824252 100644
--- a/src/mds/apitest/mdstipc.h
+++ b/src/mds/apitest/mdstipc.h
@@ -298,6 +298,9 @@ void tet_svc_subscr_VDEST_7(void);
void tet_svc_subscr_VDEST_10(void);
void tet_svc_subscr_VDEST_11(void);
void tet_svc_subscr_VDEST_12(void);
+void tet_svc_subscr_VDEST_13(void);
+void tet_svc_subscr_VDEST_14(void);
+void tet_svc_subscr_VDEST_15(void);
void cleanup_ADEST_srv(void);
void tet_svc_subscr_ADEST_1(void);
void tet_svc_subscr_ADEST_2(void);
diff --git a/src/mds/apitest/mdstipc_api.c b/src/mds/apitest/mdstipc_api.c
index dbfa00f05..929da2193 100644
--- a/src/mds/apitest/mdstipc_api.c
+++ b/src/mds/apitest/mdstipc_api.c
@@ -1105,12 +1105,12 @@ void tet_svc_install_upto_MAX()
test_validate(FAIL, 0);
}
-static int tet_verify_version(MDS_HDL mds_hdl, NCSMDS_SVC_ID your_scv_id,
- NCSMDS_SVC_ID req_svc_id,
- MDS_SVC_PVT_SUB_PART_VER svc_pvt_ver,
- NCSMDS_CHG change)
+static TET_EVENT_INFO *tet_find_event(MDS_HDL mds_hdl,
+ NCSMDS_SVC_ID your_scv_id,
+ NCSMDS_SVC_ID req_svc_id)
{
- int i, j, k, ret_val = 0;
+ int i, j, k;
+
if (is_service_on_adest(mds_hdl, your_scv_id) == NCSCC_RC_SUCCESS) {
for (i = 0; i < gl_tet_adest.svc_count; i++) {
if (gl_tet_adest.svc[i].svc_id == your_scv_id) {
@@ -1119,18 +1119,9 @@ static int tet_verify_version(MDS_HDL mds_hdl, NCSMDS_SVC_ID your_scv_id,
j++) {
if (gl_tet_adest.svc[i]
.svcevt[j]
- .svc_id == req_svc_id) {
- if ((gl_tet_adest.svc[i]
- .svcevt[j]
- .event == change) &&
- (gl_tet_adest.svc[i]
- .svcevt[j]
- .rem_svc_pvt_ver ==
- svc_pvt_ver))
- ret_val = 1;
- else
- ret_val = 0;
- }
+ .svc_id == req_svc_id)
+ return &gl_tet_adest.svc[i]
+ .svcevt[j];
}
}
}
@@ -1146,28 +1137,66 @@ static int tet_verify_version(MDS_HDL mds_hdl, NCSMDS_SVC_ID your_scv_id,
if (gl_tet_vdest[i]
.svc[j]
.svcevt[k]
- .svc_id == req_svc_id) {
- if ((gl_tet_vdest[i]
- .svc[j]
- .svcevt[k]
- .event ==
- change) &&
- (gl_tet_vdest[i]
- .svc[j]
- .svcevt[k]
- .rem_svc_pvt_ver ==
- svc_pvt_ver))
- ret_val = 1;
- else
- ret_val = 0;
- }
+ .svc_id == req_svc_id)
+ return &gl_tet_vdest[i]
+ .svc[j]
+ .svcevt[k];
}
}
}
}
}
- return ret_val;
+
+ return NULL;
+}
+
+static int tet_verify_version(MDS_HDL mds_hdl,
+ NCSMDS_SVC_ID your_scv_id,
+ NCSMDS_SVC_ID req_svc_id,
+ MDS_SVC_PVT_SUB_PART_VER svc_pvt_ver,
+ NCSMDS_CHG change)
+{
+ TET_EVENT_INFO *event_info =
+ tet_find_event(mds_hdl, your_scv_id, req_svc_id);
+
+ if (event_info == NULL)
+ return 0;
+
+ return (event_info->event == change &&
+ event_info->rem_svc_pvt_ver == svc_pvt_ver);
}
+
+static int tet_verify_event_role(MDS_HDL mds_hdl,
+ NCSMDS_SVC_ID your_scv_id,
+ NCSMDS_SVC_ID req_svc_id, NCSMDS_CHG change,
+ V_DEST_RL role)
+{
+ TET_EVENT_INFO *event_info =
+ tet_find_event(mds_hdl, your_scv_id, req_svc_id);
+
+ if (event_info == NULL)
+ return 0;
+
+ return (event_info->event == change && event_info->role == role);
+}
+
+static int tet_verify_event_role_version(MDS_HDL mds_hdl,
+ NCSMDS_SVC_ID your_scv_id,
+ NCSMDS_SVC_ID req_svc_id,
+ NCSMDS_CHG change, V_DEST_RL role,
+ MDS_SVC_PVT_SUB_PART_VER svc_pvt_ver)
+{
+ TET_EVENT_INFO *event_info =
+ tet_find_event(mds_hdl, your_scv_id, req_svc_id);
+
+ if (event_info == NULL)
+ return 0;
+
+ return (event_info->event == change &&
+ event_info->role == role &&
+ event_info->rem_svc_pvt_ver == svc_pvt_ver);
+}
+
void tet_svc_subscr_VDEST_1()
{
int FAIL = 0;
@@ -2628,6 +2657,269 @@ void tet_svc_subscr_VDEST_14() {
}
}
+void tet_svc_subscr_VDEST_15() {
+ 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 15: mxn standby transition keeps the"
+ " replacement NEW_ACTIVE\n");
+ printf("\nGet an adest handle\n");
+ if (adest_get_handle() != NCSCC_RC_SUCCESS) {
+ printf("\nFail\n");
+ FAIL = 1;
+ }
+
+ 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 parent active 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 subscriber 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 UP 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 the initial UP version\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 child active"
+ " instance\n");
+ sleep(5);
+
+ printf("\nAction: Change the parent vdest role to standby\n");
+ if (vdest_change_role(1001, V_DEST_RL_STANDBY)
+ != NCSCC_RC_SUCCESS) {
+ printf("\nFail\n");
+ FAIL = 1;
+ }
+
+ printf("\nAction: Retrieve the NO_ACTIVE 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 the NO_ACTIVE role from the"
+ " demoted active\n");
+ if (tet_verify_event_role(gl_tet_adest.mds_pwe1_hdl, 500, 600,
+ NCSMDS_NO_ACTIVE,
+ V_DEST_RL_STANDBY) != 1) {
+ printf("\nFail\n");
+ FAIL = 1;
+ }
+
+ printf("\nAction: Retrieve the NEW_ACTIVE 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 the replacement NEW_ACTIVE role and"
+ " version\n");
+ if (tet_verify_event_role_version(
+ gl_tet_adest.mds_pwe1_hdl, 500, 600,
+ NCSMDS_NEW_ACTIVE, V_DEST_RL_ACTIVE, 2) != 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 subscriber service 500\n");
+ if (mds_service_uninstall(gl_tet_adest.mds_pwe1_hdl, 500) !=
+ NCSCC_RC_SUCCESS) {
+ printf("\nFail\n");
+ FAIL = 1;
+ }
+
+ printf("\nAction: Uninstall the parent standby service 600\n");
+ if (mds_service_uninstall(gl_tet_vdest[0].mds_pwe1_hdl, 600) !=
+ NCSCC_RC_SUCCESS) {
+ printf("\nFail\n");
+ FAIL = 1;
+ }
+
+ 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 replacement service 600\n");
+ if (mds_service_install(gl_tet_vdest[0].mds_pwe1_hdl, 600, 2,
+ 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 UP 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 the version 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 the parent setup\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 DOWN 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 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 replacement service 600\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};
@@ -15095,6 +15387,9 @@ __attribute__((constructor)) static void mdsTipcAPI_constructor(void)
test_case_add(
4, tet_svc_subscr_VDEST_14,
"Conflict nway active vdests");
+ test_case_add(4, tet_svc_subscr_VDEST_15,
+ "MxN ACTIVE to STANDBY sends NEW_ACTIVE with "
+ "replacement active role and version");
test_suite_add(5, "Subscribe ADEST");
test_case_add(
--
2.34.1
The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Any opinions expressed are mine and do not necessarily represent the opinions of the Company. Emails are susceptible to interference. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is strictly prohibited and may be unlawful. If you have received this message in error, do not open any attachments but please notify the Endava Service Desk on (+44 (0)870 423 0187), and delete this message from your system. The sender accepts no responsibility for information, errors or omissions in this email, or for its use or misuse, or for any act committed or omitted in connection with this communication. If in doubt, please verify the authenticity of the contents with the sender. Please rely on your own virus checkers as no responsibility is taken by the sender for any damage rising out of any bug or virus infection.
Endava plc is a company registered in England under company number 5722669 whose registered office is at 125 Old Broad Street, London, EC2N 1AR, United Kingdom. Endava plc is the Endava group holding company and does not provide any services to clients. Each of Endava plc and its subsidiaries is a separate legal entity and has no liability for another such entity's acts or omissions.
|