Skip to content

Commit

Permalink
feat: use Amalthea to run sessions through a K8s operator (#668)
Browse files Browse the repository at this point in the history
- refactoring of the notebook service
- adapt existing and expand test suite

Co-authored-by: Andreas Bleuler <andreas.bleuler@sdsc.ethz.ch>
  • Loading branch information
olevski and Andreas Bleuler committed Sep 15, 2021
1 parent dd4970c commit f808ac0
Show file tree
Hide file tree
Showing 75 changed files with 3,471 additions and 4,834 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
test-enabled: ${{ steps.deploy-comment.outputs.test-enabled}}
steps:
- id: deploy-comment
uses: SwissDataScienceCenter/renku-actions/check-pr-description@v0.2.0
uses: SwissDataScienceCenter/renku-actions/check-pr-description@v0.3.0
with:
string: /deploy
pr_ref: ${{ github.event.number }}
Expand All @@ -41,7 +41,8 @@ jobs:
name: renku-ci-nb-${{ github.event.number }}
steps:
- name: deploy-pr
uses: SwissDataScienceCenter/renku-actions/deploy-renku@v0.2.0
if: needs.check-deploy.outputs.pr-contains-string == 'true'
uses: SwissDataScienceCenter/renku-actions/deploy-renku@v0.3.0
env:
DOCKER_PASSWORD: ${{ secrets.RENKU_DOCKER_PASSWORD }}
DOCKER_USERNAME: ${{ secrets.RENKU_DOCKER_USERNAME }}
Expand All @@ -50,7 +51,7 @@ jobs:
RANCHER_PROJECT_ID: ${{ secrets.CI_RANCHER_PROJECT }}
RENKU_RELEASE: renku-ci-nb-${{ github.event.number }}
RENKU_VALUES_FILE: "${{ github.workspace }}/values.yaml"
RENKU_VALUES: ${{ secrets.CI_RENKU_VALUES }}
RENKU_VALUES: ${{ secrets.CI_RENKU_AMALTHEA_VALUES }}
RENKUBOT_KUBECONFIG: ${{ secrets.RENKUBOT_DEV_KUBECONFIG }}
RENKUBOT_RANCHER_BEARER_TOKEN: ${{ secrets.RENKUBOT_RANCHER_BEARER_TOKEN }}
RANCHER_DEV_API_ENDPOINT: ${{ secrets.RANCHER_DEV_API_ENDPOINT }}
Expand All @@ -64,6 +65,7 @@ jobs:
renku_graph: "${{ needs.check-deploy.outputs.renku-graph }}"
renku_gateway: "${{ needs.check-deploy.outputs.renku-gateway }}"
renku_ui: "${{ needs.check-deploy.outputs.renku-ui }}"
extra_values: "${{ needs.check-deploy.outputs.extra-values }}"
- name: Check existing renkubot comment
uses: peter-evans/find-comment@v1
id: findcomment
Expand Down Expand Up @@ -100,7 +102,7 @@ jobs:
helm test ${RENKU_RELEASE} --namespace ${RENKU_RELEASE} --timeout 80m --logs
- name: Download artifact for packaging on failure
if: failure()
uses: SwissDataScienceCenter/renku-actions/download-test-artifacts@v0.2.0
uses: SwissDataScienceCenter/renku-actions/download-test-artifacts@v0.3.0
env:
RENKU_VALUES: ${{ secrets.CI_RENKU_VALUES }}
TEST_ARTIFACTS_PATH: "tests-artifacts-${{ github.sha }}"
Expand All @@ -116,7 +118,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: renku teardown
uses: SwissDataScienceCenter/renku-actions/teardown-renku@v0.2.0
uses: SwissDataScienceCenter/renku-actions/teardown-renku@v0.3.0
env:
GITLAB_TOKEN: ${{ secrets.DEV_GITLAB_TOKEN }}
KUBECONFIG: "${{ github.workspace }}/renkubot-kube.config"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
pipenv install --deploy --system --dev
- name: Test with pytest
run: |
pytest
pytest tests/unit renku_notebooks
test-chart:
needs: test
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
echo "GIT_USER=Renku Bot" >> $GITHUB_ENV
echo "GIT_EMAIL=renku@datascience.ch" >> $GITHUB_ENV
- name: Push tagged chart and images
uses: SwissDataScienceCenter/renku-actions/publish-chart@v0.2.0
uses: SwissDataScienceCenter/renku-actions/publish-chart@v0.3.0
env:
CHART_NAME: renku-notebooks
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
Expand All @@ -74,7 +74,7 @@ jobs:
- name: Wait for chart to get published
run: sleep 120
- name: Update component version
uses: SwissDataScienceCenter/renku-actions/update-component-version@v0.2.0
uses: SwissDataScienceCenter/renku-actions/update-component-version@v0.3.0
env:
CHART_NAME: renku-notebooks
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
Expand Down
106 changes: 106 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Integration tests

on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
- closed

jobs:
integration-test:
strategy:
matrix:
session-type: ["registered", "anonymous"]
if: github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.1.0
with:
cluster_name: kind
wait: 10m0s
version: v0.11.1
- name: Create values file
env:
OIDC_GITLAB_CLIENT_ID: ${{ secrets.OIDC_GITLAB_CLIENT_ID }}
OIDC_GITLAB_CLIENT_SECRET: ${{ secrets.OIDC_GITLAB_CLIENT_SECRET }}
RENKUBOT_DEV_GITLAB_ACCESS_TOKEN: ${{ secrets.RENKUBOT_DEV_GITLAB_ACCESS_TOKEN }}
run: |
cat <<EOF > test-values.yaml
amalthea:
scope:
namespaces: [default]
deployCrd: true
global:
anonymousSessions:
enabled: true
userSessionPersistentVolumes:
enabled: true
storageClass: standard
gitlab:
registry:
host: registry.dev.renku.ch
url: https://dev.renku.ch/gitlab
oidc:
clientId: $OIDC_GITLAB_CLIENT_ID
clientSecret: $OIDC_GITLAB_CLIENT_SECRET
tokenUrl: https://dev.renku.ch/gitlab/oauth/token
authUrl: https://dev.renku.ch/gitlab/oauth/authorize
allowUnverifiedEmail: true
sessionIngress:
host: test.host.com
tlsSecret: dummy-tls-secret
serverDefaults:
defaultUrl: /lab
cpu_request: 0.1
mem_request: 0.5G
disk_request: 1G
gpu_request: 0
lfs_auto_fetch: false
serverOptions:
cpu_request:
order: 1
displayName: Number of CPUs
type: enum
default: 0.1
options: [0.1, 1.0]
mem_request:
order: 2
displayName: Amount of Memory
type: enum
default: 0.5G
options: [0.5G, 2G]
tests:
sessionTypes:
- ${{ matrix.session-type }}
enabled: true
oidc_issuer: https://dev.renku.ch/gitlab
gitlab_token: $RENKUBOT_DEV_GITLAB_ACCESS_TOKEN
debug: false
EOF
- uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Setup chartpress
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
pip install --user pipx
pipx ensurepath
pipx install pipenv
pipenv install --dev
echo ${DOCKER_PASSWORD} | docker login -u ${DOCKER_USERNAME} --password-stdin
pipenv run chartpress --push
- name: Install Helm Chart
run: |
helm dep update helm-chart/renku-notebooks
helm install renku-notebooks helm-chart/renku-notebooks -f test-values.yaml --wait --timeout 5m0s
- name: Helm Test
run: |
helm test renku-notebooks --timeout 60m0s --logs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
telepresence.log
helm-chart/renku-notebooks/charts/*.tgz
git-https-proxy/node_modules/

# Created by https://www.gitignore.io/api/vim,linux,emacs,macos,python,sublimetext,visualstudiocode
# Edit at https://www.gitignore.io/?templates=vim,linux,emacs,macos,python,sublimetext,visualstudiocode
Expand Down
30 changes: 30 additions & 0 deletions Dockerfile.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM python:3.7-slim

LABEL maintainer="info@datascience.ch"

RUN pip install --no-cache-dir --disable-pip-version-check -U pip && \
pip install --no-cache-dir --disable-pip-version-check pipenv && \
apt-get update && \
apt-get install -y git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Install renku
ENV PATH=$PATH:/.renku/bin

RUN mkdir -p /.renku/bin && \
virtualenv /.renku/venv && \
. /.renku/venv/bin/activate && \
pip install --no-cache renku && \
deactivate && \
ln -s /.renku/venv/bin/renku /.renku/bin/renku

# Install all packages
COPY Pipfile Pipfile.lock /renku-notebooks/
WORKDIR /renku-notebooks
RUN pipenv install --dev

COPY renku_notebooks /renku-notebooks/renku_notebooks
COPY tests /renku-notebooks/tests

CMD ["pipenv", "run", "pytest", "tests/integration"]
3 changes: 0 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ kubernetes = "*"
gunicorn = "*"
requests = "*"
pyyaml = ">=4.2b1"
jupyterhub = "*"
"urllib3" = ">=1.24.2"
sentry-sdk = {extras = ["flask"],version = "*"}
gevent = "*"
Expand All @@ -29,12 +28,10 @@ black = "==21.7b0"
pre-commit = "*"
pytest-black = "*"
pytest-cov = "*"
jupyterhub-simplespawner = "*"
notebook = "*"
pytest-mock = "*"
ptvsd = "~=4.2"
importlib-metadata = "*"
jupyterhub-traefik-proxy = "*"
typed-ast = "*"

[requires]
Expand Down

0 comments on commit f808ac0

Please sign in to comment.