Skip to content

Instantly share code, notes, and snippets.

@av-elier
Created May 13, 2022 18:30
Show Gist options
  • Save av-elier/51123943f183ad1837975c3292ac07d4 to your computer and use it in GitHub Desktop.
Save av-elier/51123943f183ad1837975c3292ac07d4 to your computer and use it in GitHub Desktop.
Convert goreplay file to yandex.tank ammo file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
gor_delimeter = "🐵🙈🙉"
def make_ammo(req, case):
""" makes phantom ammo """
# phantom ammo template
ammo_template = (
"%d %s\n"
"%s"
)
return ammo_template % (len(req), case, req)
def main():
i = 0
req_string = ""
for stdin_line in sys.stdin:
i += 1
if i == 1:
continue
if stdin_line.strip().startswith("Connection:"):
continue
if stdin_line.strip() == "":
req_string += "Connection: keep-alive\n" # only modification is keep-alive
if stdin_line.strip() == gor_delimeter:
sys.stdout.write(make_ammo(req_string, "any"))
i = 0
req_string = ""
continue
req_string += stdin_line
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment