diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab8638b9..e569308f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -250,6 +250,8 @@ jobs: # remove old files so we can rerun in-place with "act -r" during test development rm -vf ~/.ssh/id_dropbear* ~/inst/bin/dropbearkey -t ecdsa -f ~/.ssh/id_dropbear | grep ^ecdsa > ~/.ssh/authorized_keys + # Convert to openssh format so that asyncssh can find it in tests + ~/inst/bin/dropbearconvert dropbear openssh ~/.ssh/id_dropbear ~/.ssh/id_ecdsa # to test setting SSH_PUBKEYINFO, replace the trailing comment ~/inst/bin/dropbearkey -t ecdsa -f ~/.ssh/id_dropbear_key2 | grep ^ecdsa | sed 's/[^ ]*$/key2 extra/' >> ~/.ssh/authorized_keys diff --git a/test/requirements.txt b/test/requirements.txt index 797b01f8..599a05f1 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -6,3 +6,4 @@ psutil==6.0.0 pyparsing==2.4.7 pytest==8.3.2 toml==0.10.2 +asyncssh==2.17.0 diff --git a/test/test_concurrent.py b/test/test_concurrent.py new file mode 100644 index 00000000..b0d16f17 --- /dev/null +++ b/test/test_concurrent.py @@ -0,0 +1,34 @@ +""" +Tests opening and closing several (up to 4) channels concurrently. +""" +from test_dropbear import * + +import asyncssh +import asyncio +import random + +async def run(addr, port): + async with asyncssh.connect(addr, port = port) as conn: + + chans = [] + MAX=4 + + for x in range(10000): + if len(chans) < MAX: + pipes = await conn.open_session(command = "df") + chans.append(pipes) + l = len(chans) + print(f" add, len {l}") + + if random.random() < 0.2: + i = random.randrange(0, len(chans)) + l = len(chans) + print(f" del {i}/{l}") + del chans[i] + +def test_concurrent(request, dropbear): + opt = request.config.option + host = opt.remote or LOCALADDR + port = int(opt.port) + + asyncio.run(run(host, port))