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>
This commit is contained in:
Joachim Wiberg
2026-03-20 16:18:17 +01:00
parent 281f027749
commit 94a036be3a
+12 -2
View File
@@ -489,10 +489,20 @@ class Device(Transport):
return data
def copy(self, source, target):
def copy(self, source, target, retries=3):
factory = self.get_datastore(source)
data = factory.print_mem("json", with_siblings=True, pretty=False)
self.put_datastore(target, json.loads(data))
last_error = None
for attempt in range(0, retries):
try:
self.put_datastore(target, json.loads(data))
return
except requests.exceptions.ConnectionError as e:
last_error = e
if attempt < retries - 1:
print(f"Failed copy {source}->{target}: {e} Retrying ...")
time.sleep(1)
raise last_error
def reboot(self):
self.call_rpc("ietf-system:system-restart")