Skip to content

Commit 4ed1b41

Browse files
authored
Merge pull request #509 from minrk/test-ssh
Test SSH launchers
2 parents 37da0fd + 6a660fd commit 4ed1b41

File tree

11 files changed

+529
-143
lines changed

11 files changed

+529
-143
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: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ __pycache__
2323
.coverage.*
2424
.idea
2525
htmlcov
26+
id_*sa
27+
.vscode

ci/ssh/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# syntax = docker/dockerfile:1.2.1
2+
FROM ubuntu:20.04
3+
RUN --mount=type=cache,target=/var/cache/apt \
4+
rm -f /etc/apt/apt.conf.d/docker-clean \
5+
&& apt-get update \
6+
&& apt-get -y install wget openssh-server
7+
8+
ENV MAMBA_ROOT_PREFIX=/opt/conda
9+
ENV PATH=$MAMBA_ROOT_PREFIX/bin:$PATH
10+
RUN wget -qO- https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba \
11+
&& mv bin/micromamba /usr/local/bin/micromamba
12+
13+
RUN --mount=type=cache,target=${MAMBA_ROOT_PREFIX}/pkgs \
14+
micromamba install -y -p $MAMBA_ROOT_PREFIX -c conda-forge \
15+
python=3.8 \
16+
pip \
17+
ipyparallel
18+
19+
# generate a user with home directory and trusted ssh keypair
20+
RUN useradd -m -s /bin/bash -N ciuser
21+
USER ciuser
22+
RUN mkdir ~/.ssh \
23+
&& chmod 0700 ~/.ssh \
24+
&& ssh-keygen -q -t rsa -N '' -f /home/ciuser/.ssh/id_rsa \
25+
&& cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys \
26+
&& chmod 0600 ~/.ssh/*
27+
USER root
28+
29+
30+
ENV PIP_CACHE_DIR=/tmp/pip-cache
31+
COPY . /src/ipyparallel
32+
RUN --mount=type=cache,target=${PIP_CACHE_DIR} python3 -m pip install -e 'file:///src/ipyparallel#egg=ipyparallel[test]'
33+
34+
# needed for sshd to start
35+
RUN mkdir /run/sshd
36+
# run sshd in the foreground
37+
CMD /usr/sbin/sshd -D -e

ci/ssh/docker-compose.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
sshd:
3+
image: ipyparallel-sshd
4+
build:
5+
context: ../..
6+
dockerfile: ci/ssh/Dockerfile
7+
ports:
8+
- "2222:22"

ci/ssh/ipcluster_config.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
3+
c.Cluster.controller_ip = '0.0.0.0'
4+
c.Cluster.engine_launcher_class = 'SSH'
5+
6+
ssh_key = os.path.join(os.path.dirname(__file__), "id_rsa")
7+
c.Cluster.controller_ip = '0.0.0.0'
8+
c.Cluster.engine_launcher_class = 'SSH'
9+
c.SSHEngineSetLauncher.scp_args = c.SSHLauncher.ssh_args = [
10+
"-o",
11+
"UserKnownHostsFile=/dev/null",
12+
"-o",
13+
"StrictHostKeyChecking=no",
14+
"-i",
15+
ssh_key,
16+
]
17+
c.SSHEngineSetLauncher.engines = {"[email protected]:2222": 4}
18+
c.SSHEngineSetLauncher.remote_python = "/opt/conda/bin/python3"
19+
c.SSHEngineSetLauncher.remote_profile_dir = "/home/ciuser/.ipython/profile_default"
20+
c.SSHEngineSetLauncher.engine_args = ['--debug']

0 commit comments

Comments
 (0)