Hi Vu,

Can we use  (cb->ha_state != SA_AMF_HA_ACTIVE) instead of 
`cb->is_quiesced_set == true`
as if this is a agent response, so it will have more readability .

-AVM

On 10/11/2016 10:36 AM, Vu Minh Nguyen wrote:
>   osaf/services/saf/logsv/lgs/lgs_evt.cc |   12 +++-
>   tests/logsv/tet_saLogStreamOpen_2.c    |  101 
> +++++++++++++++++++++++++++++++++
>   2 files changed, 111 insertions(+), 2 deletions(-)
>
>
> During si-swap, old active logd will enter QUEISED HA state, then STANDBY.
> In QUEISED state, IMM OI implementer will be cleared.
> If opening a new application stream or closing an app stream while
> the HA state is in QUEISED, log client will get BAD_OPERATION error.
>
> In such transition state, logsv should return TRY_AGAIN to clients.
> Once the transition is completely done, above requests will be served.
>
> 02 test cases are created to verify the fix, test case 53 & 54 of suite #2.
>
> diff --git a/osaf/services/saf/logsv/lgs/lgs_evt.cc 
> b/osaf/services/saf/logsv/lgs/lgs_evt.cc
> --- a/osaf/services/saf/logsv/lgs/lgs_evt.cc
> +++ b/osaf/services/saf/logsv/lgs/lgs_evt.cc
> @@ -1021,7 +1021,11 @@ static uint32_t proc_stream_open_msg(lgs
>       }
>     } else {
>       /* Stream does not exist */
> -    if (cb->immOiHandle == 0) {
> +
> +    // Client should try again when role changes is in transition (queued).
> +    // This check is to avoid the client getting SA_AIS_BAD_OPERATION
> +    // as there is no IMM OI implementer set.
> +    if (cb->immOiHandle == 0 || cb->is_quiesced_set == true) {
>         TRACE("IMM service unavailable, open stream failed");
>         ais_rv = SA_AIS_ERR_TRY_AGAIN;
>         goto snd_rsp;
> @@ -1153,7 +1157,11 @@ static uint32_t proc_stream_close_msg(lg
>       goto snd_rsp;
>     }
>   
> -  if ((stream->streamType == STREAM_TYPE_APPLICATION) && (cb->immOiHandle == 
> 0)) {
> +  // Client should try again when role changes is in transition (queued).
> +  // This check is to avoid the client getting SA_AIS_BAD_OPERATION
> +  // as there is no IMM OI implementer set.
> +  if ((stream->streamType == STREAM_TYPE_APPLICATION) &&
> +      (cb->immOiHandle == 0 || cb->is_quiesced_set == true)) {
>       TRACE("IMM service unavailable, close stream failed");
>       ais_rc = SA_AIS_ERR_TRY_AGAIN;
>       goto snd_rsp;
> diff --git a/tests/logsv/tet_saLogStreamOpen_2.c 
> b/tests/logsv/tet_saLogStreamOpen_2.c
> --- a/tests/logsv/tet_saLogStreamOpen_2.c
> +++ b/tests/logsv/tet_saLogStreamOpen_2.c
> @@ -795,6 +795,105 @@ void saLogMultiThreadMultiInit(void)
>       test_validate(rc, SA_AIS_OK);
>   }
>   
> +//
> +// This test to verify Open call gets BAD_OPERATION or not during si-swap
> +//
> +void saLogStreamOpen_BadOp(void)
> +{
> +     SaAisErrorT rc;
> +     char command[1000];
> +     int loop;
> +
> +
> +     rc = saLogInitialize(&logHandle, &logCallbacks, &logVersion);
> +     if (rc != SA_AIS_OK) {
> +             fprintf(stderr, "Failed at saLogInitialize: %d \n", (int)rc);
> +             test_validate(rc, SA_AIS_OK);
> +             return;
> +     }
> +
> +     // Perform si-swap in background
> +     sprintf(command, "amf-adm si-swap safSi=SC-2N,safApp=OpenSAF &");
> +     loop = system(command);
> +
> +     // To make Open probably processed righ after logsv HA is set to 
> QUEISED state.
> +     // This test is created to reproduce the issue reported in ticket #2093
> +     usleep(100*1000);
> +
> +     loop = 100;
> +tryagain:
> +     rc = saLogStreamOpen_2(logHandle, &app1StreamName, 
> &appStream1LogFileCreateAttributes,
> +                            SA_LOG_STREAM_CREATE, SA_TIME_ONE_SECOND, 
> &logStreamHandle);
> +     if (rc == SA_AIS_ERR_TRY_AGAIN && loop--) {
> +             usleep(100*1000);
> +             goto tryagain;
> +     }
> +
> +     test_validate(rc, SA_AIS_OK);
> +
> +     rc = saLogFinalize(logHandle);
> +     if (rc != SA_AIS_OK) {
> +             fprintf(stderr, "Failed to call salogFinalize: %d \n", (int) 
> rc);
> +     }
> +}
> +
> +//
> +// This test to verify Close call gets BAD_OPERATION in syslog or not during 
> si-swap
> +//
> +void saLogStreamClose_BadOp(void)
> +{
> +     SaAisErrorT rc;
> +     char command[1000];
> +     int loop;
> +
> +     rc = saLogInitialize(&logHandle, &logCallbacks, &logVersion);
> +     if (rc != SA_AIS_OK) {
> +             fprintf(stderr, "Failed at saLogInitialize: %d \n", (int)rc);
> +             test_validate(rc, SA_AIS_OK);
> +             return;
> +     }
> +
> +
> +     loop = 100;
> +tryagain:
> +     rc = saLogStreamOpen_2(logHandle, &app1StreamName, 
> &appStream1LogFileCreateAttributes,
> +                            SA_LOG_STREAM_CREATE, SA_TIME_ONE_SECOND, 
> &logStreamHandle);
> +     if (rc == SA_AIS_ERR_TRY_AGAIN && loop--) {
> +             usleep(100*1000);
> +             goto tryagain;
> +     }
> +
> +     if (rc != SA_AIS_OK) {
> +             fprintf(stderr, "Failed to open stream (%d)\n", rc);
> +             test_validate(rc, SA_AIS_OK);
> +             goto done;
> +     }
> +
> +     // Perform si-swap in background
> +     sprintf(command, "amf-adm si-swap safSi=SC-2N,safApp=OpenSAF &");
> +     loop = system(command);
> +
> +     // To make Close probably processed righ after logsv HA is set to 
> QUEISED state.
> +     // This test is created to reproduce the issue reported in ticket #2093
> +     usleep(100*1000);
> +
> +     loop = 100;
> +tryagain_2:
> +     rc = saLogStreamClose(logStreamHandle);
> +     if (rc == SA_AIS_ERR_TRY_AGAIN && loop--) {
> +             usleep(100*1000);
> +             goto tryagain_2;
> +     }
> +
> +     test_validate(rc, SA_AIS_OK);
> +
> +done:
> +     rc = saLogFinalize(logHandle);
> +     if (rc != SA_AIS_OK) {
> +             fprintf(stderr, "Failed to call salogFinalize: %d \n", (int) 
> rc);
> +     }
> +}
> +
>   extern void saLogStreamOpenAsync_2_01(void);
>   extern void saLogStreamOpenCallbackT_01(void);
>   extern void saLogWriteLog_01(void);
> @@ -885,5 +984,7 @@ extern void saLogStreamClose_01(void);
>       test_case_add(2, saLogStreamOpen_2_50, "saLogStreamOpen_2 with stream 
> number out of the limitation, ERR");
>       test_case_add(2, saLogMultipleInitialize, "saLogInitialize() then 
> saLogFinalize() multiple times. keep MDS connection, OK");
>       test_case_add(2, saLogMultiThreadMultiInit, "saLogInitialize() then 
> saLogFinalize() multiple times in multiple threads, OK");
> +    test_case_add(2, saLogStreamOpen_BadOp, "saLogStreamOpen_2 while 
> si-swap");
> +    test_case_add(2, saLogStreamClose_BadOp, "saLogStreamClose while 
> si-swap");
>   }
>   


------------------------------------------------------------------------------
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