diff --git a/rsyslog/undefined_field/undefined_field_test.go b/rsyslog/undefined_field/undefined_field_test.go index ddce316e16..b29ead960e 100644 --- a/rsyslog/undefined_field/undefined_field_test.go +++ b/rsyslog/undefined_field/undefined_field_test.go @@ -188,6 +188,7 @@ func TestUndefinedMaxNumFields(t *testing.T) { var val1 float64 = 1111 var val2 float64 = 2222 undefined2Map := map[string]interface{}{ + "": "", "undefined2": "undefined2", "undefined22": val2, "undefined23": false, @@ -200,7 +201,10 @@ func TestUndefinedMaxNumFields(t *testing.T) { "undefined.6": "undefined6", } fieldlist = []string{"undefined1", "undefined11", "undefined12", "undefined2", "undefined.6"} - if err = checkFieldsEqual(t, undefinedMap, inputMap, fieldlist); err != nil { + if err := json.Unmarshal([]byte(undefString), &undefMap); err != nil { + t.Errorf("json.Unmarshal failed for undefString [%v]: %v", undefString, err) + } + if err = checkFieldsEqual(t, undefinedMap, undefMap, fieldlist); err != nil { t.Error(err) } } diff --git a/test/zzz-rsyslog.sh b/test/zzz-rsyslog.sh index f88c832721..a4bedce510 100755 --- a/test/zzz-rsyslog.sh +++ b/test/zzz-rsyslog.sh @@ -10,6 +10,8 @@ os::util::environment::use_sudo os::test::junit::declare_suite_start "test/zzz-rsyslog" pushd ${OS_O_A_L_DIR}/rsyslog/undefined_field > /dev/null +cp undefined_field.go $ARTIFACT_DIR || : +cp undefined_field_test.go $ARTIFACT_DIR || : go test -v 2>&1 | artifact_out popd > /dev/null @@ -46,6 +48,7 @@ cleanup() { set +e get_all_logging_pod_logs oc get cm rsyslog -o yaml > $ARTIFACT_DIR/rsyslog_configmap.yaml 2>&1 + oc get cm rsyslog-bin -o yaml > $ARTIFACT_DIR/rsyslog.sh 2>&1 if [ "deploy_using_ansible" = "$deployfunc" ] ; then if [ -n "${tmpinv:-}" -a -f "${tmpinv:-}" ] ; then rm -f $tmpinv @@ -61,6 +64,7 @@ cleanup() { start_fluentd true 2>&1 | artifact_out else rpod=$( get_running_pod rsyslog ) + oc exec $rpod -c rsyslog -- env > $ARTIFACT_DIR/rsyslog_env.txt 2>&1 || : oc exec $rpod -c rsyslog -- cat /var/log/rsyslog/rsyslog_debug.log > $ARTIFACT_DIR/rsyslog_debug.log 2>&1 || : oc get clusterlogging instance -o yaml > $ARTIFACT_DIR/clinstance.yaml 2>&1 oc describe deploy cluster-logging-operator > $ARTIFACT_DIR/deploy.clo.yaml 2>&1 @@ -175,6 +179,10 @@ else fi $deployfunc +# Set kubernetes to CDM_KEEP_EMPTY_FIELDS to keep "openshift_io/node-selector": "" in +# kubernetes.namespace_annotations.openshift_io/node-selector +oc set env $rsyslog_ds CDM_KEEP_EMPTY_FIELDS="kubernetes" +start_rsyslog sleep 10 wait_for_fluentd_to_catch_up get_logmessage get_logmessage2 @@ -237,6 +245,10 @@ os::cmd::expect_success_and_not_text "cat $ops | jq -r .hits.hits[0]._source.hos ts=$( cat $ops | jq -r '.hits.hits[0]._source."@timestamp"' ) os::cmd::expect_success "test ${ts} != null" +# Unset CDM_KEEP_EMPTY_FIELDS +oc set env $rsyslog_ds CDM_KEEP_EMPTY_FIELDS- +start_rsyslog + # see if the prometheus exporter is working rpod="$( get_running_pod rsyslog )" rpod_ip="$( oc get pod ${rpod} -o jsonpath='{.status.podIP}' )" @@ -365,8 +377,9 @@ os::cmd::try_until_success "oc exec $rpod -c rsyslog -- grep 'use_undefined:' /v artifact_log "1. default values" rpod=$( get_running_pod rsyslog ) # skipped empty by mmnormalize/parse_json_skip_empty; mmexternal won't be executed. -oc exec $rpod -c rsyslog -- ls -l /var/lib/rsyslog.pod/undefined.json | artifact_out || : -oc exec $rpod -c rsyslog -- cat /var/lib/rsyslog.pod/undefined.json | artifact_out || : +oc exec $rpod -c rsyslog -- env | artifact_out +oc exec $rpod -c rsyslog -- ls -l /var/lib/rsyslog.pod/undefined.json 2>&1 | artifact_out || : +oc exec $rpod -c rsyslog -- cat /var/lib/rsyslog.pod/undefined.json 2>&1 | artifact_out || : wait_for_fluentd_to_catch_up get_logmessage get_logmessage2 os::cmd::expect_success "cat $proj | python $OS_O_A_L_DIR/hack/testing/test-viaq-data-model.py test1" os::cmd::expect_success "cat $ops | python $OS_O_A_L_DIR/hack/testing/test-viaq-data-model.py test1"