-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5302 from n2yen/dev-omhttp-patches
omhttp patches and updates
- Loading branch information
Showing
11 changed files
with
548 additions
and
8 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
export USE_VALGRIND="YES" | ||
source ${srcdir:=.}/omhttp-basic-ignorecodes.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
# This file is part of the rsyslog project, released under ASL 2.0 | ||
|
||
# Starting actual testbench | ||
. ${srcdir:=.}/diag.sh init | ||
|
||
export NUMMESSAGES=10000 | ||
|
||
port="$(get_free_port)" | ||
omhttp_start_server $port --fail-with-401-or-403-after 5000 | ||
|
||
generate_conf | ||
add_conf ' | ||
template(name="tpl" type="string" | ||
string="{\"msgnum\":\"%msg:F,58:2%\"}") | ||
module(load="../contrib/omhttp/.libs/omhttp") | ||
if $msg contains "msgnum:" then | ||
action( | ||
# Payload | ||
name="my_http_action" | ||
type="omhttp" | ||
errorfile="'$RSYSLOG_DYNNAME/omhttp.error.log'" | ||
template="tpl" | ||
server="localhost" | ||
serverport="'$port'" | ||
restpath="my/endpoint" | ||
batch="off" | ||
httpignorablecodes=["401", "NA", "403"] | ||
# Auth | ||
usehttps="off" | ||
) | ||
' | ||
startup | ||
injectmsg | ||
shutdown_when_empty | ||
wait_shutdown | ||
omhttp_get_data $port my/endpoint | ||
omhttp_stop_server | ||
seq_check 0 4999 | ||
exit_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
export USE_VALGRIND="YES" | ||
source ${srcdir:=.}/omhttp-batch-retry-metadata.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash | ||
# This file is part of the rsyslog project, released under ASL 2.0 | ||
|
||
# Starting actual testbench | ||
. ${srcdir:=.}/diag.sh init | ||
|
||
export NUMMESSAGES=50000 | ||
|
||
port="$(get_free_port)" | ||
omhttp_start_server $port --fail-every 100 --fail-with 207 | ||
|
||
generate_conf | ||
add_conf ' | ||
module(load="../contrib/omhttp/.libs/omhttp") | ||
main_queue(queue.dequeueBatchSize="2048") | ||
template(name="tpl" type="string" | ||
string="{\"msgnum\":\"%msg:F,58:2%\"}") | ||
# Echo message as-is for retry | ||
template(name="tpl_echo" type="string" string="%msg%\n") | ||
# Echo response as-is for retry | ||
template(name="tpl_response" type="string" string="{ \"message\": %msg%, \"response\": %$!omhttp!response% }\n") | ||
ruleset(name="ruleset_omhttp_retry") { | ||
#action(type="omfile" file="'$RSYSLOG_DYNNAME/omhttp.message.log'" template="tpl_echo") | ||
# log the response | ||
action(type="omfile" file="'$RSYSLOG_DYNNAME/omhttp.response.log'" template="tpl_response") | ||
action( | ||
name="action_omhttp" | ||
type="omhttp" | ||
errorfile="'$RSYSLOG_DYNNAME/omhttp.error.log'" | ||
template="tpl_echo" | ||
server="localhost" | ||
serverport="'$port'" | ||
restpath="my/endpoint" | ||
batch="on" | ||
batch.maxsize="100" | ||
batch.format="kafkarest" | ||
httpretrycodes=["207","500"] | ||
retry="on" | ||
retry.ruleset="ruleset_omhttp_retry" | ||
retry.addmetadata="on" | ||
# Auth | ||
usehttps="off" | ||
) & stop | ||
} | ||
ruleset(name="ruleset_omhttp") { | ||
action( | ||
name="action_omhttp" | ||
type="omhttp" | ||
errorfile="'$RSYSLOG_DYNNAME/omhttp.error.log'" | ||
template="tpl" | ||
server="localhost" | ||
serverport="'$port'" | ||
restpath="my/endpoint" | ||
batch="on" | ||
batch.maxsize="100" | ||
batch.format="kafkarest" | ||
httpretrycodes=["207", "500"] | ||
retry="on" | ||
retry.ruleset="ruleset_omhttp_retry" | ||
retry.addmetadata="on" | ||
# Auth | ||
usehttps="off" | ||
) & stop | ||
} | ||
if $msg contains "msgnum:" then | ||
call ruleset_omhttp | ||
' | ||
startup | ||
injectmsg | ||
shutdown_when_empty | ||
wait_shutdown | ||
omhttp_get_data $port my/endpoint kafkarest | ||
omhttp_stop_server | ||
seq_check | ||
omhttp_validate_metadata_response | ||
exit_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
export USE_VALGRIND="YES" | ||
source ${srcdir:=.}/omhttp-retry-timeout.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# This file is part of the rsyslog project, released under ASL 2.0 | ||
|
||
# Starting actual testbench | ||
. ${srcdir:=.}/diag.sh init | ||
|
||
export NUMMESSAGES=10000 | ||
|
||
port="$(get_free_port)" | ||
omhttp_start_server $port --fail-every 1000 --fail-with-delay-secs 2 | ||
|
||
generate_conf | ||
add_conf ' | ||
module(load="../contrib/omhttp/.libs/omhttp") | ||
main_queue(queue.dequeueBatchSize="2048") | ||
template(name="tpl" type="string" | ||
string="{\"msgnum\":\"%msg:F,58:2%\"}") | ||
if $msg contains "msgnum:" then | ||
action( | ||
# Payload | ||
action.resumeRetryCount="-1" | ||
action.resumeInterval="1" | ||
name="my_http_action" | ||
type="omhttp" | ||
errorfile="'$RSYSLOG_DYNNAME/omhttp.error.log'" | ||
template="tpl" | ||
server="localhost" | ||
serverport="'$port'" | ||
restpath="my/endpoint" | ||
restpathtimeout="1000" | ||
checkpath="ping" | ||
batch="off" | ||
# Auth | ||
usehttps="off" | ||
) | ||
' | ||
startup | ||
injectmsg | ||
shutdown_when_empty | ||
wait_shutdown | ||
omhttp_get_data $port my/endpoint | ||
omhttp_stop_server | ||
seq_check | ||
exit_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import json | ||
import argparse | ||
from collections import defaultdict | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description='Archive and delete core app log files') | ||
parser.add_argument('--error', action='store', type=str, help='error') | ||
parser.add_argument('--response', action='store', type=str, help='response') | ||
args = parser.parse_args() | ||
|
||
messages = defaultdict(dict) | ||
with open(args.error, "r") as error_f, open(args.response, "r") as response_f: | ||
for line in error_f: | ||
json_obj = json.loads(line) | ||
# postdata contains a json string of records array | ||
records = json.loads(json_obj['request']['postdata']) | ||
if records: | ||
for i, val in enumerate(records['records']): | ||
messages[val['value']['msgnum']]['response'] = json_obj['response'] | ||
messages[val['value']['msgnum']]['index'] = i | ||
#print (len(messages), "messages:", messages) | ||
|
||
# validate with responses | ||
for line in response_f: | ||
json_obj = json.loads(line) | ||
msgnum = json_obj['message']['msgnum'] | ||
code = json_obj['response']['code'] | ||
body = json_obj['response']['body'] | ||
batch_index = json_obj['response']['batch_index'] | ||
#print('msgnum:', msgnum, 'code:', code, 'body:', body, 'batch_index:', batch_index) | ||
assert(msgnum in messages) | ||
assert(messages[msgnum]['response']['status'] == code) | ||
assert(messages[msgnum]['response']['message'] == body) | ||
assert(messages[msgnum]['index'] == batch_index) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters