Merge lp:~abentley/charmworld/restore-questions into lp:~juju-jitsu/charmworld/trunk

Proposed by Aaron Bentley
Status: Merged
Approved by: Aaron Bentley
Approved revision: 335
Merged at revision: 335
Proposed branch: lp:~abentley/charmworld/restore-questions
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 281 lines (+187/-13)
6 files modified
Makefile (+3/-3)
charmworld/migrations/migrate.py (+5/-2)
charmworld/migrations/versions/011_ensure_category_questions.py (+15/-0)
charmworld/migrations/versions/tests/test_migrations.py (+18/-7)
charmworld/qa_questions.py (+145/-0)
setup.py (+1/-1)
To merge this branch: bzr merge lp:~abentley/charmworld/restore-questions
Reviewer Review Type Date Requested Status
Brad Crittenden (community) Approve
Review via email: mp+178753@code.launchpad.net

Commit message

Restore QA questions to migrations.

Description of the change

This branch restores the QA questions to the migrations. I had deleted them because they were old migrations. Most migrations describe a change to apply, so they can be deleted once no databases exist that lack the change. But the QA questions are a desired state, and so they must be applied to all databases, even new ones.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Hi Aaron, the code and tests look good to me. I found two typos, one legacy. Thanks.

typo: mirgrations
typo: comfigure

review: Approve
335. By Aaron Bentley

