Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Jan 14, 2025
1 parent 7e827f9 commit 12bc022
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
9 changes: 9 additions & 0 deletions integration/run-integration-tests
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,18 @@ save_trust_list > "${OLD_TRUST_LIST}"
snap list lxd || true
lxc version

set +eu

# finally run the integration tests
tox -e integration

set -eu

# LXD daemon logs
echo "::group::lxd logs"
journalctl --quiet --no-hostname --no-pager --boot=0 --lines=100 --unit=snap.lxd.daemon.service
echo "::endgroup::"

# Remove any cert added to the trusted list by the integration tests
NEW_TRUST_LIST="$(mktemp)"
save_trust_list > "${NEW_TRUST_LIST}"
Expand Down
41 changes: 30 additions & 11 deletions integration/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,38 @@ 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)
time.sleep(1)
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_buffer_original(self):
"""A command is executed on the container without buffering the output."""
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)

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"""
Expand Down
5 changes: 5 additions & 0 deletions pylxd/models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@ def execute(
manager.stop()
manager.join()

print(operation.metadata)
if hasattr(operation, "err"): print(operation.err)
print(stdout.data)
print(stderr.data)

return _InstanceExecuteResult(
operation.metadata["return"], stdout.data, stderr.data
)
Expand Down

0 comments on commit 12bc022

Please sign in to comment.