Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add acceptance tests #175

Merged
merged 36 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
93bab37
feat: add acceptance tests
olevski Jul 11, 2021
e821e77
squashme: test
olevski Jul 11, 2021
f5ff81d
fix: image build dependencies
olevski Jul 11, 2021
52b3b10
chore: add readme for tests
olevski Jul 11, 2021
09f503f
squashme: fix github action
olevski Jul 12, 2021
f3631ce
squashme: fix images
olevski Jul 12, 2021
c3fd5e2
squashme: fix images
olevski Jul 12, 2021
2df0b3b
squashme: fix usernames
olevski Jul 12, 2021
264efbe
chore: run acceptance tests only on PR
olevski Jul 12, 2021
5b4334f
squashme: fix formatting
olevski Jul 12, 2021
11193d6
squasme: add job matrix, cleanup javascript code
olevski Jul 14, 2021
3b5ffa6
squashme: fix github workflow
olevski Jul 14, 2021
9868de4
squashme: fix github workflow
olevski Jul 14, 2021
89b4c7a
squashme: fix git workflow
olevski Jul 14, 2021
1422d13
squashme: fix git workflow
olevski Jul 14, 2021
54f0ec0
squashme: fix docker builds for tests
olevski Jul 15, 2021
b0c0d5a
squashme: fix tests
olevski Jul 15, 2021
2387ca2
squashme: fix tests
olevski Jul 15, 2021
389fe24
squashme: fix tests
olevski Jul 15, 2021
a2e287d
squashme: fix tests
olevski Jul 15, 2021
a4c30b1
squashme: fix tests
olevski Jul 15, 2021
df58b62
squashme: fix tests
olevski Jul 15, 2021
204eae4
squashme: fix tests
olevski Jul 15, 2021
acb0fe9
Revert "squashme: fix tests"
olevski Jul 15, 2021
478a10d
squashme: fix tests
olevski Jul 15, 2021
2d0f8ce
squashme: fix tests
olevski Jul 15, 2021
f49dd98
squashme: fix tests
olevski Jul 15, 2021
33ceefb
squashme: fix tests
olevski Jul 15, 2021
415df91
squashme: fix tests
olevski Jul 15, 2021
2f51a6c
squashme: fix tests
olevski Jul 15, 2021
86fbd61
chore: update cypress tests
olevski Jul 15, 2021
7752b90
squashme: fix tests
olevski Jul 15, 2021
fe42026
squashme: fix tests
olevski Jul 15, 2021
a52d55f
squashme: fix tests
olevski Jul 15, 2021
849091a
squashme: fix r image
olevski Jul 15, 2021
85ab092
squashme: fix tests
olevski Jul 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/acceptance_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Acceptance tests

on:
pull_request:
types:
- synchronize
olevski marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build-base-python-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Image
run: |
docker build -t py docker/py/
docker save py > /tmp/py.tar
- name: Upload Image Artifact
uses: actions/upload-artifact@v2
with:
name: py
path: /tmp/py.tar

acceptance-tests:
needs: build-base-python-image
strategy:
matrix:
include:
- image_name: py
olevski marked this conversation as resolved.
Show resolved Hide resolved
test_user: jovyan
- image_name: cuda-tf
build_arg: BASE_IMAGE=py
test_user: jovyan
- image_name: generic
build_arg: RENKU_BASE=py
test_user: jovyan
- image_name: julia
build_arg: BASE_IMAGE=py
test_user: jovyan
- image_name: r
build_arg: RENKU_BASE=py
test_user: rstudio
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download Base Image
uses: actions/download-artifact@v2
with:
name: py
path: /tmp
- name: Load Base Image in Docker
run: |
docker load --input /tmp/py.tar
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would never have occurred to me 👍

- name: Build images
if: ${{ matrix.image_name != 'py' }}
run: |
docker build -t ${{ matrix.image_name }} --build-arg ${{ matrix.build_arg }} docker/${{ matrix.image_name }}/
- name: Py Image Acceptance Tests
uses: cypress-io/github-action@v2
env:
TEST_IMAGE_NAME: ${{ matrix.image_name }}
TEST_USER_NAME: ${{ matrix.test_user }}
with:
working-directory: tests
command: npx mocha test.js
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
# Ignore all local history of files
.history

## Node modules
**/node_modules/*
## Cypress
tests/cypress/videos/*
tests/cypress/screenshots/*

# End of https://www.gitignore.io/api/visualstudiocode
2 changes: 2 additions & 0 deletions docker/generic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ RUN apt-get update --fix-missing && \
libsm6 \
libxext6 \
libxrender1 \
tini \
wget \
vim && \
apt-get purge && \
Expand All @@ -51,6 +52,7 @@ ENV PATH ${CONDA_PATH}/bin:$PATH

# inject the renku-jupyter stack
COPY --from=renku_base /opt/conda /opt/conda
COPY --from=renku_base /entrypoint.sh /entrypoint.sh
COPY --from=renku_base --chown=1000:1000 \
/home/jovyan/ /home/${NB_USER}/

Expand Down
2 changes: 1 addition & 1 deletion docker/r/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RUN /rocker_scripts/install_rstudio.sh
# Add Tini
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
RUN chmod +x /tini && ln -s /tini /usr/bin/

# install dependencies
RUN apt-get update --fix-missing && \
Expand Down
28 changes: 28 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Acceptance Tests for Renkulab Images
olevski marked this conversation as resolved.
Show resolved Hide resolved

## Requirements
- node
- docker

## Run Tests
The following instructions assume that the user has navigated to the `test` folder already.

1. Install node packages: `npm install`
2. Build the docker images:

```
docker build -t py ../docker/py
docker build -t cuda-tf --build-arg BASE_IMAGE=py ../docker/cuda-tf/
docker build -t generic --build-arg RENKU_BASE=py ../docker/generic/
docker build -t julia --build-arg BASE_IMAGE=py ../docker/julia/
docker build -t r --build-arg RENKU_BASE=py ../docker/r/
```

3. Test an image: `TEST_IMAGE_NAME="py" TEST_USER_NAME="jovyan" npx mocha test.js`

Mocha is used to launch a test session with Cypress for each image. Mocha
captures and displays the logs from Cypress for each test. The reason for having Mocha
launch the Cypress tests is because the Cypress tests cannot run terminal commands
to launch a Jupyterlab container beacuse they operate only in the browser. However,
running Mocha tests does not have this limitation and the Mocha tests can launch
containers with Jupyterlab as well as all Cypress tests.
3 changes: 3 additions & 0 deletions tests/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"defaultCommandTimeout": 10000
}
22 changes: 22 additions & 0 deletions tests/cypress/integration/test.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
describe('Basic functionality', function() {
before(function() {
cy.visit(Cypress.env("URL"))
})
it('Can find launcher icons', function() {
cy.get('div.jp-LauncherCard')
})
it('Can find main menu at the top', function() {
cy.get('div#jp-menu-panel')
})
it('Can launch terminal', function() {
cy.get('div.jp-LauncherCard[title="Start a new terminal session"]').click()
})
it('Runs a command in the terminal to make new file', function () {
cy.get('canvas.xterm-link-layer')
cy.get('div.xterm-screen').click().type("touch new-file.txt{enter}")
})
it('Can see the new file in the file browser', function () {
cy.get('button[title="Refresh File List"]').click().wait(2000)
cy.get('li.jp-DirListing-item[title^="Name: new-file.txt"]')
})
})
22 changes: 22 additions & 0 deletions tests/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
24 changes: 24 additions & 0 deletions tests/cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
// import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')

Cypress.on('uncaught:exception', (err) => {
return false
})
Loading