Changeset 204831 in indico
- Timestamp:
- 07/22/11 09:31:29 (22 months ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
- Children:
- fa8006
- Parents:
- 3cbd3e
- git-author:
- Pedro Ferreira <jose.pedro.ferreira@…> (07/19/11 17:59:20)
- git-committer:
- Pedro Ferreira <jose.pedro.ferreira@…> (07/22/11 09:31:29)
- Files:
-
- 1 added
- 3 edited
-
bin/maintenance/indexes/all_index_check.py (added)
-
indico/MaKaC/common/indexes.py (modified) (5 diffs)
-
indico/core/index/base.py (modified) (2 diffs)
-
indico/core/index/event.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/common/indexes.py
rbedc940 r204831 35 35 from MaKaC.plugins.base import PluginsHolder 36 36 from zope.index.text import textindex 37 37 import pytz 38 import itertools 38 39 39 40 # BTrees are 32 bit by default … … 298 299 return [] 299 300 301 def _check(self, dbi=None): 302 """ 303 Performs some sanity checks 304 """ 305 i = 0 306 from MaKaC.conference import ConferenceHolder 307 confIdx = ConferenceHolder()._getIdx() 308 309 for cid, confs in self._idxCategItem.iteritems(): 310 for confId in confs: 311 # it has to be in the conference holder 312 if confId not in confIdx: 313 yield "[%s] '%s' not in ConferenceHolder" % (cid, confId) 314 # the category has to be one of the owners 315 elif cid not in (map(lambda x:x.id, ConferenceHolder().getById(confId).getOwnerPath()) + ['0']): 316 yield "[%s] Conference '%s' is not owned" % (cid, confId) 317 if dbi and i % 100 == 99: 318 dbi.sync() 319 i += 1 320 321 300 322 class CalendarIndex(Persistent): 301 323 """Implements a persistent calendar-like index. Objects (need to implement … … 564 586 return self._getObjectsStartingAfter( date ) 565 587 566 #def getObjectsStartingInYear( self, year ): 567 # lastDay = datetime( year, 12, 31 ) 568 # s1 = sets.Set() 569 # # Objects starting before last day of year (included): 570 # s1 = self._getObjectsStartingBefore(lastDay + timedelta(days=1)) 571 # if not s1: 572 # return s1 573 # firstDay = datetime( year, 1, 1 ) 574 # s2 = sets.Set() 575 # # Objects starting before first day of year (excluded): 576 # s2 = self._getObjectsStartingBefore(firstDay) 577 # # Difference: 578 # s1.difference_update( s2 ) 579 # return s1 588 def _check(self, dbi=None): 589 """ 590 Performs some sanity checks 591 """ 592 593 from MaKaC.conference import ConferenceHolder 594 confIdx = ConferenceHolder()._getIdx() 595 596 def _check_index(desc, index, func): 597 i = 0 598 for ts, confs in index.iteritems(): 599 for confId in confs: 600 # it has to be in the conference holder 601 if confId not in confIdx: 602 yield "[%s][%s] '%s' not in ConferenceHolder" % (desc, ts, confId) 603 else: 604 605 conf = ConferenceHolder().getById(confId) 606 try: 607 expectedDate = date2utctimestamp(func(conf)) 608 except OverflowError: 609 expectedDate = 'overflow' 610 611 # ts must be ok 612 if ts != expectedDate: 613 yield "[%s][%s] Conference '%s' has bogus date (should be '%s')" % (desc, ts, confId, expectedDate) 614 if dbi and i % 100 == 99: 615 dbi.sync() 616 i += 1 617 618 return itertools.chain( 619 _check_index('sdate', self._idxSdate, lambda x: x.getStartDate()), 620 _check_index('edate', self._idxEdate, lambda x: x.getEndDate())) 621 622 580 623 class CalendarDayIndex(Persistent): 581 624 def __init__( self ): … … 763 806 for event in day: 764 807 yield event 808 809 i = 0 810 confIdx = ConferenceHolder()._getIdx() 811 812 def _check(self, dbi=None, categId=''): 813 """ 814 Performs some sanity checks 815 """ 816 i = 0 817 from MaKaC.conference import ConferenceHolder 818 confIdx = ConferenceHolder()._getIdx() 819 820 for ts, confs in self._idxDay.iteritems(): 821 dt = pytz.timezone('UTC').localize(datetime.utcfromtimestamp(ts)) 822 823 for conf in confs: 824 # it has to be in the conference holder 825 if conf.getId() not in confIdx: 826 yield "[%s][%s] '%s' not in ConferenceHolder" % (ts, categId, conf.getId()) 827 else: 828 # date must be ok 829 if dt > conf.getEndDate().replace(hour=23, minute=59, second=59) \ 830 or dt < conf.getStartDate().replace(hour=0, minute=0, second=0): 831 yield "[%s] '%s' has date out of bounds '%s'(%s)" % (categId, conf.getId(), ts, dt) 832 elif categId not in (map(lambda x:x.id, conf.getOwnerPath()) + ['0']): 833 yield "[%s] Conference '%s' is not owned" % (categId, conf.getId()) 834 835 if dbi and i % 100 == 99: 836 dbi.sync() 837 i += 1 765 838 766 839 … … 915 988 else: 916 989 return [] 990 991 def _check(self, dbi=None): 992 """ 993 Performs some sanity checks 994 """ 995 for categId, calDayIdx in self._idxCategItem.iteritems(): 996 for problem in calDayIdx._check(dbi=dbi, categId=categId): 997 yield problem 917 998 918 999 -
indico/core/index/base.py
r78882e r204831 152 152 153 153 154 155 154 class DIndex(SIndex): 156 155 """ … … 211 210 self._num_objs.change(-1) 212 211 212 def _check(self, dbi=None): 213 """ 214 Simple sanity check 215 """ 216 i = 0 217 # check that the elements in fwd index are also in rev index 218 cls = self.__class__.__name__ 219 for ts, eset in self._fwd_index.iteritems(): 220 if not eset: 221 yield "[%s] Element set at '%s' is empty" % ts 222 for elem in eset: 223 uid = elem.getUniqueId() 224 key = self._adapter(elem) 225 if uid not in self._rev_index: 226 yield "[%s] An entry for '%s'(%s) should exist in _rev_index" \ 227 % (cls, uid, ts) 228 elif key not in self._rev_index[uid]: 229 yield "[%s] Element '%s'(%s) should be in _rev_index['%s']" \ 230 % (cls, uid, ts, key) 231 if dbi and i % 1000 == 999: 232 dbi.abort() 233 i += 1 234 235 # now the opposite 236 for uid, kset in self._rev_index.iteritems(): 237 for key in kset: 238 if key not in self._fwd_index: 239 yield "[%s] Key '%s' not found in _fwd_index" % (cls, key) 240 elif uid not in map(lambda x:x.getUniqueId(), self._fwd_index[key]): 241 yield "[%s] Object '%s' not in _fwd_index[%s]" % (cls, uid, key) 242 if dbi and i % 1000 == 999: 243 dbi.abort() 244 i += 1 245 213 246 214 247 class SIOIndex(DIndex): -
indico/core/index/event.py
rff34a29 r204831 60 60 if dbi: 61 61 dbi.commit() 62 63 def _check(self, dbi=None): 64 from MaKaC.conference import CategoryManager, ConferenceHolder 65 confIdx = ConferenceHolder()._getIdx() 66 categIdx = CategoryManager()._getIdx() 67 68 i = 0 69 70 for cid, index in self._container.iteritems(): 71 # simple data structure check 72 for problem in index._check(): 73 yield problem 74 75 # consistency with CategoryManager 76 if cid not in categIdx: 77 yield "Category '%s' not in CategoryManager" % cid 78 79 # consistency with ConferenceHolder 80 for ts, conf in index.iteritems(): 81 if conf.getId() not in confIdx: 82 yield "[%s] Conference '%s'(%s) not in ConferenceHolder" \ 83 % (cid, conf.getId(), ts) 84 85 if dbi and i % 100 == 99: 86 dbi.abort() 87 88 i += 1
Note: See TracChangeset
for help on using the changeset viewer.
