From c56241be28e07b7143db508cffaca9e24125c484 Mon Sep 17 00:00:00 2001 From: hamistao Date: Thu, 9 Jan 2025 23:48:19 -0300 Subject: [PATCH] WIP Signed-off-by: hamistao --- integration/test_containers.py | 23 ++++++++++++----------- pylxd/models/instance.py | 4 ++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/integration/test_containers.py b/integration/test_containers.py index ca820ef4..afbfc39c 100644 --- a/integration/test_containers.py +++ b/integration/test_containers.py @@ -158,19 +158,20 @@ def test_execute(self): def test_execute_no_buffer(self): """A command is executed on the container without buffering the output.""" - self.container.start(wait=True) - self.addCleanup(self.container.stop, wait=True) - time.sleep( - 1 - ) # Wait a little to make sure the container is ready to exec since it has just been started. - buffer = [] + while True: + self.container.start(wait=True) + self.addCleanup(self.container.stop, wait=True) + buffer = [] - result = self.container.execute(["echo", "test"], stdout_handler=buffer.append) + result = self.container.execute(["echo", "test"], stdout_handler=buffer.append) - self.assertEqual(0, result.exit_code) - self.assertEqual("", result.stdout) - self.assertEqual("", result.stderr) - self.assertEqual("test\n", "".join(buffer)) + self.assertEqual(0, result.exit_code) + self.assertEqual("", result.stdout) + self.assertEqual("", result.stderr) + self.assertEqual("test\n", "".join(buffer)) + + self.container.stop(wait=True) + time.sleep(1) def test_execute_no_decode(self): """A command is executed on the container that isn't utf-8 decodable""" diff --git a/pylxd/models/instance.py b/pylxd/models/instance.py index 6ace85ea..1a3a7d2d 100644 --- a/pylxd/models/instance.py +++ b/pylxd/models/instance.py @@ -519,6 +519,10 @@ def execute( manager.stop() manager.join() + print(operation.metadata) + print(stdout.data) + print(stderr.data) + return _InstanceExecuteResult( operation.metadata["return"], stdout.data, stderr.data )