Merge ~vultaire/charm-grafana:master into ~prometheus-charmers/charm-grafana:master
- Git
- lp:~vultaire/charm-grafana
- master
- Merge into master
Status: | Rejected | ||||
---|---|---|---|---|---|
Rejected by: | Alvaro Uria | ||||
Proposed branch: | ~vultaire/charm-grafana:master | ||||
Merge into: | ~prometheus-charmers/charm-grafana:master | ||||
Diff against target: |
671 lines (+364/-75) 16 files modified
Makefile (+50/-0) interfaces/.empty (+1/-0) layers/.empty (+1/-0) src/Makefile (+25/-0) src/config.yaml (+61/-61) src/lib/lib_grafana.py (+28/-0) src/reactive/grafana.py (+1/-14) src/requirements.txt (+1/-0) src/tests/functional/requirements.txt (+6/-0) src/tests/functional/test_deploy.py (+29/-0) src/tests/unit/conftest.py (+69/-0) src/tests/unit/example.cfg (+1/-0) src/tests/unit/requirements.txt (+5/-0) src/tests/unit/test_actions.py (+14/-0) src/tests/unit/test_lib.py (+37/-0) src/tox.ini (+35/-0) |
||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Prometheus Charmers | Pending | ||
Review via email: mp+362164@code.launchpad.net |
Commit message
Migrate to using template from charm-create and add initial unit tests
Description of the change
With this, "make unittest" will work from within the src directory.
The topmost Makefile (generated via charm-create) does not seem to work
at present; I haven't looked into why. "cd" into "src" first.
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote : | # |
Alvaro Uria (aluria) wrote : | # |
Changes here have been merged into a bigger MP. See https:/
Changes here look good to be, but rejecting the MP due to the above.
Unmerged commits
- 0332bff... by Paul Goins
-
Added tests for the data_path() helper method
The data_path() method was refactored out into the lib_grafana module,
along with required constants. This removed dependencies on modules
provided by "charm build" and allows for doing a "make unittest" within
the src directory and having it "just work".A few other small tweaks were added:
* I tweaked the tox.ini for unit testing so that it will ignore files
in the builds directory, in case "charm build" is run.* I disabled a test in the test_actions.py module as we haven't
implemented any real tests there yet. - 92fca06... by Paul Goins
-
Adding new files from charm-create template; ignoring files which already exist
- 7cf91c4... by Paul Goins
-
Moving files to match new charm template structure
- e20740c... by Jason Hobbs
-
Update packagecloud repository key.
Reviewed-on: https:/
/code.launchpad .net/~jason- hobbs/grafana- charm/+ git/grafana- charm/+ merge/361519
Reviewed-by: Xav Paice <email address hidden> - b15be8f... by Jason Hobbs
-
Update packagecloud repository key.
On January 7th, 2019, packagecloud changed to a new repository
signing key for the grafana stable repository. This change
updates this charm to use that key rather than the old one.LP: #1810969
Preview Diff
1 | diff --git a/Makefile b/Makefile | |||
2 | 0 | new file mode 100644 | 0 | new file mode 100644 |
3 | index 0000000..5bef873 | |||
4 | --- /dev/null | |||
5 | +++ b/Makefile | |||
6 | @@ -0,0 +1,50 @@ | |||
7 | 1 | ifndef JUJU_REPOSITORY | ||
8 | 2 | JUJU_REPOSITORY := $(shell pwd) | ||
9 | 3 | $(warning Warning JUJU_REPOSITORY was not set, defaulting to $(JUJU_REPOSITORY)) | ||
10 | 4 | endif | ||
11 | 5 | |||
12 | 6 | help: | ||
13 | 7 | @echo "This project supports the following targets" | ||
14 | 8 | @echo "" | ||
15 | 9 | @echo " make help - show this text" | ||
16 | 10 | @echo " make submodules - make sure that the submodules are up-to-date" | ||
17 | 11 | @echo " make lint - run flake8" | ||
18 | 12 | @echo " make test - run the unittests and lint" | ||
19 | 13 | @echo " make unittest - run the tests defined in the unittest subdirectory" | ||
20 | 14 | @echo " make functional - run the tests defined in the functional subdirectory" | ||
21 | 15 | @echo " make release - build the charm" | ||
22 | 16 | @echo " make clean - remove unneeded files" | ||
23 | 17 | @echo "" | ||
24 | 18 | |||
25 | 19 | submodules: | ||
26 | 20 | @echo "Cloning submodules" | ||
27 | 21 | @git submodule update --init --recursive | ||
28 | 22 | |||
29 | 23 | lint: | ||
30 | 24 | @echo "Running flake8" | ||
31 | 25 | @cd src && tox -e lint | ||
32 | 26 | |||
33 | 27 | test: unittest functional lint | ||
34 | 28 | |||
35 | 29 | unittest: | ||
36 | 30 | @cd src && tox -e unit | ||
37 | 31 | |||
38 | 32 | functional: build | ||
39 | 33 | @cd src && tox -e functional | ||
40 | 34 | |||
41 | 35 | build: | ||
42 | 36 | @echo "Building charm to base directory $(JUJU_REPOSITORY)" | ||
43 | 37 | @-git describe --tags > ./src/repo-info | ||
44 | 38 | @LAYER_PATH=./layers INTERFACE_PATH=./interfaces\ | ||
45 | 39 | JUJU_REPOSITORY=$(JUJU_REPOSITORY) charm build ./src --force | ||
46 | 40 | |||
47 | 41 | release: clean build | ||
48 | 42 | @echo "Charm is built at $(JUJU_REPOSITORY)/builds" | ||
49 | 43 | |||
50 | 44 | clean: | ||
51 | 45 | @echo "Cleaning files" | ||
52 | 46 | @if [ -d src/.tox ] ; then rm -r src/.tox ; fi | ||
53 | 47 | @if [ -d src/.pytest_cache ] ; then rm -r src/.pytest_cache ; fi | ||
54 | 48 | |||
55 | 49 | # The targets below don't depend on a file | ||
56 | 50 | .PHONY: lint test unittest functional build release clean help submodules | ||
57 | diff --git a/interfaces/.empty b/interfaces/.empty | |||
58 | 0 | new file mode 100644 | 51 | new file mode 100644 |
59 | index 0000000..792d600 | |||
60 | --- /dev/null | |||
61 | +++ b/interfaces/.empty | |||
62 | @@ -0,0 +1 @@ | |||
63 | 1 | # | ||
64 | diff --git a/layers/.empty b/layers/.empty | |||
65 | 0 | new file mode 100644 | 2 | new file mode 100644 |
66 | index 0000000..792d600 | |||
67 | --- /dev/null | |||
68 | +++ b/layers/.empty | |||
69 | @@ -0,0 +1 @@ | |||
70 | 1 | # | ||
71 | diff --git a/src/Makefile b/src/Makefile | |||
72 | 0 | new file mode 100644 | 2 | new file mode 100644 |
73 | index 0000000..e1e1a8b | |||
74 | --- /dev/null | |||
75 | +++ b/src/Makefile | |||
76 | @@ -0,0 +1,25 @@ | |||
77 | 1 | help: | ||
78 | 2 | @echo "This project supports the following targets" | ||
79 | 3 | @echo "" | ||
80 | 4 | @echo " make help - show this text" | ||
81 | 5 | @echo " make test - run the functional test and unittests" | ||
82 | 6 | @echo " make unittest - run the the unittest" | ||
83 | 7 | @echo " make functionaltest - run the functional tests" | ||
84 | 8 | @echo " make clean - remove unneeded files" | ||
85 | 9 | @echo "" | ||
86 | 10 | |||
87 | 11 | test: unittest functionaltest lint | ||
88 | 12 | |||
89 | 13 | unittest: | ||
90 | 14 | @tox -e unit | ||
91 | 15 | |||
92 | 16 | functionaltest: | ||
93 | 17 | @tox -e functional | ||
94 | 18 | |||
95 | 19 | clean: | ||
96 | 20 | @echo "Cleaning files" | ||
97 | 21 | @if [ -d ./.tox ] ; then rm -r ./.tox ; fi | ||
98 | 22 | @if [ -d ./.pytest_cache ] ; then rm -r ./.pytest_cache ; fi | ||
99 | 23 | |||
100 | 24 | # The targets below don't depend on a file | ||
101 | 25 | .PHONY: lint test unittest functionaltest clean help | ||
102 | diff --git a/README.md b/src/README.md | |||
103 | 0 | similarity index 100% | 26 | similarity index 100% |
104 | 1 | rename from README.md | 27 | rename from README.md |
105 | 2 | rename to src/README.md | 28 | rename to src/README.md |
106 | diff --git a/actions.yaml b/src/actions.yaml | |||
107 | 3 | similarity index 100% | 29 | similarity index 100% |
108 | 4 | rename from actions.yaml | 30 | rename from actions.yaml |
109 | 5 | rename to src/actions.yaml | 31 | rename to src/actions.yaml |
110 | diff --git a/actions/change-user-role b/src/actions/change-user-role | |||
111 | 6 | similarity index 100% | 32 | similarity index 100% |
112 | 7 | rename from actions/change-user-role | 33 | rename from actions/change-user-role |
113 | 8 | rename to src/actions/change-user-role | 34 | rename to src/actions/change-user-role |
114 | diff --git a/actions/create-api-key b/src/actions/create-api-key | |||
115 | 9 | similarity index 100% | 35 | similarity index 100% |
116 | 10 | rename from actions/create-api-key | 36 | rename from actions/create-api-key |
117 | 11 | rename to src/actions/create-api-key | 37 | rename to src/actions/create-api-key |
118 | diff --git a/actions/create-user b/src/actions/create-user | |||
119 | 12 | similarity index 100% | 38 | similarity index 100% |
120 | 13 | rename from actions/create-user | 39 | rename from actions/create-user |
121 | 14 | rename to src/actions/create-user | 40 | rename to src/actions/create-user |
122 | diff --git a/actions/delete-user b/src/actions/delete-user | |||
123 | 15 | similarity index 100% | 41 | similarity index 100% |
124 | 16 | rename from actions/delete-user | 42 | rename from actions/delete-user |
125 | 17 | rename to src/actions/delete-user | 43 | rename to src/actions/delete-user |
126 | diff --git a/actions/get-admin-password b/src/actions/get-admin-password | |||
127 | 18 | similarity index 100% | 44 | similarity index 100% |
128 | 19 | rename from actions/get-admin-password | 45 | rename from actions/get-admin-password |
129 | 20 | rename to src/actions/get-admin-password | 46 | rename to src/actions/get-admin-password |
130 | diff --git a/actions/grafana_utils.py b/src/actions/grafana_utils.py | |||
131 | 21 | similarity index 100% | 47 | similarity index 100% |
132 | 22 | rename from actions/grafana_utils.py | 48 | rename from actions/grafana_utils.py |
133 | 23 | rename to src/actions/grafana_utils.py | 49 | rename to src/actions/grafana_utils.py |
134 | diff --git a/actions/import-dashboard b/src/actions/import-dashboard | |||
135 | 24 | similarity index 100% | 50 | similarity index 100% |
136 | 25 | rename from actions/import-dashboard | 51 | rename from actions/import-dashboard |
137 | 26 | rename to src/actions/import-dashboard | 52 | rename to src/actions/import-dashboard |
138 | diff --git a/actions/set-user-password b/src/actions/set-user-password | |||
139 | 27 | similarity index 100% | 53 | similarity index 100% |
140 | 28 | rename from actions/set-user-password | 54 | rename from actions/set-user-password |
141 | 29 | rename to src/actions/set-user-password | 55 | rename to src/actions/set-user-password |
142 | diff --git a/config.yaml b/src/config.yaml | |||
143 | 30 | similarity index 64% | 56 | similarity index 64% |
144 | 31 | rename from config.yaml | 57 | rename from config.yaml |
145 | 32 | rename to src/config.yaml | 58 | rename to src/config.yaml |
146 | index 3d58088..ee5cf85 100644 | |||
147 | --- a/config.yaml | |||
148 | +++ b/src/config.yaml | |||
149 | @@ -13,68 +13,68 @@ options: | |||
150 | 13 | default: | | 13 | default: | |
151 | 14 | - | | 14 | - | |
152 | 15 | -----BEGIN PGP PUBLIC KEY BLOCK----- | 15 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
154 | 16 | Version: GnuPG v1 | 16 | Version: GnuPG v1.4.11 (GNU/Linux) |
155 | 17 | 17 | ||
216 | 18 | mQINBFLUbogBEADceEoxBDoE6QM5xV/13qiELbFIkQgy/eEi3UesXmJblFdU7wcD | 18 | mQINBFu7jn8BEAC+f2xaHm8VnvpsoK2mD9dQAPDf9Pslvv0EH0Rhs6D54LpkF7hj |
217 | 19 | LOW3NuOIx/dgbZljeMEerj6N1cR7r7X5sVoFVEZiK4RLkC3Cpdns0d90ud2f3VyK | 19 | VjeUH+cpNha7Gcr4vTubcVVAsq5mHplatn54UmHUg1inuNbe32vVcoDF/UPtg4tg |
218 | 20 | K7PXRBstdLm3JlW9OWZoe4VSADSMGWm1mIhT601qLKKAuWJoBIhnKY/RhA/RBXt7 | 20 | nq9CbGFQvCRX4gEGVfiOsoipKhu50hv09LEyN7y8bYoWSrYcjPL2fswr94Bm4+Kq |
219 | 21 | z22g4ta9bT67PlliTo1a8y6DhUA7gd+5TsVHaxDRrzc3mKObdyS5LOT/gf8Ti2tY | 21 | IFdHwKBKYrJQ390NuIrP+ncBDIJ5ubdMtM5S2gpKEW4daO/4pnfr7YmgfQr34+Xe |
220 | 22 | BY5MBbQ8NUGExls4dXKlieePhKutFbde7sq3n5sdp1Ndoran1u0LsWnaSDx11R3x | 22 | 5SkVcOix3CqPXwQ/OyTPwhZJssXljxcWbcOM09hCZBRqADAshuFJwlvn/meXRWK4 |
221 | 23 | iYfXJ6xGukAc6pYlUD1yYjU4oRGhD2fPyuewqhHNUVwqupTBQtEGULrtdwK04kgI | 23 | 5Mlnr3BaCEDhLgaLHlBRdT0jF6LYl4K0qY2o60NUlnPFWLRYB+jJFFISFrhiwpoQ |
222 | 24 | H93ssGRsLqUKe88uZeeBczVuupv8ZLd1YcQ29AfJHe6nsevsgjF+eajYlzsvC8BN | 24 | mo+6erbBa2AHB7MoZmzpXzWDz8UQSuxw1UYKQYU21f4aLiu14Q2bvaICLY518+JQ |
223 | 25 | q3nOvvedcuI6BW4WWFjraH06GNTyMAZi0HibTg65guZXp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ZfhHxEIt65edkIz1wETOch3LIg6RaF | 40 | XSl/zM3xlvgzFSgrYpVfQ5d8A6D+YrvA9nuC84mRf60fg+rORrwQed6M1M4YcdwB |
239 | 41 | wsXgrZCNTB/zjKGAFEzxOSBkjhyJCY2g74QNObKgTSeGNFqG0ZBHe2/JQ33UxrDt | 41 | jsVHyevY4oDMkkwQ0mOLbbQeTalm5RxrRvqocOfgwTTVrBxJuQIt51TC8KP1vcny |
240 | 42 | peKvCYTbjuWlyrkCDQRS1G6IARAArtNBXq+CNU9DR2YCi759fLR9F62Ec/QLWY3c | 42 | fkuE+hq8k1MWJlTGAMg2w/MJFwc1yE4+op+SJk8qB9vJ81RbOGlUaY2D4CCC4MLF |
241 | 43 | /D26OqjTgjxAzGKbu1aLzphP8tq1GDCbWQ2BMMZI+L0Ed502u6kC0fzvbppRRXrV | 43 | rrFFmWyR6By5Ag0EW7uOfwEQAOHSuWMTXEjN7THgi1zhWWlolcunuAYGas8hlB6U |
242 | 44 | axBrwxY9XhnzvkXXzwNwnBalkrJ5Yk0lN8ocwCuUJohms7V14nEDyHgAB8yqCEWz | 44 | PaV8oTMEII3xwR4STZcpIsEd31cuq3lwwRS8y7HpDhYfhY8uuIXOQ7cCXzEkXJ1H |
243 | 45 | Qm/SIZw35N/insTXshcdiUGeyufo85SFhCUqZ1x1TkSC/FyDG+BCwArfj8Qwdab3 | 45 | YX+3WMnCnzGe+k2u3sL9TGdcNludFHEMiNJrRIY1RvZGCsT+r1FE2T0P8t4zvog6 |
244 | 46 | UlUEkF6czTjwWIO+5vYuR8bsCGYKCSrGRh5nxw0tuGXWXWFlBMSZP6mFcCDRQDGc | 46 | 986wwKXu4TUk0nyGW6CWP+3mZOIu5BLSKvusWex6c2sbYUuSDPYwpq4atsk+NDmY |
245 | 47 | KOuGTjiWzLJcgsEcBoIX4WpHJYgl6ovex7HkfQsWPYL5V1FIHMlw34ALx4aQDH0d | 47 | e0bZq4SPFzluRs6QI20rxZLimmkplBoatblhOIefG7vf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LpPKncDup/9iJbjiR17DDFMwgyCoy5O | 70 | srsLH+X3IUQw7F16j3/NIumxUygbgsioA4ZEBKdsuXU/2eHJ1ywJ52YB0ZHGlYqA |
269 | 71 | HJICQ5lckNNgkHTS6Xiogkt28YfK4P3S0GaZgIrhKQ7AmO3O+hB12Zr+olpeyhGB | 71 | toejg/dvFGdtT24hKo4hedEc8ymBLujeHpZe3x3u/dvPftwBAyrx+txOTC5luv1q |
270 | 72 | OpBD80URntdEcenvfnXBY/BsuAVbTGXiBzrlBEyQxg656jUeqAdXg+nzCvP0yJlB | 72 | Ttqd5NRqsnw2KArA8ZM7iPJinvUaoIZVDPJghh7b+0PrYjM+fpFmUeAAN7jgttvO |
271 | 73 | UOjEcwyhK/U2nw9nGyaR3u0a9r24LgijGpdGabIeJm6O9vuuqFHHGI72pWUEs355 | 73 | DK11MKLqaRvk4njE//vfxjZpSJaktlUJTFpzwXuYQbuTdwDJNJcuFVmjfMWT5tKf |
272 | 74 | lt8q1pAoJUv8NehQmlaR0h5wcwhEtwM6fiSIUTnuJnyHT053GjsUD7ef5fY1KEFm | 74 | 2cy8N9cgPhrulZDbYU/S8ZOFJUQ4qpHpf+q+NDGnucM3kCNkOMgqeBfBvC5wJP5C |
273 | 75 | aZeW04kRtFDOPinz0faE8hvsxzsVgkKye1c2vkXKdOXvA3x+pZzlTHtcgMOhjKQA | 75 | ZHoaKVW9+o1CKmFKYz+1woY6qugYB/8Uy7gy3C9qGbi7UZwMFUJUCYxu5htHuB/a |
274 | 76 | sA== | 76 | tTUJ4nM//ichv9TCsTA5X/tYJBD0USEVl0bMV4CtS+qP2il17D846bA= |
275 | 77 | =H60S | 77 | =ewdt |
276 | 78 | -----END PGP PUBLIC KEY BLOCK----- | 78 | -----END PGP PUBLIC KEY BLOCK----- |
277 | 79 | type: string | 79 | type: string |
278 | 80 | description: | | 80 | description: | |
279 | diff --git a/copyright b/src/copyright | |||
280 | 81 | similarity index 100% | 81 | similarity index 100% |
281 | 82 | rename from copyright | 82 | rename from copyright |
282 | 83 | rename to src/copyright | 83 | rename to src/copyright |
283 | diff --git a/files/dashboards_backup b/src/files/dashboards_backup | |||
284 | 84 | similarity index 100% | 84 | similarity index 100% |
285 | 85 | rename from files/dashboards_backup | 85 | rename from files/dashboards_backup |
286 | 86 | rename to src/files/dashboards_backup | 86 | rename to src/files/dashboards_backup |
287 | diff --git a/getstarted.md b/src/getstarted.md | |||
288 | 87 | similarity index 100% | 87 | similarity index 100% |
289 | 88 | rename from getstarted.md | 88 | rename from getstarted.md |
290 | 89 | rename to src/getstarted.md | 89 | rename to src/getstarted.md |
291 | diff --git a/icon.svg b/src/icon.svg | |||
292 | 90 | similarity index 100% | 90 | similarity index 100% |
293 | 91 | rename from icon.svg | 91 | rename from icon.svg |
294 | 92 | rename to src/icon.svg | 92 | rename to src/icon.svg |
295 | diff --git a/layer.yaml b/src/layer.yaml | |||
296 | 93 | similarity index 100% | 93 | similarity index 100% |
297 | 94 | rename from layer.yaml | 94 | rename from layer.yaml |
298 | 95 | rename to src/layer.yaml | 95 | rename to src/layer.yaml |
299 | diff --git a/src/lib/lib_grafana.py b/src/lib/lib_grafana.py | |||
300 | 96 | new file mode 100644 | 96 | new file mode 100644 |
301 | index 0000000..b074e53 | |||
302 | --- /dev/null | |||
303 | +++ b/src/lib/lib_grafana.py | |||
304 | @@ -0,0 +1,28 @@ | |||
305 | 1 | from charmhelpers.core import hookenv, unitdata | ||
306 | 2 | from charms.reactive import remove_state | ||
307 | 3 | |||
308 | 4 | |||
309 | 5 | APT_COMMON = '/var/lib/grafana' | ||
310 | 6 | SNAP_NAME = 'grafana' | ||
311 | 7 | SNAP_COMMON = '/var/snap/{}/common/data'.format(SNAP_NAME) | ||
312 | 8 | |||
313 | 9 | |||
314 | 10 | class GrafanaHelper(): | ||
315 | 11 | def __init__(self): | ||
316 | 12 | self.charm_config = hookenv.config() | ||
317 | 13 | |||
318 | 14 | def action_function(self): | ||
319 | 15 | ''' An example function for calling from an action ''' | ||
320 | 16 | return | ||
321 | 17 | |||
322 | 18 | |||
323 | 19 | def data_path(): | ||
324 | 20 | data_dir = {'snap': SNAP_COMMON, | ||
325 | 21 | 'apt': APT_COMMON} | ||
326 | 22 | kv = unitdata.kv() | ||
327 | 23 | source = kv.get('install_method') | ||
328 | 24 | if source in ('snap', 'apt'): | ||
329 | 25 | return data_dir[source] | ||
330 | 26 | else: | ||
331 | 27 | hookenv.status_set('blocked', 'Unsupported install_method') | ||
332 | 28 | remove_state('grafana.installed') | ||
333 | diff --git a/metadata.yaml b/src/metadata.yaml | |||
334 | 0 | similarity index 100% | 29 | similarity index 100% |
335 | 1 | rename from metadata.yaml | 30 | rename from metadata.yaml |
336 | 2 | rename to src/metadata.yaml | 31 | rename to src/metadata.yaml |
337 | diff --git a/reactive/grafana.py b/src/reactive/grafana.py | |||
338 | 3 | similarity index 90% | 32 | similarity index 90% |
339 | 4 | rename from reactive/grafana.py | 33 | rename from reactive/grafana.py |
340 | 5 | rename to src/reactive/grafana.py | 34 | rename to src/reactive/grafana.py |
341 | index f98e11c..54f80c6 100644 | |||
342 | --- a/reactive/grafana.py | |||
343 | +++ b/src/reactive/grafana.py | |||
344 | @@ -31,12 +31,11 @@ from charms.reactive import ( | |||
345 | 31 | ) | 31 | ) |
346 | 32 | 32 | ||
347 | 33 | from charms.layer import snap | 33 | from charms.layer import snap |
348 | 34 | from lib_grafana import data_path, SNAP_NAME | ||
349 | 34 | 35 | ||
350 | 35 | SVCNAME = {'snap': 'snap.grafana.grafana', | 36 | SVCNAME = {'snap': 'snap.grafana.grafana', |
351 | 36 | 'apt': 'grafana-server'} | 37 | 'apt': 'grafana-server'} |
352 | 37 | SNAP_NAME = 'grafana' | ||
353 | 38 | SNAP_DATA = '/var/snap/{}/current'.format(SNAP_NAME) | 38 | SNAP_DATA = '/var/snap/{}/current'.format(SNAP_NAME) |
354 | 39 | SNAP_COMMON = '/var/snap/{}/common/data'.format(SNAP_NAME) | ||
355 | 40 | 39 | ||
356 | 41 | GRAFANA_INI = {'snap': '{}/conf/grafana.ini'.format(SNAP_DATA), | 40 | GRAFANA_INI = {'snap': '{}/conf/grafana.ini'.format(SNAP_DATA), |
357 | 42 | 'apt': '/etc/grafana/grafana.ini'} | 41 | 'apt': '/etc/grafana/grafana.ini'} |
358 | @@ -126,18 +125,6 @@ def install_packages(): | |||
359 | 126 | hookenv.status_set('blocked', 'Unsupported install_method') | 125 | hookenv.status_set('blocked', 'Unsupported install_method') |
360 | 127 | 126 | ||
361 | 128 | 127 | ||
362 | 129 | def data_path(): | ||
363 | 130 | data_dir = {'snap': SNAP_COMMON, | ||
364 | 131 | 'apt': '/var/lib/grafana'} | ||
365 | 132 | kv = unitdata.kv() | ||
366 | 133 | source = kv.get('install_method') | ||
367 | 134 | if source in ('snap', 'apt'): | ||
368 | 135 | return data_dir[source] | ||
369 | 136 | else: | ||
370 | 137 | hookenv.status_set('blocked', 'Unsupported install_method') | ||
371 | 138 | remove_state('grafana.installed') | ||
372 | 139 | |||
373 | 140 | |||
374 | 141 | @when('grafana.installed') | 128 | @when('grafana.installed') |
375 | 142 | @when('config.changed.install_plugins') | 129 | @when('config.changed.install_plugins') |
376 | 143 | def install_plugins(): | 130 | def install_plugins(): |
377 | diff --git a/src/requirements.txt b/src/requirements.txt | |||
378 | 144 | new file mode 100644 | 131 | new file mode 100644 |
379 | index 0000000..8462291 | |||
380 | --- /dev/null | |||
381 | +++ b/src/requirements.txt | |||
382 | @@ -0,0 +1 @@ | |||
383 | 1 | # Include python requirements here | ||
384 | diff --git a/scripts/get_admin_password b/src/scripts/get_admin_password | |||
385 | 0 | similarity index 100% | 2 | similarity index 100% |
386 | 1 | rename from scripts/get_admin_password | 3 | rename from scripts/get_admin_password |
387 | 2 | rename to src/scripts/get_admin_password | 4 | rename to src/scripts/get_admin_password |
388 | diff --git a/templates/dashboards/prometheus/CephCluster.json.j2 b/src/templates/dashboards/prometheus/CephCluster.json.j2 | |||
389 | 3 | similarity index 100% | 5 | similarity index 100% |
390 | 4 | rename from templates/dashboards/prometheus/CephCluster.json.j2 | 6 | rename from templates/dashboards/prometheus/CephCluster.json.j2 |
391 | 5 | rename to src/templates/dashboards/prometheus/CephCluster.json.j2 | 7 | rename to src/templates/dashboards/prometheus/CephCluster.json.j2 |
392 | diff --git a/templates/dashboards/prometheus/CephOSD.json.j2 b/src/templates/dashboards/prometheus/CephOSD.json.j2 | |||
393 | 6 | similarity index 100% | 8 | similarity index 100% |
394 | 7 | rename from templates/dashboards/prometheus/CephOSD.json.j2 | 9 | rename from templates/dashboards/prometheus/CephOSD.json.j2 |
395 | 8 | rename to src/templates/dashboards/prometheus/CephOSD.json.j2 | 10 | rename to src/templates/dashboards/prometheus/CephOSD.json.j2 |
396 | diff --git a/templates/dashboards/prometheus/CephPools.json.j2 b/src/templates/dashboards/prometheus/CephPools.json.j2 | |||
397 | 9 | similarity index 100% | 11 | similarity index 100% |
398 | 10 | rename from templates/dashboards/prometheus/CephPools.json.j2 | 12 | rename from templates/dashboards/prometheus/CephPools.json.j2 |
399 | 11 | rename to src/templates/dashboards/prometheus/CephPools.json.j2 | 13 | rename to src/templates/dashboards/prometheus/CephPools.json.j2 |
400 | diff --git a/templates/dashboards/prometheus/OpenStackCloud.json.j2 b/src/templates/dashboards/prometheus/OpenStackCloud.json.j2 | |||
401 | 12 | similarity index 100% | 14 | similarity index 100% |
402 | 13 | rename from templates/dashboards/prometheus/OpenStackCloud.json.j2 | 15 | rename from templates/dashboards/prometheus/OpenStackCloud.json.j2 |
403 | 14 | rename to src/templates/dashboards/prometheus/OpenStackCloud.json.j2 | 16 | rename to src/templates/dashboards/prometheus/OpenStackCloud.json.j2 |
404 | diff --git a/templates/dashboards/prometheus/RabbitMQ.json.j2 b/src/templates/dashboards/prometheus/RabbitMQ.json.j2 | |||
405 | 15 | similarity index 100% | 17 | similarity index 100% |
406 | 16 | rename from templates/dashboards/prometheus/RabbitMQ.json.j2 | 18 | rename from templates/dashboards/prometheus/RabbitMQ.json.j2 |
407 | 17 | rename to src/templates/dashboards/prometheus/RabbitMQ.json.j2 | 19 | rename to src/templates/dashboards/prometheus/RabbitMQ.json.j2 |
408 | diff --git a/templates/dashboards/prometheus/Swift.json.j2 b/src/templates/dashboards/prometheus/Swift.json.j2 | |||
409 | 18 | similarity index 100% | 20 | similarity index 100% |
410 | 19 | rename from templates/dashboards/prometheus/Swift.json.j2 | 21 | rename from templates/dashboards/prometheus/Swift.json.j2 |
411 | 20 | rename to src/templates/dashboards/prometheus/Swift.json.j2 | 22 | rename to src/templates/dashboards/prometheus/Swift.json.j2 |
412 | diff --git a/templates/dashboards/prometheus/Telegraf.json.j2 b/src/templates/dashboards/prometheus/Telegraf.json.j2 | |||
413 | 21 | similarity index 100% | 23 | similarity index 100% |
414 | 22 | rename from templates/dashboards/prometheus/Telegraf.json.j2 | 24 | rename from templates/dashboards/prometheus/Telegraf.json.j2 |
415 | 23 | rename to src/templates/dashboards/prometheus/Telegraf.json.j2 | 25 | rename to src/templates/dashboards/prometheus/Telegraf.json.j2 |
416 | diff --git a/templates/grafana.ini.j2 b/src/templates/grafana.ini.j2 | |||
417 | 24 | similarity index 100% | 26 | similarity index 100% |
418 | 25 | rename from templates/grafana.ini.j2 | 27 | rename from templates/grafana.ini.j2 |
419 | 26 | rename to src/templates/grafana.ini.j2 | 28 | rename to src/templates/grafana.ini.j2 |
420 | diff --git a/templates/juju-dashboards-backup.j2 b/src/templates/juju-dashboards-backup.j2 | |||
421 | 27 | similarity index 100% | 29 | similarity index 100% |
422 | 28 | rename from templates/juju-dashboards-backup.j2 | 30 | rename from templates/juju-dashboards-backup.j2 |
423 | 29 | rename to src/templates/juju-dashboards-backup.j2 | 31 | rename to src/templates/juju-dashboards-backup.j2 |
424 | diff --git a/src/tests/functional/requirements.txt b/src/tests/functional/requirements.txt | |||
425 | 30 | new file mode 100644 | 32 | new file mode 100644 |
426 | index 0000000..f76bfbb | |||
427 | --- /dev/null | |||
428 | +++ b/src/tests/functional/requirements.txt | |||
429 | @@ -0,0 +1,6 @@ | |||
430 | 1 | flake8 | ||
431 | 2 | juju | ||
432 | 3 | mock | ||
433 | 4 | pytest | ||
434 | 5 | pytest-asyncio | ||
435 | 6 | requests | ||
436 | diff --git a/src/tests/functional/test_deploy.py b/src/tests/functional/test_deploy.py | |||
437 | 0 | new file mode 100644 | 7 | new file mode 100644 |
438 | index 0000000..c41422d | |||
439 | --- /dev/null | |||
440 | +++ b/src/tests/functional/test_deploy.py | |||
441 | @@ -0,0 +1,29 @@ | |||
442 | 1 | import pytest | ||
443 | 2 | from juju.model import Model | ||
444 | 3 | |||
445 | 4 | # Treat tests as coroutines | ||
446 | 5 | pytestmark = pytest.mark.asyncio | ||
447 | 6 | |||
448 | 7 | series = ['bionic'] | ||
449 | 8 | |||
450 | 9 | |||
451 | 10 | @pytest.fixture | ||
452 | 11 | async def model(): | ||
453 | 12 | model = Model() | ||
454 | 13 | await model.connect_current() | ||
455 | 14 | yield model | ||
456 | 15 | await model.disconnect() | ||
457 | 16 | |||
458 | 17 | |||
459 | 18 | @pytest.mark.parametrize('series', series) | ||
460 | 19 | async def test_grafana_deploy(model, series): | ||
461 | 20 | app = await model.deploy('.', series=series) | ||
462 | 21 | await model.block_until(lambda: app.status == 'active') | ||
463 | 22 | assert True | ||
464 | 23 | |||
465 | 24 | |||
466 | 25 | # def test_example_action(self, deploy, unit): | ||
467 | 26 | # uuid = unit.run_action('example-action') | ||
468 | 27 | # action_output = deploy.get_action_output(uuid, full_output=True) | ||
469 | 28 | # print(action_output) | ||
470 | 29 | # assert action_output['status'] == 'completed' | ||
471 | diff --git a/src/tests/unit/conftest.py b/src/tests/unit/conftest.py | |||
472 | 0 | new file mode 100644 | 30 | new file mode 100644 |
473 | index 0000000..aca2a0f | |||
474 | --- /dev/null | |||
475 | +++ b/src/tests/unit/conftest.py | |||
476 | @@ -0,0 +1,69 @@ | |||
477 | 1 | #!/usr/bin/python3 | ||
478 | 2 | import mock | ||
479 | 3 | import pytest | ||
480 | 4 | |||
481 | 5 | |||
482 | 6 | # If layer options are used, add this to grafana | ||
483 | 7 | # and import layer in lib_grafana | ||
484 | 8 | @pytest.fixture | ||
485 | 9 | def mock_layers(monkeypatch): | ||
486 | 10 | import sys | ||
487 | 11 | sys.modules['charms.layer'] = mock.Mock() | ||
488 | 12 | sys.modules['reactive'] = mock.Mock() | ||
489 | 13 | # Mock any functions in layers that need to be mocked here | ||
490 | 14 | |||
491 | 15 | def options(layer): | ||
492 | 16 | # mock options for layers here | ||
493 | 17 | if layer == 'example-layer': | ||
494 | 18 | options = {'port': 9999} | ||
495 | 19 | return options | ||
496 | 20 | else: | ||
497 | 21 | return None | ||
498 | 22 | |||
499 | 23 | monkeypatch.setattr('lib_grafana.layer.options', options) | ||
500 | 24 | |||
501 | 25 | |||
502 | 26 | @pytest.fixture | ||
503 | 27 | def mock_hookenv_config(monkeypatch): | ||
504 | 28 | import yaml | ||
505 | 29 | |||
506 | 30 | def mock_config(): | ||
507 | 31 | cfg = {} | ||
508 | 32 | yml = yaml.load(open('./config.yaml')) | ||
509 | 33 | |||
510 | 34 | # Load all defaults | ||
511 | 35 | for key, value in yml['options'].items(): | ||
512 | 36 | cfg[key] = value['default'] | ||
513 | 37 | |||
514 | 38 | # Manually add cfg from other layers | ||
515 | 39 | # cfg['my-other-layer'] = 'mock' | ||
516 | 40 | return cfg | ||
517 | 41 | |||
518 | 42 | monkeypatch.setattr('lib_grafana.hookenv.config', mock_config) | ||
519 | 43 | |||
520 | 44 | |||
521 | 45 | @pytest.fixture | ||
522 | 46 | def mock_remote_unit(monkeypatch): | ||
523 | 47 | monkeypatch.setattr('lib_grafana.hookenv.remote_unit', lambda: 'unit-mock/0') | ||
524 | 48 | |||
525 | 49 | |||
526 | 50 | @pytest.fixture | ||
527 | 51 | def mock_charm_dir(monkeypatch): | ||
528 | 52 | monkeypatch.setattr('lib_grafana.hookenv.charm_dir', lambda: '/mock/charm/dir') | ||
529 | 53 | |||
530 | 54 | |||
531 | 55 | @pytest.fixture | ||
532 | 56 | def grafana(tmpdir, mock_hookenv_config, mock_charm_dir, monkeypatch): | ||
533 | 57 | from lib_grafana import GrafanaHelper | ||
534 | 58 | helper = GrafanaHelper() | ||
535 | 59 | |||
536 | 60 | # Example config file patching | ||
537 | 61 | cfg_file = tmpdir.join('example.cfg') | ||
538 | 62 | with open('./tests/unit/example.cfg', 'r') as src_file: | ||
539 | 63 | cfg_file.write(src_file.read()) | ||
540 | 64 | helper.example_config_file = cfg_file.strpath | ||
541 | 65 | |||
542 | 66 | # Any other functions that load helper will get this version | ||
543 | 67 | monkeypatch.setattr('lib_grafana.GrafanaHelper', lambda: helper) | ||
544 | 68 | |||
545 | 69 | return helper | ||
546 | diff --git a/src/tests/unit/example.cfg b/src/tests/unit/example.cfg | |||
547 | 0 | new file mode 100644 | 70 | new file mode 100644 |
548 | index 0000000..81b1e94 | |||
549 | --- /dev/null | |||
550 | +++ b/src/tests/unit/example.cfg | |||
551 | @@ -0,0 +1 @@ | |||
552 | 1 | This is an example config file included with the unit tests | ||
553 | diff --git a/src/tests/unit/requirements.txt b/src/tests/unit/requirements.txt | |||
554 | 0 | new file mode 100644 | 2 | new file mode 100644 |
555 | index 0000000..9c685e5 | |||
556 | --- /dev/null | |||
557 | +++ b/src/tests/unit/requirements.txt | |||
558 | @@ -0,0 +1,5 @@ | |||
559 | 1 | charmhelpers | ||
560 | 2 | charms.reactive | ||
561 | 3 | mock | ||
562 | 4 | pytest | ||
563 | 5 | pytest-cov | ||
564 | diff --git a/src/tests/unit/test_actions.py b/src/tests/unit/test_actions.py | |||
565 | 0 | new file mode 100644 | 6 | new file mode 100644 |
566 | index 0000000..731147e | |||
567 | --- /dev/null | |||
568 | +++ b/src/tests/unit/test_actions.py | |||
569 | @@ -0,0 +1,14 @@ | |||
570 | 1 | import imp | ||
571 | 2 | |||
572 | 3 | import mock | ||
573 | 4 | |||
574 | 5 | from pytest import mark | ||
575 | 6 | |||
576 | 7 | class TestActions(): | ||
577 | 8 | @mark.skip() | ||
578 | 9 | def test_example_action(self, grafana, monkeypatch): | ||
579 | 10 | mock_function = mock.Mock() | ||
580 | 11 | monkeypatch.setattr(grafana, 'action_function', mock_function) | ||
581 | 12 | assert mock_function.call_count == 0 | ||
582 | 13 | imp.load_source('action_function', './actions/example-action') | ||
583 | 14 | assert mock_function.call_count == 1 | ||
584 | diff --git a/src/tests/unit/test_lib.py b/src/tests/unit/test_lib.py | |||
585 | 0 | new file mode 100644 | 15 | new file mode 100644 |
586 | index 0000000..733a33c | |||
587 | --- /dev/null | |||
588 | +++ b/src/tests/unit/test_lib.py | |||
589 | @@ -0,0 +1,37 @@ | |||
590 | 1 | #!/usr/bin/python3 | ||
591 | 2 | |||
592 | 3 | from pytest import mark | ||
593 | 4 | import mock | ||
594 | 5 | import lib_grafana | ||
595 | 6 | |||
596 | 7 | |||
597 | 8 | class TestLib(): | ||
598 | 9 | def test_grafana(self, grafana): | ||
599 | 10 | ''' See if the helper fixture works to load charm configs ''' | ||
600 | 11 | # NOTE: This was added per the charm-create template; leaving it in in case it is useful. | ||
601 | 12 | assert isinstance(grafana.charm_config, dict) | ||
602 | 13 | |||
603 | 14 | @mark.parametrize( | ||
604 | 15 | 'install_method,result', | ||
605 | 16 | [ | ||
606 | 17 | ('snap', lib_grafana.SNAP_COMMON), | ||
607 | 18 | ('apt', lib_grafana.APT_COMMON), | ||
608 | 19 | ] | ||
609 | 20 | ) | ||
610 | 21 | @mock.patch('lib_grafana.unitdata.kv') | ||
611 | 22 | def test_data_path_valid_method_returns_dir(self, unitdata_kv_mock, install_method, result): | ||
612 | 23 | unitdata_kv_mock.return_value = { | ||
613 | 24 | 'install_method': install_method, | ||
614 | 25 | } | ||
615 | 26 | assert lib_grafana.data_path() == result | ||
616 | 27 | |||
617 | 28 | @mock.patch('lib_grafana.remove_state') | ||
618 | 29 | @mock.patch('lib_grafana.hookenv.status_set') | ||
619 | 30 | @mock.patch('lib_grafana.unitdata.kv') | ||
620 | 31 | def test_data_path_invalid_method_sets_blocked_status(self, unitdata_kv_mock, status_set_mock, remove_state_mock): | ||
621 | 32 | unitdata_kv_mock.return_value = { | ||
622 | 33 | 'install_method': 'bad_method', | ||
623 | 34 | } | ||
624 | 35 | assert lib_grafana.data_path() is None | ||
625 | 36 | assert status_set_mock.mock_calls[-1] == mock.call('blocked', 'Unsupported install_method') | ||
626 | 37 | assert remove_state_mock.mock_calls[-1] == mock.call('grafana.installed') | ||
627 | diff --git a/src/tox.ini b/src/tox.ini | |||
628 | 0 | new file mode 100644 | 38 | new file mode 100644 |
629 | index 0000000..bd49daf | |||
630 | --- /dev/null | |||
631 | +++ b/src/tox.ini | |||
632 | @@ -0,0 +1,35 @@ | |||
633 | 1 | [tox] | ||
634 | 2 | skipsdist=True | ||
635 | 3 | envlist = unit, functional | ||
636 | 4 | skip_missing_interpreters = True | ||
637 | 5 | |||
638 | 6 | [testenv] | ||
639 | 7 | basepython = python3 | ||
640 | 8 | setenv = | ||
641 | 9 | PYTHONPATH = . | ||
642 | 10 | |||
643 | 11 | [testenv:unit] | ||
644 | 12 | commands = pytest -v --ignore {toxinidir}/tests/functional --ignore {toxinidir}/builds --cov=lib --cov=reactice --cov=actions --cov-report=term | ||
645 | 13 | deps = -r{toxinidir}/tests/unit/requirements.txt | ||
646 | 14 | -r{toxinidir}/requirements.txt | ||
647 | 15 | setenv = PYTHONPATH={toxinidir}/lib | ||
648 | 16 | |||
649 | 17 | [testenv:functional] | ||
650 | 18 | passenv = | ||
651 | 19 | HOME | ||
652 | 20 | JUJU_REPOSITORY | ||
653 | 21 | PATH | ||
654 | 22 | commands = pytest -v --ignore {toxinidir}/tests/unit | ||
655 | 23 | deps = -r{toxinidir}/tests/functional/requirements.txt | ||
656 | 24 | -r{toxinidir}/requirements.txt | ||
657 | 25 | |||
658 | 26 | [testenv:lint] | ||
659 | 27 | commands = flake8 | ||
660 | 28 | deps = flake8 | ||
661 | 29 | |||
662 | 30 | [flake8] | ||
663 | 31 | exclude = | ||
664 | 32 | .git, | ||
665 | 33 | __pycache__, | ||
666 | 34 | .tox, | ||
667 | 35 | |||
668 | diff --git a/wheelhouse.txt b/src/wheelhouse.txt | |||
669 | 0 | similarity index 100% | 36 | similarity index 100% |
670 | 1 | rename from wheelhouse.txt | 37 | rename from wheelhouse.txt |
671 | 2 | rename to src/wheelhouse.txt | 38 | rename to src/wheelhouse.txt |
This merge proposal is being monitored by mergebot. Change the status to Approved to merge.