close
Skip to content

docs: in integration tests, use consistent approach to logging and packing#2150

Merged
dwilding merged 6 commits intocanonical:mainfrom
dwilding:integration-pack-log
Oct 30, 2025
Merged

docs: in integration tests, use consistent approach to logging and packing#2150
dwilding merged 6 commits intocanonical:mainfrom
dwilding:integration-pack-log

Conversation

@dwilding
Copy link
Copy Markdown
Contributor

@dwilding dwilding commented Oct 28, 2025

This PR updates How to write integration tests for a charm and the httpbin-demo charm to be consistent with the Charmcraft 4 profiles and our new machine tutorial:

  • How to write integration tests for a charm

    • Use sleep to wait for Juju to process logs, then output the logs to stderr.
    • Change conftest.py to check the CHARM_PATH environment variable instead of packing the charm.
    • Update surrounding docs to clarify that packing should be separate from running integration tests, and to explain how to specify which .charm file to deploy in the tests.
    • Make all tests depend on the charm fixture, for a better failure experience if there's no .charm file available.

    Preview of updated doc

  • httpbin-demo charm - Use sleep to wait for Juju to process logs, then output the logs to stderr.

I haven't updated the integration tests in the Kubernetes charm tutorial. We plan to switch the tutorial to use the Charmcraft 4 profile at a later date.

Copy link
Copy Markdown
Contributor

@james-garner-canonical james-garner-canonical left a comment

Choose a reason for hiding this comment

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

Some small suggestions, but looks good to me overall -- and we'll need to update this next cycle when we work on pytest-jubilant anyway.

Comment thread docs/howto/write-integration-tests-for-a-charm.md Outdated
CHARM_PATH=/path/to/foo.charm tox -e integration
```

Your tests will use the context of the current controller in Juju, and by default will create a new model per module, that will be destroyed when the test is finished. The cloud, controller and model name can be specified with the parameters `--cloud`, `--controller` and `--model` parameters.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Your tests will use the context of the current controller in Juju, and by default will create a new model per module, that will be destroyed when the test is finished. The cloud, controller and model name can be specified with the parameters `--cloud`, `--controller` and `--model` parameters.
Your tests will use the context of the current controller in Juju. By default a new model is created for each test module, that will be destroyed when the test is finished -- this is determined by the scope of the `juju` fixture. The cloud, controller and model name can be specified with the parameters `--cloud`, `--controller` and `--model`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Building on James's:

Suggested change
Your tests will use the context of the current controller in Juju, and by default will create a new model per module, that will be destroyed when the test is finished. The cloud, controller and model name can be specified with the parameters `--cloud`, `--controller` and `--model` parameters.
Your tests will use the current Juju controller. By default a new model will be created for each test module, which will be destroyed when the test is finished -- this is determined by the scope of the `juju` fixture. The cloud, controller and model name can be specified with the parameters `--cloud`, `--controller` and `--model` parameters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good suggestions, thanks. I adjusted slightly for readability, as I feel the sentence about parameters fits better with the following paragraph. Here's what I've gone with:

Your tests will use the current Juju controller. By default, a new model will be created for each test module. The model will be destroyed when the test is finished. This is determined by the scope of the juju fixture.

Use the --cloud, --controller, and --model parameters to specify the cloud, controller, and model name. If you specify the model name and include the --keep-models parameter, you can reuse a model from a previous test run. For example:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just noticed that 'the model will be destroyed when the test is finished' is a bit inaccurate, since it's not till the module of tests has finished

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well spotted! I've opened #2154 to fix

Copy link
Copy Markdown
Collaborator

@tonyandrewmeyer tonyandrewmeyer left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. Looks good to me, just a small suggestion building on one from James.

Comment thread docs/howto/write-integration-tests-for-a-charm.md Outdated
CHARM_PATH=/path/to/foo.charm tox -e integration
```

Your tests will use the context of the current controller in Juju, and by default will create a new model per module, that will be destroyed when the test is finished. The cloud, controller and model name can be specified with the parameters `--cloud`, `--controller` and `--model` parameters.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Building on James's:

Suggested change
Your tests will use the context of the current controller in Juju, and by default will create a new model per module, that will be destroyed when the test is finished. The cloud, controller and model name can be specified with the parameters `--cloud`, `--controller` and `--model` parameters.
Your tests will use the current Juju controller. By default a new model will be created for each test module, which will be destroyed when the test is finished -- this is determined by the scope of the `juju` fixture. The cloud, controller and model name can be specified with the parameters `--cloud`, `--controller` and `--model` parameters.

@dwilding dwilding merged commit 312f379 into canonical:main Oct 30, 2025
56 checks passed
@dwilding dwilding deleted the integration-pack-log branch October 30, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants