Skip to content

docs: add COS Lite integration tests to K8s tutorial#2478

Merged
dwilding merged 10 commits into
canonical:mainfrom
dwilding:k8s-tutorial-cos-integration
May 22, 2026
Merged

docs: add COS Lite integration tests to K8s tutorial#2478
dwilding merged 10 commits into
canonical:mainfrom
dwilding:k8s-tutorial-cos-integration

Conversation

@dwilding
Copy link
Copy Markdown
Contributor

@dwilding dwilding commented May 16, 2026

This PR follows on from #2411 and resolves #1838.

I'm adding a new section Write integration tests (preview) to the last chapter of the K8s tutorial. The tests in this section match what was added to the example charm in the previous PR.

Other changes:

  • Adjusted the part where we talk about adding cosl to dependencies. It wasn't clear why 1.9.1 should be added based on the versions required by libs, so I'm explicitly saying to add the latest version of the package. Preview

  • During earlier testing, I found that the postgres deployment can cause the integration tests to time out. We don't want to specify a timeout in that test, so I've added some info to the tutorial chapter (Preview):

    If the test fails with a timeout error, override the default timeout in test_database_integration:
    ...

@dwilding dwilding marked this pull request as ready for review May 16, 2026 05:09
@dwilding dwilding requested a review from tromai May 16, 2026 05:10
Copy link
Copy Markdown
Contributor

@tromai tromai left a comment

Choose a reason for hiding this comment

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

The docs changes look good to me. Thank you.

I agree with letting the users know about overriding the timeout period.

There might be an issue that makes the test timeout, and increasing the period doesn't help. In such case, the reader should debug their tests or look for help. This could be a small "note" or "warning" at the end. I'm not sure whether we should include it, as it's hard to know how long is too long.

@dwilding
Copy link
Copy Markdown
Contributor Author

There might be an issue that makes the test timeout, and increasing the period doesn't help. In such case, the reader should debug their tests or look for help. This could be a small "note" or "warning" at the end. I'm not sure whether we should include it, as it's hard to know how long is too long.

Yeah, I think it's hard to give general advice. But I like your thinking. I've updated the advice slightly:

Then run tox -e integration again. If the test still fails, try our example charm for this chapter instead, in case there's a mistake in your code.

@tromai
Copy link
Copy Markdown
Contributor

tromai commented May 19, 2026

Then run tox -e integration again. If the test still fails, try our example charm for this chapter instead, in case there's a mistake in your code.

This is perfect. Thanks!

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.

Looks good to me, thanks @dwilding. My main suggestion is that we add @pytest.mark.juju_setup to the deploy and integrate tests (should add them to the examples too in this PR if so).

Add two test functions to `tests/integration/test_charm.py`:

```python
def test_deploy_cos(cos: jubilant.Juju):
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.

Presumably we'd want this.

Suggested change
def test_deploy_cos(cos: jubilant.Juju):
@pytest.mark.juju_setup
def test_deploy_cos(cos: jubilant.Juju):

And I guess we want it on the integrate test as well.

Again, something I should have noticed in the previous PR.

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.

Pretty sure you did notice it in the previous PR. I deferred doing it there because I want to get @pytest.mark.juju_setup into the profiles first. I'm going to use the same excuse here 🙂 When canonical/charmcraft#2695 merges, I'll open an Ops PR to add @pytest.mark.juju_setup to the tutorials and example charms.

@dwilding dwilding merged commit 8e009f4 into canonical:main May 22, 2026
59 checks passed
@dwilding dwilding deleted the k8s-tutorial-cos-integration branch May 22, 2026 03:32
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.

K8s tutorial: add integration tests for COS Lite relations

4 participants