osaf/services/saf/logsv/lgs/lgs_imm.c | 47 ++++++----
tests/logsv/tet_LogOiOps.c | 141 ++++++++++++++++++++++++++++++++++
2 files changed, 170 insertions(+), 18 deletions(-)
At start up, `logStreamFileFormat` attribute in configuration obj has <empty>
value.
Means that, built-in file format will be used as default value for app stream.
If user sets an value to logStreamFileFormat, users can not delete the value of
this attribute.
This patch makes the attribute value can be deleted.
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
@@ -697,14 +697,19 @@ static SaAisErrorT config_ccb_completed_
TRACE("attribute %s", attribute->attrName);
- /* Ignore deletion of attributes except for logDataGroupname*/
+ /**
+ * Ignore deletion of attributes
+ * except for logDataGroupname,
+ * and logStreamFileFormat
+ */
if ((strcmp(attribute->attrName, LOG_DATA_GROUPNAME) != 0) &&
- (attribute->attrValuesNumber == 0)) {
- report_oi_error(immOiHandle, opdata->ccbId,
+ (strcmp(attribute->attrName, LOG_STREAM_FILE_FORMAT)
!= 0) &&
+ (attribute->attrValuesNumber == 0)) {
+ report_oi_error(immOiHandle, opdata->ccbId,
"deletion of value is not allowed for
attribute %s stream %s",
attribute->attrName,
opdata->objectName.value);
- ais_rc = SA_AIS_ERR_BAD_OPERATION;
- goto done;
+ ais_rc = SA_AIS_ERR_BAD_OPERATION;
+ goto done;
}
if (attribute->attrValuesNumber != 0) {
@@ -738,16 +743,19 @@ static SaAisErrorT config_ccb_completed_
TRACE("groupname: %s is accepted", groupname);
}
} else if (!strcmp(attribute->attrName,
LOG_STREAM_FILE_FORMAT)) {
- char *logFileFormat = *((char **) value);
- rc = lgs_cfg_verify_log_file_format(logFileFormat);
- 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;
+ if (attribute->attrValuesNumber == 0) {
+ TRACE("Delete logStreamFileFormat");
+ } else {
+ char *logFileFormat = *((char **) value);
+ rc =
lgs_cfg_verify_log_file_format(logFileFormat);
+ 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("logFileFormat: %s value is accepted",
logFileFormat);
}
- TRACE("logFileFormat: %s value is accepted",
logFileFormat);
- goto done;
} else if (!strcmp(attribute->attrName, LOG_MAX_LOGRECSIZE)) {
SaUint32T maxLogRecordSize = *((SaUint32T *)value);
rc = lgs_cfg_verify_max_logrecsize(maxLogRecordSize);
@@ -758,7 +766,6 @@ static SaAisErrorT config_ccb_completed_
goto done;
}
TRACE("maxLogRecordSize: %s is accepted",
attribute->attrName);
- goto done;
} else if (!strcmp(attribute->attrName,
LOG_STREAM_SYSTEM_HIGH_LIMIT)) {
vattr.logStreamSystemHighLimit = *((SaUint32T *)value);
vattr.logStreamSystemHighLimit_changed = true;
@@ -794,7 +801,6 @@ static SaAisErrorT config_ccb_completed_
goto done;
}
TRACE("logFileIoTimeout: %d value is accepted",
logFileIoTimeout);
- goto done;
} else if (!strcmp(attribute->attrName, LOG_FILE_SYS_CONFIG)) {
report_oi_error(immOiHandle, opdata->ccbId,
"%s cannot be changed",
attribute->attrName);
@@ -1946,11 +1952,16 @@ static void config_ccb_apply_modify(cons
lgs_cfgupd_list_create(LOG_DATA_GROUPNAME,
value_str, &config_data);
} else if (!strcmp(attribute->attrName,
LOG_STREAM_FILE_FORMAT)) {
+ if (value == NULL) {
+ /* Use built-in file format as default */
+ value_str = DEFAULT_APP_SYS_FORMAT_EXP;
+ } else {
+ value_str = *((char **)value);
+ }
/**
* This attribute value is used for default log file
format of
* app stream. Changing this value don't result in
cfg/log file creation.
- */
- value_str = *((char **)value);
+ */
lgs_cfgupd_list_create(LOG_STREAM_FILE_FORMAT,
value_str, &config_data);
} else if (!strcmp(attribute->attrName,
LOG_STREAM_SYSTEM_HIGH_LIMIT)) {
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
@@ -3128,6 +3128,140 @@ void verMaxFilesRotated(void)
rc_validate(WEXITSTATUS(rc), 1);
}
+/* Add test cases to test #1490 */
+
+/* Verify that logStreamFileFormat value is allowed to delete */
+void verLogStreamFileFormat(void)
+{
+ int rc;
+ char command[256];
+ char logFileFmt[256];
+ bool logFmtEmtpy = true;
+
+ /* Get current value of logStreamFileFormat attribute */
+ rc = get_attr_value(&configurationObject, "logStreamFileFormat", NULL,
+ logFileFmt);
+ if (rc != -1) {
+ logFmtEmtpy = false;
+ }
+
+ sprintf(command, "immcfg -a logStreamFileFormat= %s 2> /dev/null",
+ LOGTST_IMM_LOG_CONFIGURATION);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+
+ if ((logFmtEmtpy == false) && (WEXITSTATUS(rc) == 0)) {
+ /* The value is deleted. Restore it */
+ sprintf(command, "immcfg -a logStreamFileFormat=\"%s\" %s 2>
/dev/null",
+ logFileFmt, LOGTST_IMM_LOG_CONFIGURATION);
+ rc = system(command);
+ }
+}
+
+/* Verify that logDataGroupname value is allowed to delete */
+void verLogDataGroupName(void)
+{
+ int rc;
+ char command[256];
+ char logGroupName[256];
+ bool logGroupEmpty = true;
+
+ /* Get current value of logDataGroupname attribute */
+ rc = get_attr_value(&configurationObject, "logDataGroupname", NULL,
+ logGroupName);
+ if (rc != -1) {
+ logGroupEmpty = false;
+ }
+
+ sprintf(command, "immcfg -a logDataGroupname= %s",
+ LOGTST_IMM_LOG_CONFIGURATION);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+
+ if ((logGroupEmpty == false) && (WEXITSTATUS(rc) == 0)) {
+ /* The value is deleted. Restore it */
+ sprintf(command, "immcfg -a logDataGroupname=\"%s\" %s",
+ logGroupName, LOGTST_IMM_LOG_CONFIGURATION);
+ rc = system(command);
+ }
+}
+
+/* One CCB with valid attributes, Allowed */
+void verCCBWithValidValues(void)
+{
+ int rc;
+ char command[256];
+ uint32_t timeout = 500;
+ uint32_t *tmp_to = &timeout;
+ uint32_t maxRec = 0;
+ uint32_t *tmp_max = &maxRec;
+
+ /* Get current values of ttributes */
+ rc = get_attr_value(&configurationObject, "logFileIoTimeout",
(void**)&tmp_to,
+ NULL);
+ if (rc != -1) {
+ timeout = *tmp_to;
+ }
+
+ rc = get_attr_value(&configurationObject, "logMaxLogrecsize",
(void**)&tmp_max,
+ NULL);
+ if (rc != -1) {
+ maxRec = *tmp_max;
+ }
+
+ sprintf(command, "immcfg -a logFileIoTimeout=600 -a logMaxLogrecsize=2000
%s",
+ LOGTST_IMM_LOG_CONFIGURATION);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+
+ if (WEXITSTATUS(rc) == 0) {
+ /* Restore the values */
+ sprintf(command, "immcfg -a logFileIoTimeout=%d -a
logMaxLogrecsize=%d %s",
+ timeout,
+ maxRec,
+ LOGTST_IMM_LOG_CONFIGURATION);
+ rc = system(command);
+ }
+}
+
+/* One CCB with many valid attributes, but one of them invalid. Not Allowed */
+void verCCBWithInvalidValues(void)
+{
+ int rc;
+ char command[256];
+ uint32_t timeout = 500;
+ uint32_t *tmp_to = &timeout;
+ uint32_t maxRec = 0;
+ uint32_t *tmp_max = &maxRec;
+
+ /* Get current values of ttributes */
+ rc = get_attr_value(&configurationObject, "logFileIoTimeout",
(void**)&tmp_to,
+ NULL);
+ if (rc != -1) {
+ timeout = *tmp_to;
+ }
+
+ rc = get_attr_value(&configurationObject, "logMaxLogrecsize",
(void**)&tmp_max,
+ NULL);
+ if (rc != -1) {
+ maxRec = *tmp_max;
+ }
+
+ /* invalid value to logMaxLogrecsize */
+ sprintf(command, "immcfg -a logFileIoTimeout=600 -a
logMaxLogrecsize=800000 %s "
+ " 2> /dev/null ", LOGTST_IMM_LOG_CONFIGURATION);
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 1);
+
+ if (WEXITSTATUS(rc) == 0) {
+ /* Restore the values */
+ sprintf(command, "immcfg -a logFileIoTimeout=%d -a
logMaxLogrecsize=%d %s",
+ timeout,
+ maxRec,
+ LOGTST_IMM_LOG_CONFIGURATION);
+ rc = system(command);
+ }
+}
__attribute__ ((constructor)) static void saOiOperations_constructor(void)
{
@@ -3224,6 +3358,13 @@ void verMaxFilesRotated(void)
test_case_add(5, verLogMaxLogrecsize_Err_01, "CCB Object Modify:
logMaxLogrecsize < 150, ERR");
test_case_add(5, verLogMaxLogrecsize_Err_02, "CCB Object Modify:
logMaxLogrecsize > 65535, ERR");
+ /* Add test cases to test #1490 */
+ test_case_add(5, verLogStreamFileFormat, "CCB Object Modify: delete
logStreamFileFormat, OK");
+ test_case_add(5, verLogDataGroupName, "CCB Object Modify: delete
logDataGroupname, OK");
+ test_case_add(5, verCCBWithValidValues, "CCB Object Modify many
attributes with valid values, OK");
+ test_case_add(5, verCCBWithInvalidValues, "CCB Object Modify many
attributes with one invalid values, ERR");
+
+
/* Stream configuration object */
/* Tests for create */
test_suite_add(6, "LOG OI tests, Stream configuration object attribute
validation");
------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel