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