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

ci: initial implementation of top-level pytest tests #433

Merged

Conversation

jiridanek
Copy link
Member

@jiridanek jiridanek commented Feb 26, 2024

Description

This establishes a top level Poetry-managed environment for writing tests for Notebooks in Python. There is currently a single test to check that all Pipfiles have the correct python version specified in them.

Documentation

Pytest supports two styles of writing tests, either class-based (unittest package style) or function and fixtures-based (pytest package style). Here's docs for the unittests approach https://docs.python.org/3/library/unittest.html#basic-example, and for the support in Pytest https://docs.pytest.org/en/7.1.x/how-to/unittest.html.

Main advantage of Pytest is that it can export results as JUnit XML files out of the box, and that it supports assertions using the assert keyword, instead of having to use the assert methods.

How Has This Been Tested?

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link
Contributor

openshift-ci bot commented Feb 26, 2024

Hi @jiridanek. Thanks for your PR.

I'm waiting for a opendatahub-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jiridanek
Copy link
Member Author

Yeah, this, @jstourac just mentioned this PR at a meeting, asking about status

Copy link
Contributor

openshift-ci bot commented Jun 21, 2024

@jiridanek: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/runtime-intel-pyt-ubi9-python-3-9-pr-image-mirror 5fbdfdb link true /test runtime-intel-pyt-ubi9-python-3-9-pr-image-mirror
ci/prow/notebook-jupyter-intel-ml-ubi9-python-3-9-pr-image-mirror 5fbdfdb link true /test notebook-jupyter-intel-ml-ubi9-python-3-9-pr-image-mirror
ci/prow/notebook-jupyter-intel-pyt-ubi9-python-3-9-pr-image-mirror 5fbdfdb link true /test notebook-jupyter-intel-pyt-ubi9-python-3-9-pr-image-mirror
ci/prow/notebook-jupyter-intel-tf-ubi9-python-3-9-pr-image-mirror 5fbdfdb link true /test notebook-jupyter-intel-tf-ubi9-python-3-9-pr-image-mirror
ci/prow/runtime-intel-tf-ubi9-python-3-9-pr-image-mirror 5fbdfdb link true /test runtime-intel-tf-ubi9-python-3-9-pr-image-mirror
ci/prow/anaconda-ubi8-e2e-tests 5fbdfdb link true /test anaconda-ubi8-e2e-tests
ci/prow/intel-notebooks-e2e-tests 5fbdfdb link true /test intel-notebooks-e2e-tests
ci/prow/rstudio-notebook-e2e-tests 5fbdfdb link true /test rstudio-notebook-e2e-tests
ci/prow/runtimes-ubi9-e2e-tests 5fbdfdb link true /test runtimes-ubi9-e2e-tests
ci/prow/notebooks-ubi9-e2e-tests 5fbdfdb link true /test notebooks-ubi9-e2e-tests
ci/prow/runtimes-ubi8-e2e-tests 5fbdfdb link true /test runtimes-ubi8-e2e-tests
ci/prow/codeserver-notebook-e2e-tests 5fbdfdb link true /test codeserver-notebook-e2e-tests

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@jiridanek jiridanek force-pushed the jd_2024_02_24_unittests branch 3 times, most recently from 87fc54c to 20b7c4f Compare July 9, 2024 08:23
@jiridanek jiridanek marked this pull request as ready for review July 9, 2024 08:25
@openshift-ci openshift-ci bot requested review from dibryant and harshad16 July 9, 2024 08:25
@jiridanek jiridanek changed the title Jd 2024 02 24 unittests ci: initial implementation of top-level pytest tests Jul 9, 2024
Copy link
Member

@jstourac jstourac left a comment

Choose a reason for hiding this comment

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

I wonder - do we plan to utilize this also for the functional testing of the build images or is this planned just as a set of checks for something like the static code analysis? Maybe a combination of both?

My concern here is that we don't introduce yet another "static code" check which we already have written in bash scripts elsewhere. The ultimate goal should be to replace the current Makefile like testing approach with something more flexible, cleaner and more scalable. Does this apply to this approach?

id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.12'
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering whether such new python version won't collide with possible future basic functional tests to test actual python packages? Shouldn't we rather stick to what we have in 2024a branch, that means Python 3.11? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Python 3.12 is not a problem. I think that that would be a valid comment for what @paulovmr is doing in

(and he has that handled, in his PR there's a separate env for every image)

Here, if we wanted to run something inside the images, which is the only meaningful way to do functional tests of packages installed in images, then we would naturally not use the python, package version, or lock file maintained in the top level by poetry, but we'd run pip install the same way as the current makefile tests install papermill, etc.

Copy link
Member Author

@jiridanek jiridanek left a comment

Choose a reason for hiding this comment

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

I wonder - do we plan to utilize this also for the functional testing of the build images or is this planned just as a set of checks for something like the static code analysis? Maybe a combination of both?

I want to use https://github.com/testcontainers/testcontainers-python to test the built images.

My concern here is that we don't introduce yet another "static code" check which we already have written in bash scripts elsewhere. The ultimate goal should be to replace the current Makefile like testing approach with something more flexible, cleaner and more scalable. Does this apply to this approach?

Absolutely; replacing static checks with Python would be also nice, I think, but the main goal for me is testing the built images.

id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.12'
Copy link
Member Author

Choose a reason for hiding this comment

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

Python 3.12 is not a problem. I think that that would be a valid comment for what @paulovmr is doing in

(and he has that handled, in his PR there's a separate env for every image)

Here, if we wanted to run something inside the images, which is the only meaningful way to do functional tests of packages installed in images, then we would naturally not use the python, package version, or lock file maintained in the top level by poetry, but we'd run pip install the same way as the current makefile tests install papermill, etc.

```
$ poetry init
$ poetry add --dev pytest
$ poetry add --dev pytest-subtests
```
Copy link
Contributor

openshift-ci bot commented Jul 12, 2024

New changes are detected. LGTM label has been removed.

Copy link
Contributor

openshift-ci bot commented Jul 17, 2024

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: jstourac

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit fecd10c into opendatahub-io:main Jul 17, 2024
8 checks passed
jstourac pushed a commit to jstourac/notebooks that referenced this pull request Nov 13, 2024
[RHOAIENG-15710] fix the version of codeflare-sdk shown for 2024.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants