Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TestCase data management #476

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/grizzly/common/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class TestFileMap:

class TestCase:
__slots__ = (
"_files",
"_in_place",
"_root",
"adapter_name",
"assets",
"assets_path",
Expand All @@ -57,9 +60,6 @@ class TestCase:
"input_fname",
"timestamp",
"version",
"_files",
"_in_place",
"_root",
)

def __init__(
Expand Down Expand Up @@ -326,14 +326,14 @@ def dump(self, dst_path: Path, include_details: bool = False) -> None:
}
if self.adapter_name:
info["adapter"] = self.adapter_name
if self.duration:
info["duration"] = self.duration
if self.duration is not None:
info["duration"] = round(self.duration, 1)
if self.env_vars:
info["env"] = self.env_vars
if self.hang:
info["hang"] = self.hang
if self.input_fname:
info["input"] = Path(self.input_fname).name
info["input"] = self.input_fname
if self.timestamp:
info["timestamp"] = self.timestamp
if self.version:
Expand Down
17 changes: 12 additions & 5 deletions src/grizzly/common/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,14 @@ def test_testcase_14(tmp_path):
assert (dst / "_assets_" / "asset.txt").is_file()


def test_testcase_15(tmp_path):
@mark.parametrize(
"duration, hang, https, input_fname",
[
(1.2, True, True, "foo/test.name"),
(0, False, False, None),
],
)
def test_testcase_15(tmp_path, duration, hang, https, input_fname):
"""test TestCase - dump, load and compare"""
asset_path = tmp_path / "assets"
asset_path.mkdir()
Expand All @@ -364,11 +371,11 @@ def test_testcase_15(tmp_path):
working = tmp_path / "working"
with TestCase("a.html", "adpt") as org:
# set non default values
org.duration = 1.23
org.duration = duration
org.env_vars = {"en1": "1", "en2": "2"}
org.https = not org.https
org.hang = not org.hang
org.input_fname = "infile"
org.https = https
org.hang = hang
org.input_fname = input_fname
org.add_from_bytes(b"a", org.entry_point)
org.assets = {"sample": asset.name}
org.assets_path = asset_path
Expand Down
2 changes: 1 addition & 1 deletion src/grizzly/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from .common.reporter import Reporter
from .common.storage import TestCase

__all__ = ("SessionError", "LogOutputLimiter", "Session")
__all__ = ("LogOutputLimiter", "Session", "SessionError")
__author__ = "Tyson Smith"
__credits__ = ["Tyson Smith", "Jesse Schwartzentruber"]

Expand Down
2 changes: 0 additions & 2 deletions src/grizzly/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def setup(self, input_path, _server_map):

def generate(self, testcase, _server_map):
assert testcase.adapter_name == self.name
testcase.input_fname = self.fuzz["input"]
testcase.add_from_bytes(b"test", testcase.entry_point)
if self.remaining is not None:
assert self.remaining > 0
Expand Down Expand Up @@ -101,7 +100,6 @@ def test_session_01(mocker, harness, profiling, coverage, relaunch, iters, runti
runtime_limit=runtime,
)
assert session.status.iteration == max_iters
assert session.status.test_name == "file.bin"
assert target.close.call_count == max_iters / relaunch
assert target.check_result.call_count == max_iters
assert target.handle_hang.call_count == 0
Expand Down