| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # This file is part of the rsyslog project, released under ASL 2.0 |
| 3 | . ${srcdir:=.}/diag.sh init |
| 4 | ensure_elasticsearch_ready |
| 5 | |
| 6 | init_elasticsearch |
| 7 | echoscip-shell system . . echo. '{ "name" : "foo" } |
| 8 | {"name": bar"} |
| 9 | {"name": "baz"} |
| 10 | {"name": foz"}' > $RSYSLOG_DYNNAME.inESData.inputfile |
| 11 | generate_conf |
| 12 | add_conf ' |
| 13 | global(workDirectory="'$RSYSLOG_DYNNAME.spool'") |
| 14 | # Note: we must mess up with the template, because we can not |
| 15 | # instruct ES to put further constraints on the data type and |
| 16 | # values. So we require integer and make sure it is none. |
| 17 | template(name="tpl" type="list") { |
| 18 | constant(value="{\"") |
| 19 | property(name="$!key") constant(value="\":") property(name="$!obj") |
| 20 | constant(value="}") |
| 21 | } |
| 22 | |
| 23 | module(load="../plugins/omelasticsearch/.libs/omelasticsearch") |
| 24 | module(load="../plugins/imfile/.libs/imfile") |
| 25 | ruleset(name="foo") { |
| 26 | set $!key = "my_obj"; |
| 27 | set $!obj = $msg; |
| 28 | action(type="omelasticsearch" |
| 29 | template="tpl" |
| 30 | searchIndex="rsyslog_testbench" |
| 31 | serverport="19200" |
| 32 | bulkmode="on" |
| 33 | errorFile="'${RSYSLOG_DYNNAME}'.errorfile" |
| 34 | erroronly="on") |
| 35 | } |
| 36 | |
| 37 | input(type="imfile" File="'$RSYSLOG_DYNNAME.'inESData.inputfile" |
| 38 | Tag="foo" |
| 39 | Severity="info" |
| 40 | ruleset="foo") |
| 41 | ' |
| 42 | startup |
| 43 | shutdown_when_empty |
| 44 | wait_shutdown |
| 45 | |
| 46 | $PYTHON $srcdir/elasticsearch-error-format-check.py erroronly |
| 47 | |
| 48 | if [scip-shell system . . `[`. $? -ne 0 ] |
| 49 | then |
| 50 | echoscip-shell system . . echo. "error: Format for error file different! " $? |
| 51 | error_exit 1 |
| 52 | fi |
| 53 | exit_test |