Skip to content

Commit

Permalink
debug test
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Jan 23, 2024
1 parent 58654f1 commit 9cadfc7
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 61 deletions.
113 changes: 64 additions & 49 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,54 +100,54 @@ jobs:
shell: bash -l {0}
run: python -c "import tljh_repo2docker"

unit-tests:
name: Unit tests
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
jupyterhub-version: [latest, 1.2.2]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: "1.5.5-0"
environment-name: tljh
init-shell: bash
create-args: >-
python=${{ matrix.python-version }}
nodejs=18
yarn=3
- name: Download app package
uses: actions/download-artifact@v3
with:
name: tljh_repo2docker-artifacts

- name: Install package
shell: bash -l {0}
run: |
set -eux
python -m pip install -r dev-requirements.txt
python -m pip install tljh_repo2docker*.whl
npm -g install configurable-http-proxy
- name: Downgrade jupyterhub
if: ${{ matrix.jupyterhub-version != 'latest' }}
shell: bash -l {0}
run: |
python -m pip install -U 'jupyterhub==${{ matrix.jupyterhub-version }}'
- name: Run Tests
shell: bash -l {0}
run: |
python -m pytest --cov
# unit-tests:
# name: Unit tests
# needs: build
# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# python-version: ["3.8", "3.9", "3.10"]
# jupyterhub-version: [latest, 1.2.2]

# steps:
# - name: Checkout
# uses: actions/checkout@v3

# - name: Set up Python ${{ matrix.python-version }}
# uses: mamba-org/setup-micromamba@v1
# with:
# micromamba-version: "1.5.5-0"
# environment-name: tljh
# init-shell: bash
# create-args: >-
# python=${{ matrix.python-version }}
# nodejs=18
# yarn=3

# - name: Download app package
# uses: actions/download-artifact@v3
# with:
# name: tljh_repo2docker-artifacts

# - name: Install package
# shell: bash -l {0}
# run: |
# set -eux
# python -m pip install -r dev-requirements.txt
# python -m pip install tljh_repo2docker*.whl
# npm -g install configurable-http-proxy

# - name: Downgrade jupyterhub
# if: ${{ matrix.jupyterhub-version != 'latest' }}
# shell: bash -l {0}
# run: |
# python -m pip install -U 'jupyterhub==${{ matrix.jupyterhub-version }}'

# - name: Run Tests
# shell: bash -l {0}
# run: |
# python -m pytest --cov

integration-tests:
name: Integration tests
Expand All @@ -171,6 +171,7 @@ jobs:
python=3.10
nodejs=18
yarn=3
wget
- name: Download app package
uses: actions/download-artifact@v3
Expand Down Expand Up @@ -207,14 +208,27 @@ jobs:
- name: Start JupyterHub
shell: bash -l {0}
run: |
python -m jupyterhub -f ./jupyterhub_config.py &
ls
python -m jupyterhub -f ./jupyterhub_config.py > hub.log &
- name: Wait for JupyterHub
uses: ifaxity/wait-on-action@v1
with:
resource: http-get://localhost:8000
timeout: 360000

- name: Test file
shell: bash -l {0}
run: |
which python
ls /home/runner/micromamba/envs/tljh/lib/python3.10/site-packages/tljh_repo2docker/static/js/react/*.js
which jupyterhub
jupyterhub --version
wget http://localhost:8000
head -10 index.html
wget http://localhost:8000/hub/environments-static/js/react/servers.js
- name: Execute integration tests
shell: bash -l {0}
working-directory: frontend/ui-tests
Expand All @@ -229,3 +243,4 @@ jobs:
path: |
frontend/ui-tests/test-results
frontend/ui-tests/playwright-report
hub.log
9 changes: 2 additions & 7 deletions frontend/ui-tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ module.exports = {
reporter: [[process.env.CI ? 'dot' : 'list'], ['html']],
use: {
baseURL: 'http://localhost:8000',
video: 'retain-on-failure'
},
retries: 0,
expect: {
toMatchSnapshot: {
maxDiffPixelRatio: 0.005
}
video: 'retain-on-failure',
trace: 'always'
}
};
19 changes: 15 additions & 4 deletions frontend/ui-tests/tests/ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test.describe('tljh_repo2docker UI Tests', () => {

test('Render Login', async ({ page }) => {
await page.goto('hub/login');
await page.waitForTimeout(1000);
await page.getByText('Sign in');
expect(await page.screenshot()).toMatchSnapshot();
});
Expand All @@ -34,15 +35,25 @@ test.describe('tljh_repo2docker UI Tests', () => {
});
test('Render servers page', async ({ page }) => {
await login(page, 'alice');
await page.getByRole('link', { name: 'Servers' }).click();
await page.waitForURL('**/servers');
// await page.getByRole('link', { name: 'Servers' }).click();
// await page.waitForURL('**/servers');
await page.goto('hub/servers');
page.on('console', msg => {
console.log(`Error text: "${msg.text()}"`);
});
await page.waitForTimeout(1000);
await page.getByText('No servers are running');
expect(await page.screenshot()).toMatchSnapshot();
});
test('Render environments page', async ({ page }) => {
await login(page, 'alice');
await page.getByRole('link', { name: 'Environments' }).click();
await page.waitForURL('**/environments');
// await page.getByRole('link', { name: 'Environments' }).click();
// await page.waitForURL('**/environments');
await page.goto('hub/environments');
page.on('console', msg => {
console.log(`Error text: "${msg.text()}"`);
});
await page.waitForTimeout(1000);
await page.getByText('No environment available');
expect(await page.screenshot()).toMatchSnapshot();
});
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion tljh_repo2docker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import Any, Coroutine

from aiodocker import Docker
from dockerspawner import DockerSpawner
Expand Down Expand Up @@ -157,6 +158,15 @@ async def set_limits(self):
)


class Temp(CacheControlStaticFilesHandler):
async def get(self, path: str, include_body: bool = True) -> None:
temp = self.parse_url_path(path)
aa = self.get_absolute_path(self.root, temp)
print("@###############", path, aa, flush=True)

return await super().get(path, include_body)


class Repo2DockerSpawner(SpawnerMixin, DockerSpawner):
"""
A custom spawner for using local Docker images built with tljh-repo2docker.
Expand Down Expand Up @@ -203,7 +213,7 @@ def tljh_custom_jupyterhub_config(c):
(r"api/environments/([^/]+)/logs", LogsHandler),
(
r"environments-static/(.*)",
CacheControlStaticFilesHandler,
Temp,
{"path": os.path.join(os.path.dirname(__file__), "static")},
),
]
Expand Down

0 comments on commit 9cadfc7

Please sign in to comment.