Skip to content

Commit

Permalink
#19: move slc notebook to repo ai lab (#300)
Browse files Browse the repository at this point in the history
fixes #19
  • Loading branch information
tomuben authored Jul 23, 2024
1 parent c1245f0 commit 19217eb
Show file tree
Hide file tree
Showing 14 changed files with 1,861 additions and 18 deletions.
1 change: 1 addition & 0 deletions doc/changes/changes_2.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Version: 2.1.0

* 277 Added the SaaS database parameters to the configuration page.
* 279 Made the notebooks tests running in SaaS as well as in the Docker-DB.
* 19 Added SLC notebook

## Security

Expand Down
65 changes: 48 additions & 17 deletions doc/developer_guide/testing.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,82 @@
### Tests
# Tests

XAL comes with a number of tests in directory `test`.
Besides, unit and integrations tests in the respective directories
there are tests in directory `codebuild`, see [Executing AWS CodeBuild](ci.md#executing-aws-codebuild).
XAIL comes with a number of tests in the directory `test`. Besides, unit and integration tests in the respective directories, there are tests in the directory `codebuild`, see [Executing AWS CodeBuild](ci.md#executing-aws-codebuild).

# Speeding up Docker-based Tests
## Speeding up Docker-based Tests

Creating a docker image is quite time-consuming, currently around 7 minutes. In order to use an existing
docker image in the tests in `integration/test_create_dss_docker_image.py`
simply add CLI option `--dss-docker-image` when calling `pytest`:
Creating a docker image is quite time-consuming, currently around 7 minutes.

To get test results faster, you can use an existing Docker image. You can create such an image using the [CLI command](commands.md#release-commands) `create-docker-image` or run your tests once with an additional CLI option `--keep-dss-docker-image` to keep the image rather than removing it after the test session.

Sample usage of the command `create-docker-image`:
```shell
poetry run exasol/ds/sandbox/main.py \
create-docker-image \
--version 9.9.9 \
--log-level info
```

To use an existing docker image in the tests in `integration/test_create_dss_docker_image.py`, simply add the CLI option `--dss-docker-image` when calling `pytest`:

```shell
poetry run pytest --dss-docker-image exasol/ai-lab:2.1.0
```

#### Executing tests involving AWS resources
## Tests for Jupyter Notebooks

The AI-Lab also contains end-to-end tests for Jupyter notebooks. Executing these tests can take several hours, currently ~3h.

The notebook tests are based on a common parameterized [test-runner](../../test/notebook_test_runner/test_notebooks_in_dss_docker_image.py). The test-runner contains a single parameterized test case on the outer level. Each time the test is executed, the test is parameterized with a Python file from the directory [test/notebooks](../../test/notebooks/) containing the particular test cases for one of the Jupyter notebooks.

The outer test case then uses a session-scoped fixture for creating an ordinary AI-Lab Docker image. Another session-scoped fixture adds some packages for executing the notebook tests, resulting in a second Docker image. Finally, the test-runner launches a Docker container from the second image and runs the inner test cases for the current notebook inside the Docker container.

In total, the following Docker entities are involved:
* Docker image 1 of the AI-Lab
* Docker image 2 for running the inner notebook tests
* Docker container running Docker image 2

In AWS web interface, IAM create an access key for CLI usage and save or download the *access key id* and the *secret access key*.
### Speeding up Notebook Tests

In file `~/.aws/config` add lines
You can speed up the notebook tests using the [same strategy](#speeding-up-docker-based-tests) as for tests involving the basic Docker image for the AI-Lab.

The CLI option to keep the image is `--keep-docker-image-notebook-test`, the option for using an existing Docker image for executing the notebook tests is `--docker-image-notebook-test`.

```shell
poetry run pytest --docker-image-notebook-test <name:version>
```

## Executing Tests Involving AWS Resources

In the AWS web interface, IAM create an access key for CLI usage and save or download the *access key id* and the *secret access key*.

In the file `~/.aws/config`, add lines:

```
[profile dss_aws_tests]
region = eu-central-1
```

In file `~/.aws/credentials` add
In the file `~/.aws/credentials`, add:

```
[dss_aws_tests]
aws_access_key_id=...
aws_secret_access_key=...
```

In case your are using MFA authentication please allocate a temporary token.
In case you are using MFA authentication, please allocate a temporary token.

After that you can set an environment variable and execute the tests involving AWS resources:
After that, you can set an environment variable and execute the tests involving AWS resources:

```shell
export AWS_PROFILE=dss_aws_tests_mfa
poetry run pytest test/test_deploy_codebuild.py
```

#### Executing tests involving Ansible
## Executing Tests Involving Ansible

For making pytest display Ansible log messages, please use
To make pytest display Ansible log messages, please use:

```shell
poetry run pytest -s -o log_cli=true -o log_cli_level=INFO
```
```
Loading

0 comments on commit 19217eb

Please sign in to comment.