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
Conversation
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.
Would it be worth it to have |
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." |
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. |
There was a problem hiding this 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.
test/charms/test_smoke/README.md
Outdated
## Usage | ||
|
||
Run `tox -e smoke` in the root directory of this repository to build and deploy this charm. |
There was a problem hiding this comment.
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.
There was a problem hiding this 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']: |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
test/smoke/test_smoke.py
Outdated
logger = logging.getLogger(__name__) | ||
|
||
|
||
CURRENT_CHANNEL = '20.04' # Focal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this used?
test/charms/test_smoke/config.yaml
Outdated
# | ||
# Learn more about config at: https://juju.is/docs/sdk/config | ||
|
||
options: {} |
There was a problem hiding this comment.
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
test/charms/test_smoke/config.yaml
Outdated
@@ -0,0 +1,10 @@ | |||
# Copyright 2022 Penelope Valentine Gale |
There was a problem hiding this comment.
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?
# Copyright 2022 Penelope Valentine Gale | ||
# See LICENSE file for licensing details. | ||
|
There was a problem hiding this comment.
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?
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.) |
) 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.
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?
[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:
Documentation changes
tox -e smoke
before releasing a version of ops.Bug reference
Changelog
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.