Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/coverage_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
chmod +x rcd-ubuntu-latest
./rcd-ubuntu-latest -version $HZ_VERSION &
# wait for a bit for RCD to download artifacts
sleep 10
python3 ./tests/hzrc/waitport.py
pytest --verbose --cov=hazelcast --cov-report=xml

- name: Run tests (Windows)
Expand All @@ -149,7 +149,7 @@ jobs:
run: |
Start-Process -FilePath .\rcd-windows-latest -ArgumentList '-version', $Env:HZ_VERSION -RedirectStandardOutput rcd-stdout.log -RedirectStandardError rcd-stderr.log
# wait for a bit for RCD to download artifacts
sleep 10
python3 ./tests/hzrc/waitport.py
echo "RCD Log:"
cat rcd-stdout.log
cat rcd-stderr.log
Expand Down
47 changes: 47 additions & 0 deletions tests/hzrc/waitport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import asyncio
import socket
import sys


class Protocol(asyncio.BaseProtocol):
pass


async def connect(host: str, port: int):
loop = asyncio.get_running_loop()
while True:
try:
return await loop.create_connection(
lambda: Protocol(),
host,
port,
family=socket.AF_INET,
)
except ConnectionRefusedError:
await asyncio.sleep(0.1)


async def print_waiting_msg(host, port):
await asyncio.sleep(1)
print(f"Waiting for {host}:{port} to become available...")


async def amain():
host = "127.0.0.1"
port = 9701
timeout = 120 # seconds
msg_task = asyncio.create_task(print_waiting_msg(host, port))

try:
await asyncio.wait_for(connect(host, port), timeout)
except TimeoutError:
print(f"FAILED to connect in {timeout} seconds.")
sys.exit(1)

msg_task.cancel()
print(f"OK, {host}:{port} is up.")
await asyncio.sleep(1)


if __name__ == "__main__":
asyncio.run(amain())
Loading