Skip to content

Commit d31a9e0

Browse files
committed
get tests running with ssh / docker-compose
SSHLauncher switched to record host+pid instead of holding open connection needed for to/from_dict
1 parent 37da0fd commit d31a9e0

File tree

8 files changed

+473
-105
lines changed

8 files changed

+473
-105
lines changed

.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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
EXPOSE 22
35+
# needed for sshd to start
36+
RUN mkdir /run/sshd
37+
# run sshd in the foreground
38+
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)