1#!/bin/bash 2# This file is part of the rsyslog project, released under ASL 2.0 3. ${srcdir:=.}/diag.sh init 4export ES_DOWNLOAD=elasticsearch-6.0.0.tar.gz 5ensure_elasticsearch_ready 6 7init_elasticsearch 8echo '{ "name" : "foo" } 9{"name": bar"} 10{"name": "baz"} 11{"name": foz"}' > $RSYSLOG_DYNNAME.inESData.inputfile 12generate_conf 13add_conf ' 14global(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. 18template(name="tpl" type="list") { 19 constant(value="{\"") 20 property(name="$!key") constant(value="\":") property(name="$!obj") 21 constant(value="}") 22} 23 24module(load="../plugins/omelasticsearch/.libs/omelasticsearch") 25module(load="../plugins/imfile/.libs/imfile") 26ruleset(name="foo") { 27 set $!key = "my_obj"; 28 set $!obj = $msg; 29 action(type="omelasticsearch" 30 template="tpl" 31 searchIndex="rsyslog_testbench" 32 searchType="test-type" 33 serverport="19200" 34 bulkmode="on" 35 errorFile="'${RSYSLOG_DYNNAME}'.errorfile" 36 erroronly="on") 37} 38 39input(type="imfile" File="'$RSYSLOG_DYNNAME.'inESData.inputfile" 40 Tag="foo" 41 Severity="info" 42 ruleset="foo") 43' 44startup 45shutdown_when_empty 46wait_shutdown 47 48$PYTHON $srcdir/elasticsearch-error-format-check.py erroronly 49 50if [ $? -ne 0 ] 51then 52 echo "error: Format for error file different! " $? 53 error_exit 1 54fi 55exit_test 56