Skip to content

Commit

Permalink
Fix string index
Browse files Browse the repository at this point in the history
  • Loading branch information
undera committed Aug 29, 2022
1 parent 5af8aaf commit c2facbe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ It is intentionally not fully-capable _load testing tool_, it is just _load gene

### 0.5.2 -- next
- requests from URLs file have default empty label, to avoid garbaging reports with too many labels
- retry reading string index file, for the case it lags behind binary file
- retry reading string index file


### 0.5.1 -- 25 jul 2022
Expand Down
18 changes: 9 additions & 9 deletions taurus/encarno/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,15 @@ def generate_payload(self, scenario: bzt.engine.Scenario):

if self.input_strings:
with open(self.input_strings, 'w') as fp:
fp.writelines(x + "\n" for x in str_list)
fp.writelines(x + "\n" for x in str_list[1:])

else:
self.input_strings = self.engine.find_file(scenario.get("input-strings"))

return uses_regex

def _generate_payload_inner(self, scenario):
str_list = []
str_list = [""] # we always assume #0 is empty str, because encarno binary does
all_consumes = set()
all_extracts = set()

Expand Down Expand Up @@ -388,16 +388,16 @@ def _get_metadata_indexed(self, request, host, consumes, ext_tpls, asserts, str_

metadata = {
"plen": len(tcp_payload.encode('utf-8')),
"a": str_list.index(host) + 1,
"l": str_list.index(request.label) + 1,
"a": str_list.index(host),
"l": str_list.index(request.label),
}

for val in consumes:
if val not in str_list:
str_list.append(val)

if consumes:
metadata["r"] = [str_list.index(x) + 1 for x in consumes]
metadata["r"] = [str_list.index(x) for x in consumes]

if ext_tpls:
metadata["e"] = []
Expand All @@ -406,7 +406,7 @@ def _get_metadata_indexed(self, request, host, consumes, ext_tpls, asserts, str_
if s_data not in str_list:
str_list.append(s_data)

metadata["e"].append(str_list.index(s_data) + 1)
metadata["e"].append(str_list.index(s_data))

if asserts:
metadata["c"] = []
Expand All @@ -415,7 +415,7 @@ def _get_metadata_indexed(self, request, host, consumes, ext_tpls, asserts, str_
if item not in str_list:
str_list.append(item)

metadata["c"].append(str_list.index(item) + 1)
metadata["c"].append(str_list.index(item))

return metadata

Expand Down Expand Up @@ -598,7 +598,7 @@ def __init__(self, filename, str_filename, parent_logger, health_filename):
self.log = parent_logger.getChild(self.__class__.__name__)
self.file = FileReader(filename=filename, file_opener=lambda x: open(x, 'rb'), parent_logger=self.log)
self.str_file = FileReader(filename=str_filename, parent_logger=self.log)
self.str_map = {}
self.str_map = {0: ""}
self.partial_buffer = bytes()
self.health_reader = HealthReader(health_filename, parent_logger)

Expand Down Expand Up @@ -658,7 +658,7 @@ def _get_strindex(self, idx):
self.log.error("String index %s is not present in %s even after retries", idx, self.str_file.name)
return "INDEX_NOT_FOUND"

return self.str_map[idx - 1]
return self.str_map[idx]


class HealthReader:
Expand Down

0 comments on commit c2facbe

Please sign in to comment.