Skip to content

Commit cce0b40

Browse files
Add disable retries (#125)
* Add disable retries * Fix test_harness overload for bad import.
1 parent 260e092 commit cce0b40

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

python/restate/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
# we don't have the appropriate dependencies installed
3535

3636
# pylint: disable=unused-argument, redefined-outer-name
37-
def test_harness(app, follow_logs = False, restate_image = ""): # type: ignore
37+
def test_harness(app, # type: ignore
38+
follow_logs: bool = False,
39+
restate_image: str = "",
40+
always_replay: bool = False,
41+
disable_retries: bool = False):
3842
"""a dummy harness constructor to raise ImportError"""
3943
raise ImportError("Install restate-sdk[harness] to use this feature")
4044

python/restate/harness.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class RestateContainer(DockerContainer):
129129

130130
log_thread: typing.Optional[threading.Thread] = None
131131

132-
def __init__(self, image, always_replay):
132+
def __init__(self, image, always_replay, disable_retries):
133133
super().__init__(image)
134134
self.with_exposed_ports(8080, 9070)
135135
self.with_env('RESTATE_LOG_FILTER', 'restate=info')
@@ -143,6 +143,8 @@ def __init__(self, image, always_replay):
143143
else:
144144
self.with_env('RESTATE_WORKER__INVOKER__INACTIVITY_TIMEOUT', '10m')
145145
self.with_env('RESTATE_WORKER__INVOKER__ABORT_TIMEOUT', '10m')
146+
if disable_retries:
147+
self.with_env('RESTATE_WORKER__INVOKER__RETRY_POLICY__TYPE', 'none')
146148

147149
self.with_kwargs(extra_hosts={"host.docker.internal" : "host-gateway"})
148150

@@ -192,6 +194,7 @@ class TestConfiguration:
192194
restate_image: str = "restatedev/restate:latest"
193195
stream_logs: bool = False
194196
always_replay: bool = False
197+
disable_retries: bool = False
195198

196199

197200
class RestateTestHarness:
@@ -213,7 +216,8 @@ def start(self):
213216
self.server = AsgiServer(self.asgi_app, self.bind_address).start()
214217
self.restate = RestateContainer(
215218
image=self.config.restate_image,
216-
always_replay=self.config.always_replay) \
219+
always_replay=self.config.always_replay,
220+
disable_retries=self.config.disable_retries) \
217221
.start(self.config.stream_logs)
218222
try:
219223
self._register_sdk()
@@ -263,7 +267,8 @@ def __exit__(self, exc_type, exc_value, traceback):
263267
def test_harness(app,
264268
follow_logs: bool = False,
265269
restate_image: str = "restatedev/restate:latest",
266-
always_replay: bool = False) -> RestateTestHarness:
270+
always_replay: bool = False,
271+
disable_retries: bool = False) -> RestateTestHarness:
267272
"""
268273
Creates a test harness for running Restate services together with restate-server.
269274
@@ -274,12 +279,14 @@ def test_harness(app,
274279
:param always_replay: When True, this forces restate-server to always replay
275280
on a suspension point. This is useful to hunt non deterministic bugs
276281
that might prevent your code to replay correctly (default is False).
282+
:param disable_retries: When True, retries are disabled (default is False).
277283
:return: An instance of RestateTestHarness initialized with the provided app and configuration.
278284
:rtype: RestateTestHarness
279285
"""
280286
config = TestConfiguration(
281287
restate_image=restate_image,
282288
stream_logs=follow_logs,
283-
always_replay=always_replay
289+
always_replay=always_replay,
290+
disable_retries=disable_retries
284291
)
285292
return RestateTestHarness(app, config)

0 commit comments

Comments
 (0)