[Libreoffice-commits] buildbot.git: 2 commits - tb3/tests
Bjoern Michaelsen
bjoern.michaelsen at canonical.com
Sun Aug 11 18:12:02 PDT 2013
tb3/tests/helpers.py | 18 ++++----
tb3/tests/tb3/repostate.py | 1
tb3/tests/tb3/scheduler.py | 91 ++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 100 insertions(+), 10 deletions(-)
New commits:
commit 33e930f6109cdfb9a678cd8d61d05a19bd453f77
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Tue Aug 6 12:57:52 2013 +0200
refactor bisect runs a bit
diff --git a/tb3/tests/tb3/scheduler.py b/tb3/tests/tb3/scheduler.py
index 9e923a5..29d2553 100755
--- a/tb3/tests/tb3/scheduler.py
+++ b/tb3/tests/tb3/scheduler.py
@@ -132,51 +132,42 @@ class TestBisectRuns(TestScheduler):
real_state = self.__get_fake_buildresult(commit)
stored_state = self.repohistory.get_commit_state(commit).state
return (real_state, stored_state)
+ def __get_commit_range(self, begin, end):
+ if begin == end:
+ return []
+ commits = self.git('rev-list', '%s..%s' % (begin, end)).strip('\n').split('\n')
+ return [commit for commit in commits if len(commit) == 40]
+
+
def __check_consisitency(self):
- for commit in self.__get_all_commits():
- real_state = self.__get_fake_buildresult(commit)
- stored_state = self.repohistory.get_commit_state(commit)
- if real_state == 'GOOD':
- if not stored_state.state in ['UNKNOWN', 'GOOD', 'ASSUMED_GOOD', 'POSSIBLY_BREAKING']:
- print('%s is really %s, but stored as %s' % (commit, real_state, stored_state.state))
- else:
- if not stored_state.state in ['UNKNOWN', 'BAD', 'POSSIBLY_BREAKING', 'BREAKING', 'ASSUMED_BAD']:
- print('%s is really %s, but stored as %s' % (commit, real_state, stored_state.state))
(real_state, stored_state) = self.__get_states(self.preb1)
self.assertIn(real_state, ['GOOD'])
self.assertIn(stored_state, ['GOOD'])
- if self.preb1 != self.state.get_last_good():
- commits = self.git('rev-list', '%s..%s^' % (self.preb1, self.state.get_last_good())).strip('\n').split('\n')
- for commit in self.git('rev-list', '%s..%s^' % (self.preb1, self.state.get_last_good())).strip('\n').split('\n'):
- if len(commit) == 40:
- (real_state, stored_state) = self.__get_states(commit)
- self.assertIn(real_state, ['GOOD'])
- self.assertIn(stored_state, ['ASSUMED_GOOD', 'GOOD'])
+ for commit in self.__get_commit_range(self.preb1, self.state.get_last_good()):
+ (real_state, stored_state) = self.__get_states(commit)
+ self.assertIn(real_state, ['GOOD'])
+ self.assertIn(stored_state, ['ASSUMED_GOOD', 'GOOD'])
(real_state, stored_state) = self.__get_states(self.state.get_last_good())
self.assertIn(real_state, ['GOOD'])
self.assertIn(stored_state, ['GOOD'])
- for commit in self.git('rev-list', '%s..%s^' % (self.state.get_last_good(), self.postb2)).strip('\n').split('\n'):
- if len(commit) == 40:
- (real_state, stored_state) = self.__get_states(commit)
- self.assertIn(real_state, ['GOOD'])
- self.assertIn(stored_state, ['POSSIBLY_BREAKING'])
+ for commit in self.__get_commit_range(self.state.get_last_good(), "%s^" % self.postb2):
+ (real_state, stored_state) = self.__get_states(commit)
+ self.assertIn(real_state, ['GOOD'])
+ self.assertIn(stored_state, ['POSSIBLY_BREAKING'])
(real_state, stored_state) = self.__get_states(self.postb2)
self.assertIn(real_state, ['BAD'])
self.assertIn(stored_state, ['POSSIBLY_BREAKING', 'BAD', 'BREAKING'])
- commits = self.git('rev-list', '%s..%s^' % (self.postb2, self.state.get_first_bad())).strip('\n').split('\n')
- for commit in commits:
- if len(commit) == 40:
- (real_state, stored_state) = self.__get_states(commit)
- self.assertIn(real_state, ['BAD'])
- self.assertIn(stored_state, ['POSSIBLY_BREAKING'])
+ for commit in self.__get_commit_range(self.postb2, "%s^" % self.state.get_first_bad()):
+ (real_state, stored_state) = self.__get_states(commit)
+ self.assertIn(real_state, ['BAD'])
+ self.assertIn(stored_state, ['POSSIBLY_BREAKING'])
(real_state, stored_state) = self.__get_states(self.state.get_first_bad())
self.assertIn(real_state, ['BAD'])
self.assertIn(stored_state, ['BAD', 'BREAKING'])
- if self.state.get_first_bad() != self.head:
- for commit in self.git('rev-list', '%s..%s' % (self.state.get_first_bad(), self.head)).strip('\n').split('\n'):
- (real_state, stored_state) = self.__get_states(commit)
- self.assertIn(real_state, ['BAD'])
- self.assertIn(stored_state, ['BAD', 'ASSUMED_BAD'])
+ for commit in self.__get_commit_range(self.state.get_first_bad(), self.head):
+ (real_state, stored_state) = self.__get_states(commit)
+ self.assertIn(real_state, ['BAD'])
+ self.assertIn(stored_state, ['BAD', 'ASSUMED_BAD'])
(real_state, stored_state) = self.__get_states(self.head)
self.assertIn(real_state, ['BAD'])
self.assertIn(stored_state, ['BAD'])
commit b5ef69c4299c2124e1e24b9ab953da4db63c9569
Author: Bjoern Michaelsen <bjoern.michaelsen at canonical.com>
Date: Tue Aug 6 12:52:48 2013 +0200
test bisect runs
diff --git a/tb3/tests/helpers.py b/tb3/tests/helpers.py
index a82d5d9..cd8053d 100755
--- a/tb3/tests/helpers.py
+++ b/tb3/tests/helpers.py
@@ -12,33 +12,33 @@ import os.path
import sh
import tempfile
-def createTestRepo():
+def createTestRepo(commitmultiplier=1):
testdir = tempfile.mkdtemp()
git = sh.git.bake('--no-pager',_cwd=testdir)
git.init()
touch = sh.touch.bake(_cwd=testdir)
- for commit in range(0,10):
+ for commit in range(0,10*commitmultiplier):
touch('commit%d' % commit)
git.add('commit%d' % commit)
git.commit('.', '-m', 'commit %d' % commit)
if commit == 0:
git.tag('pre-branchoff-1')
- elif commit == 3:
+ elif commit == 3*commitmultiplier:
git.tag('pre-branchoff-2')
- elif commit == 5:
+ elif commit== 5*commitmultiplier:
git.tag('branchpoint')
- elif commit == 7:
+ elif commit == 7*commitmultiplier:
git.tag('post-branchoff-1')
- elif commit == 9:
+ elif commit == 9*commitmultiplier:
git.tag('post-branchoff-2')
git.checkout('-b', 'branch', 'branchpoint')
- for commit in range(5,10):
+ for commit in range(commitmultiplier,10*commitmultiplier):
touch('branch%d' % commit)
git.add('branch%d' % commit)
git.commit('.', '-m', 'branch %d' % commit)
- if commit == 7:
+ if commit == 7*commitmultiplier:
git.tag('post-branchoff-on-branch-1')
- elif commit == 9:
+ elif commit == 9*commitmultiplier:
git.tag('post-branchoff-on-branch-2')
return (testdir, git)
# vim: set et sw=4 ts=4:
diff --git a/tb3/tests/tb3/repostate.py b/tb3/tests/tb3/repostate.py
index 8656697..e159245 100755
--- a/tb3/tests/tb3/repostate.py
+++ b/tb3/tests/tb3/repostate.py
@@ -154,6 +154,7 @@ class TestRepoUpdater(unittest.TestCase):
self.updater.set_finished(self.head, 'testbuilder', 'BAD', 'foo')
self.assertEqual(self.history.get_commit_state('%s^' % self.head).state, 'ASSUMED_BAD')
+
if __name__ == '__main__':
unittest.main()
# vim: set et sw=4 ts=4:
diff --git a/tb3/tests/tb3/scheduler.py b/tb3/tests/tb3/scheduler.py
index 64c075e..9e923a5 100755
--- a/tb3/tests/tb3/scheduler.py
+++ b/tb3/tests/tb3/scheduler.py
@@ -19,6 +19,9 @@ import tb3.scheduler
import tb3.repostate
class TestScheduler(unittest.TestCase):
+ def __init__(self, *args, **kwargs):
+ super(TestScheduler, self).__init__(*args, **kwargs)
+ self.testrepomultiplier = 1
def __resolve_ref(self, refname):
return self.git('show-ref', refname).split(' ')[0]
def _show_log(self, commit):
@@ -41,7 +44,7 @@ class TestScheduler(unittest.TestCase):
self.assertRegex(commit_msg, expected_message)
return proposals[0]
def setUp(self):
- (self.testdir, self.git) = helpers.createTestRepo()
+ (self.testdir, self.git) = helpers.createTestRepo(self.testrepomultiplier)
self.state = tb3.repostate.RepoState('linux', 'master', self.testdir)
self.repohistory = tb3.repostate.RepoHistory('linux', self.testdir)
self.updater = tb3.repostate.RepoStateUpdater('linux', 'master', self.testdir)
@@ -109,6 +112,101 @@ class TestBisectScheduler(TestScheduler):
self.updater.set_scheduled(best_proposal.commit, 'box', datetime.timedelta(hours=4))
best_proposal = self._get_best_proposal(self.scheduler, datetime.datetime.now(), 'commit [36]', 8, False)
+class TestBisectRuns(TestScheduler):
+ def __init__(self, *args, **kwargs):
+ super(TestBisectRuns, self).__init__(*args, **kwargs)
+ self.testrepomultiplier = 10
+ def __resolve_ref(self, refname):
+ return self.git('show-ref', refname).split(' ')[0]
+ def __is_pre_postb2(self, commit):
+ if commit == self.postb2:
+ return False
+ return self.git('merge-base', '--is-ancestor', commit, self.postb2, _ok_code=[0,1]).exit_code == 0
+ def __get_fake_buildresult(self, commit):
+ if self.__is_pre_postb2(commit):
+ return 'GOOD'
+ return 'BAD'
+ def __get_all_commits(self):
+ return self.git('rev-list', '%s..%s' % (self.preb1, self.head)).strip('\n').split('\n')
+ def __get_states(self, commit):
+ real_state = self.__get_fake_buildresult(commit)
+ stored_state = self.repohistory.get_commit_state(commit).state
+ return (real_state, stored_state)
+ def __check_consisitency(self):
+ for commit in self.__get_all_commits():
+ real_state = self.__get_fake_buildresult(commit)
+ stored_state = self.repohistory.get_commit_state(commit)
+ if real_state == 'GOOD':
+ if not stored_state.state in ['UNKNOWN', 'GOOD', 'ASSUMED_GOOD', 'POSSIBLY_BREAKING']:
+ print('%s is really %s, but stored as %s' % (commit, real_state, stored_state.state))
+ else:
+ if not stored_state.state in ['UNKNOWN', 'BAD', 'POSSIBLY_BREAKING', 'BREAKING', 'ASSUMED_BAD']:
+ print('%s is really %s, but stored as %s' % (commit, real_state, stored_state.state))
+ (real_state, stored_state) = self.__get_states(self.preb1)
+ self.assertIn(real_state, ['GOOD'])
+ self.assertIn(stored_state, ['GOOD'])
+ if self.preb1 != self.state.get_last_good():
+ commits = self.git('rev-list', '%s..%s^' % (self.preb1, self.state.get_last_good())).strip('\n').split('\n')
+ for commit in self.git('rev-list', '%s..%s^' % (self.preb1, self.state.get_last_good())).strip('\n').split('\n'):
+ if len(commit) == 40:
+ (real_state, stored_state) = self.__get_states(commit)
+ self.assertIn(real_state, ['GOOD'])
+ self.assertIn(stored_state, ['ASSUMED_GOOD', 'GOOD'])
+ (real_state, stored_state) = self.__get_states(self.state.get_last_good())
+ self.assertIn(real_state, ['GOOD'])
+ self.assertIn(stored_state, ['GOOD'])
+ for commit in self.git('rev-list', '%s..%s^' % (self.state.get_last_good(), self.postb2)).strip('\n').split('\n'):
+ if len(commit) == 40:
+ (real_state, stored_state) = self.__get_states(commit)
+ self.assertIn(real_state, ['GOOD'])
+ self.assertIn(stored_state, ['POSSIBLY_BREAKING'])
+ (real_state, stored_state) = self.__get_states(self.postb2)
+ self.assertIn(real_state, ['BAD'])
+ self.assertIn(stored_state, ['POSSIBLY_BREAKING', 'BAD', 'BREAKING'])
+ commits = self.git('rev-list', '%s..%s^' % (self.postb2, self.state.get_first_bad())).strip('\n').split('\n')
+ for commit in commits:
+ if len(commit) == 40:
+ (real_state, stored_state) = self.__get_states(commit)
+ self.assertIn(real_state, ['BAD'])
+ self.assertIn(stored_state, ['POSSIBLY_BREAKING'])
+ (real_state, stored_state) = self.__get_states(self.state.get_first_bad())
+ self.assertIn(real_state, ['BAD'])
+ self.assertIn(stored_state, ['BAD', 'BREAKING'])
+ if self.state.get_first_bad() != self.head:
+ for commit in self.git('rev-list', '%s..%s' % (self.state.get_first_bad(), self.head)).strip('\n').split('\n'):
+ (real_state, stored_state) = self.__get_states(commit)
+ self.assertIn(real_state, ['BAD'])
+ self.assertIn(stored_state, ['BAD', 'ASSUMED_BAD'])
+ (real_state, stored_state) = self.__get_states(self.head)
+ self.assertIn(real_state, ['BAD'])
+ self.assertIn(stored_state, ['BAD'])
+ def test_bisect_regression(self):
+ self.updater.set_finished(self.preb1, 'testbuilder', self.__get_fake_buildresult(self.preb1), 'foo')
+ self.updater.set_finished(self.head, 'testbuilder', self.__get_fake_buildresult(self.head), 'foo')
+ self.state.set_last_good(self.preb1)
+ self.state.set_first_bad(self.head)
+ self.state.set_last_bad(self.head)
+ self.scheduler = tb3.scheduler.BisectScheduler('linux', 'master', self.testdir)
+ now = datetime.datetime.now()
+ duration = datetime.timedelta(hours=1)
+ all_commits = self.scheduler.get_commits(self.preb1, self.head)
+ for step in range(100):
+ try:
+ proposals = self.scheduler.get_proposals(now)
+ first_commit = proposals[0].commit
+ self.updater.set_scheduled(first_commit, 'box', duration)
+ proposals = self.scheduler.get_proposals(now)
+ second_commit = proposals[0].commit
+ self.updater.set_scheduled(second_commit, 'box', duration)
+ self.updater.set_finished(first_commit, 'testbuilder', self.__get_fake_buildresult(first_commit), 'foo')
+ self.updater.set_finished(second_commit, 'testbuilder', self.__get_fake_buildresult(second_commit), 'foo')
+ self.__check_consisitency()
+ except IndexError:
+ pass
+ (real_state, stored_state) = self.__get_states(self.postb2)
+ self.assertIn(real_state, ['BAD'])
+ self.assertIn(stored_state, ['BREAKING'])
+
class TestMergeScheduler(TestScheduler):
def test_get_proposal(self):
self.state.set_last_good(self.preb1)
More information about the Libreoffice-commits
mailing list