def create_tests(): from work.fogbugzConnect import FogBugzConnect from config import project_with_name f = FogBugzConnect() #we create test cases if and only if all the following conditions are met: #1. Bugs and features #2. Open cases #3. Cases with an estimate (otherwise, the person assigned might just be a placeholder person...) #4. Cases that are decided (not Undecided) #5. Cases that are in projects for which we have review-workflow: yes cases = f.fbConnection.search(q='(category:"bug" OR category:"feature") status:"open" estimatecurrent:"1m.." -milestone:"Undecided"', cols="sProject") cache = buildbot_cache_get() CACHE_KEY = "autoTestMake-cache" if not cache.has_key(CACHE_KEY): cache[CACHE_KEY] = [] casesList = map(lambda x: int(x["ixbug"]),cases.cases) casesList = filter(lambda x: x not in cache[CACHE_KEY],casesList) juche.info(casesList) from work.work import autoTestMake for case in cases.cases.contents: project = project_with_name(case.sproject.contents[0]) if not project: juche.info("No project named %s in buildbot.yaml" % case.sproject.contents[0]) continue if not ("review-workflow" in project.keys() and project["review-workflow"] == "yes"): continue result = autoTestMake(int(case["ixbug"])) if not result: cache[CACHE_KEY].append(case["ixbug"]) buildbot_cache_set(cache)
def test_active_tickets(self): projects = get_config()["Projects"] from work.fogbugzConnect import TEST_IXCATEGORY cases = self.f.fbConnection.search(q="assignedTo:=%d" % self.f.ixPerson,cols="ixCategory,sProject,hrsOrigEst,hrsElapsed,sStatus") #clean up any cases erroneously assigned to glados. for case in cases.cases: caseno = int(case["ixbug"]) if int(case.ixcategory.contents[0])==TEST_IXCATEGORY: self.glados_reassign(caseno,reactivate=False) continue proj = project_with_name(case.sproject.contents[0]) if not proj: self.glados_reassign(caseno,reactivate=False) continue if "review-workflow" in proj and proj["review-workflow"] == "no": self.glados_reassign(caseno, reactivate=False) continue if not self.f.isReadyForTest(caseno): self.glados_reassign(caseno,reactivate=False,why="Not testing this case because it is not marked as resolved/implemented.") continue (parent,test) = self.f.getCaseTuple(caseno,oldTestCasesOK=True,exceptOnFailure=False) if not test: juche.info("Ignoring case %d because it has no test case assigned." % caseno) continue if self.be_in_purgatory(parent,test,case,proj): juche.info("Ignoring case %d because of purgatory." % caseno) continue if self.test(case,proj): #returns true if we integrate something return self.test_active_tickets() #break out of this loop, because who knows what is happening with the list of active cases now, and re-test everything.
def integrate_changed(self,gitConnection,integration_branch,sProject): juche.dictate(integrate_changed_hook=integration_branch) gitConnection.checkoutExistingBranchRaw(integration_branch) self.deploy(gitConnection,integration_branch,project_with_name(sProject)) #Here's the problem: A and B are in the review queue. They are mutually exclusive (can't merge them both in.) #You pass patch A. It's merged in. We need to re-test B. Perhaps the merge will fail now, or perhaps the unit test will fail. #We "invalidate" (put back in the glados queue; snatch from the reviewer) all cases in the review queue and they will be re-tested on the next pass. cases = self.f.fbConnection.search(q="project:'%s' status:'Resolved' (category:'Bug' OR category:'Feature')" % (sProject),cols="sStatus") for case in cases.cases: caseno = int(case["ixbug"]) if self.f.getIntegrationBranch(caseno)!=integration_branch: continue if not self.f.isReadyForTest(caseno): continue juche.info( "Invalidating "+case["ixbug"]) self.f.fbConnection.assign(ixBug=case["ixbug"],ixPersonAssignedTo=self.f.ixPerson,sEvent="Invalidation. Are you getting unexpected e-mails surrounding this case event? File a bug against buildbot.") self.test_active_tickets()
def test_deploy(self): git = GitConnect(WORK_DIR+"semaps") print self.a.deploy(git,"1.5.1",project_with_name("semaps"))
def test_versionno(self): git = GitConnect(WORK_DIR+"mindful-meals") print self.a.deploy(git,"0.1",project_with_name("mindful-meals"))
def test_exec(self): print self.a.exec_tests(project_with_name("work.py")) print self.a.exec_tests(project_with_name("semaps")) pass