Skip to content

Commit 28cb5b9

Browse files
committed
try running ssh tests on ci
1 parent 0a9abba commit 28cb5b9

File tree

4 files changed

+40
-13
lines changed

4 files changed

+40
-13
lines changed

.github/workflows/test.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
include:
21+
- python: "3.9"
22+
ssh: ssh
2123
- python: "3.6"
2224
tornado: "5.1.1"
2325
- python: "3.6"
2426
- python: "3.7"
2527
controller_ip: "*"
2628
- python: "3.8"
27-
mpi: true
29+
mpi: mpi
2830
- python: "3.9"
2931

3032
steps:
@@ -42,6 +44,14 @@ jobs:
4244
run: |
4345
echo "IPP_CONTROLLER_IP=${{ matrix.controller_ip }}" >> $GITHUB_ENV
4446
47+
- name: Set up docker-compose for ssh launcher
48+
if: ${{ matrix.ssh }}
49+
run: |
50+
export DOCKER_BUILDKIT=1
51+
export COMPOSE_DOCKER_CLI_BUILD=1
52+
cd ci/ssh
53+
docker-compose up -d --build
54+
4555
- name: Install Python (conda) ${{ matrix.python }}
4656
if: matrix.mpi
4757
run: |
@@ -76,8 +86,13 @@ jobs:
7686
run: |
7787
pytest -vx --color=yes --cov=ipyparallel ipyparallel/tests/test_cluster.py
7888
89+
- name: Run ssh tests
90+
if: ${{ matrix.ssh }}
91+
run: |
92+
pytest -ra -v --maxfail=2 --color=yes --cov=ipyparallel ipyparallel/tests/test_ssh.py
93+
7994
- name: Run tests
80-
if: ${{ ! matrix.mpi }}
95+
if: ${{ ! matrix.mpi && ! matrix.ssh }}
8196
# FIXME: --color=yes explicitly set because:
8297
# https://github.com/actions/runner/issues/241
8398
run: |

ci/ssh/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ ENV PIP_CACHE_DIR=/tmp/pip-cache
3131
COPY . /src/ipyparallel
3232
RUN --mount=type=cache,target=${PIP_CACHE_DIR} python3 -m pip install -e 'file:///src/ipyparallel#egg=ipyparallel[test]'
3333

34-
EXPOSE 22
3534
# needed for sshd to start
3635
RUN mkdir /run/sshd
3736
# run sshd in the foreground

ci/ssh/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ services:
55
context: ../..
66
dockerfile: ci/ssh/Dockerfile
77
ports:
8-
- 2222:22
8+
- "2222:22"

ipyparallel/tests/conftest.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import sys
66
from subprocess import check_call
7-
from subprocess import STDOUT
7+
from subprocess import check_output
88
from tempfile import TemporaryDirectory
99
from unittest import mock
1010

@@ -113,24 +113,37 @@ def ssh_dir(request):
113113
repo_root = os.path.abspath(os.path.join(ipp.__file__, os.pardir, os.pardir))
114114
ci_directory = os.environ.get("CI_DIR", os.path.join(repo_root, 'ci'))
115115
ssh_dir = os.path.join(ci_directory, "ssh")
116-
# build image
117-
check_call(["docker", "compose", "build"], cwd=ssh_dir)
118-
# launch service
119-
check_call(["docker", "compose", "up", "-d"], cwd=ssh_dir)
120-
# shutdown service when we exit
121-
request.addfinalizer(lambda: check_call(["docker", "compose", "down"], cwd=ssh_dir))
116+
117+
# only run ssh test if service was started before
118+
try:
119+
out = check_output(['docker-compose', 'ps', '-q'], cwd=ssh_dir)
120+
except Exception:
121+
pytest.skip("Needs docker compose")
122+
else:
123+
if not out.strip():
124+
pytest.skip("ssh service not running")
125+
126+
# below is necessary for building/starting service as part of fixture
127+
# currently we use whether the service is already started to decide whether to run the tests
128+
# # build image
129+
# check_call(["docker-compose", "build"], cwd=ssh_dir)
130+
# # launch service
131+
# check_call(["docker-compose", "up", "-d"], cwd=ssh_dir)
132+
# # shutdown service when we exit
133+
# request.addfinalizer(lambda: check_call(["docker-compose", "down"], cwd=ssh_dir))
122134
return ssh_dir
123135

124136

125137
@pytest.fixture
126138
def ssh_key(tmpdir, ssh_dir):
127139
key_file = tmpdir.join("id_rsa")
128140
check_call(
141+
# this should be `docker compose cp sshd:...`
142+
# but docker-compose 1.x doesn't support `cp` yet
129143
[
130144
'docker',
131-
'compose',
132145
'cp',
133-
'sshd:/home/ciuser/.ssh/id_rsa',
146+
'ssh_sshd_1:/home/ciuser/.ssh/id_rsa',
134147
key_file,
135148
],
136149
cwd=ssh_dir,

0 commit comments

Comments
 (0)