def testPatch(self): patch = change.Patch('https://codereview.chromium.org', 2851943002, 40001) other_patch = change.Patch(u'https://codereview.chromium.org', 2851943002, 40001) self.assertEqual(patch, other_patch) string = 'https://codereview.chromium.org/2851943002/40001' self.assertEqual(str(patch), string) self.assertEqual(patch.id_string, string)
def testBuildCanceled(self, put, get_job_status): change = change_module.Change( (change_module.Commit('src', 'base git hash'), change_module.Commit('v8', 'dep git hash')), patch=change_module.Patch('https://example.org', 2565263002, 20001)) quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests') execution = quest.Start(change) # Request a build. put.return_value = {'build': {'id': 'build_id'}} execution.Poll() # Check build status. get_job_status.return_value = { 'build': { 'status': 'COMPLETED', 'result': 'CANCELED', 'cancelation_reason': 'TIMEOUT', } } execution.Poll() self.assertExecutionFailure(execution, find_isolate.BuildError)
def testMidpointRaisesWithDifferingPatch(self): change_a = change.Change(change.Dep('src', '0e57e2b')) change_b = change.Change( change.Dep('src', 'babe852'), patch=change.Patch('https://codereview.chromium.org', 2565263002, 20001)) with self.assertRaises(change.NonLinearError): change.Change.Midpoint(change_a, change_b)
def testAsDict(self): patch = change.Patch('https://codereview.chromium.org', 2851943002, 40001) expected = { 'server': 'https://codereview.chromium.org', 'issue': 2851943002, 'patchset': 40001, } self.assertEqual(patch.AsDict(), expected)
def testChangeHasPatch(self): change = change_module.Change( change_module.Dep('src', 'f9f2b720'), patch=change_module.Patch('https://codereview.chromium.org', 2570613003, 1)) execution = find_isolated.FindIsolated('Mac Pro Perf').Start(change) execution.Poll() self.assertExecutionFailure(execution)
def testFromDictWithAllFields(self, _): c = change.Change.FromDict({ 'base_commit': {'repository': 'src', 'git_hash': 'aaa7336'}, 'deps': ({'repository': 'catapult', 'git_hash': 'e0a2efb'},), 'patch': { 'server': 'https://codereview.chromium.org', 'issue': 2565263002, 'patchset': 20001, }, }) base_commit = change.Dep('src', 'aaa7336') deps = (change.Dep('catapult', 'e0a2efb'),) patch = change.Patch('https://codereview.chromium.org', 2565263002, 20001) expected = change.Change(base_commit, deps, patch) self.assertEqual(c, expected)
def testChange(self): base_commit = change.Dep('src', 'aaa7336') dep = change.Dep('catapult', 'e0a2efb') patch = change.Patch('https://codereview.chromium.org', 2565263002, 20001) # Also test the deps conversion to frozenset. c = change.Change(base_commit, [dep], patch) self.assertEqual(c, change.Change(base_commit, (dep,), patch)) string = ('src@aaa7336 catapult@e0a2efb + ' 'https://codereview.chromium.org/2565263002/20001') self.assertEqual(str(c), string) self.assertEqual(c.base_commit, base_commit) self.assertEqual(c.deps, frozenset((dep,))) self.assertEqual(c.all_deps, (base_commit, dep)) self.assertEqual(c.patch, patch)
def testBuildLifecycle(self, put, get_job_status): change = change_module.Change( (change_module.Commit('src', 'base git hash'), change_module.Commit('v8', 'dep git hash')), patch=change_module.Patch('https://example.org', 2565263002, 20001)) quest = find_isolate.FindIsolate('Mac Pro Perf', 'telemetry_perf_tests') execution = quest.Start(change) # Request a build. put.return_value = {'build': {'id': 'build_id'}} execution.Poll() self.assertFalse(execution.completed) put.assert_called_once_with( find_isolate.BUCKET, { 'builder_name': 'Mac Builder', 'properties': { 'clobber': True, 'parent_got_revision': 'base git hash', 'deps_revision_overrides': { 'https://chromium.googlesource.com/v8/v8': 'dep git hash', }, 'patch_storage': 'rietveld', 'rietveld': 'https://example.org', 'issue': 2565263002, 'patchset': 20001, } }) # Check build status. get_job_status.return_value = {'build': {'status': 'STARTED'}} execution.Poll() self.assertFalse(execution.completed) get_job_status.assert_called_once_with('build_id') # Look up isolate hash. isolate.Put((('Mac Builder', change, 'telemetry_perf_tests', 'isolate git hash'), )) execution.Poll() self.assertExecutionSuccess(execution)
def testChange(self): base_commit = change.Dep('chromium', 'aaa7336c821888839f759c6c0a36b56c6678') dep = change.Dep('catapult', 'e0a2efbb3d1a81aac3c90041eefec24f066d26ba') patch = change.Patch('https://codereview.chromium.org', 2565263002, 20001) # Also test the deps conversion to frozenset. c = change.Change(base_commit, [dep], patch) self.assertEqual(c, change.Change(base_commit, (dep,), patch)) string = ('chromium@aaa7336 catapult@e0a2efb + ' 'https://codereview.chromium.org/2565263002/20001') id_string = ('chromium@aaa7336c821888839f759c6c0a36b56c6678 ' 'catapult@e0a2efbb3d1a81aac3c90041eefec24f066d26ba + ' 'https://codereview.chromium.org/2565263002/20001') self.assertEqual(str(c), string) self.assertEqual(c.id_string, id_string) self.assertEqual(c.base_commit, base_commit) self.assertEqual(c.deps, frozenset((dep,))) self.assertEqual(c.all_deps, (base_commit, dep)) self.assertEqual(c.patch, patch)
def testBuildSucceededButIsolateIsMissing(self, put, get_job_status): change = change_module.Change( change_module.Dep('src', 'base git hash'), (change_module.Dep('v8', 'dep git hash'), ), patch=change_module.Patch('https://example.org', 2565263002, 20001)) execution = find_isolate.FindIsolate('Mac Pro Perf').Start(change) # Request a build. put.return_value = {'build': {'id': 'build_id'}} execution.Poll() # Check build status. get_job_status.return_value = { 'build': { 'status': 'COMPLETED', 'result': 'SUCCESS', } } execution.Poll() self.assertExecutionFailure(execution, find_isolate.BuildError)
def testAsDict(self): base_commit = change.Dep('chromium', 'aaa7336c82') dep = change.Dep('catapult', 'e0a2efbb3d') patch = change.Patch('https://codereview.chromium.org', 2565263002, 20001) c = change.Change(base_commit, [dep], patch) expected = { 'base_commit': { 'repository': 'chromium', 'git_hash': 'aaa7336c82' }, 'deps': [{ 'repository': 'catapult', 'git_hash': 'e0a2efbb3d' }], 'patch': { 'server': 'https://codereview.chromium.org', 'issue': 2565263002, 'patchset': 20001, }, } self.assertEqual(c.AsDict(), expected)