The logtest 6 49 and logtest 6 50 failed because the admin
operation fail due to closing log file timeout.

Update to try again the command admin operation in test cases
---
 src/log/apitest/tet_LogOiOps.c | 54 ++++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 20 deletions(-)

diff --git a/src/log/apitest/tet_LogOiOps.c b/src/log/apitest/tet_LogOiOps.c
index 25f53d3a2..4133b6bbe 100644
--- a/src/log/apitest/tet_LogOiOps.c
+++ b/src/log/apitest/tet_LogOiOps.c
@@ -5479,6 +5479,23 @@ done:
                       &v_saLogStreamFixedLogRecordSize, SA_IMM_ATTR_SAUINT32T);
 }
 
+// Execute admin operation command and retry if it failed
+int execute_admin_operation_and_retries(const char *command)
+{
+       int rc = 0;
+       const uint64_t kWaitTime10s = 10 * 1000;
+       struct timespec timeout_time;
+       osaf_set_millis_timeout(kWaitTime10s, &timeout_time);
+       while (!osaf_is_timeout(&timeout_time)) {
+               // Do the retries in case rotate/delete file fail due to
+               // filesystem issue
+               rc = systemCall(command);
+               if (rc == 0) break;
+               osaf_nanosleep(&kOneSecond);
+       }
+       return rc;
+}
+
 //
 // Test case for verifying the admin operation rotates log file is accepted
 // Steps:
@@ -5490,7 +5507,6 @@ void admin_rotate_log_file(void)
 {
        int rc = 0;
        char command[MAX_DATA];
-       const uint64_t kWaitTime10s = 10 * 1000;
        const char *object_dn =
                        "safLgStrCfg=admin_rotate_file,safApp=safLogService";
 
@@ -5502,15 +5518,7 @@ void admin_rotate_log_file(void)
        if (rc == 0) {
                // Admin operation rotate log file
                sprintf(command, "immadm -o 2 %s", object_dn);
-               struct timespec timeout_time;
-               osaf_set_millis_timeout(kWaitTime10s, &timeout_time);
-               do {
-                       // Do the retries in case rotate file fail due to
-                       // filesystem issue
-                       osaf_nanosleep(&kOneSecond);
-                       rc = systemCall(command);
-               } while (rc != 0 && !osaf_is_timeout(&timeout_time));
-
+               rc = execute_admin_operation_and_retries(command);
                rc_validate(rc, 0);
 
                // Delete object
@@ -5568,7 +5576,8 @@ void verRotatedLogCfgFile(void)
        FILE *fp = popen(command1, "r");
 
        // Get number of cfg and log file
-       while (fgets(num_files_c, sizeof(num_files_c) - 1, fp) != NULL) {};
+       while (fgets(num_files_c, sizeof(num_files_c) - 1, fp) != NULL) {
+       };
        pclose(fp);
 
        // Verify cfg/log files are rotated by checking
@@ -5588,7 +5597,7 @@ void verRotatedLogCfgFile(void)
 void verRotatedLogCfgFile2(void)
 {
        int rc;
-       char command[MAX_DATA];
+       char command[MAX_DATA], command1[MAX_DATA];
        const char *object_dn =
                        "safLgStrCfg=verRotatedFile2,safApp=safLogService";
        char num_files_c[10];
@@ -5600,20 +5609,24 @@ void verRotatedLogCfgFile2(void)
                         "-a saLogStreamFileName=verRotatedFile2"
                         " -a saLogStreamMaxFilesRotated=2",
                         object_dn);
+       // Command to delete configuration application stream
+       sprintf(command1, "immcfg -d %s", object_dn);
+
        // Create  the app stream.
        rc = systemCall(command);
        if (rc != 0) {
                rc_validate(rc, 0);
                return;
        }
+       osaf_nanosleep(&kHundredMilliseconds);
 
        // Do admin operation to rotate log file without the parameter
        // Two new log files are created. One oldest file is removed.
        sprintf(command, "immadm -o 2 %s", object_dn);
        for (int i = 0; i < 2; ++i) {
-               osaf_nanosleep(&kOneSecond);
-               rc = systemCall(command);
+               rc = execute_admin_operation_and_retries(command);
                if (rc != 0) {
+                       systemCall(command1);
                        rc_validate(rc, 0);
                        return;
                }
@@ -5626,13 +5639,12 @@ void verRotatedLogCfgFile2(void)
                         log_root_path, "verRotatedFile2");
        FILE *fp = popen(command, "r");
        // Get number of log files
-       while (fgets(num_files_c, sizeof(num_files_c) - 1, fp) != NULL) {};
+       while (fgets(num_files_c, sizeof(num_files_c) - 1, fp) != NULL) {
+       };
        pclose(fp);
 
-       // Command to delete configuration application stream
-       sprintf(command, "immcfg -d %s", object_dn);
        // Close the application stream
-       rc = systemCall(command);
+       rc = systemCall(command1);
        if (rc != 0) {
                rc_validate(rc, 0);
                return;
@@ -5689,8 +5701,9 @@ void verRotatedLogCfgFile3(void)
        // Admin operation to remove 1 oldest log files
        sprintf(command1, "immadm -o 2 -p numberOfFilesToRemove:SA_UINT32_T:1 "
                          "%s", object_dn);
-       rc = systemCall(command1);
+       rc = execute_admin_operation_and_retries(command1);
        if (rc != 0) {
+               systemCall(command2);
                rc_validate(rc, 0);
                return;
        }
@@ -5702,7 +5715,8 @@ void verRotatedLogCfgFile3(void)
                          log_root_path, "verRotatedFile3");
        FILE *fp = popen(command1, "r");
        // Get number of cfg and log file
-       while (fgets(num_files_c, sizeof(num_files_c) - 1, fp) != NULL) {};
+       while (fgets(num_files_c, sizeof(num_files_c) - 1, fp) != NULL) {
+       };
        pclose(fp);
 
        // Close the application stream
-- 
2.15.1



_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to