Skip to content

Commit

Permalink
integration/test_containers: Give containers some time before exec
Browse files Browse the repository at this point in the history
Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Jan 10, 2025
1 parent 7ad1730 commit 31890c1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions integration/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import time
import unittest

from integration.testing import IntegrationTestCase
Expand Down Expand Up @@ -145,6 +146,9 @@ def test_execute(self):
"""A command is executed on the container."""
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.

result = self.container.execute(["echo", "test"])

Expand All @@ -156,6 +160,9 @@ 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 = []

result = self.container.execute(["echo", "test"], stdout_handler=buffer.append)
Expand All @@ -169,6 +176,9 @@ def test_execute_no_decode(self):
"""A command is executed on the container that isn't utf-8 decodable"""
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.

result = self.container.execute(["printf", "\\xff"], decode=None)

Expand All @@ -180,6 +190,9 @@ def test_execute_force_decode(self):
"""A command is executed and force output to ascii"""
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.

result = self.container.execute(
["printf", "qu\\xe9"], decode=True, encoding="latin1"
Expand All @@ -193,6 +206,9 @@ def test_execute_pipes(self):
"""A command receives data from stdin and write to stdout handler"""
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.
test_msg = "Hello world!\n"
stdout_msgs = []

Expand Down

0 comments on commit 31890c1

Please sign in to comment.