Merge charm-hw-health:improve-dev-workflow into charm-hw-health:master

Proposed by Facundo Ciccioli
Status: Rejected
Rejected by: Haw Loeung
Proposed branch: charm-hw-health:improve-dev-workflow
Merge into: charm-hw-health:master
Diff against target: 113 lines (+57/-5)
4 files modified
src/README.md (+41/-0)
src/tests/functional/conftest.py (+7/-3)
src/tests/functional/test_hwhealth.py (+5/-1)
src/tox.ini (+4/-1)
Reviewer Review Type Date Requested Status
Tom Haddon Abstain
Paul Goins Needs Fixing
🤖 prod-jenkaas-bootstack (community) continuous-integration Needs Fixing
BootStack Reviewers mr tracking; do not claim Pending
BootStack Reviewers Pending
Review via email: mp+399589@code.launchpad.net
To post a comment you must log in.
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

FAILED: Continuous integration, rev:6e476272c328c0f0739f4103299546aa54a42cae

No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want jenkins to rebuild you need to trigger it yourself):
https://code.launchpad.net/~llama-charmers/charm-hw-health/+git/charm-hw-health/+merge/399589/+edit-commit-message

https://jenkins.canonical.com/bootstack/job/lp-charm-hw-health-ci/2/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/bootstack/job/lp-charm-test-unit/53/
    None: https://jenkins.canonical.com/bootstack/job/lp-update-mp/140/

Click here to trigger a rebuild:
https://jenkins.canonical.com/bootstack/job/lp-charm-hw-health-ci/2//rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Paul Goins (vultaire) wrote :

This is an interesting patch. I have some small concerns; please take a look.

review: Needs Fixing
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Tom Haddon (mthaddon) wrote :

Abstaining, just claimed the review to take it off the canonical-is-reviewers dashboard, mergebot has been switched to add bootstack-reviewers for future MPs.

review: Abstain

Unmerged commits

6e47627... by Facundo Ciccioli

Some docs and funcionality that came in handy while working on this charm

It's the second time I have to learn these stuff, maybe it's useful for
others here.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/README.md b/src/README.md
index e367400..8b9d4b2 100644
--- a/src/README.md
+++ b/src/README.md
@@ -117,6 +117,47 @@ file a bug (see link below) and it will be added.
117117
118Manufacturer option needs to be left in auto mode.118Manufacturer option needs to be left in auto mode.
119119
120# Functional tests' tricks
121
122The functional tests obey a couple of environment variables meant to facilitate
123a quicker write-execute-modify cycle.
124
125* `TESTS_PRESERVE_MODEL`: Setting this to whatever non-empty string will
126 prevent the tests' code from destroying the test model after the tests have
127 ran (note that not setting this will cause the model to be destroyed in any
128 case, not just on a successful run).
129* `TESTS_USE_MODEL`: Set it to a pre-existent model so that the tests are run
130 in it, instead of creating a new one.
131* `TESTS_JUJU_SETTLE_TIMEOUT_sec`: Set this to the desired timeout when waiting
132 for the model to settle after having performed some action on it (like adding
133 a relation or deploying a unit). Defaults to 600 (10 minutes).
134
135Tox is configured to let those variables through (anything starting with
136`TESTS_`) to the commands it executes. Hence if you're using the `Makefile` for
137instance, you can do this:
138
139```
140$ make TESTS_JUJU_SETTLE_TIMEOUT_sec=1200 functional
141```
142
143Also, for the functional tests only, any positional arguments passed in to tox
144after a double dash (`--`) will be inserted at the end of the `pytest` command.
145This can be very handy to filter out everything except the tests you're working
146on:
147
148```
149$ make TESTS_PRESERVE_MODEL=1 functional # This will take a long time
150$ . $(find -path '/func/' -name activate)
151(func)$ cd src
152(func)$ TEST_USE_MODEL=$(juju models | awk '/functest-/ {print $1;}' | tr -d \*) \
153 tox -e func -- -k 'test_my_wip_test and bionic'
154
155```
156
157If you're changing you charm's code and not only your test's, you'll have to
158remember to `make build` and `juju upgrade-charm ...` before re-running your
159test.
160
120# Contact Information161# Contact Information
121162
122Please contact the Nagios charmers via the "Submit a bug" link.163Please contact the Nagios charmers via the "Submit a bug" link.
diff --git a/src/tests/functional/conftest.py b/src/tests/functional/conftest.py
index c7c856c..f898e30 100644
--- a/src/tests/functional/conftest.py
+++ b/src/tests/functional/conftest.py
@@ -60,11 +60,15 @@ async def controller():
60@pytest.fixture(scope="module")60@pytest.fixture(scope="module")
61async def model(controller): # pylint: disable=redefined-outer-name61async def model(controller): # pylint: disable=redefined-outer-name
62 """Create model which lives only for the duration of the test."""62 """Create model which lives only for the duration of the test."""
63 model_name = "functest-{}".format(uuid.uuid4())63 model_name = os.getenv("TESTS_USE_MODEL", "functest-{}".format(uuid.uuid4()))
64 _model = await controller.add_model(model_name)64 if os.getenv("TESTS_USE_MODEL"):
65 model_f = controller.get_model
66 else:
67 model_f = controller.add_model
68 _model = await model_f(model_name)
65 yield _model69 yield _model
66 await _model.disconnect()70 await _model.disconnect()
67 if not os.getenv("test_preserve_model"):71 if not os.getenv("TESTS_PRESERVE_MODEL"):
68 await controller.destroy_model(model_name)72 await controller.destroy_model(model_name)
69 while model_name in await controller.list_models():73 while model_name in await controller.list_models():
70 await asyncio.sleep(1)74 await asyncio.sleep(1)
diff --git a/src/tests/functional/test_hwhealth.py b/src/tests/functional/test_hwhealth.py
index 634c545..5b84b36 100644
--- a/src/tests/functional/test_hwhealth.py
+++ b/src/tests/functional/test_hwhealth.py
@@ -22,7 +22,7 @@ SERIES = [
22CHARM_DIR = dirname(dirname(dirname(abspath(__file__))))22CHARM_DIR = dirname(dirname(dirname(abspath(__file__))))
23CHARM_BUILD_DIR = dirname(CHARM_DIR)23CHARM_BUILD_DIR = dirname(CHARM_DIR)
24NRPECFG_DIR = "/etc/nagios/nrpe.d"24NRPECFG_DIR = "/etc/nagios/nrpe.d"
25DEF_TIMEOUT = 60025DEF_TIMEOUT = int(os.getenv('TESTS_JUJU_SETTLE_TIMEOUT_sec', '600'))
26# These go along with the hpe repos for the hp* tools26# These go along with the hpe repos for the hp* tools
2727
28################28################
@@ -75,6 +75,10 @@ async def deploy_app(request, model):
75 release = request.param75 release = request.param
76 channel = "stable"76 channel = "stable"
77 hw_health_app_name = "hw-health-{}".format(release)77 hw_health_app_name = "hw-health-{}".format(release)
78 if os.getenv("TESTS_USE_MODEL"):
79 yield model.applications[hw_health_app_name]
80 return
81
78 hw_health_checksum_app_name = "hw-health-checksum-{}".format(release)82 hw_health_checksum_app_name = "hw-health-checksum-{}".format(release)
7983
80 for principal_app in ["ubuntu", "nagios"]:84 for principal_app in ["ubuntu", "nagios"]:
diff --git a/src/tox.ini b/src/tox.ini
index 7da331e..1acdf41 100644
--- a/src/tox.ini
+++ b/src/tox.ini
@@ -76,5 +76,8 @@ commands =
76deps = -r{toxinidir}/tests/unit/requirements.txt76deps = -r{toxinidir}/tests/unit/requirements.txt
7777
78[testenv:func]78[testenv:func]
79commands = pytest -v --ignore {toxinidir}/tests/unit79passenv =
80 {[testenv]passenv}
81 TESTS_*
82commands = pytest -v --ignore {toxinidir}/tests/unit {posargs}
80deps = -r{toxinidir}/tests/functional/requirements.txt83deps = -r{toxinidir}/tests/functional/requirements.txt

Subscribers

No one subscribed via source and target branches