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

Added a very basic smoke test. Run it with tox -e smoke #800

Merged
merged 6 commits into from Aug 10, 2022

Conversation

pengale
Copy link
Contributor

@pengale pengale commented Jul 14, 2022

This PR adds a smoke test will build a new "smoke" charm in test/charms/test_smoke.
The test will attempt to deploy xenial, bionic and focal versions of the charm.

Checklist

  • [N] Have any types changed? If so, have the type annotations been updated?

  • [N/A] If this code exposes model data, does it do so thoughtfully, in a way that aids understanding?

    We want to avoid simple passthrough of model data, without contextualization, where possible.
    
  • [Y] Do error messages, if any, present charm authors or operators with enough information to solve the problem?

QA steps

Make sure that you are on a box with charmcraft and juju installed, and that you are connected to a "machine" controller, such as a local lxd cloud. Then run:

tox -e smoke

Documentation changes

  • This adds a step to the release process. Right now, it's a manual step: run tox -e smoke before releasing a version of ops.

Bug reference

Changelog

  • Adds smoke test charm to test/charms dir.
  • Adds tox smoke env that builds and deploys the charm.

Notes

There are a few wonky things about this, including how we inject the current ops package, and the fact that we test with just the focal version of the charm. Future versions of this smoke test should clear those wonky bits up, as well as add automation.

This requires a development box with an active juju controller, and
charmcraft installed.

The smoke test will build the "smoke" charm in test/charms/test_smoke
and try to deploy xenial, bionic and focal versions of the charm.

There are a few wonky things about this, including how we inject the
current ops package, and the fact that we test with just the focal
version of the charm. Future versions of this smoke test should clear
those wonky bits up, as well as add automation.
@rwcarlsen
Copy link
Contributor

Would it be worth it to have tox -e smoke set up the entire environment inside lxd containers rather than doing stuff directly with juju on my/the host machine?

@pengale
Copy link
Contributor Author

pengale commented Jul 21, 2022

Would it be worth it to have tox -e smoke set up the entire environment inside lxd containers rather than doing stuff directly with juju on my/the host machine?

Eventually, yes!

... though we also want this to work on AWS and other substrates, so you'd need to make it configurable.

But that's out of scope for this PR, which was just "get this thing setup while I'm letting my brain work on dashboard on a background thread."

@pengale
Copy link
Contributor Author

pengale commented Jul 21, 2022

Also, thank you for taking a look :-)

And one more thing: this doesn't work on AWS, because pytest-operator can't handle the self signed cert. I think that's a bug in pytest-operator and/or python-libjuju. I don't think that we need to handle it in this code.

Copy link
Contributor

@rwcarlsen rwcarlsen left a comment

Choose a reason for hiding this comment

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

Looks fine. Just one small note below about adding some setup explanation in a couple spots.

Comment on lines 7 to 9
## Usage

Run `tox -e smoke` in the root directory of this repository to build and deploy this charm.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you include the QA steps info from the PR description here - the stuff about how to make sure your environment is prepared to run the tests. Also probably worth noting that same info as a comment inside tox.ini.

Copy link
Contributor

@PietroPasotti PietroPasotti 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! Just a few minor comments

# older versions of Juju.)
charm = await ops_test.build_charm("./test/charms/test_smoke/")

for series in ['focal', 'bionic', 'xenial']:
Copy link
Contributor

Choose a reason for hiding this comment

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

use pytest.mark.parametrize to give a better error message (use ids=['focal', ...] for bonus points)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I started in on this, and it ended up adding a lot of complexity. The build needs to get moved into a separate routine, and then we need a data structure to track our charm artifact. None of that is difficult to write, but it didn't feel worthwhile to do so until this test gets more complex.

logger = logging.getLogger(__name__)


CURRENT_CHANNEL = '20.04' # Focal
Copy link
Contributor

Choose a reason for hiding this comment

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

where is this used?

#
# Learn more about config at: https://juju.is/docs/sdk/config

options: {}
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC we can remove the file completely if there's no config

@@ -0,0 +1,10 @@
# Copyright 2022 Penelope Valentine Gale
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the copyright not be Canonical?

@PietroPasotti PietroPasotti mentioned this pull request Aug 5, 2022
1 task
@pengale pengale merged commit c2ffe25 into canonical:main Aug 10, 2022
Comment on lines +1 to +3
# Copyright 2022 Penelope Valentine Gale
# See LICENSE file for licensing details.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like maybe fixing this copyright line got missed before the merge?

@benhoyt
Copy link
Collaborator

benhoyt commented Aug 14, 2022

Is this being run by GitHub Actions? If so, I'm wondering why the tests are succeeding when the Xenial fix #810 isn't yet merged?

@pengale
Copy link
Contributor Author

pengale commented Aug 15, 2022

Is this being run by GitHub Actions? If so, I'm wondering why the tests are succeeding when the Xenial fix #810 isn't yet merged?

The smoke tests are manual tests for now -- this is something that I timeboxed and snuck in as a bonus.

We intend to automate them in the future. (Probably the next time I need to take a thinking break on what I'm officially working on for a bit.)

rwcarlsen pushed a commit to rwcarlsen/operator that referenced this pull request Aug 17, 2022
)

This requires a development box with an active juju controller, and
charmcraft installed.

The smoke test will build the "smoke" charm in test/charms/test_smoke
and try to deploy xenial, bionic and focal versions of the charm.

There are a few wonky things about this, including how we inject the
current ops package, and the fact that we test with just the focal
version of the charm. Future versions of this smoke test should clear
those wonky bits up, as well as add automation.
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.

None yet

5 participants