Skip to content

Commit

Permalink
Merge pull request #493 from nats-io/ci-updates
Browse files Browse the repository at this point in the history
CI updates
  • Loading branch information
wallyqs authored Sep 11, 2023
2 parents ec5da08 + 8699e07 commit db07022
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cache:
- $HOME/nats-server

python:
- "3.8"
- "3.9"
- "3.10"

Expand Down Expand Up @@ -83,7 +84,21 @@ jobs:
- bash ./scripts/install_nats.sh
install:
- pip install -e .[fast-mail-parser]
- name: "Python: 3.7"
python: "3.7"
before_install:
- sudo apt update && sudo apt install gcc build-essential -y
- sudo apt-get install python3-pip
- sudo apt-get install python3-pytest
- pip install --upgrade pip
- bash ./scripts/install_nats.sh
install:
- pip install -e .[aiohttp,fast-mail-parser]
script:
- pytest -vv -s --continue-on-collection-errors tests
allow_failures:
- name: "Python: 3.7"
- name: "Python: 3.8"
- name: "Python: 3.11"
- name: "Python: 3.11/uvloop"
- name: "Python: 3.11 (nats-server@dev)"
Expand Down
2 changes: 1 addition & 1 deletion nats/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
)
from .transport import TcpTransport, Transport, WebSocketTransport

__version__ = '2.3.1'
__version__ = '2.4.0'
__lang__ = 'python3'
_logger = logging.getLogger(__name__)
PROTOCOL = 1
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ follow_imports = "silent"
show_error_codes = true
check_untyped_defs = false

[tool.pytest.ini_options]
addopts = ["--cov=nats", "--cov-report=html"]

[tool.yapf]
split_before_first_argument = true
dedent_closing_brackets = true
Expand Down
14 changes: 8 additions & 6 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ async def subscription_handler(msg):

async def subscription_handler2(msg):
msgs2.append(msg)
if len(msgs2) >= 1:
if len(msgs2) >= 1 and not fut.done():
fut.set_result(True)

await nc.connect(no_echo=True)
Expand Down Expand Up @@ -1274,8 +1274,6 @@ async def err_cb(e):

@async_test
async def test_closing_tasks(self):
nc = NATS()

disconnected_count = 0
errors = []
closed_future = asyncio.Future()
Expand All @@ -1298,12 +1296,11 @@ async def err_cb(e):
'disconnected_cb': disconnected_cb,
'error_cb': err_cb,
'closed_cb': closed_cb,
'servers': ["nats://foo:[email protected]:4223"],
'max_reconnect_attempts': 3,
'dont_randomize': True,
}

await nc.connect(**options)
nc = await nats.connect("nats://foo:[email protected]:4223", **options)
self.assertTrue(nc.is_connected)

# Do a sudden close and wrap up test.
Expand All @@ -1316,7 +1313,7 @@ async def err_cb(e):
for task in asyncio.all_tasks():
if not task.done():
pending_tasks_count += 1
self.assertEqual(expected_tasks, pending_tasks_count)
self.assertTrue(pending_tasks_count <= expected_tasks)

@async_test
async def test_pending_data_size_flush_reconnect(self):
Expand Down Expand Up @@ -2666,6 +2663,11 @@ async def test_protocol_mixing(self):

@async_test
async def test_drain_cancelled_errors_raised(self):
try:
from unittest.mock import AsyncMock
except ImportError:
pytest.skip("skip since cannot use AsyncMock")

nc = NATS()
await nc.connect()

Expand Down
9 changes: 8 additions & 1 deletion tests/test_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ async def error_cb(err):

@async_test
async def test_fetch_cancelled_errors_raised(self):
try:
from unittest.mock import AsyncMock
except ImportError:
pytest.skip("skip since cannot use AsyncMock")

import tracemalloc
tracemalloc.start()

Expand Down Expand Up @@ -2717,9 +2722,11 @@ async def error_handler(e):
await kv.put("hello.world", b'Hello World!')
msg = await sub.next_msg()
assert msg.data == b''
assert len(msg.headers) == 5
assert msg.headers['Nats-Sequence'] == '1'
assert msg.headers['Nats-Msg-Size'] == '12'
assert msg.headers['Nats-Stream'] == 'KV_TEST_UPDATE_HEADERS'
await sub.unsubscribe()
await nc.close()


class ObjectStoreTest(SingleJetStreamServerTestCase):
Expand Down

0 comments on commit db07022

Please sign in to comment.