Merge lp:~veebers/juju-ci-tools/migration-log-check-fix into lp:juju-ci-tools

Proposed by Christopher Lee
Status: Merged
Merged at revision: 1823
Proposed branch: lp:~veebers/juju-ci-tools/migration-log-check-fix
Merge into: lp:juju-ci-tools
Prerequisite: lp:~veebers/juju-ci-tools/model-migration-remove-mongo
Diff against target: 103 lines (+25/-25)
2 files modified
assess_model_migration.py (+2/-2)
tests/test_assess_model_migration.py (+23/-23)
To merge this branch: bzr merge lp:~veebers/juju-ci-tools/migration-log-check-fix
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+313328@code.launchpad.net

Description of the change

Fix for log migration test so it checks all previous logs.

Withou --replay the logs returned might not include the logs in the
timeframe that we're interested in.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you for fixing this intermittent failure.

review: Approve (code)
1813. By Christopher Lee

Merged model-migration-remove-mongo into migration-log-check-fix.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'assess_model_migration.py'
2--- assess_model_migration.py 2016-12-21 21:50:59 +0000
3+++ assess_model_migration.py 2016-12-21 21:50:59 +0000
4@@ -47,6 +47,7 @@
5 dest_client = bs2.client
6 ensure_migration_including_resources_succeeds(
7 source_client, dest_client)
8+ ensure_model_logs_are_migrated(source_client, dest_client)
9 with temp_dir() as temp:
10 ensure_migrating_with_insufficient_user_permissions_fails(
11 source_client, dest_client, temp)
12@@ -59,7 +60,6 @@
13 source_client, dest_client, temp)
14
15 if args.use_develop:
16- ensure_model_logs_are_migrated(source_client, dest_client)
17 ensure_migration_rolls_back_on_failure(
18 source_client, dest_client)
19 ensure_api_login_redirects(source_client, dest_client)
20@@ -372,7 +372,7 @@
21 log.info('Attempting migration process')
22 migrated_model = migrate_model_to_controller(new_model_client, dest_client)
23 after_migration_logs = migrated_model.get_juju_output(
24- 'debug-log', '--no-tail', '-l', 'DEBUG')
25+ 'debug-log', '--no-tail', '--replay', '-l', 'DEBUG')
26 if before_migration_logs not in after_migration_logs:
27 raise JujuAssertionError('Logs failed to be migrated.')
28 log.info('SUCCESS: logs migrated.')
29
30=== modified file 'tests/test_assess_model_migration.py'
31--- tests/test_assess_model_migration.py 2016-12-21 21:50:59 +0000
32+++ tests/test_assess_model_migration.py 2016-12-21 21:50:59 +0000
33@@ -710,6 +710,10 @@
34 yield '/tmp/dir'
35
36
37+def patch_amm(target):
38+ return patch.object(amm, target, autospec=True)
39+
40+
41 class TestAssessModelMigration(TestCase):
42
43 def test_runs_develop_tests_when_requested(self):
44@@ -721,9 +725,6 @@
45 bs1.booted_context.return_value = noop_context()
46 bs2.existing_booted_context.return_value = noop_context()
47
48- def patch_amm(target):
49- return patch.object(amm, target, autospec=True)
50-
51 patch_between = patch_amm(
52 'ensure_migration_including_resources_succeeds')
53 patch_user = patch_amm(
54@@ -768,30 +769,29 @@
55 bs1.booted_context.return_value = noop_context()
56 bs2.existing_booted_context.return_value = noop_context()
57
58- with patch.object(
59- amm,
60- 'ensure_migrating_with_insufficient_user_permissions_fails',
61- autospec=True) as m_user:
62- with patch.object(
63- amm,
64- 'ensure_migrating_with_superuser_user_permissions_succeeds', # NOQA
65- autospec=True) as m_super:
66- with patch.object(
67- amm,
68- 'ensure_migration_including_resources_succeeds',
69- autospec=True) as m_between:
70- with patch.object(
71- amm,
72- 'ensure_migration_rolls_back_on_failure',
73- autospec=True) as m_rollback:
74- with patch.object(
75- amm, 'temp_dir',
76- autospec=True, return_value=tmp_ctx()):
77- amm.assess_model_migration(bs1, bs2, args)
78+ patch_user = patch_amm(
79+ 'ensure_migrating_with_insufficient_user_permissions_fails')
80+ patch_super = patch_amm(
81+ 'ensure_migrating_with_superuser_user_permissions_succeeds')
82+ patch_between = patch_amm(
83+ 'ensure_migration_including_resources_succeeds')
84+ patch_rollback = patch_amm('ensure_migration_rolls_back_on_failure')
85+ patch_logs = patch_amm('ensure_model_logs_are_migrated')
86+
87+ with patch_user as m_user:
88+ with patch_super as m_super:
89+ with patch_between as m_between:
90+ with patch_rollback as m_rollback:
91+ with patch_logs as m_logs:
92+ with patch.object(
93+ amm, 'temp_dir',
94+ autospec=True, return_value=tmp_ctx()):
95+ amm.assess_model_migration(bs1, bs2, args)
96 source_client = bs1.client
97 dest_client = bs2.client
98 m_user.assert_called_once_with(source_client, dest_client, '/tmp/dir')
99 m_super.assert_called_once_with(source_client, dest_client, '/tmp/dir')
100 m_between.assert_called_once_with(source_client, dest_client)
101+ m_logs.assert_called_once_with(source_client, dest_client)
102
103 self.assertEqual(m_rollback.call_count, 0)

Subscribers

People subscribed via source and target branches