Skip to content

Commit

Permalink
zzz-rsyslog.sh - Set kubernetes to CDM_KEEP_EMPTY_FIELDS to keep "ope…
Browse files Browse the repository at this point in the history
…nshift_io/node-selector": ""

in kubernetes.namespace_annotations.openshift_io/node-selector.

undefined_field_test.go - Check returned undefString from processUndefinedAndMaxNumFields against
the expected value.
  • Loading branch information
nhosoi committed Jul 22, 2019
1 parent 6ddbf31 commit 04e09fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 5 additions & 1 deletion rsyslog/undefined_field/undefined_field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}
}
17 changes: 15 additions & 2 deletions test/zzz-rsyslog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}' )"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 04e09fa

Please sign in to comment.