Merge lp:~corey.bryant/charms/trusty/neutron-api/db-stamp into lp:~openstack-charmers-archive/charms/trusty/neutron-api/next

Proposed by Corey Bryant
Status: Merged
Merged at revision: 60
Proposed branch: lp:~corey.bryant/charms/trusty/neutron-api/db-stamp
Merge into: lp:~openstack-charmers-archive/charms/trusty/neutron-api/next
Diff against target: 125 lines (+49/-15)
3 files modified
hooks/neutron_api_hooks.py (+1/-1)
hooks/neutron_api_utils.py (+20/-2)
unit_tests/test_neutron_api_utils.py (+28/-12)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/neutron-api/db-stamp
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+238550@code.launchpad.net
To post a comment you must log in.
58. By Corey Bryant

Stamp neutron database before upgrade.

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
This MP triggered a test on the Ubuntu OSCI system. Here is a summary of results.

#456 neutron-api-next for corey.bryant mp238550
charm_unit_test

This build:
http://10.98.191.181:8080/job/charm_unit_test/456/

MP URL:
https://code.launchpad.net/~corey.bryant/charms/trusty/neutron-api/db-stamp/+merge/238550

Proposed branch:
lp:~corey.bryant/charms/trusty/neutron-api/db-stamp

Results summary:
    UNIT OK: believed to pass, but you should confirm results

UNIT Results (max last 25 lines) from
/var/lib/jenkins/workspace/charm_unit_test/unit-test.456:
Starting tests...
.......................................................
Name Stmts Miss Cover Missing
---------------------------------------------------------
hooks/neutron_api_context 80 6 93% 22, 34-36, 78, 110
hooks/neutron_api_hooks 190 16 92% 120-121, 179-180, 193, 258, 303, 322-333, 408-409
hooks/neutron_api_utils 105 8 92% 216, 249-261
---------------------------------------------------------
TOTAL 375 30 92%
----------------------------------------------------------------------
Ran 55 tests in 3.681s

OK

Ubuntu OSCI Jenkins is currently in development on a Canonical private network, but we plan to publish results to a public instance soon. Tests are triggered if the proposed branch rev changes, or if the MP is placed into "Needs review" status after being otherwise for >= 1hr. Human review of results is still recommended.
http://10.98.191.181:8080/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
This MP triggered a test on the Ubuntu OSCI system. Here is a summary of results.

#650 neutron-api-next for corey.bryant mp238550
charm_lint_check

This build:
http://10.98.191.181:8080/job/charm_lint_check/650/

MP URL:
https://code.launchpad.net/~corey.bryant/charms/trusty/neutron-api/db-stamp/+merge/238550

Proposed branch:
lp:~corey.bryant/charms/trusty/neutron-api/db-stamp

Results summary:
    LINT OK: believed to pass, but you should confirm results

LINT Results (max last 25 lines) from
/var/lib/jenkins/workspace/charm_lint_check/make-lint.650:
I: config.yaml: option ssl_key has no default value
I: config.yaml: option os-admin-network has no default value
I: config.yaml: option nsx-controllers has no default value
I: config.yaml: option vip has no default value
I: config.yaml: option nsx-l3-uuid has no default value
I: config.yaml: option ssl_ca has no default value
I: config.yaml: option ssl_cert has no default value
I: config.yaml: option os-internal-network has no default value
I: config.yaml: option os-public-network has no default value
I: config.yaml: option nsx-tz-uuid has no default value

Ubuntu OSCI Jenkins is currently in development on a Canonical private network, but we plan to publish results to a public instance soon. Tests are triggered if the proposed branch rev changes, or if the MP is placed into "Needs review" status after being otherwise for >= 1hr. Human review of results is still recommended.
http://10.98.191.181:8080/

Revision history for this message
Ryan Beisner (1chb1n) wrote :

UOSCI bot says:
This MP triggered a test on the Ubuntu OSCI system. Here is a summary of results.

#229 neutron-api-next for corey.bryant mp238550
charm_amulet_test

This build:
http://10.98.191.181:8080/job/charm_amulet_test/229/

MP URL:
https://code.launchpad.net/~corey.bryant/charms/trusty/neutron-api/db-stamp/+merge/238550

Proposed branch:
lp:~corey.bryant/charms/trusty/neutron-api/db-stamp

Results summary:
    AMULET FAIL: amulet-test missing

AMULET Results not found.

Ubuntu OSCI Jenkins is currently in development on a Canonical private network, but we plan to publish results to a public instance soon. Tests are triggered if the proposed branch rev changes, or if the MP is placed into "Needs review" status after being otherwise for >= 1hr. Human review of results is still recommended.
http://10.98.191.181:8080/

Revision history for this message
Liam Young (gnuoy) wrote :

Approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/neutron_api_hooks.py'
--- hooks/neutron_api_hooks.py 2014-10-14 16:12:41 +0000
+++ hooks/neutron_api_hooks.py 2014-10-16 12:57:15 +0000
@@ -165,7 +165,7 @@
165 if not relation_ids('neutron-api'):165 if not relation_ids('neutron-api'):
166 log('Not running neutron database migration, no nova-cloud-controller'166 log('Not running neutron database migration, no nova-cloud-controller'
167 'is present.')167 'is present.')
168 elif os_release('nova-common') <= 'icehouse':168 elif os_release('neutron-server') <= 'icehouse':
169 log('Not running neutron database migration as migrations are handled'169 log('Not running neutron database migration as migrations are handled'
170 'by the neutron-server process.')170 'by the neutron-server process.')
171 else:171 else:
172172
=== modified file 'hooks/neutron_api_utils.py'
--- hooks/neutron_api_utils.py 2014-10-07 12:29:50 +0000
+++ hooks/neutron_api_utils.py 2014-10-16 12:57:15 +0000
@@ -159,7 +159,7 @@
159159
160160
161def register_configs(release=None):161def register_configs(release=None):
162 release = release or os_release('nova-common')162 release = release or os_release('neutron-server')
163 configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,163 configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
164 openstack_release=release)164 openstack_release=release)
165 for cfg, rscs in resource_map().iteritems():165 for cfg, rscs in resource_map().iteritems():
@@ -189,6 +189,7 @@
189189
190 :param configs: The charms main OSConfigRenderer object.190 :param configs: The charms main OSConfigRenderer object.
191 """191 """
192 cur_os_rel = os_release('neutron-server')
192 new_src = config('openstack-origin')193 new_src = config('openstack-origin')
193 new_os_rel = get_os_codename_install_source(new_src)194 new_os_rel = get_os_codename_install_source(new_src)
194195
@@ -210,11 +211,28 @@
210211
211 # set CONFIGS to load templates from new release212 # set CONFIGS to load templates from new release
212 configs.set_release(openstack_release=new_os_rel)213 configs.set_release(openstack_release=new_os_rel)
214
215 if cur_os_rel == 'icehouse':
216 stamp_neutron_database('icehouse')
213 migrate_neutron_database()217 migrate_neutron_database()
214218
215219
220def stamp_neutron_database(release):
221 '''Stamp the database with the current release before upgrade.'''
222 log('Stamping the neutron database with release %s.' % release)
223 plugin = config('neutron-plugin')
224 cmd = ['neutron-db-manage',
225 '--config-file', NEUTRON_CONF,
226 '--config-file', neutron_plugin_attribute(plugin,
227 'config',
228 'neutron'),
229 'stamp',
230 release]
231 subprocess.check_output(cmd)
232
233
216def migrate_neutron_database():234def migrate_neutron_database():
217 '''Runs neutron-db-manage to init a new database or migrate existing'''235 '''Initializes a new database or upgrades an existing database.'''
218 log('Migrating the neutron database.')236 log('Migrating the neutron database.')
219 plugin = config('neutron-plugin')237 plugin = config('neutron-plugin')
220 cmd = ['neutron-db-manage',238 cmd = ['neutron-db-manage',
221239
=== modified file 'unit_tests/test_neutron_api_utils.py'
--- unit_tests/test_neutron_api_utils.py 2014-09-30 09:17:06 +0000
+++ unit_tests/test_neutron_api_utils.py 2014-10-16 12:57:15 +0000
@@ -146,29 +146,45 @@
146 nutils.keystone_ca_cert_b64()146 nutils.keystone_ca_cert_b64()
147 self.assertTrue(self.b64encode.called)147 self.assertTrue(self.b64encode.called)
148148
149 def test_do_openstack_upgrade(self):149 @patch.object(nutils, 'migrate_neutron_database')
150 @patch.object(nutils, 'stamp_neutron_database')
151 def test_do_openstack_upgrade(self, stamp_neutron_db, migrate_neutron_db):
150 self.config.side_effect = self.test_config.get152 self.config.side_effect = self.test_config.get
151 self.test_config.set('openstack-origin', 'cloud:precise-havana')153 self.test_config.set('openstack-origin', 'cloud:trusty-juno')
152 self.get_os_codename_install_source.return_value = 'havana'154 self.os_release.side_effect = 'icehouse'
155 self.get_os_codename_install_source.return_value = 'juno'
153 configs = MagicMock()156 configs = MagicMock()
154 nutils.do_openstack_upgrade(configs)157 nutils.do_openstack_upgrade(configs)
155 configs.set_release.assert_called_with(openstack_release='havana')158 self.os_release.assert_called_with('neutron-server')
156 self.log.assert_called()159 self.log.assert_called()
160 self.configure_installation_source.assert_called_with(
161 'cloud:trusty-juno'
162 )
157 self.apt_update.assert_called_with(fatal=True)163 self.apt_update.assert_called_with(fatal=True)
158 dpkg_opts = [164 dpkg_opts = [
159 '--option', 'Dpkg::Options::=--force-confnew',165 '--option', 'Dpkg::Options::=--force-confnew',
160 '--option', 'Dpkg::Options::=--force-confdef',166 '--option', 'Dpkg::Options::=--force-confdef',
161 ]167 ]
168 self.apt_upgrade.assert_called_with(options=dpkg_opts,
169 fatal=True,
170 dist=True)
162 pkgs = nutils.BASE_PACKAGES171 pkgs = nutils.BASE_PACKAGES
163 pkgs.sort()172 pkgs.sort()
164 self.apt_install.assert_called_with(173 self.apt_install.assert_called_with(packages=pkgs,
165 options=dpkg_opts,174 options=dpkg_opts,
166 packages=pkgs,175 fatal=True)
167 fatal=True176 configs.set_release.assert_called_with(openstack_release='juno')
168 )177 stamp_neutron_db.assert_called()
169 self.configure_installation_source.assert_called_with(178 migrate_neutron_db.assert_called()
170 'cloud:precise-havana'179
171 )180 def test_stamp_neutron_database(self):
181 nutils.stamp_neutron_database('icehouse')
182 cmd = ['neutron-db-manage',
183 '--config-file', '/etc/neutron/neutron.conf',
184 '--config-file', '/etc/neutron/plugins/ml2/ml2_conf.ini',
185 'stamp',
186 'icehouse']
187 self.subprocess.check_output.assert_called_with(cmd)
172188
173 def test_migrate_neutron_database(self):189 def test_migrate_neutron_database(self):
174 nutils.migrate_neutron_database()190 nutils.migrate_neutron_database()

Subscribers

People subscribed via source and target branches