Skip to content

Commit daab75e

Browse files
committed
test: infamy: retry copy() on ConnectionError in restconf transport
A service restart triggered by finit during sysrepo callbacks can drop an in-flight HTTP connection, causing copy("candidate", "running") to fail with RemoteDisconnected. Add retry logic consistent with the existing PATCH retry pattern in put_config_dict(). Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent ee1e94e commit daab75e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/infamy/restconf.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,20 @@ def get_data(self, xpath=None, parse=True):
489489

490490
return data
491491

492-
def copy(self, source, target):
492+
def copy(self, source, target, retries=3):
493493
factory = self.get_datastore(source)
494494
data = factory.print_mem("json", with_siblings=True, pretty=False)
495-
self.put_datastore(target, json.loads(data))
495+
last_error = None
496+
for attempt in range(0, retries):
497+
try:
498+
self.put_datastore(target, json.loads(data))
499+
return
500+
except requests.exceptions.ConnectionError as e:
501+
last_error = e
502+
if attempt < retries - 1:
503+
print(f"Failed copy {source}->{target}: {e} Retrying ...")
504+
time.sleep(1)
505+
raise last_error
496506

497507
def reboot(self):
498508
self.call_rpc("ietf-system:system-restart")

0 commit comments

Comments
 (0)