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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

mishaschwartz
Copy link
Collaborator

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.

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
./optional-components/local-dev-test
./optional-components/prometheus-log-parser
./optional-components/secure-data-proxy
./optional-components/wps-healthchecks
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need this ./optional-components/wps-healthchecks? Should it be deleted given you added health check to all containers by default (good call).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I left the WPS healthchecks in their own optional component. I'm happy to move them into the main docker compose files so that they're enabled by default but I left them as they were initially.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not for this PR if you prefer separate, but I really like your idea to have all healthcheck on by default instead of optionally. I do not see any good reasons for someone to disable it so why make it optional.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I think I agree. I'll see if @fmigneault has an opinion but otherwise I can merge the WPS healthchecks in as part of this PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with making them defined by default.

@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

@@ -1,6 +1,10 @@
#!/bin/sh

BIRDHOUSE_COLOR=${BIRDHOUSE_COLOR:-1}
# support NO_COLOR flag (https://no-color.org/)
if [ -z "${BIRDHOUSE_COLOR}" ] && [ "${NO_COLOR}" != '1' ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if [ -z "${BIRDHOUSE_COLOR}" ] && [ "${NO_COLOR}" != '1' ]; then
if [ -z "${BIRDHOUSE_COLOR}" ] && [ -z "${NO_COLOR}" ]; then

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://no-color.og/ says "NO_COLOR environment variable that, when present and not an empty string (regardless of its value), prevents the addition of ANSI color." so I think we should not just check for NO_COLOR == 1.

@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.

@@ -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

Choose a reason for hiding this comment

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

Can this be renamed to test.env so highlights are properly done on GitHub?
This will help read and review changes.

We can add a top-level comment to be explicit that this corresponds to env.local corresponding to https://github.com/bird-house/birdhouse-deploy/blob/master/birdhouse/env.local.example.

./optional-components/local-dev-test
./optional-components/prometheus-log-parser
./optional-components/secure-data-proxy
./optional-components/wps-healthchecks
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with making them defined by default.

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?

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