Fix typos.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2013-07-18 21:33:26 +0000
+++ Makefile 2013-08-06 13:54:26 +0000
@@ -91,17 +91,17 @@
91# ###################91# ###################
9292
93test: test.ini $(INI) bin/nosetests93test: test.ini $(INI) bin/nosetests
94 $(NOSE) charmworld migrations94 $(NOSE) charmworld
9595
96testid: test.ini bin/nosetests96testid: test.ini bin/nosetests
97 # Run specific nose id tests.97 # Run specific nose id tests.
98 # To set up the index you must run `make testid` once to completion to98 # To set up the index you must run `make testid` once to completion to
99 # setup the index. Then you can run a group of tests like:99 # setup the index. Then you can run a group of tests like:
100 # Call with `ID="3 5" make testid`100 # Call with `ID="3 5" make testid`
101 $(NOSE) -v -s -x --with-id $(ID) charmworld migrations101 $(NOSE) -v -s -x --with-id $(ID) charmworld
102102
103testdebug: test.ini bin/nosetests103testdebug: test.ini bin/nosetests
104 $(NOSE) --with-id --pdb --pdb-failures charmworld migrations104 $(NOSE) --with-id --pdb --pdb-failures charmworld
105105
106check: clear_ini clean sysdeps install testid106check: clear_ini clean sysdeps install testid
107107
108108
=== renamed directory 'migrations' => 'charmworld/migrations'
=== modified file 'charmworld/migrations/migrate.py'
--- migrations/migrate.py 2013-07-15 21:31:05 +0000
+++ charmworld/migrations/migrate.py 2013-08-06 13:54:26 +0000
@@ -389,6 +389,10 @@
389 print "Updated the datastore to version: {0}".format(new_version)389 print "Updated the datastore to version: {0}".format(new_version)
390390
391391
392def get_migration_path():
393 return join(abspath(dirname(__file__)), 'versions')
394
395
392def main():396def main():
393 """Target for the console entry point."""397 """Target for the console entry point."""
394 configure_logging()398 configure_logging()
@@ -396,8 +400,7 @@
396 ini = get_ini()400 ini = get_ini()
397401
398 # Add the migration path to the ini.402 # Add the migration path to the ini.
399 migration_path = join(abspath(dirname(__file__)), 'versions')403 ini['migrations'] = get_migration_path()
400 ini['migrations'] = migration_path
401404
402 args.func(ini, args)405 args.func(ini, args)
403406
404407
=== added file 'charmworld/migrations/versions/011_ensure_category_questions.py'
--- charmworld/migrations/versions/011_ensure_category_questions.py 1970-01-01 00:00:00 +0000
+++ charmworld/migrations/versions/011_ensure_category_questions.py 2013-08-06 13:54:26 +0000
@@ -0,0 +1,15 @@
1# Copyright 2013 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4from charmworld.qa_questions import iter_categories
5
6
7def upgrade(db, index_client):
8 """Update each category of questions from new_category_data.
9
10 This update elaborates on the 001_* migration. Subsequent qa form
11 migrations can replace new_category_data and run this same method.
12 """
13 db.qa.drop()
14 for category_dict in iter_categories():
15 db.qa.insert(category_dict)
016
=== modified file 'charmworld/migrations/versions/tests/test_migrations.py'
--- migrations/versions/tests/test_migrations.py 2013-07-22 19:18:21 +0000
+++ charmworld/migrations/versions/tests/test_migrations.py 2013-08-06 13:54:26 +0000
@@ -6,8 +6,8 @@
6)6)
7from charmworld.models import CharmSource7from charmworld.models import CharmSource
8from charmworld.testing import MongoTestBase8from charmworld.testing import MongoTestBase
9import migrations.migrate9from charmworld.migrations import migrate
10from migrations.migrate import Versions10from charmworld.migrations.migrate import Versions
1111
1212
13def fake():13def fake():
@@ -18,12 +18,12 @@
1818
19 def setUp(self):19 def setUp(self):
20 super(MigrationTestBase, self).setUp()20 super(MigrationTestBase, self).setUp()
21 self.versions = Versions('migrations/versions/')21 self.versions = Versions(migrate.get_migration_path())
22 true_configure_logging = migrations.migrate.configure_logging22 true_configure_logging = migrate.configure_logging
23 migrations.migrate.configure_logging = fake23 migrate.configure_logging = fake
24 self.addCleanup(24 self.addCleanup(
25 setattr, migrations.migrate,25 setattr, migrate,
26 'comfigure_logging', true_configure_logging)26 'configure_logging', true_configure_logging)
2727
2828
29class TestMigration010(MigrationTestBase):29class TestMigration010(MigrationTestBase):
@@ -78,3 +78,14 @@
78 self.index_client.get('e')78 self.index_client.get('e')
79 self.assertEqual({'_id': 'e', 'config': ['a']},79 self.assertEqual({'_id': 'e', 'config': ['a']},
80 self.db.charms.find_one({'_id': 'e'}))80 self.db.charms.find_one({'_id': 'e'}))
81
82
83class TestMigration011(MigrationTestBase):
84
85 def test_migration(self):
86 self.use_index_client()
87 source = CharmSource.from_request(self)
88 self.assertItemsEqual([], self.db.qa.find())
89 self.versions.run_migration(self.db, self.index_client,
90 '011_ensure_category_questions.py')
91 self.assertIn('reliable', [cat['name'] for cat in self.db.qa.find()])
8192
=== added file 'charmworld/qa_questions.py'
--- charmworld/qa_questions.py 1970-01-01 00:00:00 +0000
+++ charmworld/qa_questions.py 2013-08-06 13:54:26 +0000
@@ -0,0 +1,145 @@
1# Copyright 2012, 2013 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4# -*- coding: utf-8 -*-
5"""
6Load qa questions into the collection for populating the scoring parts of
7the quality assessment form.
8
9"""
10
11
12def iter_categories():
13 """Complete this function with work to be done for the migration/update.
14
15 db is the pymongo db instance for our datastore. Charms are in db.charms
16 for instance.
17 """
18
19 initial = [
20 (
21 u'reliable',
22 u'Reliable',
23 [
24 (u'Check for integrity from upstream source', 1, u''),
25 (u'Fail gracefully if upstream source goes missing', 1, u''),
26 (u'Contain a suite of tests with the charm that pass', 1, u''),
27 (u'Passes tests from Jenkins on jujucharms.com', 1, u''),
28 ]
29 ),
30
31 (
32 u'secure',
33 u'Secure',
34 [
35 (u'Contain a well tested AppArmor profile', 1, ''),
36 (u'Conform to security policies of the charm store', 1,
37 'Tight access control'),
38 (u"Doesn't run as root", 1, ''),
39 (u'Per instance or service access control', 1, ''),
40 ]
41 ),
42
43 (
44 u'flexible',
45 u'Flexible',
46 [
47 (
48 u'Contain opinionated tuning options', 1,
49 u'Examples (depends on the service): "safe", "default",'
50 ' "fast", "real fast, not so safe". Don\'t expose every'
51 ' configuration, pick those that reflect real world usage.'
52 ' Make it so I don\'t have to read the book.'
53 ),
54 (u'Use existing interfaces with other charms', 1,
55 u'Highly relatable'),
56 ]
57 ),
58
59 (
60 u'data_handling',
61 u'Data Handling',
62 [
63 (u'Integrate data storage best practices', 1,
64 u'Backups based on service usage'),
65 (u"Handle the service's user data", 1, u'Version control'),
66 (u"Handle the service's user data", 1,
67 u'Automated snapshots and backup.'),
68 ]
69 ),
70
71 (
72 u'scalable',
73 u'Scaleable',
74 [
75 (u"Responds to add-unit based on the service's needs", 1,
76 u'Configuration should not require additional steps to scale'
77 ' horizontally'),
78 (u'Be tested with a real workload, not just a synthetic'
79 ' benchmark', 1, ''),
80 (u'From upstream and existing devops practices for that'
81 ' service', 1, ''),
82 (u'Community peer reviewed', 1, ''),
83 (u'Have a configure option for most performant configuration'
84 ' if not the default', 1, ''),
85 ]
86 ),
87
88 (
89 u'easy_deploy',
90 u'Easy to Deploy',
91 [
92 (u'README with examples of use for a typical workload', 1, ''),
93 (u'README with examples of use for workloads at scale', 1, ''),
94 (u'README with examples of use recommend best-practice'
95 ' relationships', 1, ''),
96 (u'Allow installation from pure upstream source', 1, ''),
97 (u'Allow installation from your local source', 1, ''),
98 (u'Allow installation from PPA (if available)', 1, ''),
99 (u'Allow installation from the Ubuntu repository', 1, ''),
100 ]
101 ),
102
103 (
104 u'responsive',
105 u'Responsive to DevOps Needs',
106 [
107 (u'Allow for easy upgrade via juju upgrade-charm', 1, ''),
108 (u'Allow upgrading the service itself.', 1, ''),
109 (u'Responsive to user bug reports and concerns', 1, ''),
110 (u'Maintainable, easy to read and modify', 1, ''),
111 ]
112 ),
113
114 (
115 u'upstream',
116 u'Upstream Friendly',
117 [
118 (u'Follow upstream best practices', 1,
119 u'Provide an option for a barebones "pure upstream"'
120 ' configuration'),
121 (u'Should go lock-step with deployment recommendations', 1,
122 u'Provide tip-of-trunk testing if feasible'),
123 (u'Fresh charm on release day!', 1, ''),
124 (
125 u"Endeavour to be upstream's recommended way to deploy"
126 ' that service in the cloud (website mention or'
127 ' something)', 1, ''
128 ),
129 ]
130 ),
131 ]
132
133 """Add the sample data into the db."""
134 for cat in initial:
135 category_dict = {
136 'name': cat[0],
137 'description': cat[1],
138 'questions': [{
139 'id': '{0}_{1}'.format(cat[0].lower(), i),
140 'description': q[0],
141 'points': q[1],
142 'extended_description': q[2]
143 } for i, q in enumerate(cat[2])]
144 }
145 yield category_dict
0146
=== modified file 'setup.py'
--- setup.py 2013-06-28 20:56:31 +0000
+++ setup.py 2013-08-06 13:54:26 +0000
@@ -36,7 +36,7 @@
36 enqueue = charmworld.jobs.lp:main36 enqueue = charmworld.jobs.lp:main
37 dequeue = charmworld.jobs.lp:dequeue37 dequeue = charmworld.jobs.lp:dequeue
38 ingest-queued = charmworld.jobs.worker:main38 ingest-queued = charmworld.jobs.worker:main
39 migrations = migrations.migrate:main39 migrations = charmworld.migrations.migrate:main
40 es-update = charmworld.search:update_main40 es-update = charmworld.search:update_main
41 sync-index = charmworld.models:sync_index41 sync-index = charmworld.models:sync_index
42 [beaker.backends]42 [beaker.backends]

Subscribers

People subscribed via source and target branches