osaf/services/saf/logsv/lgs/lgs_imm.cc | 54 +++++++++++++++++++++++--------
tests/logsv/logtest.c | 2 +
tests/logsv/logtest.h | 1 +
tests/logsv/tet_Log_recov.c | 57 ++++++++++++++++++++++++++++++++++
4 files changed, 100 insertions(+), 14 deletions(-)
logsv supposed there were only three well-known config streams at logsv startup.
But this is not true when headless mode is enabled, so the stream id was
wrongly assigned to streams.
One more thing, with headless enabled, app streams can be found at startup
and app stream DN can be named not under `safApp=safLogService`.
So, searching config objects under the root `safApp=safLogService` could
miss the config app streams. e.g: app stream with DN "safLgStrCfg=Test"
This patch fix the problem and also add new test suite #12 to test
if created app stream can be deleted after headless.
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
@@ -144,6 +144,21 @@ static void report_om_error(SaImmOiHandl
}
/**
+ * Check to see if given DN is well-known stream or notE
+ *
+ * @param dn stream DN
+ * @ret true if well-known stream, false otherwise
+ */
+static bool is_well_know_stream(const char* dn)
+{
+ if (strcmp(dn, SA_LOG_STREAM_ALARM) == 0) return true;
+ if (strcmp(dn, SA_LOG_STREAM_NOTIFICATION) == 0) return true;
+ if (strcmp(dn, SA_LOG_STREAM_SYSTEM) == 0) return true;
+
+ return false;
+}
+
+/**
* Pack and send a log service config checkpoint using mbcsv
* @param stream
*
@@ -1694,7 +1709,11 @@ static SaAisErrorT stream_ccb_completed_
log_stream_t *stream = log_stream_get_by_name(name);
if (stream != NULL) {
- if (stream->streamId < 3) {
+ /**
+ * Use stream name (DN) to regcogize if the stream is
well-known or not
+ * instead of using streamID. This is to avoid any mishandling
on streamId.
+ */
+ if (is_well_know_stream(name)) {
report_oi_error(immOiHandle, opdata->ccbId,
"Stream delete: well known stream '%s'
cannot be deleted", name);
goto done;
@@ -2713,13 +2732,11 @@ SaAisErrorT lgs_imm_init_configStreams(l
SaImmSearchHandleT immSearchHandle;
SaImmSearchParametersT_2 objectSearch;
SaImmAttrValuesT_2 **attributes;
+ int wellknownStreamId = 0;
+ int appStreamId = 3;
int streamId = 0;
SaNameT objectName;
- SaNameT root_name;
-
- strcpy((char *) root_name.value, "safApp=safLogService");
- root_name.length = sizeof("safApp=safLogService");
-
+ const char *className = "SaLogStreamConfig";
TRACE_ENTER();
@@ -2735,27 +2752,36 @@ SaAisErrorT lgs_imm_init_configStreams(l
osaf_abort(0);
}
- /* Search for all objects of class "SaLogStreamConfig" */
- objectSearch.searchOneAttr.attrName =
const_cast<SaImmAttrNameT>("safLgStrCfg");
+ /* Search for all objects of class "SaLogStreamConfig". */
+ /* Should not base on the attribute name `safLgStrCfg` as the user can
create any class having that name */
+ objectSearch.searchOneAttr.attrName =
const_cast<SaImmAttrNameT>("SaImmAttrClassName");
objectSearch.searchOneAttr.attrValueType = SA_IMM_ATTR_SASTRINGT;
- objectSearch.searchOneAttr.attrValue = NULL;
-
- if ((om_rc = immutil_saImmOmSearchInitialize_2(omHandle, &root_name,
+ objectSearch.searchOneAttr.attrValue = &className;
+
+ /**
+ * Search from root as app stream DN name can be any - maybe not under
the RDN `safApp=safLogService`
+ * Therefore, searching all class under `safApp=safLogService` might
miss configurable app stream
+ * eg: app stream with DN `saLgStrCfg=test`
+ */
+ if ((om_rc = immutil_saImmOmSearchInitialize_2(omHandle, NULL,
SA_IMM_SUBTREE, SA_IMM_SEARCH_ONE_ATTR |
SA_IMM_SEARCH_GET_NO_ATTR,
&objectSearch, NULL, /* Get no attributes */
&immSearchHandle)) == SA_AIS_OK) {
while (immutil_saImmOmSearchNext_2(immSearchHandle,
&objectName, &attributes) == SA_AIS_OK) {
- /* Note: Here is creationTimeStamp and severityFilter
set
- * Can be recovered if scAbseceAllowed
+ /**
+ * With headless mode enabled, when lgsv restarts,
there could be other configurable app streams.
+ * It differs from legacy mode in which no app stream
could be exist at startup.
+ *
+ * With well-known streams, stream ID is in reserved
numbers [0-2].
*/
+ streamId = is_well_know_stream((char
*)objectName.value)? wellknownStreamId++:appStreamId++;
ais_rc = stream_create_and_configure((char*)
objectName.value,
&stream, streamId, accessorHandle);
if (ais_rc != SA_AIS_OK) {
LOG_WA("stream_create_and_configure failed %d",
ais_rc);
goto done;
}
- streamId += 1;
}
}
diff --git a/tests/logsv/logtest.c b/tests/logsv/logtest.c
--- a/tests/logsv/logtest.c
+++ b/tests/logsv/logtest.c
@@ -505,6 +505,7 @@ int main(int argc, char **argv)
add_suite_9();
add_suite_10();
add_suite_11();
+ add_suite_12();
test_list();
exit(0);
case 'e':
@@ -535,6 +536,7 @@ int main(int argc, char **argv)
add_suite_9();
add_suite_10();
add_suite_11();
+ add_suite_12();
break;
case 'v':
if (silent_flg == true) {
diff --git a/tests/logsv/logtest.h b/tests/logsv/logtest.h
--- a/tests/logsv/logtest.h
+++ b/tests/logsv/logtest.h
@@ -98,6 +98,7 @@ void print_t(const char *format, ...) __
void add_suite_9(void);
void add_suite_10(void);
void add_suite_11(void);
+void add_suite_12(void);
int get_active_sc(void);
int get_attr_value(SaNameT *inObjName, char *inAttr, void *outValue);
diff --git a/tests/logsv/tet_Log_recov.c b/tests/logsv/tet_Log_recov.c
--- a/tests/logsv/tet_Log_recov.c
+++ b/tests/logsv/tet_Log_recov.c
@@ -1901,6 +1901,50 @@ done:
rc = system(command);
}
+
+//>
+// For test suite #12
+//<
+/**
+ * Create 02 configurable app streams
+ */
+void saLogRecov_createCfgAppStreams()
+{
+ int rc;
+ char command[256];
+
+ /* DN under RDN safApp=safLogservice */
+ sprintf(command, "immcfg -c SaLogStreamConfig
safLgStrCfg=testCfgAppStream,safApp=safLogService "
+ "-a saLogStreamFileName=testCfgAppStream -a
saLogStreamPathName=suite12");
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+
+ /* DN not under safApp=safLogService */
+ sprintf(command, "immcfg -c SaLogStreamConfig
safLgStrCfg=testCfgAppStream1 "
+ "-a saLogStreamFileName=testCfgAppStream1 -a
saLogStreamPathName=suite12");
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+}
+
+/**
+ * Create 02 configurable app streams
+ */
+void saLogRecov_delCfgAppStreams()
+{
+ int rc;
+ char command[256];
+
+ /* DN under RDN safApp=safLogservice */
+ sprintf(command, "immcfg -d
safLgStrCfg=testCfgAppStream,safApp=safLogService ");
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+
+ /* DN not under safApp=safLogService */
+ sprintf(command, "immcfg -d safLgStrCfg=testCfgAppStream1");
+ rc = system(command);
+ rc_validate(WEXITSTATUS(rc), 0);
+}
+
/**
* Test suite 9
* Testing recovery of "runtime" app streams
@@ -1997,3 +2041,16 @@ void add_suite_11(void)
test_case_add(11, saLogRecov_req_node_start, ""); /* Start SC nodes */
test_case_add(11, saLogRecov_verRtStream_cleanup, "SC nodes started:
after 10 mins, the stream is cleanup, OK");
}
+
+/**
+ * Test suite 12
+ * Verify created configurable app streams can be deleted after headless.
+ */
+void add_suite_12(void)
+{
+ test_suite_add(12, "LOG Server down/up: verify app streams can be
deleted after headless");
+ test_case_add(12, saLogRecov_createCfgAppStreams, "Create 02
configurable app streams");
+ test_case_add(12, saLogRecov_req_node_stop, ""); /* Stop SC nodes */
+ test_case_add(12, saLogRecov_req_node_start, ""); /* Start SC nodes */
+ test_case_add(12, saLogRecov_delCfgAppStreams, "SC nodes started:
delete created app streams");
+}
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel