osaf/services/saf/logsv/README | 21 +
osaf/services/saf/logsv/lgs/lgs_config.c | 50 +-
osaf/services/saf/logsv/lgs/lgs_config.h | 1 +
osaf/services/saf/logsv/lgs/lgs_file.c | 1 +
osaf/services/saf/logsv/lgs/lgs_imm.c | 224 +++++---
tests/logsv/logtest.c | 2 +-
tests/logsv/tet_LogOiOps.c | 714 +++++++++++++++++++++++++++++-
7 files changed, 867 insertions(+), 146 deletions(-)
More log service configuration attributes can be changed in runtime
including logMaxLogrecsize
diff --git a/osaf/services/saf/logsv/README b/osaf/services/saf/logsv/README
--- a/osaf/services/saf/logsv/README
+++ b/osaf/services/saf/logsv/README
@@ -212,6 +212,8 @@ The following attributes can be changed
Can be changed to an existing path.
- logStreamFileFormat
+ - logMaxLogrecsize
+ - logFileIoTimeout
- logStreamSystemHighLimit
logStreamSystemLowLimit
@@ -500,6 +502,8 @@ in the same way as checkpointing is done
Configuration changes are now checkpointed using a variable length buffer
containing a cfgupd list.
+With this change, when attributes are check pointed,
+the list is always updated with all check pointed values.
CONTRIBUTORS/MAINTAINERS
========================
@@ -711,3 +715,20 @@ of second from log timestamp (@Ck, @Nk).
- @Nk: for alarm and notification log stream.
Preceding and trailing zeros (0) if needed should exist.
+
+
+2. Log record size could be up to 32Kb (#1288)
+----------------------------------------------
+With this ticket, logMaxLogrecsize and logFileIoTimeout attributes
+could be possible to change in runtime.
+
+logMaxLogrecsize attribute value could be up to 32768 (32Kb).
+
+logFileIoTimeout, this attribute defines the time period for
+which the main thread has to wait for the file IO operation to complete.
+The value is in milliseconds. In default, the main thread waits up to 500ms
+for file handling thread complete file IO operation.
+
+If user suffers the timeout when sending a big record size (e.g: 32Kb),
+He can adjust the waiting time by updating logFileIoTimeout attribute value up
to 5000ms.
+
diff --git a/osaf/services/saf/logsv/lgs/lgs_config.c
b/osaf/services/saf/logsv/lgs/lgs_config.c
--- a/osaf/services/saf/logsv/lgs/lgs_config.c
+++ b/osaf/services/saf/logsv/lgs/lgs_config.c
@@ -120,24 +120,22 @@ static struct {
SaUint32T logStreamSystemLowLimit;
SaUint32T logStreamAppHighLimit;
SaUint32T logStreamAppLowLimit;
-
- /* Not runtime configurable */
SaUint32T logMaxLogrecsize;
SaUint32T logMaxApplicationStreams;
SaUint32T logFileIoTimeout;
SaUint32T logFileSysConfig;
} lgs_conf_def = {
- PKGLOGDIR, /*logRootDirectory*/
- "", /*logDataGroupname*/
- DEFAULT_APP_SYS_FORMAT_EXP, /* logStreamFileFormat */
- 1024, /*logMaxLogrecsize*/
- 0, /*logStreamSystemHighLimit*/
- 0, /*logStreamSystemLowLimit*/
- 0, /*logStreamAppHighLimit*/
- 0, /*logStreamAppLowLimit*/
- 64, /*logMaxApplicationStreams*/
- 500, /*logFileIoTimeout*/
- 1, /*logFileSysConfig*/
+ .logRootDirectory = PKGLOGDIR, /*logRootDirectory*/
+ .logDataGroupname = "", /*logDataGroupname*/
+ .logStreamFileFormat = DEFAULT_APP_SYS_FORMAT_EXP, /*
logStreamFileFormat */
+ .logStreamSystemHighLimit = 0, /*logStreamSystemHighLimit*/
+ .logStreamSystemLowLimit = 0, /*logStreamSystemLowLimit*/
+ .logStreamAppHighLimit = 0, /*logStreamAppHighLimit*/
+ .logStreamAppLowLimit = 0, /*logStreamAppLowLimit*/
+ .logMaxLogrecsize = 1024, /*logMaxLogrecsize*/
+ .logMaxApplicationStreams = 64, /*logMaxApplicationStreams*/
+ .logFileIoTimeout = 500, /*logFileIoTimeout*/
+ .logFileSysConfig = 1, /*logFileSysConfig*/
};
static lgs_conf_t lgs_conf = {
@@ -544,9 +542,8 @@ int lgs_cfg_verify_log_file_format(const
/**
* Verify logMaxLogrecsize; Max size of a log record including header
* Rules:
- * - Because of an incorrect declaration in the server (uint16_t) that shall be
- * uint32_t the max value cannot be set > 2^15-1 (32767)
- * - Must be > 256
+ * - Must be >= 256
+ * - Must not larger than 65535 (UINT16_MAX)
*
* @param max_logrecsize_in[in]
* @return -1 on error
@@ -554,8 +551,7 @@ int lgs_cfg_verify_log_file_format(const
int lgs_cfg_verify_max_logrecsize(uint32_t max_logrecsize_in)
{
int rc = 0;
-
- if ((max_logrecsize_in > 32767) || (max_logrecsize_in < 256)) {
+ if ((max_logrecsize_in > 65535) || (max_logrecsize_in < 256)) {
LOG_NO("verify_max_logrecsize Fail");
rc = -1;
}
@@ -609,14 +605,24 @@ int lgs_cfg_verify_max_application_strea
/**
* Verify logFileIoTimeout
- * Rules: No rules defined will always return 0 (ok)
- *
+ * Rules: timeout must not be larger than 15s as it will impact on amf
healthcheck.
+ * - Maximum value is less than 5s
+ * - Minimum timeout is not less than 500ms
+ * NOTE: This range has not been measured in real system yet.
* @param log_file_io_timeout[in]
* @return -1 on error
*/
-static int lgs_cfg_verify_file_io_timeout(uint32_t log_file_io_timeout)
+int lgs_cfg_verify_file_io_timeout(uint32_t log_file_io_timeout)
{
- return 0;
+ int rc = 0;
+
+ if ((log_file_io_timeout < 500) || (log_file_io_timeout > 5000)) {
+ LOG_NO("logFileIoTimeout has invalid value = %u",
+ log_file_io_timeout);
+ rc = -1;
+ }
+
+ return rc;
}
/**
diff --git a/osaf/services/saf/logsv/lgs/lgs_config.h
b/osaf/services/saf/logsv/lgs/lgs_config.h
--- a/osaf/services/saf/logsv/lgs/lgs_config.h
+++ b/osaf/services/saf/logsv/lgs/lgs_config.h
@@ -97,6 +97,7 @@ int lgs_cfg_verify_log_file_format(const
int lgs_cfg_verify_max_logrecsize(uint32_t max_logrecsize_in);
int lgs_cfg_verify_mbox_limit(uint32_t high, uint32_t low);
int lgs_cfg_verify_max_application_streams(uint32_t max_app_streams);
+int lgs_cfg_verify_file_io_timeout(uint32_t log_file_io_timeout);
/*
* Handle runtime object for showing actual configuration
diff --git a/osaf/services/saf/logsv/lgs/lgs_file.c
b/osaf/services/saf/logsv/lgs/lgs_file.c
--- a/osaf/services/saf/logsv/lgs/lgs_file.c
+++ b/osaf/services/saf/logsv/lgs/lgs_file.c
@@ -428,6 +428,7 @@ lgsf_retcode_t log_file_api(lgsf_apipar_
if (rc != 0) osaf_abort(rc);
/* Wait for an answer */
+ max_waittime_ms = *(SaUint32T *) lgs_cfg_get(LGS_IMM_FILEHDL_TIMEOUT);
get_timeout_time(&timeout_time, max_waittime_ms);
while (lgs_com_data.answer_f == false) {
diff --git a/osaf/services/saf/logsv/lgs/lgs_imm.c
b/osaf/services/saf/logsv/lgs/lgs_imm.c
--- a/osaf/services/saf/logsv/lgs/lgs_imm.c
+++ b/osaf/services/saf/logsv/lgs/lgs_imm.c
@@ -772,9 +772,15 @@ static SaAisErrorT config_ccb_completed_
TRACE("%s value is accepted", logFileFormat);
goto done;
} else if (!strcmp(attribute->attrName, LOG_MAX_LOGRECSIZE)) {
- report_oi_error(immOiHandle, opdata->ccbId,
- "%s cannot be changed",
attribute->attrName);
- ais_rc = SA_AIS_ERR_FAILED_OPERATION;
+ SaUint32T maxLogRecordSize = *((SaUint32T *)value);
+ rc = lgs_cfg_verify_max_logrecsize(maxLogRecordSize);
+ if (rc == -1) {
+ report_oi_error(immOiHandle, opdata->ccbId,
+ "%s value is NOT accepted",
attribute->attrName);
+ ais_rc = SA_AIS_ERR_INVALID_PARAM;
+ goto done;
+ }
+ TRACE("%s is accepted", attribute->attrName);
goto done;
} else if (!strcmp(attribute->attrName,
LOG_STREAM_SYSTEM_HIGH_LIMIT)) {
vattr_v3.logStreamSystemHighLimit = *((SaUint32T
*)value);
@@ -802,9 +808,15 @@ static SaAisErrorT config_ccb_completed_
ais_rc = SA_AIS_ERR_FAILED_OPERATION;
goto done;
} else if (!strcmp(attribute->attrName, LOG_FILE_IO_TIMEOUT)) {
- report_oi_error(immOiHandle, opdata->ccbId,
- "%s cannot be changed",
attribute->attrName);
- ais_rc = SA_AIS_ERR_FAILED_OPERATION;
+ SaUint32T logFileIoTimeout = *((SaUint32T *) value);
+ rc = lgs_cfg_verify_file_io_timeout(logFileIoTimeout);
+ if (rc == -1) {
+ report_oi_error(immOiHandle, opdata->ccbId,
+ "%s value is NOT accepted",
attribute->attrName);
+ ais_rc = SA_AIS_ERR_INVALID_PARAM;
+ goto done;
+ }
+ TRACE("%d value is accepted", logFileIoTimeout);
goto done;
} else if (!strcmp(attribute->attrName, LOG_FILE_SYS_CONFIG)) {
report_oi_error(immOiHandle, opdata->ccbId,
@@ -1063,35 +1075,36 @@ bool chk_filepath_stream_exist(
/**
* Verify fixedLogRecordSize and maxLogFileSize.
* Rules:
- * - fixedLogRecordSize must be less than maxLogFileSize
- * - fixedLogRecordSize must be less than or equal to logMaxLogrecsize
- * - fixedLogRecordSize can be 0. Means variable record size
- * - maxLogFileSize must be bigger than 0. No limit is not supported
- * - maxLogFileSize must be bigger than logMaxLogrecsize
+ * 1 - saLogStreamFixedLogRecordSize must be less than
saLogStreamMaxLogFileSize
+ * 2 - saLogStreamFixedLogRecordSize must be less than or equal to
logMaxLogrecsize
+ * 3 - saLogStreamFixedLogRecordSize can be 0. Means variable record size
+ * 4 - saLogStreamMaxLogFileSize must be bigger than 0. No limit is not
supported
+ * 5 - saLogStreamMaxLogFileSize must be bigger than logMaxLogrecsize
+ * 6 - saLogStreamMaxLogFileSize must be bigger than
saLogStreamFixedLogRecordSize
*
- * The ..._flag variable == true means that the corresponding attribute is
- * changed.
+ * The ..._mod variable == true means that the corresponding attribute is
+ * modified.
*
- * @param immOiHandle
- * @param maxLogFileSize
- * @param maxLogFileSize_flag
- * @param fixedLogRecordSize
- * @param fixedLogRecordSize_flag
- * @param stream
- * @param operationType
+ * @param immOiHandle[in]
+ * @param streamMaxLogFileSize[in]
+ * @param streamMaxLogFileSize_mod[in]
+ * @param streamFixedLogRecordSize[in]
+ * @param streamFixedLogRecordSize_mod[in]
+ * @param stream[in]
+ * @param operationType[in]
* @return false if error
*/
static bool chk_max_filesize_recordsize_compatible(SaImmOiHandleT immOiHandle,
- SaUint64T maxLogFileSize,
- bool maxLogFileSize_mod,
- SaUint32T fixedLogRecordSize,
- bool fixedLogRecordSize_mod,
+ SaUint64T streamMaxLogFileSize,
+ bool streamMaxLogFileSize_mod,
+ SaUint32T streamFixedLogRecordSize,
+ bool streamFixedLogRecordSize_mod,
log_stream_t *stream,
enum CcbUtilOperationType operationType,
SaImmOiCcbIdT ccbId)
{
- SaUint64T i_maxLogFileSize = 0;
- SaUint32T i_fixedLogRecordSize = 0;
+ SaUint64T i_streamMaxLogFileSize = 0;
+ SaUint32T i_streamFixedLogRecordSize = 0;
SaUint32T i_logMaxLogrecsize = 0;
lgs_stream_defval_t *stream_default;
@@ -1117,77 +1130,98 @@ static bool chk_max_filesize_recordsize_
LOG_ER("448 %s stream == NULL", __FUNCTION__);
osafassert(0);
}
- if (fixedLogRecordSize_mod == false) {
- /* fixedLogRecordSize is not given. Get from stream */
- i_fixedLogRecordSize = stream->fixedLogRecordSize;
- TRACE("\t448 Get from stream, fixedLogRecordSize = %d",
- i_fixedLogRecordSize);
+ if (streamFixedLogRecordSize_mod == false) {
+ /* streamFixedLogRecordSize is not given. Get from
stream */
+ i_streamFixedLogRecordSize = stream->fixedLogRecordSize;
+ TRACE("\t448 Get from stream, streamFixedLogRecordSize
= %d",
+ i_streamFixedLogRecordSize);
} else {
- i_fixedLogRecordSize = fixedLogRecordSize;
+ i_streamFixedLogRecordSize = streamFixedLogRecordSize;
}
- if (maxLogFileSize_mod == false) {
- /* maxLogFileSize is not given. Get from stream */
- i_maxLogFileSize = stream->maxLogFileSize;
- TRACE("\t448 Get from stream, maxLogFileSize = %lld",
- i_maxLogFileSize);
+ if (streamMaxLogFileSize_mod == false) {
+ /* streamMaxLogFileSize is not given. Get from stream */
+ i_streamMaxLogFileSize = stream->maxLogFileSize;
+ TRACE("\t448 Get from stream, streamMaxLogFileSize =
%lld",
+ i_streamMaxLogFileSize);
} else {
- i_maxLogFileSize = maxLogFileSize;
- TRACE("\t448 Modified maxLogFileSize = %lld",
i_maxLogFileSize);
+ i_streamMaxLogFileSize = streamMaxLogFileSize;
+ TRACE("\t448 Modified streamMaxLogFileSize = %lld",
i_streamMaxLogFileSize);
}
} else if (operationType == CCBUTIL_CREATE) {
TRACE("\t448 operationType == CCBUTIL_CREATE");
/* The stream does not yet exist
*/
- if (fixedLogRecordSize_mod == false) {
- /* fixedLogRecordSize is not given. Use default */
- i_fixedLogRecordSize =
stream_default->saLogStreamFixedLogRecordSize;
- TRACE("\t448 Get default, fixedLogRecordSize = %d",
- i_fixedLogRecordSize);
+ if (streamFixedLogRecordSize_mod == false) {
+ /* streamFixedLogRecordSize is not given. Use default */
+ i_streamFixedLogRecordSize =
stream_default->saLogStreamFixedLogRecordSize;
+ TRACE("\t448 Get default, streamFixedLogRecordSize =
%d",
+ i_streamFixedLogRecordSize);
} else {
- i_fixedLogRecordSize = fixedLogRecordSize;
+ i_streamFixedLogRecordSize = streamFixedLogRecordSize;
}
- if (maxLogFileSize_mod == false) {
- /* maxLogFileSize is not given. Use default */
- i_maxLogFileSize =
stream_default->saLogStreamMaxLogFileSize;
- TRACE("\t448 Get default, maxLogFileSize = %lld",
- i_maxLogFileSize);
+ if (streamMaxLogFileSize_mod == false) {
+ /* streamMaxLogFileSize is not given. Use default */
+ i_streamMaxLogFileSize =
stream_default->saLogStreamMaxLogFileSize;
+ TRACE("\t448 Get default, streamMaxLogFileSize = %lld",
+ i_streamMaxLogFileSize);
} else {
- i_maxLogFileSize = maxLogFileSize;
+ i_streamMaxLogFileSize = streamMaxLogFileSize;
}
} else {
/* Unknown operationType */
LOG_ER("%s Unknown operationType", __FUNCTION__);
osafassert(0);
}
-
- /** Do the verification **/
- if (i_maxLogFileSize <= i_logMaxLogrecsize) {
- /* maxLogFileSize must be bigger than logMaxLogrecsize */
- report_oi_error(immOiHandle, ccbId,
- "maxLogFileSize out of range");
- TRACE("\t448 i_maxLogFileSize (%lld) <= i_logMaxLogrecsize
(%d)",
- i_maxLogFileSize, i_logMaxLogrecsize);
- rc = false;
- } else if (i_fixedLogRecordSize == 0) {
- /* fixedLogRecordSize can be 0. Means variable record size */
- TRACE("\t448 fixedLogRecordSize = 0");
- rc = true;
- } else if (i_fixedLogRecordSize >= i_maxLogFileSize) {
- /* fixedLogRecordSize must be less than maxLogFileSize */
- report_oi_error(immOiHandle, ccbId,
- "fixedLogRecordSize out of range");
- TRACE("\t448 i_fixedLogRecordSize >= i_maxLogFileSize");
- rc = false;
- } else if (i_fixedLogRecordSize > i_logMaxLogrecsize) {
- /* fixedLogRecordSize must be less than maxLogFileSize */
- report_oi_error(immOiHandle, ccbId,
- "fixedLogRecordSize out of range");
- TRACE("\t448 i_fixedLogRecordSize > i_logMaxLogrecsize");
- rc = false;
+
+
+ /*
+ * Do verification
+ */
+ if (streamMaxLogFileSize_mod == true) {
+ if (i_streamMaxLogFileSize <= i_logMaxLogrecsize) {
+ /* streamMaxLogFileSize must be bigger than
logMaxLogrecsize */
+ report_oi_error(immOiHandle, ccbId,
+ "streamMaxLogFileSize
out of range");
+ TRACE("\t448 i_streamMaxLogFileSize (%lld) <=
i_logMaxLogrecsize (%d)",
+ i_streamMaxLogFileSize, i_logMaxLogrecsize);
+ rc = false;
+ goto done;
+ } else if (i_streamMaxLogFileSize <=
i_streamFixedLogRecordSize) {
+ /* streamMaxLogFileSize must be bigger than
streamFixedLogRecordSize */
+ report_oi_error(immOiHandle, ccbId,
+ "streamMaxLogFileSize
out of range");
+ TRACE("\t448 i_streamMaxLogFileSize (%lld) <=
i_streamFixedLogRecordSize (%d)",
+ i_streamMaxLogFileSize,
i_streamFixedLogRecordSize);
+ rc = false;
+ goto done;
+ }
}
-
+
+ if (streamFixedLogRecordSize_mod == true) {
+ if (i_streamFixedLogRecordSize == 0) {
+ /* streamFixedLogRecordSize can be 0. Means variable
record size */
+ TRACE("\t448 streamFixedLogRecordSize = 0");
+ rc = true;
+ } else if (i_streamFixedLogRecordSize >=
i_streamMaxLogFileSize) {
+ /* streamFixedLogRecordSize must be less than
streamMaxLogFileSize */
+ report_oi_error(immOiHandle, ccbId,
+
"streamFixedLogRecordSize out of range");
+ TRACE("\t448 i_streamFixedLogRecordSize (%d) >=
i_streamMaxLogFileSize (%lld)",
+ i_streamFixedLogRecordSize,
i_streamMaxLogFileSize);
+ rc = false;
+ } else if (i_streamFixedLogRecordSize > i_logMaxLogrecsize) {
+ /* streamFixedLogRecordSize must be less than
streamMaxLogFileSize */
+ report_oi_error(immOiHandle, ccbId,
+
"streamFixedLogRecordSize out of range");
+ TRACE("\t448 i_streamFixedLogRecordSize (%d) >
i_logMaxLogrecsize (%d)",
+ i_streamFixedLogRecordSize,
i_logMaxLogrecsize);
+ rc = false;
+ }
+ }
+
+done:
TRACE_LEAVE2("448 rc = %d", rc);
return rc;
}
@@ -1218,10 +1252,10 @@ static SaAisErrorT check_attr_validity(S
char *i_pathName = NULL;
bool i_pathName_mod = false;
/* Modification flag -> true if modified */
- SaUint32T i_fixedLogRecordSize = 0;
- bool i_fixedLogRecordSize_mod = false;
- SaUint64T i_maxLogFileSize = 0;
- bool i_maxLogFileSize_mod = false;
+ SaUint32T i_streamFixedLogRecordSize = 0;
+ bool i_streamFixedLogRecordSize_mod = false;
+ SaUint64T i_streamMaxLogFileSize = 0;
+ bool i_streamMaxLogFileSize_mod = false;
SaUint32T i_logFullAction = 0;
bool i_logFullAction_mod = false;
char *i_logFileFormat = NULL;
@@ -1322,16 +1356,16 @@ static SaAisErrorT check_attr_validity(S
/* Save and compare with FixedLogRecordSize after all
attributes
* are read. Must be bigger than FixedLogRecordSize
*/
- i_maxLogFileSize = *((SaUint64T *) value);
- i_maxLogFileSize_mod = true;
+ i_streamMaxLogFileSize = *((SaUint64T *) value);
+ i_streamMaxLogFileSize_mod = true;
TRACE("\t448 Saved attribute \"%s\"",
attribute->attrName);
} else if (!strcmp(attribute->attrName,
"saLogStreamFixedLogRecordSize")) {
/* Save and compare with MaxLogFileSize after all
attributes
* are read. Must be smaller than MaxLogFileSize
*/
- i_fixedLogRecordSize = *((SaUint64T *) value);
- i_fixedLogRecordSize_mod = true;
+ i_streamFixedLogRecordSize = *((SaUint64T *) value);
+ i_streamFixedLogRecordSize_mod = true;
TRACE("\t448 Saved attribute \"%s\"",
attribute->attrName);
} else if (!strcmp(attribute->attrName,
"saLogStreamLogFullAction")) {
@@ -1436,14 +1470,14 @@ static SaAisErrorT check_attr_validity(S
/* saLogStreamMaxLogFileSize or saLogStreamFixedLogRecordSize
* See chk_max_filesize_recordsize_compatible() for rules
*/
- if (i_maxLogFileSize_mod || i_fixedLogRecordSize_mod) {
+ if (i_streamMaxLogFileSize_mod ||
i_streamFixedLogRecordSize_mod) {
TRACE("\t448 Check saLogStreamMaxLogFileSize,"
" saLogStreamFixedLogRecordSize");
if (chk_max_filesize_recordsize_compatible(immOiHandle,
- i_maxLogFileSize,
- i_maxLogFileSize_mod,
- i_fixedLogRecordSize,
- i_fixedLogRecordSize_mod,
+ i_streamMaxLogFileSize,
+ i_streamMaxLogFileSize_mod,
+ i_streamFixedLogRecordSize,
+ i_streamFixedLogRecordSize_mod,
stream,
opdata->operationType,
opdata->ccbId) == false) {
@@ -1966,6 +2000,16 @@ static void config_ccb_apply_modify(cons
mailbox_lim_upd = true;
lgs_cfgupd_list_create(LOG_STREAM_APP_LOW_LIMIT,
uint32_str, &config_data);
+ } else if (!strcmp(attribute->attrName, LOG_MAX_LOGRECSIZE)) {
+ uint32_val = *(SaUint32T *) value;
+ snprintf(uint32_str, 20, "%u", uint32_val);
+ lgs_cfgupd_list_create(LOG_MAX_LOGRECSIZE,
+ uint32_str, &config_data);
+ } else if (!strcmp(attribute->attrName, LOG_FILE_IO_TIMEOUT)) {
+ uint32_val = *(SaUint32T *) value;
+ snprintf(uint32_str, 20, "%u", uint32_val);
+ lgs_cfgupd_list_create(LOG_FILE_IO_TIMEOUT,
+ uint32_str, &config_data);
}
attrMod = opdata->param.modify.attrMods[i++];
diff --git a/tests/logsv/logtest.c b/tests/logsv/logtest.c
--- a/tests/logsv/logtest.c
+++ b/tests/logsv/logtest.c
@@ -190,7 +190,7 @@ void init_logrootpath(void)
/**
- * Get attribute value in string from IMM
+ * Get attribute value from IMM
* @param inObjname Distinguished Name
* @param inAttr Attribute to search for value
* @param outNume The holder for the output for number data type attribute
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
@@ -28,6 +28,24 @@
#define opensaf_user "opensaf"
#define data_group "log-data"
+/**
+ * Due to the ticket #1443, if creating/deleting conf obj class continuously,
+ * logsv will be crashed or deleting action gets failed.
+ *
+ * For now, until the ticket is fixed, adding some delay b/w creating/deleting
+ * as a workaround to avoid impact on testing that frequently encounter
+ * when running whole test suite in one go.
+ *
+ */
+
+/* Add delay 10ms. Once the #1443 is done, undefine following macro */
+#define __ADD_SLEEP__
+#ifdef __ADD_SLEEP__
+static void delay_ms(void) { usleep (10*1000); }
+#else
+static void delay_ms(void) {};
+#endif // __ADD_SLEEP__
+
static SaLogFileCreateAttributesT_2 appStreamLogFileCreateAttributes =
{
.logFilePathName = DEFAULT_APP_FILE_PATH_NAME,
@@ -1061,21 +1079,6 @@ void saLogOi_81(void)
}
/**
- * CCB Object Modify, logMaxLogrecsize. Not allowed
- * Result, Reject
- */
-void saLogOi_53(void)
-{
- int rc;
- char command[256];
-
- sprintf(command, "immcfg -a logMaxLogrecsize=%d "
- "logConfig=1,safApp=safLogService 2> /dev/null",1025);
- rc = system(command);
- rc_validate(WEXITSTATUS(rc), 1);
-}
-
-/**
* CCB Object Modify, logStreamSystemHighLimit > logStreamSystemLowLimit. OK
* Result OK
*/
@@ -1211,21 +1214,6 @@ void saLogOi_62(void)
}
/**
- * CCB Object Modify, logFileIoTimeout. Not allowed
- * Result, Reject
- */
-void saLogOi_63(void)
-{
- int rc;
- char command[256];
-
- sprintf(command, "immcfg -a logFileIoTimeout=%d"
- " logConfig=1,safApp=safLogService 2> /dev/null",600);
- rc = system(command);
- rc_validate(WEXITSTATUS(rc), 1);
-}
-
-/**
* CCB Object Modify, logFileSysConfig. Not allowed
* Result, Reject
*/
@@ -1281,6 +1269,7 @@ void saLogOi_65(void)
rc = system(command);
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
}
@@ -1335,6 +1324,7 @@ void saLogOi_68(void)
rc = system(command);
/* Delete the test object */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 1);
@@ -1356,6 +1346,7 @@ void saLogOi_69(void)
rc = system(command);
/* Delete the test object */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
@@ -1411,6 +1402,7 @@ void saLogOi_72(void)
rc = system(command);
/* Delete the test object */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
}
@@ -1437,6 +1429,7 @@ void saLogOi_73(void)
/* Delete the test object */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
rc = tet_system(command);
if (rc != 0) {
fprintf(stderr, "%s Fail rc=%d\n", command, rc);
@@ -1468,6 +1461,7 @@ void saLogOi_74(void)
}
/* Delete the test object */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
rc = tet_system(command);
if (rc != 0) {
fprintf(stderr, "'%s' Fail rc=%d\n", command, rc);
@@ -1510,6 +1504,7 @@ void saLogOi_76(void)
rc = system(command);
/* Delete the test object */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
}
@@ -1587,6 +1582,7 @@ void saLogOi_100(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
@@ -1615,6 +1611,7 @@ void saLogOi_101(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 1);
@@ -1643,6 +1640,7 @@ void saLogOi_102(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 1);
@@ -1671,6 +1669,7 @@ void saLogOi_103(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 1);
@@ -1705,8 +1704,10 @@ void saLogOi_104(void)
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
sprintf(command,"immcfg -d safLgStrCfg=str6a,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
}
@@ -1733,6 +1734,7 @@ void saLogOi_105(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6a,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
@@ -1760,6 +1762,7 @@ void saLogOi_106(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
@@ -1788,6 +1791,7 @@ void saLogOi_107(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 1);
@@ -1816,6 +1820,7 @@ void saLogOi_108(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 1);
@@ -1844,6 +1849,7 @@ void saLogOi_109(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
@@ -1872,6 +1878,7 @@ void saLogOi_110(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
@@ -1900,6 +1907,7 @@ void saLogOi_111(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
@@ -1928,6 +1936,7 @@ void saLogOi_112(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 1);
@@ -1956,6 +1965,7 @@ void saLogOi_113(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 0);
@@ -1984,6 +1994,7 @@ void saLogOi_114(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 1);
@@ -2012,6 +2023,7 @@ void saLogOi_115(void)
rc = system(command);
/* Delete */
sprintf(command,"immcfg -d safLgStrCfg=str6,safApp=safLogService");
+ delay_ms();
safassert(system(command),0);
rc_validate(WEXITSTATUS(rc), 1);
@@ -2471,6 +2483,627 @@ void verDefaultLogFileFmt(void)
#undef MAX_LOGRECSIZE
+/**
+ * Add test cases for ticket #1288
+ * - logFileIoTimeout is changeable in runtime
+ * - logMaxLogrecsize is changeable in runtime
+ * - Max log record is up to 65535
+ */
+
+#define MAX_LOGRECSIZE (65535)
+
+/**
+ * CCB Object Modify, logFileIoTimeout.
+ * Verify it is possible to change the value
+ */
+void verLogFileIoTimeout(void)
+{
+ int rc;
+ char command[256];
+ uint32_t val = 0;
+ uint32_t *tmp = &val;
+
+ /* Get current value of logMaxApplicationStreams */
+ rc = get_attr_value(&configurationObject, "logFileIoTimeout",
+ (void **)&tmp, NULL);
+ if (rc == -1) {
+ /* if failed, use default value */
+ fprintf(stderr, "Failed to get attribute value from IMM \n");
+ val = 500;
+ } else {
+ val = *tmp;
+ }
+
+ sprintf(command, "immcfg -a logFileIoTimeout=%d"
+ " logConfig=1,safApp=safLogService 2> /dev/null", 600);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+
+ /* If perform the command succesfully, restore to previous value. */
+ if (WEXITSTATUS(rc) == 0) {
+ sprintf(command, "immcfg -a logFileIoTimeout=%u"
+ " logConfig=1,safApp=safLogService 2>
/dev/null", val);
+ rc = system(command);
+ }
+}
+
+/**
+ * CCB Object Modify, logFileIoTimeout < 500. Not allowed
+ * Result, Reject
+ */
+void verLogFileIoTimeout_Err_01(void)
+{
+ int rc;
+ char command[256];
+
+ sprintf(command, "immcfg -a logFileIoTimeout=%d"
+ " logConfig=1,safApp=safLogService 2> /dev/null", 400);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 1);
+}
+
+/**
+ * CCB Object Modify, logFileIoTimeout > 5000. Not allowed
+ * Result, Reject
+ */
+void verLogFileIoTimeout_Err_02(void)
+{
+ int rc;
+ char command[256];
+
+ sprintf(command, "immcfg -a logFileIoTimeout=%d"
+ " logConfig=1,safApp=safLogService 2> /dev/null", 6000);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 1);
+}
+
+/**
+ * CCB Object Modify, valid logMaxLogrecsize value is in range [256 - 65535].
+ */
+void verLogMaxLogrecsize(void)
+{
+ int rc;
+ char command[256];
+ uint32_t logMaxRec = 0;
+ uint32_t *tmp = &logMaxRec;
+
+ /* Get current value of the attribute, use default value if failed (-1) */
+ rc = get_attr_value(&configurationObject, "logMaxLogrecsize", (void
**)&tmp,
+ NULL);
+ if (rc == -1) {
+ /* Failed, use default one */
+ fprintf(stderr, "Failed to get attribute value from IMM\n");
+ logMaxRec = 1024;
+ } else {
+ logMaxRec = *tmp;
+ }
+
+ sprintf(command, "immcfg -a logMaxLogrecsize=%d "
+ "logConfig=1,safApp=safLogService 2> /dev/null",
MAX_LOGRECSIZE);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+
+ /* Restore logMaxLogrecsize to previous value */
+ sprintf(command, "immcfg -a logMaxLogrecsize=%d "
+ "logConfig=1,safApp=safLogService 2> /dev/null",
logMaxRec);
+ rc = system(command);
+}
+
+/**
+ * CCB Object Modify, verify the rule:
+ * saLogStreamMaxLogFileSize > logMaxLogrecsize >=
saLogStreamFixedLogRecordSize
+ */
+void verLogMaxLogrecsize_dep(void)
+{
+ int rc;
+ char command[256];
+ uint32_t logMaxRec = 0;
+ uint32_t *tmp = &logMaxRec;
+
+ /* Get current value of the attribute, use default value if failed (-1) */
+ rc = get_attr_value(&configurationObject, "logMaxLogrecsize", (void
**)&tmp,
+ NULL);
+ if (rc == -1) {
+ /* Failed, use default one */
+ fprintf(stderr, "Failed to get attribute value from IMM\n");
+ logMaxRec = 1024;
+ } else {
+ logMaxRec = *tmp;
+ }
+
+ /* Change the logMaxLogrecsize */
+ sprintf(command, "immcfg -a logMaxLogrecsize=%d "
+ "logConfig=1,safApp=safLogService 2> /dev/null", 1000);
+ rc = system(command);
+ if (WEXITSTATUS(rc)) {
+ /* Failed to perform command. Report test failed */
+ fprintf(stderr, "Failed to perfom command - %s \n", command);
+ rc_validate(WEXITSTATUS(rc), 0);
+ return;
+ }
+
+ /* Create an stream with valid values */
+ sprintf(command, "immcfg -c SaLogStreamConfig
safLgStrCfg=Test,safApp=safLogService"
+ " -a saLogStreamFileName=Test -a
saLogStreamPathName=Test"
+ " -a saLogStreamFixedLogRecordSize=1000 "
+ " -a saLogStreamMaxLogFileSize=5000");
+ rc = system(command);
+ if (WEXITSTATUS(rc)) {
+ /* Failed to perform command. Report test failed */
+ fprintf(stderr, "Failed to perfom command - %s \n", command);
+ rc_validate(WEXITSTATUS(rc), 0);
+ goto done;
+ }
+
+ /* Change the logMaxLogrecsize to value less than above
fixedLogRecordSize */
+ sprintf(command, "immcfg -a logMaxLogrecsize=%d "
+ "logConfig=1,safApp=safLogService 2> /dev/null", 500);
+ rc = system(command);
+ if (WEXITSTATUS(rc)) {
+ /* Failed to perform command. Report test failed */
+ fprintf(stderr, "Failed to perfom command - %s \n", command);
+ rc_validate(WEXITSTATUS(rc), 0);
+ goto free_class;
+ }
+
+ /*
+ * Change the saLogStreamMaxLogFileSize to valid value.
+ * Verify that the command performs succesfully.
+ */
+ sprintf(command, "immcfg -a saLogStreamMaxLogFileSize=%d "
+ "safLgStrCfg=Test,safApp=safLogService 2> /dev/null",
6000);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+
+free_class:
+ /* Delete created obj class */
+ sprintf(command, "immcfg -d safLgStrCfg=Test,safApp=safLogService "
+ "2> /dev/null");
+ rc = system(command);
+
+done:
+ /* Restore logMaxLogrecsize to previous value */
+ sprintf(command, "immcfg -a logMaxLogrecsize=%d "
+ "logConfig=1,safApp=safLogService 2> /dev/null",
logMaxRec);
+ rc = system(command);
+}
+
+/**
+ * CCB Object Modify, logMaxLogrecsize < 256. Not allowed.
+ */
+void verLogMaxLogrecsize_Err_01(void)
+{
+ int rc;
+ char command[256];
+
+ sprintf(command, "immcfg -a logMaxLogrecsize=%d "
+ "logConfig=1,safApp=safLogService 2> /dev/null", 255);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 1);
+}
+
+/**
+ * CCB Object Modify, logMaxLogrecsize > 65535. Not allowed.
+ */
+void verLogMaxLogrecsize_Err_02(void)
+{
+ int rc;
+ char command[256];
+
+ sprintf(command, "immcfg -a logMaxLogrecsize=%d "
+ "logConfig=1,safApp=safLogService 2> /dev/null",
MAX_LOGRECSIZE + 1);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 1);
+}
+
+/**
+ * Also add test cases to verify the rules:
+ * ---------------------------------------
+ * 1 - saLogStreamFixedLogRecordSize must be less than
saLogStreamMaxLogFileSize
+ * 2 - saLogStreamFixedLogRecordSize must be less than or equal to
logMaxLogrecsize
+ * 3 - saLogStreamFixedLogRecordSize can be 0. Means variable record size
+ * 4 - saLogStreamMaxLogFileSize must be bigger than 0. No limit is not
supported
+ * 5 - saLogStreamMaxLogFileSize must be bigger than logMaxLogrecsize
+ * 6 - saLogStreamMaxLogFileSize must be bigger than
saLogStreamFixedLogRecordSize
+ * ----------------------------------------
+ *
+ * For rules #2, #3, #5, test cases are already added above.
+ */
+
+/**
+ * CCB Object modify, verify rule #1/#6
+ * saLogStreamFixedLogRecordSize < saLogStreamMaxLogFileSize. Allowed.
+ */
+void verFixLogRec_MaxFileSize(void)
+{
+ int rc;
+ char command[256];
+ uint32_t fixLogRec = 0;
+ uint32_t *tmpFix = &fixLogRec;
+ uint32_t maxFileSize = 0;
+ uint32_t *tmpMax = &maxFileSize;
+ uint32_t logMaxRec = 0;
+ uint32_t *tmp = &logMaxRec;
+
+ /* Get current value of logMaxLogrecsize attribute, use default value if
failed (-1) */
+ rc = get_attr_value(&configurationObject, "logMaxLogrecsize", (void
**)&tmp,
+ NULL);
+ if (rc == -1) {
+ /* Failed, use default one */
+ fprintf(stderr, "Failed to get attribute value from IMM\n");
+ logMaxRec = 1024;
+ } else {
+ logMaxRec = *tmp;
+ }
+
+ /* Get current value of saLogStreamFixedLogRecordSize */
+ rc = get_attr_value(&alarmStreamName, "saLogStreamFixedLogRecordSize",
+ (void **)&tmpFix, NULL);
+ if (rc == -1) {
+ /* Report test failed and exit if getting value failed */
+ fprintf(stderr, "Failed to get attribute value from IMM \n");
+ test_validate(rc, 0);
+ return;
+ }
+
+ /* Backup the current saLogStreamFixedLogRecordSize value */
+ fixLogRec = *tmpFix;
+
+ /* Get current value of saLogStreamMaxLogFileSize */
+ rc = get_attr_value(&alarmStreamName, "saLogStreamMaxLogFileSize",
+ (void **)&tmpMax, NULL);
+ if (rc == -1) {
+ /* Report test failed and exit if getting value failed */
+ fprintf(stderr, "Failed to get attribute value from IMM \n");
+ test_validate(rc, 0);
+ return;
+ }
+
+ /* Backup the current saLogStreamMaxLogFileSize value */
+ maxFileSize = *tmpMax;
+
+ /* Allow to set saLogStreamMaxLogFileSize >
saLogStreamFixedLogRecordSize */
+ sprintf(command, "immcfg -a saLogStreamMaxLogFileSize=%d "
+ "-a saLogStreamFixedLogRecordSize=%d %s 2> /dev/null",
+ logMaxRec + 1, logMaxRec, SA_LOG_STREAM_ALARM);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+
+ /* Restore the changed value */
+ if (WEXITSTATUS(rc) == 0) {
+ sprintf(command, "immcfg -a saLogStreamMaxLogFileSize=%d "
+ " -a saLogStreamFixedLogRecordSize=%d %s 2>
/dev/null",
+ maxFileSize, fixLogRec, SA_LOG_STREAM_ALARM);
+ rc = system(command);
+ }
+}
+
+/**
+ * CCB Object modify, verify rule #1/#6
+ * saLogStreamFixedLogRecordSize > saLogStreamMaxLogFileSize. Not allowed.
+ */
+void verFixLogRec_MaxFileSize_Err(void)
+{
+ int rc;
+ char command[256];
+ uint32_t fixLogRec = 0;
+ uint32_t *tmpFix = &fixLogRec;
+ uint32_t maxFileSize = 0;
+ uint32_t *tmpMax = &maxFileSize;
+
+ /* Get current value of saLogStreamFixedLogRecordSize */
+ rc = get_attr_value(&alarmStreamName, "saLogStreamFixedLogRecordSize",
+ (void **)&tmpFix, NULL);
+ if (rc == -1) {
+ /* Report test failed and exit if getting value failed */
+ fprintf(stderr, "Failed to get attribute value from IMM \n");
+ test_validate(rc, 0);
+ return;
+ }
+
+ /* Backup the current saLogStreamFixedLogRecordSize value */
+ fixLogRec = *tmpFix;
+
+ /* Get current value of saLogStreamMaxLogFileSize */
+ rc = get_attr_value(&alarmStreamName, "saLogStreamMaxLogFileSize",
+ (void **)&tmpMax, NULL);
+ if (rc == -1) {
+ /* Report test failed and exit if getting value failed */
+ fprintf(stderr, "Failed to get attribute value from IMM \n");
+ test_validate(rc, 0);
+ return;
+ }
+
+ /* Backup the current saLogStreamMaxLogFileSize value */
+ maxFileSize = *tmpMax;
+
+ /* Not allow to set saLogStreamMaxLogFileSize <
saLogStreamFixedLogRecordSize */
+ sprintf(command, "immcfg -a saLogStreamMaxLogFileSize=%d %s 2>
/dev/null",
+ fixLogRec - 1, SA_LOG_STREAM_ALARM);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 1);
+
+ /* Restore the changed value */
+ if (WEXITSTATUS(rc) == 0) {
+ sprintf(command, "immcfg -a saLogStreamMaxLogFileSize=%d %s 2>
/dev/null",
+ maxFileSize, SA_LOG_STREAM_ALARM);
+ rc = system(command);
+ }
+}
+
+/**
+ * CCB Object modify, verify rule #4
+ * saLogStreamMaxLogFileSize = 0. Not allowed.
+ */
+void verMaxLogFileSize_Err(void)
+{
+ int rc;
+ char command[256];
+ uint32_t val = 0;
+ uint32_t *tmp = &val;
+
+ /* Get current value of logMaxApplicationStreams */
+ rc = get_attr_value(&alarmStreamName, "saLogStreamMaxLogFileSize",
+ (void **)&tmp, NULL);
+ if (rc == -1) {
+ /* Report test failed and exit if getting value failed */
+ fprintf(stderr, "Failed to get attribute value from IMM \n");
+ test_validate(rc, 0);
+ return;
+ }
+
+ /* Backup the current value */
+ val = *tmp;
+
+ /* Allow to set saLogStreamMaxLogFileSize=0 */
+ sprintf(command, "immcfg -a saLogStreamMaxLogFileSize=0 %s 2>
/dev/null",
+ SA_LOG_STREAM_ALARM);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 1);
+
+ /* Restore the changed value */
+ if (WEXITSTATUS(rc) == 0) {
+ sprintf(command, "immcfg -a saLogStreamMaxLogFileSize=%d %s 2>
/dev/null",
+ val, SA_LOG_STREAM_ALARM);
+ rc = system(command);
+ }
+}
+
+/**
+ * Write a maximum log record to app stream.
+ * Then, verify if it is done succesfully or not.
+ *
+ * Steps:
+ *
+ * 1. Change the logMaxLogrecsize value to maximum one.
+ * 2. Create application stream with saLogStreamFixedLogRecordSize
+ * equal to logMaxLogrecsize (maximum value).
+ * 3. Create a log record buffer with 65535 bytes.
+ * 4. Using saflogger tool, writing that buffer to the created app stream.
+ * 5. Get file size of the app stream log file
+ * 6. Verify if the size of file is larger than 65535 bytes or not
+ * 7. Delete created app class
+ */
+
+void verMaxLogRecord_01(void)
+{
+ int rc;
+ char command[66000];
+ char logRecord[MAX_LOGRECSIZE];
+ uint32_t logMaxRec = 0;
+ uint32_t *tmp = &logMaxRec;
+
+ /* Get current value of the attribute, use default value if failed (-1) */
+ rc = get_attr_value(&configurationObject, "logMaxLogrecsize", (void
**)&tmp,
+ NULL);
+ if (rc == -1) {
+ /* Failed, use default one */
+ fprintf(stderr, "Failed to get attribute value from IMM\n");
+ logMaxRec = 1024;
+ } else {
+ logMaxRec = *tmp;
+ }
+
+ /* Change the attribute value to maximum one */
+ sprintf(command, "immcfg -a logMaxLogrecsize=%u"
+ " logConfig=1,safApp=safLogService 2> /dev/null",
MAX_LOGRECSIZE);
+
+ rc = system(command);
+ if (WEXITSTATUS(rc)) {
+ /* Failed to set logMaxLogrecsize. Report test failed */
+ fprintf(stderr, "Failed to perform command = %s\n", command);
+ rc_validate(WEXITSTATUS(rc), 0);
+ return;
+ }
+
+ /* Set saLogStreamFixedLogRecordSize = 0, fix log record =
maxLogRecordSize */
+ sprintf(command, "immcfg -c SaLogStreamConfig
safLgStrCfg=maxrecsize,safApp=safLogService"
+ " -a saLogStreamFileName=verMaxLogrecsize -a
saLogStreamPathName=vermaxsize"
+ " -a saLogStreamFixedLogRecordSize=0");
+
+ rc = system(command);
+ if (WEXITSTATUS(rc)) {
+ /* Fail to perform the command. Report TC failed */
+ fprintf(stderr, "Failed to perform command = %s", command);
+ rc_validate(WEXITSTATUS(rc), 0);
+ goto done;
+ }
+
+ /* Prepare log record data */
+ memset(logRecord, 'A', MAX_LOGRECSIZE - 2);
+ logRecord[MAX_LOGRECSIZE - 1] = '\0';
+
+ sprintf(command, "saflogger -a
safLgStrCfg=maxrecsize,safApp=safLogService \"%s\"",
+ logRecord);
+
+ rc = system(command);
+ if (WEXITSTATUS(rc)) {
+ /* Fail to perform command. Report test failed. */
+ fprintf(stderr, "Failed to perform command = %s\n", command);
+ rc_validate(WEXITSTATUS(rc), 0);
+ goto free_class;
+ }
+ /* Write log record succesfully. Then, measure the log file size. */
+ FILE *fp = NULL;
+ char fileSize_c[10];
+ uint32_t fileSize = 0;
+
+ /* Command to get exact app stream log file, and measure that file
size. */
+ sprintf(command, "find %s/vermaxsize -type f -mmin -1 "
+ "| egrep \"%s_([0-9]{8}_[0-9]{6}\\.log$)\" "
+ "| xargs wc -c | awk '{printf $1}'",
+ log_root_path, "verMaxLogrecsize");
+
+ fp = popen(command, "r");
+
+ if (fp == NULL) {
+ /* Fail to read size of log file. Report test failed. */
+ fprintf(stderr, "Failed to run command = %s\n", command);
+ test_validate(1, 0);
+ goto free_class;
+ }
+ /* Get output of the command - actually the file size in chars */
+ while (fgets(fileSize_c, sizeof(fileSize_c) - 1, fp) != NULL) {};
+ pclose(fp);
+
+ /* Convert chars to number */
+ fileSize = atoi(fileSize_c);
+
+ if (fileSize < MAX_LOGRECSIZE) {
+ fprintf(stderr, "Log file size (%u) is less than %d \n",
+ fileSize, MAX_LOGRECSIZE);
+ test_validate(fileSize, MAX_LOGRECSIZE);
+ goto free_class;
+ } else {
+ rc_validate(WEXITSTATUS(rc), 0);
+ }
+
+free_class:
+ /* Delete class created */
+ (void)strcpy(command, "immcfg -d
safLgStrCfg=maxrecsize,safApp=safLogService");
+ rc = system(command);
+
+done:
+ /* Restore logMaxLogrecsize to previous value */
+ sprintf(command, "immcfg -a logMaxLogrecsize=%d "
+ "logConfig=1,safApp=safLogService 2> /dev/null",
logMaxRec);
+ rc = system(command);
+}
+
+/**
+ * Write a log record containing special characters.
+ * Make sure the logsv functions normally.
+ */
+void verMaxLogRecord_02(void)
+{
+ int rc;
+ char command[66000];
+ char logRecord[MAX_LOGRECSIZE];
+ uint32_t logMaxRec = 0;
+ uint32_t *tmp = &logMaxRec;
+
+ /* Get current value of the attribute, use default value if failed (-1) */
+ rc = get_attr_value(&configurationObject, "logMaxLogrecsize", (void
**)&tmp,
+ NULL);
+ if (rc == -1) {
+ /* Failed, use default one */
+ fprintf(stderr, "Failed to get attribute value from IMM\n");
+ logMaxRec = 1024;
+ } else {
+ logMaxRec = *tmp;
+ }
+
+ /* Change the attribute value to maximum one */
+ sprintf(command, "immcfg -a logMaxLogrecsize=%u"
+ " logConfig=1,safApp=safLogService 2> /dev/null",
MAX_LOGRECSIZE);
+
+ rc = system(command);
+ if (WEXITSTATUS(rc)) {
+ /* Failed to set logMaxLogrecsize. Report test failed */
+ fprintf(stderr, "Failed to perform command = %s\n", command);
+ rc_validate(WEXITSTATUS(rc), 0);
+ return;
+ }
+ /* Set saLogStreamFixedLogRecordSize = max */
+ sprintf(command, "immcfg -c SaLogStreamConfig
safLgStrCfg=specialCharactor,safApp=safLogService"
+ " -a saLogStreamFileName=specialCharactor -a
saLogStreamPathName=vermaxsize"
+ " -a saLogStreamFixedLogRecordSize=%d", MAX_LOGRECSIZE);
+
+ rc = system(command);
+ if (WEXITSTATUS(rc)) {
+ /* Fail to perform the command. Report TC failed */
+ fprintf(stderr, "Failed to perform command = %s", command);
+ rc_validate(WEXITSTATUS(rc), 0);
+ goto done;
+ }
+
+ /* Prepare log record data with special characters */
+ memset(logRecord, 'A', MAX_LOGRECSIZE - 2);
+ logRecord[1] = '\t';
+ logRecord[2] = 't';
+ logRecord[3] = '\n';
+ logRecord[4] = 'n';
+ logRecord[5] = ' ';
+ logRecord[6] = 'S';
+ logRecord[MAX_LOGRECSIZE - 1] = '\0';
+
+ sprintf(command, "saflogger -a
safLgStrCfg=specialCharactor,safApp=safLogService \"%s\"",
+ logRecord);
+
+ rc = system(command);
+ if (WEXITSTATUS(rc)) {
+ /* Fail to perform command. Report test failed. */
+ fprintf(stderr, "Failed to perform command = %s\n", command);
+ rc_validate(WEXITSTATUS(rc), 0);
+ goto free_class;
+ }
+ /* Write log record succesfully. Then, measure the log file size. */
+ FILE *fp = NULL;
+ char fileSize_c[10];
+ uint32_t fileSize = 0;
+
+ /* Command to get exact app stream log file, and measure that file
size. */
+ sprintf(command, "find %s/vermaxsize -type f -mmin -1 "
+ "| egrep \"%s_([0-9]{8}_[0-9]{6}\\.log$)\" "
+ "| xargs wc -c | awk '{printf $1}'",
+ log_root_path, "specialCharactor");
+
+ fp = popen(command, "r");
+
+ if (fp == NULL) {
+ /* Fail to read size of log file. Report test failed. */
+ fprintf(stderr, "Failed to run command = %s\n", command);
+ test_validate(1, 0);
+ goto free_class;
+ }
+ /* Get output of the command - actually the file size in chars */
+ while (fgets(fileSize_c, sizeof(fileSize_c) - 1, fp) != NULL) {};
+ pclose(fp);
+
+ /* Convert chars to number */
+ fileSize = atoi(fileSize_c);
+
+ if (fileSize < MAX_LOGRECSIZE) {
+ fprintf(stderr, "Log file size (%u) is less than %d \n",
+ fileSize, MAX_LOGRECSIZE);
+ test_validate(fileSize, MAX_LOGRECSIZE);
+ goto free_class;
+ } else {
+ rc_validate(WEXITSTATUS(rc), 0);
+ }
+
+free_class:
+ /* Delete class created */
+ (void)strcpy(command, "immcfg -d
safLgStrCfg=specialCharactor,safApp=safLogService");
+ rc = system(command);
+
+done:
+ /* Restore logMaxLogrecsize to previous value */
+ sprintf(command, "immcfg -a logMaxLogrecsize=%d "
+ "logConfig=1,safApp=safLogService 2> /dev/null",
logMaxRec);
+ rc = system(command);
+}
+
__attribute__ ((constructor)) static void saOiOperations_constructor(void)
{
/* Stream objects */
@@ -2546,7 +3179,6 @@ void verDefaultLogFileFmt(void)
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");
- test_case_add(5, saLogOi_53, "CCB Object Modify, logMaxLogrecsize. Not
allowed");
test_case_add(5, saLogOi_54, "CCB Object Modify, logStreamSystemHighLimit
> logStreamSystemLowLimit. OK");
test_case_add(5, saLogOi_55, "CCB Object Modify, logStreamSystemHighLimit
= logStreamSystemLowLimit, != 0. Ok");
test_case_add(5, saLogOi_56, "CCB Object Modify, logStreamSystemHighLimit
< logStreamSystemLowLimit. Error");
@@ -2556,9 +3188,17 @@ void verDefaultLogFileFmt(void)
test_case_add(5, saLogOi_60, "CCB Object Modify, logStreamAppHighLimit <
logStreamAppLowLimit. Error");
test_case_add(5, saLogOi_61, "CCB Object Modify, logStreamAppHighLimit =
logStreamAppLowLimit = 0. OK");
test_case_add(5, saLogOi_62, "CCB Object Modify, logMaxApplicationStreams.
Not allowed");
- test_case_add(5, saLogOi_63, "CCB Object Modify, logFileIoTimeout. Not
allowed");
test_case_add(5, saLogOi_64, "CCB Object Modify, logFileSysConfig. Not
allowed");
-
+
+ /* Add test cases to test #1288 */
+ test_case_add(5, verLogFileIoTimeout, "CCB Object Modify:
logFileIoTimeout is in range [500 - 5000], OK");
+ test_case_add(5, verLogFileIoTimeout_Err_01, "CCB Object Modify:
logFileIoTimeout < 500, ERR");
+ test_case_add(5, verLogFileIoTimeout_Err_02, "CCB Object Modify:
logFileIoTimeout > 5000, ERR");
+ test_case_add(5, verLogMaxLogrecsize, "CCB Object Modify:
logMaxLogrecsize is in range [256 - 65535], OK");
+ test_case_add(5, verLogMaxLogrecsize_dep, "CCB Object Modify:
logMaxLogrecsize dependencies, OK");
+ test_case_add(5, verLogMaxLogrecsize_Err_01, "CCB Object Modify:
logMaxLogrecsize < 256, ERR");
+ test_case_add(5, verLogMaxLogrecsize_Err_02, "CCB Object Modify:
logMaxLogrecsize > 65535, ERR");
+
/* Stream configuration object */
/* Tests for create */
test_suite_add(6, "LOG OI tests, Stream configuration object attribute
validation");
@@ -2586,6 +3226,9 @@ void verDefaultLogFileFmt(void)
test_case_add(6, saLogOi_106, "Modify: saLogStreamMaxLogFileSize >
logMaxLogrecsize, Ok");
test_case_add(6, saLogOi_107, "Modify: saLogStreamMaxLogFileSize ==
logMaxLogrecsize, ERR");
test_case_add(6, saLogOi_108, "Modify: saLogStreamMaxLogFileSize <
logMaxLogrecsize, ERR");
+ test_case_add(6, verFixLogRec_MaxFileSize, "Modify:
saLogStreamMaxLogFileSize > saLogStreamFixedLogRecordSize, OK");
+ test_case_add(6, verFixLogRec_MaxFileSize_Err, "Modify:
saLogStreamMaxLogFileSize <= saLogStreamFixedLogRecordSize, ERR");
+ test_case_add(6, verMaxLogFileSize_Err, "Modify:
saLogStreamMaxLogFileSize == 0, ERR");
test_case_add(6, saLogOi_109, "Modify: saLogStreamFixedLogRecordSize <
logMaxLogrecsize, Ok");
test_case_add(6, saLogOi_110, "Modify: saLogStreamFixedLogRecordSize ==
0, Ok");
test_case_add(6, saLogOi_111, "Modify: saLogStreamFixedLogRecordSize ==
logMaxLogrecsize, Ok");
@@ -2593,4 +3236,9 @@ void verDefaultLogFileFmt(void)
test_case_add(6, saLogOi_113, "Modify: saLogStreamMaxFilesRotated <
128, Ok");
test_case_add(6, saLogOi_114, "Modify: saLogStreamMaxFilesRotated >
128, ERR");
test_case_add(6, saLogOi_115, "Modify: saLogStreamMaxFilesRotated ==
128, ERR");
+
+ /* Add test cases to test #1288 */
+ test_case_add(6, verMaxLogRecord_01, "Modify:
saLogStreamFixedLogRecordSize == 0, write a record = 65535 bytes, OK");
+ test_case_add(6, verMaxLogRecord_02, "Modify:
saLogStreamFixedLogRecordSize == 65535, Write a record = 65535 bytes with
special characters, OK");
+
}
------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel