Changeset 456:f9ff5e179d36

Show
Ignore:
Timestamp:
08/01/08 16:39:56 (5 months ago)
Author:
"Brian Warner <warner@lothar.com>"
branch:
default
Message:

test_logging: more test coverage: don't reclassify at startup if classified/ exists

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ChangeLog

    r455 r456  
    33        * foolscap/test/test_logging.py (IncidentGatherer.test_emit): add 
    44        test coverage for re-classifying existing incidents 
     5        (IncidentGatherer.test_emit._update_classifiers_again): and verify 
     6        that leaving the classified/ directory in place properly inhibits 
     7        reclassification at startup 
    58 
    69        * foolscap/referenceable.py (RemoteReferenceOnly.getRemoteTubID): 
  • foolscap/test/test_logging.py

    r455 r456  
    970970        d.addCallback(lambda res: ig.disownServiceParent()) 
    971971 
     972        incident_d2 = defer.Deferred() 
    972973        def _update_classifiers(res): 
    973974            self.remove_classified_incidents(ig) 
     
    981982            ig2.add_classifier(classify_foom) 
    982983            ig2.setServiceParent(self.parent) 
     984            self.ig2 = ig2 
    983985 
    984986            # incidents should be classified in startService 
    985             unknowns_fn = os.path.join(ig2.basedir, "classified", "unknown") 
     987            unknowns_fn = os.path.join(ig.basedir, "classified", "unknown") 
    986988            self.failIf(os.path.exists(unknowns_fn)) 
    987             booms_fn = os.path.join(ig2.basedir, "classified", "boom") 
     989            booms_fn = os.path.join(ig.basedir, "classified", "boom") 
    988990            booms = [fn.strip() for fn in open(booms_fn,"r").readlines()] 
    989991            self.failUnlessEqual(len(booms), 1) 
    990             fooms_fn = os.path.join(ig2.basedir, "classified", "foom") 
     992            fooms_fn = os.path.join(ig.basedir, "classified", "foom") 
    991993            self.failIf(os.path.exists(fooms_fn)) 
     994 
     995            ig2.cb_new_incident = incident_d2.callback 
    992996 
    993997            return ig2.d 
    994998        d.addCallback(_update_classifiers) 
     999        d.addCallback(lambda res: self.logger.msg("foom", level=log.WEIRD)) 
     1000        d.addCallback(lambda res: incident_d2) 
     1001        def _new_incident2((abs_fn, rel_fn)): 
     1002            # this one should be classified as "foom" 
     1003 
     1004            # it should have been classified as "unknown" 
     1005            fooms_fn = os.path.join(ig.basedir, "classified", "foom") 
     1006            fooms = [fn.strip() for fn in open(fooms_fn,"r").readlines()] 
     1007            self.failUnlessEqual(len(fooms), 1) 
     1008            self.failUnlessEqual(fooms[0], rel_fn) 
     1009            unknowns_fn = os.path.join(ig.basedir, "classified", "unknown") 
     1010            self.failIf(os.path.exists(unknowns_fn)) 
     1011        d.addCallback(_new_incident2) 
     1012 
     1013        # and if we remove the classification functions (but do *not* remove 
     1014        # the classified incidents), the new gatherer should not reclassify 
     1015        # anything 
     1016 
     1017        d.addCallback(self.stall, 0.5) 
     1018        d.addCallback(lambda res: self.ig2.disownServiceParent()) 
     1019        def _update_classifiers_again(res): 
     1020            ig3 = self.create_incident_gatherer(basedir) 
     1021            ig3.setServiceParent(self.parent) 
     1022 
     1023            unknowns_fn = os.path.join(ig.basedir, "classified", "unknown") 
     1024            self.failIf(os.path.exists(unknowns_fn)) 
     1025            booms_fn = os.path.join(ig.basedir, "classified", "boom") 
     1026            booms = [fn.strip() for fn in open(booms_fn,"r").readlines()] 
     1027            self.failUnlessEqual(len(booms), 1) 
     1028            fooms_fn = os.path.join(ig.basedir, "classified", "foom") 
     1029            fooms = [fn.strip() for fn in open(fooms_fn,"r").readlines()] 
     1030            self.failUnlessEqual(len(fooms), 1) 
     1031            return ig3.d 
     1032        d.addCallback(_update_classifiers_again) 
    9951033 
    9961034        # give the call to remote_logport a chance to retire