-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add acceptance tests with cypress/mocha
- Loading branch information
Showing
12 changed files
with
2,118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Acceptance tests | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- synchronize | ||
|
||
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 | ||
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 | ||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Acceptance Tests for Renkulab Images | ||
|
||
## 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"defaultCommandTimeout": 10000 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"]') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}) |
Oops, something went wrong.