Hi VU,

ACK with following :

Not an issue but It is good to use lgs_conf.logRootDirectory insted of 
new_logRootDirectory

for the remaining part of logRootDirectory_filemove()  , because 
mutex_unlocked for  lgs_conf.logRootDirectory

-AVM

On 10/10/2016 4:48 PM, Lennart Lund wrote:
> Hi Vu
>
> Ack with comment. See below
>
> /***
>   * Support older check-point protocols prior to version 5
>   */
> /**
>   * Used for updating logRootDirectory on standby when check-pointed
>   *
>   * Set the logRootDirectory parameter in the lgs_conf struct
>   * Used for holding data from config object
>   *
>   * @param root_path_str
>   */
> void lgs_rootpathconf_set(const std::string &root_path_str) {
>
> [Lennart]
> The comments and maybe the place of this function seems incorrect since this 
> function is not only used on standby server
>
> Thanks
> Lennart
>
>
>> -----Original Message-----
>> From: Vu Minh Nguyen [mailto:vu.m.ngu...@dektech.com.au]
>> Sent: den 21 september 2016 10:08
>> To: Lennart Lund <lennart.l...@ericsson.com>; mahesh.va...@oracle.com
>> Cc: opensaf-devel@lists.sourceforge.net
>> Subject: [PATCH 1 of 1] log: fix failure to create directory when changing
>> logRootDirectory [#2054]
>>
>>   osaf/services/saf/logsv/lgs/lgs_imm.cc |   3 +
>>   tests/logsv/tet_LogOiOps.c             |  82
>> ++++++++++++++++++++++++++++++++++
>>   2 files changed, 85 insertions(+), 0 deletions(-)
>>
>>
>> When changing `logRootDirectory`, the new directory was not updated to
>> global `lgs_conf.logRootDirectory`, therefore all refering to new directory
>> got the old value.
>>
>> This patch adds code to make sure new directory updated.
>> And one test case #03 of suite #5 are added to verify this case.
>>
>> diff --git a/osaf/services/saf/logsv/lgs/lgs_imm.cc
>> b/osaf/services/saf/logsv/lgs/lgs_imm.cc
>> --- a/osaf/services/saf/logsv/lgs/lgs_imm.cc
>> +++ b/osaf/services/saf/logsv/lgs/lgs_imm.cc
>> @@ -1858,6 +1858,9 @@ void logRootDirectory_filemove(
>>       stream = log_stream_get_by_id(--num);
>>     }
>>
>> +  // Change logrootDirectory to new_logRootDirectory
>> +  lgs_rootpathconf_set(new_logRootDirectory);
>> +
>>     /* Create new files at new path
>>      */
>>     num = get_number_of_streams();
>> diff --git a/tests/logsv/tet_LogOiOps.c b/tests/logsv/tet_LogOiOps.c
>> --- a/tests/logsv/tet_LogOiOps.c
>> +++ b/tests/logsv/tet_LogOiOps.c
>> @@ -1023,6 +1023,87 @@ done:
>>   }
>>
>>   /**
>> + * CCB Object Modify, root directory. Path exist. OK
>> + * Result shall be OK
>> + */
>> +void change_root_path(void)
>> +{
>> +    int rc = 0, tst_stat = 0;
>> +    char command[256];
>> +    char tstdir[256];
>> +
>> +    /* Path to test directory */
>> +    sprintf(tstdir, "%s/croot", log_root_path);
>> +
>> +    // Remove if the test folder is exist
>> +    sprintf(command, "rm -rf %s/", tstdir);
>> +    rc = tet_system(command);
>> +
>> +    /* Create test directory */
>> +    sprintf(command, "mkdir -p %s", tstdir);
>> +    rc = tet_system(command);
>> +    if (rc != 0) {
>> +            fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
>> +            tst_stat = 1;
>> +            goto done;
>> +    }
>> +
>> +    /* Make sure it can be accessed by server */
>> +    sprintf(command, "chmod ugo+w,ugo+r %s", tstdir);
>> +    rc = tet_system(command);
>> +    if (rc != 0) {
>> +            fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
>> +            tst_stat = 1;
>> +            goto done;
>> +    }
>> +
>> +    sprintf(command, "immcfg -c SaLogStreamConfig
>> safLgStrCfg=testRoot "
>> +            "-a saLogStreamPathName=./testRoot -a
>> saLogStreamFileName=testRoot");
>> +    rc = tet_system(command);
>> +    if (rc != 0) {
>> +            fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
>> +            tst_stat = 1;
>> +            goto done;
>> +    }
>> +
>> +    /* Change to xxtest */
>> +    sprintf(command, "immcfg -a logRootDirectory=%s
>> logConfig=1,safApp=safLogService", tstdir);
>> +    rc = tet_system(command);
>> +    if (rc != 0) {
>> +            fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
>> +            tst_stat = 1;
>> +            goto free;
>> +    }
>> +
>> +    // Verify if the directory and subdirectly are created successfully
>> +    usleep(100*1000); // to make sure logsv done processing of
>> directories creation
>> +    sprintf(command, "ls %s/testRoot 1>/dev/null", tstdir);
>> +    rc = tet_system(command);
>> +    if (rc != 0) {
>> +            fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
>> +            tst_stat = 1;
>> +    }
>> +
>> +    /* Change back */
>> +    sprintf(command, "immcfg -a logRootDirectory=%s
>> logConfig=1,safApp=safLogService", log_root_path);
>> +    rc = tet_system(command);
>> +    if (rc != 0) {
>> +            fprintf(stderr, "'%s' Fail to restore rc=%d\n", command, rc);
>> +    }
>> +
>> +free:
>> +    // Delete test app stream
>> +    sprintf(command, "immcfg -d safLgStrCfg=testRoot");;
>> +    rc = tet_system(command);
>> +    if (rc != 0) {
>> +            fprintf(stderr, "'%s' Fail to restore  rc=%d\n", command, rc);
>> +    }
>> +
>> +done:
>> +    rc_validate(tst_stat, 0);
>> +}
>> +
>> +/**
>>    * CCB Object Modify, data group. Group does not exist. Not allowed
>>    * Result shall be reject
>>    */
>> @@ -3776,6 +3857,7 @@ done:
>>      test_suite_add(5, "LOG OI tests, Service configuration object");
>>      test_case_add(5, saLogOi_52, "CCB Object Modify, root directory.
>> Path does not exist. Not allowed");
>>      test_case_add(5, saLogOi_48, "CCB Object Modify, root directory.
>> Path exist. OK");
>> +    test_case_add(5, change_root_path, "CCB Object Modify, change
>> root directory. Path exist. OK");
>>      test_case_add(5, saLogOi_79, "CCB Object Modify, data group.
>> Group does not exist. Not allowed");
>>      test_case_add(5, saLogOi_80, "CCB Object Modify, data group.
>> Group exists. OK");
>>      test_case_add(5, saLogOi_81, "CCB Object Modify, delete data
>> group. OK");


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