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

Add integration test framework #492

Merged
merged 12 commits into from
Jan 17, 2025
Merged

Add integration test framework #492

merged 12 commits into from
Jan 17, 2025

Conversation

mishaschwartz
Copy link
Collaborator

@mishaschwartz mishaschwartz commented Jan 7, 2025

Overview

This update adds a framework for testing the deployed stack using pytest. This will allow developers to check
that their changes are consistent with the existing stack and to add additionally tests when new functionality
is introduced.

Changes to implement this include:

  • existing unit tests are moved to the tests/unit/ directory
  • new integration tests are written in the tests/integration/ directory. More tests will be added in the
    future!
  • conftest.py scripts updated to bring the stack up/down in a consistent way for the integration tests.
  • unit tests updated to accomodate new testing infrastructure as needed.
  • unit tests updated to test logging outputs better
  • birdhouse interface script updated to support testing infrastructure (this should not change anything for
    other end-users).
  • additional documentation added to birdhouse interface to improve user experience.
  • docker healthchecks added to more components so that the readiness of the stack can be determined with or
    without the use of the canarie-api component.
  • deprecates the optional-components/wps-healthchecks component since the healthchecks are now added by default
    to all WPS components.

Next steps:

  • add more integration tests as needed
  • add a framework for testing migrating the stack from one version to another

Changes

Non-breaking changes

  • Adds integration tests and healthchecks

Breaking changes

  • None

Related Issue / Discussion

  • Introduces a mechanism for testing the stack locally so that we don't need to rely on integration tests run by notebooks through Jenkins. Since the Jenkins CI tests have been broken lately.
  • This also gives developers a mechanism to tests their work locally and establishes a simple way to write integration tests (without the need to wrap them in jupyter notebooks).
  • This PR only introduces the framework for creating these tests. Once this is approved, the actual work of writing the tests can start.
  • Further discussion/planning is needed if we want to eventually run these tests in the CI pipeline

Additional Information

CI Operations

birdhouse_daccs_configs_branch: master
birdhouse_skip_ci: false

@github-actions github-actions bot added ci/deployment Related to deployment utilities and scripts ci/operations Continuous Integration components ci/tests Issues or changes related to tests scripts component/cowbird Related to https://github.com/Ouranosinc/cowbird component/geoserver Related to GeoServer or one of its underlying services component/jupyterhub Related to JupyterHub as development frontend with notebooks component/magpie Related to https://github.com/Ouranosinc/Magpie component/STAC Features or components related to STAC component/THREDDS Features or components related to THREDDS component/twitcher Related to https://github.com/bird-house/twitcher component/weaver Related to https://github.com/crim-ca/weaver documentation Improvements or additions to documentation feature/WPS Feature or service related to Web Processing Service labels Jan 7, 2025
Copy link
Collaborator

@tlvu tlvu left a comment

Choose a reason for hiding this comment

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

Very interesting PR. Just my just pass. I'll come back.

birdhouse/birdhouse-compose.sh Show resolved Hide resolved
tests/env.local.test Outdated Show resolved Hide resolved
@tlvu tlvu self-requested a review January 9, 2025 20:02
Copy link
Collaborator

@tlvu tlvu left a comment

Choose a reason for hiding this comment

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

one more minor comment

birdhouse/scripts/logging.include.sh Outdated Show resolved Hide resolved
@tlvu tlvu self-requested a review January 15, 2025 00:26
Copy link
Collaborator

@fmigneault fmigneault left a comment

Choose a reason for hiding this comment

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

Nice PR!

Comment on lines +102 to +104
if [ "${option}" = "no-suffix" ]; then
configs_cmd_suffix=
fi
Copy link
Collaborator

Choose a reason for hiding this comment

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

If $(print_config_command) was used, wouldn't if [ -z "$1" ]; then work the same?

Just curious. no-suffix is fine, but seems like a roundabout way with unnecessary hardcoded values.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By using a constant like 'no-suffix', it allows us to easily add other options in the future as well. For this specific use case [ -z "$1" ] would work as well but it's not as friendly to future developers.

I also like no-suffix because it's self-documenting 🤷

@@ -22,3 +22,10 @@ services:
REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
restart: always
logging: *default-logging
healthcheck:
test: ["CMD", "curl", "--fail", "${BIRDHOUSE_FQDN_PUBLIC}"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally we should use an internal endpoint/port to avoid loop-back requests.

Also, consider using another endpoint such as the /version, since the root path gets redirected to whichever "frontend" entrypoint is defined, which might be inconsistent or pinging another redirected service from the stack.

Copy link
Collaborator Author

@mishaschwartz mishaschwartz Jan 16, 2025

Choose a reason for hiding this comment

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

I like the idea to an internal endpoint.

Just a note: curl won't follow redirects unless the --location flag is used so we don't have to worry about redirects to inconsistent places in this case.

So something like curl --fail http://localhost is sufficient because either it will redirect (success) if the nginx component is working or will fail if it isn't.

tests/env.local.test Outdated Show resolved Hide resolved
tests/env.local.test Outdated Show resolved Hide resolved
Copy link
Collaborator

@tlvu tlvu left a comment

Choose a reason for hiding this comment

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

Other than the minor NO_COLOR left, great PR !



@pytest.fixture(scope="module", autouse=True)
def start_stack(request, cli_path, local_env_file, tmp_data_persist_root, stack_info, pytestconfig):
Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't seen usage of this new fixture. In fact, same for most of the new fixtures here.

I am guessing you are simply setting up for the future?

Copy link
Collaborator Author

@mishaschwartz mishaschwartz Jan 16, 2025

Choose a reason for hiding this comment

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

Fixtures with autouse=True are used automatically in tests within their scope. So you won't see most of these referenced explicitly in tests (but they are being used!).

Copy link
Collaborator

Choose a reason for hiding this comment

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

OH ! Interesting!

Copy link
Collaborator

@fmigneault fmigneault left a comment

Choose a reason for hiding this comment

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

Just needs a line to changelog about the deprecated wps-healthchecks.

@mishaschwartz mishaschwartz merged commit 31ab4ff into master Jan 17, 2025
4 of 5 checks passed
@mishaschwartz mishaschwartz deleted the integration-tests branch January 17, 2025 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/deployment Related to deployment utilities and scripts ci/operations Continuous Integration components ci/tests Issues or changes related to tests scripts component/cowbird Related to https://github.com/Ouranosinc/cowbird component/geoserver Related to GeoServer or one of its underlying services component/jupyterhub Related to JupyterHub as development frontend with notebooks component/magpie Related to https://github.com/Ouranosinc/Magpie component/STAC Features or components related to STAC component/THREDDS Features or components related to THREDDS component/twitcher Related to https://github.com/bird-house/twitcher component/weaver Related to https://github.com/crim-ca/weaver documentation Improvements or additions to documentation feature/WPS Feature or service related to Web Processing Service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants