Skip to content

Commit 3c9f91f

Browse files
epaganonPrabhakar Kumar
authored and
Prabhakar Kumar
committed
Fixes failing tests for the alternates/building-on-matlab-docker-image.
1 parent 55e1676 commit 3c9f91f

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

.github/workflows/build-test-publish.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,4 @@ jobs:
8181
UPPERCASE_RELEASE=${LOWERCASE_RELEASE^}
8282
docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE}
8383
docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE}
84-
docker push ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE}
85-
docker push ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE}
84+
docker push --all-tags ${{ env.IMAGE_BASE_NAME }}

.github/workflows/non-interactive-build-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,4 @@ jobs:
8181
UPPERCASE_RELEASE=${LOWERCASE_RELEASE^}
8282
docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE}
8383
docker tag ${{ env.IMAGE_BASE_NAME }}:${MATLAB_RELEASE} ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE}
84-
docker push ${{ env.IMAGE_BASE_NAME }}:${LOWERCASE_RELEASE}
85-
docker push ${{ env.IMAGE_BASE_NAME }}:${UPPERCASE_RELEASE}
84+
docker push --all-tags ${{ env.IMAGE_BASE_NAME }}

tests/alternates/building-on-matlab-docker-image/test_entrypoint.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from utils import helpers
1010
import docker
11+
import pexpect
1112
import testinfra
1213
import unittest
1314

@@ -44,13 +45,15 @@ def test_no_entry_option(self):
4445
expected_login_msg = (
4546
"Please enter your MathWorks Account email address and press Enter:"
4647
)
47-
self.container = self.client.containers.run(
48+
self.container = self.client.containers.create(
4849
image=self.image_name,
49-
detach=True,
5050
stdin_open=True,
51+
tty=True,
5152
)
52-
helpers.wait_for_msg_in_log(self.container, expected_login_msg)
53-
self.assertIn(expected_login_msg, self.container.logs(tail=1).decode())
53+
self.child = pexpect.spawn(f"docker start -i {self.container.id}")
54+
self.child.expect(expected_login_msg)
55+
output = self.child.after.decode().strip()
56+
self.assertIn(expected_login_msg.lower(), output.lower())
5457

5558
def test_shell_option(self):
5659
"""Test that if the '-shell' option is specified, then a '/bin/bash' process is started"""
@@ -142,20 +145,6 @@ def test_batch_option(self):
142145

143146
self.assertGreater(len(host.process.filter(user="matlab", comm="MATLAB")), 0)
144147

145-
def test_custom_option(self):
146-
"""Test that if a custom option is specified, the custom command is run in bash."""
147-
custom_option = "pwd"
148-
expected_output = "/home/matlab"
149-
150-
self.container = self.client.containers.run(
151-
image=self.image_name,
152-
detach=True,
153-
command=custom_option,
154-
)
155-
self.container.wait()
156-
157-
self.assertEqual(self.container.logs().decode().strip(), expected_output)
158-
159148

160149
################################################################################
161150

tests/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
docker
44
markdown-it-py
5+
pexpect
56
pytest-testinfra

tests/utils/helpers.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,15 @@ def wait_for_msg_in_log(container, msg, timeout=30):
121121
"""Wait until the expected log message is printed to stdout"""
122122

123123
def msg_is_logged():
124-
return msg in container.logs().decode()
124+
return msg.lower() in container.logs().decode().lower()
125125

126126
try:
127127
wait_for(msg_is_logged, timeout)
128128
except TimeoutError:
129-
raise RuntimeError(f"The message {msg} was not printed to stdout.")
129+
output = container.logs().decode()
130+
raise RuntimeError(
131+
f"The message\n\n\t'{msg}'\n\nwas not printed to stdout:\n\n{output}"
132+
)
130133

131134

132135
def wait_for_container_status(client, id, status, timeout=30):

0 commit comments

Comments
 (0)