Mercurial > bitten > bitten-test
annotate bitten/tests/upgrades.py @ 860:ac28bc3feb2a
Refuse to create log folder during database upgrade if the folder already exists. The existence of such a folder is an indication that a previous attempt to migrate the logs into files has failed and that the folder should be removed before continuing. See #462 for further discussion.
author | hodgestar |
---|---|
date | Sun, 17 Oct 2010 23:20:44 +0000 |
parents | ee95915922dd |
children |
rev | line source |
---|---|
708 | 1 # -*- coding: utf-8 -*- |
2 # | |
832 | 3 # Copyright (C) 2009-2010 Edgewall Software |
708 | 4 # All rights reserved. |
5 # | |
6 # This software is licensed as described in the file COPYING, which | |
7 # you should have received as part of this distribution. The terms | |
8 # are also available at http://bitten.edgewall.org/wiki/License. | |
9 | |
10 import unittest | |
735
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
11 import logging |
708 | 12 |
13 import warnings | |
14 warnings.filterwarnings('ignore', '^Unknown table') | |
15 warnings.filterwarnings('ignore', '^the sets module is deprecated') | |
16 | |
860
ac28bc3feb2a
Refuse to create log folder during database upgrade if the folder already exists. The existence of such a folder is an indication that a previous attempt to migrate the logs into files has failed and that the folder should be removed before continuing. See #462 for further discussion.
hodgestar
parents:
846
diff
changeset
|
17 from trac.core import TracError |
708 | 18 from trac.test import EnvironmentStub |
19 from trac.db import Table, Column, Index, DatabaseManager | |
20 from bitten.upgrades import update_sequence, drop_index | |
21 from bitten import upgrades, main, model | |
22 | |
23 import os | |
24 import shutil | |
25 import tempfile | |
26 | |
27 | |
28 class BaseUpgradeTestCase(unittest.TestCase): | |
29 | |
30 schema = None | |
31 other_tables = [] | |
32 | |
33 def setUp(self): | |
34 self.env = EnvironmentStub() | |
710
c599830cf185
Only patch test configuration database uri if the version of Trac has support for different test databases.
hodgestar
parents:
708
diff
changeset
|
35 if hasattr(self.env, 'dburi'): |
c599830cf185
Only patch test configuration database uri if the version of Trac has support for different test databases.
hodgestar
parents:
708
diff
changeset
|
36 # Trac gained support for testing against different databases in 0.11.5 |
c599830cf185
Only patch test configuration database uri if the version of Trac has support for different test databases.
hodgestar
parents:
708
diff
changeset
|
37 # If this support is available, we copy the test db uri configuration |
c599830cf185
Only patch test configuration database uri if the version of Trac has support for different test databases.
hodgestar
parents:
708
diff
changeset
|
38 # into the main test config so it can be picked up by |
846
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
39 # upgrades.parse_scheme() |
710
c599830cf185
Only patch test configuration database uri if the version of Trac has support for different test databases.
hodgestar
parents:
708
diff
changeset
|
40 self.env.config.set('trac', 'database', self.env.dburi) |
708 | 41 self.env.path = tempfile.mkdtemp() |
735
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
42 logs_dir = self.env.config.get("bitten", "logs_dir", "log/bitten") |
708 | 43 if os.path.isabs(logs_dir): |
44 raise ValueError("Should not have absolute logs directory for temporary test") | |
45 logs_dir = os.path.join(self.env.path, logs_dir) | |
735
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
46 self.logs_dir = logs_dir |
708 | 47 |
48 db = self.env.get_db_cnx() | |
49 cursor = db.cursor() | |
50 | |
51 for table_name in self.other_tables: | |
52 cursor.execute("DROP TABLE IF EXISTS %s" % (table_name,)) | |
53 | |
54 connector, _ = DatabaseManager(self.env)._get_connector() | |
55 for table in self.schema: | |
56 cursor.execute("DROP TABLE IF EXISTS %s" % (table.name,)) | |
57 for stmt in connector.to_sql(table): | |
58 cursor.execute(stmt) | |
59 | |
60 db.commit() | |
61 | |
62 def tearDown(self): | |
63 shutil.rmtree(self.env.path) | |
735
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
64 del self.logs_dir |
708 | 65 del self.env |
66 | |
67 | |
735
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
68 class LogWatcher(logging.Handler): |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
69 |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
70 def __init__(self, level=0): |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
71 logging.Handler.__init__(self, level=0) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
72 self.records = [] |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
73 |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
74 def emit(self, record): |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
75 self.records.append(record) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
76 |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
77 |
708 | 78 class UpgradeHelperTestCase(BaseUpgradeTestCase): |
79 | |
80 schema = [ | |
81 Table('test_update_sequence', key='id')[ | |
82 Column('id', auto_increment=True), Column('name'), | |
83 ], | |
84 Table('test_drop_index', key='id')[ | |
85 Column('id', type='int'), Column('name', size=20), | |
86 Index(['name']) | |
87 ], | |
88 ] | |
89 | |
90 def test_update_sequence(self): | |
91 db = self.env.get_db_cnx() | |
92 cursor = db.cursor() | |
93 | |
94 for rowid, name in [(1, 'a'), (2, 'b'), (3, 'c')]: | |
95 cursor.execute("INSERT INTO test_update_sequence (id, name)" | |
96 " VALUES (%s, %s)", (rowid, name)) | |
97 update_sequence(self.env, db, 'test_update_sequence', 'id') | |
98 | |
99 cursor.execute("INSERT INTO test_update_sequence (name)" | |
100 " VALUES (%s)", ('d',)) | |
101 | |
102 cursor.execute("SELECT id FROM test_update_sequence WHERE name = %s", | |
103 ('d',)) | |
104 row = cursor.fetchone() | |
105 self.assertEqual(row[0], 4) | |
106 | |
107 def test_drop_index(self): | |
108 db = self.env.get_db_cnx() | |
109 cursor = db.cursor() | |
110 | |
111 cursor.execute("INSERT INTO test_drop_index (id, name)" | |
112 " VALUES (%s, %s)", (1, 'a')) | |
113 | |
114 def do_drop(): | |
115 drop_index(self.env, db, 'test_drop_index', 'test_drop_index_name_idx') | |
116 | |
117 # dropping the index should succeed the first time and fail the next | |
118 do_drop() | |
119 self.assertRaises(Exception, do_drop) | |
120 | |
121 | |
122 class UpgradeScriptsTestCase(BaseUpgradeTestCase): | |
123 | |
124 schema = [ | |
125 # Sytem | |
126 Table('system', key='name')[ | |
127 Column('name'), Column('value') | |
128 ], | |
129 # Config | |
130 Table('bitten_config', key='name')[ | |
131 Column('name'), Column('path'), Column('label'), | |
132 Column('active', type='int'), Column('description') | |
133 ], | |
134 # Platform | |
135 Table('bitten_platform', key='id')[ | |
136 Column('id', auto_increment=True), Column('config'), Column('name') | |
137 ], | |
138 Table('bitten_rule', key=('id', 'propname'))[ | |
139 Column('id'), Column('propname'), Column('pattern'), | |
140 Column('orderno', type='int') | |
141 ], | |
142 # Build | |
143 Table('bitten_build', key='id')[ | |
144 Column('id', auto_increment=True), Column('config'), Column('rev'), | |
145 Column('rev_time', type='int'), Column('platform', type='int'), | |
146 Column('slave'), Column('started', type='int'), | |
147 Column('stopped', type='int'), Column('status', size=1), | |
148 Index(['config', 'rev', 'slave']) | |
149 ], | |
150 Table('bitten_slave', key=('build', 'propname'))[ | |
151 Column('build', type='int'), Column('propname'), Column('propvalue') | |
152 ], | |
153 # Build Step | |
154 Table('bitten_step', key=('build', 'name'))[ | |
155 Column('build', type='int'), Column('name'), Column('description'), | |
156 Column('status', size=1), Column('log'), | |
157 Column('started', type='int'), Column('stopped', type='int') | |
158 ], | |
159 ] | |
160 | |
161 other_tables = [ | |
162 'bitten_log', | |
163 'bitten_log_message', | |
164 'bitten_report', | |
165 'bitten_report_item', | |
166 'bitten_error', | |
167 'old_step', | |
846
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
168 'old_config_v2', |
708 | 169 'old_log_v5', |
170 'old_log_v8', | |
846
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
171 'old_rule_v9', |
762
5f0cfee44540
Add new last_activity field to build. I considered reusing stopped, but this seemed cleaner and more obvious, which seems like the right way to go.
wbell
parents:
737
diff
changeset
|
172 'old_build_v11', |
708 | 173 ] |
174 | |
175 basic_data = [ | |
176 ['system', | |
177 ('name', 'value'), [ | |
178 ('bitten_version', '1'), | |
179 ] | |
180 ], | |
181 ['bitten_config', | |
182 ('name',), [ | |
183 ('test_config',), | |
184 ] | |
185 ], | |
186 ['bitten_platform', | |
187 ('config', 'name'), [ | |
188 ('test_config', 'test_plat'), | |
189 ] | |
190 ], | |
191 ['bitten_build', | |
790
330fa697bc85
Extend upgrade test to check that build ids are preserved.
hodgestar
parents:
762
diff
changeset
|
192 ('id', 'config', 'rev', 'platform', 'rev_time'), [ |
330fa697bc85
Extend upgrade test to check that build ids are preserved.
hodgestar
parents:
762
diff
changeset
|
193 (12, 'test_config', '123', 1, 456), |
708 | 194 ] |
195 ], | |
196 ['bitten_step', | |
197 ('build', 'name', 'log'), [ | |
790
330fa697bc85
Extend upgrade test to check that build ids are preserved.
hodgestar
parents:
762
diff
changeset
|
198 (12, 'step1', None), |
330fa697bc85
Extend upgrade test to check that build ids are preserved.
hodgestar
parents:
762
diff
changeset
|
199 (12, 'step2', "line1\nline2"), |
708 | 200 ] |
201 ], | |
202 ] | |
203 | |
204 def _do_upgrade(self): | |
205 """Do an full upgrade.""" | |
206 import inspect | |
207 db = self.env.get_db_cnx() | |
208 | |
209 versions = sorted(upgrades.map.keys()) | |
210 for version in versions: | |
211 for function in upgrades.map.get(version): | |
212 self.assertTrue(inspect.getdoc(function)) | |
213 function(self.env, db) | |
214 | |
215 db.commit() | |
216 | |
217 def _insert_data(self, data): | |
218 """Insert data for upgrading.""" | |
219 db = self.env.get_db_cnx() | |
220 cursor = db.cursor() | |
221 | |
222 for table, cols, vals in data: | |
223 cursor.executemany("INSERT INTO %s (%s) VALUES (%s)" | |
224 % (table, ','.join(cols), | |
225 ','.join(['%s' for c in cols])), | |
226 vals) | |
227 | |
228 db.commit() | |
229 | |
230 def _check_basic_upgrade(self): | |
231 """Check the results of an upgrade of basic data.""" | |
232 configs = list(model.BuildConfig.select(self.env, | |
233 include_inactive=True)) | |
234 platforms = list(model.TargetPlatform.select(self.env)) | |
235 builds = list(model.Build.select(self.env)) | |
236 steps = list(model.BuildStep.select(self.env)) | |
237 logs = list(model.BuildLog.select(self.env)) | |
238 | |
239 self.assertEqual(len(configs), 1) | |
240 self.assertEqual(configs[0].name, 'test_config') | |
241 | |
242 self.assertEqual(len(platforms), 1) | |
243 self.assertEqual(platforms[0].config, 'test_config') | |
244 self.assertEqual(platforms[0].name, 'test_plat') | |
245 | |
246 self.assertEqual(len(builds), 1) | |
790
330fa697bc85
Extend upgrade test to check that build ids are preserved.
hodgestar
parents:
762
diff
changeset
|
247 self.assertEqual(builds[0].id, 12) |
708 | 248 self.assertEqual(builds[0].config, 'test_config') |
249 self.assertEqual(builds[0].rev, '123') | |
250 self.assertEqual(builds[0].platform, 1) | |
251 self.assertEqual(builds[0].rev_time, 456) | |
252 | |
253 self.assertEqual(len(steps), 2) | |
790
330fa697bc85
Extend upgrade test to check that build ids are preserved.
hodgestar
parents:
762
diff
changeset
|
254 self.assertEqual(steps[0].build, 12) |
708 | 255 self.assertEqual(steps[0].name, 'step1') |
790
330fa697bc85
Extend upgrade test to check that build ids are preserved.
hodgestar
parents:
762
diff
changeset
|
256 self.assertEqual(steps[1].build, 12) |
708 | 257 self.assertEqual(steps[1].name, 'step2') |
258 | |
259 self.assertEqual(len(logs), 1) | |
790
330fa697bc85
Extend upgrade test to check that build ids are preserved.
hodgestar
parents:
762
diff
changeset
|
260 self.assertEqual(logs[0].build, 12) |
708 | 261 self.assertEqual(logs[0].step, 'step2') |
262 log_file = logs[0].get_log_file(logs[0].filename) | |
263 self.assertEqual(file(log_file, "rU").read(), "line1\nline2\n") | |
264 | |
846
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
265 # check final sequences |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
266 for tbl, col in [ |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
267 ('bitten_build', 'id'), |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
268 ('bitten_log', 'id'), |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
269 ('bitten_platform', 'id'), |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
270 ('bitten_report', 'id'), |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
271 ]: |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
272 self._check_sequence(tbl, col) |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
273 |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
274 def _check_sequence(self, tbl, col): |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
275 scheme = upgrades.parse_scheme(self.env) |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
276 if scheme == "postgres": |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
277 self._check_postgres_sequence(tbl, col) |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
278 |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
279 def _check_postgres_sequence(self, tbl, col): |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
280 """Check a PostgreSQL sequence for the given table and column.""" |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
281 seq = '%s_%s_seq' % (tbl, col) |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
282 cursor = self.env.get_db_cnx().cursor() |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
283 cursor.execute("SELECT MAX(%s) FROM %s" % (col, tbl)) |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
284 current_max = cursor.fetchone()[0] or 0 # if currently None |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
285 cursor.execute("SELECT nextval('%s')" % (seq,)) |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
286 current_seq = cursor.fetchone()[0] - 1 |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
287 self.assertEqual(current_max, current_seq, |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
288 "On %s (col: %s) expected column max (%d) " |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
289 "and sequence value (%d) to match" |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
290 % (tbl, col, current_max, current_seq)) |
ee95915922dd
Add checks that (PostgreSQL) sequences have ended up in the correct state at the end of the upgrade scripts. Test currently fails on PostgreSQL as a result of #632.
hodgestar
parents:
832
diff
changeset
|
291 |
708 | 292 def test_null_upgrade(self): |
293 self._do_upgrade() | |
294 | |
295 def test_basic_upgrade(self): | |
296 self._insert_data(self.basic_data) | |
297 self._do_upgrade() | |
298 self._check_basic_upgrade() | |
299 | |
300 def test_upgrade_via_buildsetup(self): | |
301 self._insert_data(self.basic_data) | |
302 db = self.env.get_db_cnx() | |
303 build_setup = main.BuildSetup(self.env) | |
304 self.assertTrue(build_setup.environment_needs_upgrade(db)) | |
305 build_setup.upgrade_environment(db) | |
306 self._check_basic_upgrade() | |
307 | |
308 # check bitten table version | |
309 cursor = db.cursor() | |
310 cursor.execute("SELECT value FROM system WHERE name='bitten_version'") | |
311 rows = cursor.fetchall() | |
312 self.assertEqual(rows, [(str(model.schema_version),)]) | |
313 | |
735
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
314 def test_fix_log_levels_misnaming(self): |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
315 logfiles = { |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
316 "1.log": "", |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
317 "2.log": "", |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
318 "3.log": "", |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
319 "1.log.level": "info\n", |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
320 "2.log.levels": "info\ninfo\n", |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
321 "3.log.level": "warn\n", |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
322 "3.log.levels": "warn\nwarn\n", |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
323 "4.log.level": "error\n", |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
324 } |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
325 expected_deletions = [ |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
326 "4.log.level", |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
327 ] |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
328 |
860
ac28bc3feb2a
Refuse to create log folder during database upgrade if the folder already exists. The existence of such a folder is an indication that a previous attempt to migrate the logs into files has failed and that the folder should be removed before continuing. See #462 for further discussion.
hodgestar
parents:
846
diff
changeset
|
329 os.makedirs(self.logs_dir) |
735
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
330 for filename, data in logfiles.items(): |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
331 path = os.path.join(self.logs_dir, filename) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
332 logfile = open(path, "w") |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
333 logfile.write(data) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
334 logfile.close() |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
335 |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
336 logwatch = LogWatcher(logging.INFO) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
337 self.env.log.setLevel(logging.INFO) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
338 self.env.log.addHandler(logwatch) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
339 |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
340 upgrades.fix_log_levels_misnaming(self.env, None) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
341 |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
342 filenames = sorted(os.listdir(self.logs_dir)) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
343 for filename in filenames: |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
344 path = os.path.join(self.logs_dir, filename) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
345 origfile = filename in logfiles and filename or filename.replace("levels", "level") |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
346 self.assertEqual(logfiles[origfile], open(path).read()) |
737
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
347 self.assertTrue(filename not in expected_deletions) |
735
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
348 |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
349 self.assertEqual(len(filenames), len(logfiles) - len(expected_deletions)) |
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
350 |
737
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
351 logs = sorted(logwatch.records, key=lambda rec: rec.getMessage()) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
352 self.assertEqual(len(logs), 5) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
353 self.assertTrue(logs[0].getMessage().startswith( |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
354 "Deleted 1 stray log level (0 errors)")) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
355 self.assertTrue(logs[1].getMessage().startswith( |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
356 "Deleted stray log level file 4.log.level")) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
357 self.assertTrue(logs[2].getMessage().startswith( |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
358 "Error renaming")) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
359 self.assertTrue(logs[3].getMessage().startswith( |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
360 "Renamed 1 incorrectly named log level files from previous migrate (1 errors)")) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
361 self.assertTrue(logs[4].getMessage().startswith( |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
362 "Renamed incorrectly named log level file")) |
735
90903d6cc932
Add upgrade script to fix badly named .log.level files. Don't use BuildLog.LEVELS_SUFFIX in upgrade scripts. See #517.
hodgestar
parents:
710
diff
changeset
|
363 |
737
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
364 def test_remove_stray_log_levels_files(self): |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
365 logfiles = { |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
366 "1.log": "", |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
367 "1.log.levels": "info\n", |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
368 "2.log.levels": "info\ninfo\n", |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
369 } |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
370 expected_deletions = [ |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
371 "2.log.levels", |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
372 ] |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
373 |
860
ac28bc3feb2a
Refuse to create log folder during database upgrade if the folder already exists. The existence of such a folder is an indication that a previous attempt to migrate the logs into files has failed and that the folder should be removed before continuing. See #462 for further discussion.
hodgestar
parents:
846
diff
changeset
|
374 os.makedirs(self.logs_dir) |
737
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
375 for filename, data in logfiles.items(): |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
376 path = os.path.join(self.logs_dir, filename) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
377 logfile = open(path, "w") |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
378 logfile.write(data) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
379 logfile.close() |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
380 |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
381 logwatch = LogWatcher(logging.INFO) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
382 self.env.log.setLevel(logging.INFO) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
383 self.env.log.addHandler(logwatch) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
384 |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
385 upgrades.remove_stray_log_levels_files(self.env, None) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
386 |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
387 filenames = sorted(os.listdir(self.logs_dir)) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
388 for filename in filenames: |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
389 path = os.path.join(self.logs_dir, filename) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
390 self.assertEqual(logfiles[filename], open(path).read()) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
391 self.assertTrue(filename not in expected_deletions) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
392 |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
393 self.assertEqual(len(filenames), len(logfiles) - len(expected_deletions)) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
394 |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
395 logs = sorted(logwatch.records, key=lambda rec: rec.getMessage()) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
396 self.assertEqual(len(logs), 2) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
397 self.assertTrue(logs[0].getMessage().startswith( |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
398 "Deleted 1 stray log levels (0 errors)")) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
399 self.assertTrue(logs[1].getMessage().startswith( |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
400 "Deleted stray log levels file 2.log.levels")) |
5f95a6f38490
Add upgrade method that cleans up .log.levels files which at one point where not properly deleted when builds were removed (with test). Fix fix_log_levels_misnaming test to not rely on the order of logging messages (log message order reflects the directory listing order which can vary).
hodgestar
parents:
735
diff
changeset
|
401 |
860
ac28bc3feb2a
Refuse to create log folder during database upgrade if the folder already exists. The existence of such a folder is an indication that a previous attempt to migrate the logs into files has failed and that the folder should be removed before continuing. See #462 for further discussion.
hodgestar
parents:
846
diff
changeset
|
402 def test_migrate_logs_to_files_with_logs_dir(self): |
ac28bc3feb2a
Refuse to create log folder during database upgrade if the folder already exists. The existence of such a folder is an indication that a previous attempt to migrate the logs into files has failed and that the folder should be removed before continuing. See #462 for further discussion.
hodgestar
parents:
846
diff
changeset
|
403 os.makedirs(self.logs_dir) |
ac28bc3feb2a
Refuse to create log folder during database upgrade if the folder already exists. The existence of such a folder is an indication that a previous attempt to migrate the logs into files has failed and that the folder should be removed before continuing. See #462 for further discussion.
hodgestar
parents:
846
diff
changeset
|
404 self.assertRaises(TracError, upgrades.migrate_logs_to_files, |
ac28bc3feb2a
Refuse to create log folder during database upgrade if the folder already exists. The existence of such a folder is an indication that a previous attempt to migrate the logs into files has failed and that the folder should be removed before continuing. See #462 for further discussion.
hodgestar
parents:
846
diff
changeset
|
405 self.env, None) |
ac28bc3feb2a
Refuse to create log folder during database upgrade if the folder already exists. The existence of such a folder is an indication that a previous attempt to migrate the logs into files has failed and that the folder should be removed before continuing. See #462 for further discussion.
hodgestar
parents:
846
diff
changeset
|
406 |
708 | 407 |
408 def suite(): | |
409 suite = unittest.TestSuite() | |
410 suite.addTest(unittest.makeSuite(UpgradeHelperTestCase, 'test')) | |
411 suite.addTest(unittest.makeSuite(UpgradeScriptsTestCase, 'test')) | |
412 return suite | |
413 | |
414 if __name__ == '__main__': | |
415 unittest.main(defaultTest='suite') |