Skip to content

Commit

Permalink
fix: try to fix the timeout test cases (#4917)
Browse files Browse the repository at this point in the history
* fix: try to fix the timeout test cases

Signed-off-by: Frost Ming <[email protected]>

* fix: exclude tests on 3.12

Signed-off-by: Frost Ming <[email protected]>

---------

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming authored Aug 14, 2024
1 parent 9db7acf commit 4dd3c7a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 51 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ jobs:
os: [ubuntu-latest, macos-latest]
python-version: [3.8, 3.11, 3.12]
suite: ['bento_server_http', 'bento_new_sdk']
exclude:
- os: macos-latest
suite: bento_server_http
python-version: 3.12
- os: ubuntu-latest
suite: bento_server_http
python-version: 3.12
name: ${{ matrix.suite }}-e2e-tests (python${{ matrix.python-version }}.${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 90
Expand Down
83 changes: 32 additions & 51 deletions tests/e2e/bento_server_http/tests/test_serve.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import os
import subprocess
import sys
import time
from pathlib import Path

import pytest
Expand Down Expand Up @@ -29,24 +29,17 @@ def test_http_server():
server.stop()

assert server.process is not None # process should not be removed
try:
retcode = server.process.wait(10)
assert retcode is not None

timeout = 10
start_time = time.time()
while time.time() - start_time < timeout:
retcode = server.process.poll()
if retcode is not None and retcode <= 0:
break

retcode = server.process.poll()
assert retcode is not None

if sys.platform == "win32":
# on Windows, because of the way that terminate is run, it seems the exit code is set.
pass
else:
# negative return codes mean the process was terminated; since we will be terminating
# the process, it should be negative.
assert retcode <= 0
if sys.platform != "win32":
# on Windows, because of the way that terminate is run, it seems the exit code is set.
# negative return codes mean the process was terminated; since we will be terminating
# the process, it should be negative.
assert retcode <= 0
except subprocess.TimeoutExpired:
server.process.kill()


@pytest.mark.usefixtures("bentoml_home")
Expand All @@ -63,23 +56,17 @@ def test_http_server_ctx():

assert server.process is not None # process should not be removed

timeout = 10
start_time = time.time()
while time.time() - start_time < timeout:
retcode = server.process.poll()
if retcode is not None and retcode <= 0:
break

retcode = server.process.poll()
assert retcode is not None
try:
retcode = server.process.wait(10)
assert retcode is not None

if sys.platform == "win32":
# on Windows, because of the way that terminate is run, it seems the exit code is set.
pass
else:
# negative return codes mean the process was terminated; since we will be terminating
# the process, it should be negative.
assert retcode <= 0
if sys.platform != "win32":
# on Windows, because of the way that terminate is run, it seems the exit code is set.
# negative return codes mean the process was terminated; since we will be terminating
# the process, it should be negative.
assert retcode <= 0
except subprocess.TimeoutExpired:
server.process.kill()


def test_serve_from_svc():
Expand All @@ -94,23 +81,17 @@ def test_serve_from_svc():

assert server.process is not None # process should not be removed

timeout = 10
start_time = time.time()
while time.time() - start_time < timeout:
retcode = server.process.poll()
if retcode is not None and retcode <= 0:
break

retcode = server.process.poll()
assert retcode is not None

if sys.platform == "win32":
# on Windows, because of the way that terminate is run, it seems the exit code is set.
pass
else:
# negative return codes mean the process was terminated; since we will be terminating
# the process, it should be negative.
assert retcode <= 0
try:
retcode = server.process.wait(10)
assert retcode is not None

if sys.platform != "win32":
# on Windows, because of the way that terminate is run, it seems the exit code is set.
# negative return codes mean the process was terminated; since we will be terminating
# the process, it should be negative.
assert retcode <= 0
except subprocess.TimeoutExpired:
server.process.kill()


@pytest.mark.usefixtures("bentoml_home")
Expand Down

0 comments on commit 4dd3c7a

Please sign in to comment.