When changing root directory (immcfg -a logRootDirectory=NEW_ROOT
logConfig=1,safApp=safLogService),
The "NEW_ROOT" need to be verify if it is writeable in ccb_completed_callback by
log server. But log server is busy in sometimes cause test case fails.
The patch fixes test case do retry the immcfg command
---
src/log/apitest/tet_LogOiOps.c | 48 ++++++++++++++++++++++++------------------
src/log/logd/lgs_config.cc | 2 ++
src/log/logd/lgs_imm.cc | 4 ++--
3 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/src/log/apitest/tet_LogOiOps.c b/src/log/apitest/tet_LogOiOps.c
index ba6fde6cc..86da4f862 100644
--- a/src/log/apitest/tet_LogOiOps.c
+++ b/src/log/apitest/tet_LogOiOps.c
@@ -22,6 +22,7 @@
#include <saImmOm.h>
#include <limits.h>
#include <unistd.h>
+#include "base/osaf_time.h"
#include "base/saf_error.h"
#include "logtest.h"
@@ -1626,6 +1627,8 @@ void saLogOi_502(void)
int rc = 0, tst_stat = 0;
char command[MAX_DATA];
char tstdir[MAX_DATA];
+ struct timespec timeout_time;
+ const int kWaitTime = 10*1000;
/* Path to test directory */
sprintf(tstdir, "%s/xxtest", log_root_path);
@@ -1655,28 +1658,31 @@ void saLogOi_502(void)
goto done;
}
- /* Change to xxtest */
- sprintf(
- command,
- "immcfg -a logRootDirectory=%s logConfig=1,safApp=safLogService",
- tstdir);
- rc = systemCall(command);
- if (rc != 0) {
- fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
- tst_stat = 1;
- goto done;
- }
- /* Change back */
- sprintf(
- command,
- "immcfg -a logRootDirectory=%s logConfig=1,safApp=safLogService",
- log_root_path);
- rc = systemCall(command);
- if (rc != 0) {
- fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
- tst_stat = 1;
- goto done;
+ // Change to root directory to xxtest
+ sprintf(command, "immcfg -a logRootDirectory=%s "
+ "logConfig=1,safApp=safLogService > /dev/null 2>&1",
+ tstdir);
+ for (int i = 0; i < 2; i++) {
+ osaf_set_millis_timeout(kWaitTime, &timeout_time);
+ // Try again in case command fails due to lgsv is busy
+ do {
+ rc = system(command);
+ if (rc == 0) break;
+ osaf_nanosleep(&kOneSecond);
+ } while (!osaf_is_timeout(&timeout_time));
+
+ if (rc != 0) {
+ fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
+ tst_stat = 1;
+ break;
+ }
+
+ // Change back
+ sprintf(command, "immcfg -a logRootDirectory=%s logConfig=1,"
+ "safApp=safLogService > /dev/null 2>&1",
+ log_root_path);
+ osaf_nanosleep(&kOneSecond);
}
done:
diff --git a/src/log/logd/lgs_config.cc b/src/log/logd/lgs_config.cc
index 89600adfa..a70a2f6c6 100644
--- a/src/log/logd/lgs_config.cc
+++ b/src/log/logd/lgs_config.cc
@@ -1489,6 +1489,8 @@ bool lgs_path_is_writeable_dir_h(const std::string
&pathname) {
if (api_rc != LGSF_SUCESS) {
TRACE("%s - API error %s", __FUNCTION__, lgsf_retcode_str(api_rc));
is_writeable_dir = false;
+ if (api_rc == LGSF_BUSY)
+ LOG_NO("Logsv is busy");
} else {
if (apipar.hdl_ret_code_out == 0)
is_writeable_dir = false;
diff --git a/src/log/logd/lgs_imm.cc b/src/log/logd/lgs_imm.cc
index a4d8f0fce..a0d8377b5 100644
--- a/src/log/logd/lgs_imm.cc
+++ b/src/log/logd/lgs_imm.cc
@@ -774,11 +774,11 @@ static SaAisErrorT config_ccb_completed_modify(
std::string pathName = *(static_cast<char **>(value));
if (lgs_cfg_verify_root_dir(pathName) != 0) {
report_oi_error(immOiHandle, opdata->ccbId,
- "pathName: %s is NOT accepted", pathName.c_str());
+ "validation of pathName: %s fails",
pathName.c_str());
ais_rc = SA_AIS_ERR_BAD_OPERATION;
goto done;
}
- TRACE("pathName: %s is accepted", pathName.c_str());
+ TRACE("validation of pathName: %s fails", pathName.c_str());
}
} else if (!strcmp(attribute->attrName, LOG_DATA_GROUPNAME)) {
if (attribute->attrValuesNumber == 0) {
--
2.13.0
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel