From 4babe061ac7fbb92721a24ae6d5eb6336083dffc Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Dec 20 2018 15:39:43 +0000 Subject: Speed up the test suite by dropping some of the sleep calls Signed-off-by: Pierre-Yves Chibon --- diff --git a/tests/test_pagure_flask_dump_load_ticket.py b/tests/test_pagure_flask_dump_load_ticket.py index df372ac..4494971 100644 --- a/tests/test_pagure_flask_dump_load_ticket.py +++ b/tests/test_pagure_flask_dump_load_ticket.py @@ -168,8 +168,6 @@ class PagureFlaskDumpLoadTicketTests(tests.Modeltests): # Test reloading the JSON self.tearDown() self.setUp() - # Give the worker time to spawn - time.sleep(2) tests.create_projects(self.session) # Create repo diff --git a/tests/test_pagure_flask_internal.py b/tests/test_pagure_flask_internal.py index c588ba1..6f1279b 100644 --- a/tests/test_pagure_flask_internal.py +++ b/tests/test_pagure_flask_internal.py @@ -2144,7 +2144,6 @@ class PagureFlaskInternaltests(tests.Modeltests): output = self.app.get(js_data['url']) while output.status_code == 418: - time.sleep(0.5) output = self.app.get(js_data['url']) js_data2 = json.loads(output.get_data(as_text=True)) self.assertTrue(js_data2['results'][3] > 1509110062) diff --git a/tests/test_pagure_flask_ui_fork.py b/tests/test_pagure_flask_ui_fork.py index b19b0f0..bc5a12a 100644 --- a/tests/test_pagure_flask_ui_fork.py +++ b/tests/test_pagure_flask_ui_fork.py @@ -96,7 +96,6 @@ def set_up_git_repo( # list of binary strings representing parents of the new commit prev_commit ) - time.sleep(1) refname = 'refs/heads/master:refs/heads/master' ori_remote = clone_repo.remotes[0] PagureRepo.push(ori_remote, refname) diff --git a/tests/test_pagure_flask_ui_pr_no_sources.py b/tests/test_pagure_flask_ui_pr_no_sources.py index 343ae24..a09b748 100644 --- a/tests/test_pagure_flask_ui_pr_no_sources.py +++ b/tests/test_pagure_flask_ui_pr_no_sources.py @@ -73,13 +73,7 @@ class PagureFlaskPrNoSourcestests(tests.Modeltests): path = os.path.join( self.path, 'repos', 'test.git', 'refs', 'pull', '1', 'head') - cnt = 0 - while not os.path.exists(path): - time.sleep(0.1) - cnt += 1 - if cnt == 100: - # We're about 10 seconds in, let's bail - raise Exception('Sorry, worker took too long') + self.assertTrue(os.path.exists(path)) def set_up_git_repo(self, repo, fork, branch_from='feature'): """ Set up the git repo and create the corresponding PullRequest diff --git a/tests/test_pagure_flask_ui_remote_pr.py b/tests/test_pagure_flask_ui_remote_pr.py index 2710a46..54e9f67 100644 --- a/tests/test_pagure_flask_ui_remote_pr.py +++ b/tests/test_pagure_flask_ui_remote_pr.py @@ -92,7 +92,7 @@ class PagureRemotePRtests(tests.Modeltests): # list of binary strings representing parents of the new commit prev_commit ) - time.sleep(1) + # time.sleep(1) refname = 'refs/heads/master:refs/heads/master' ori_remote = clone_repo.remotes[0] PagureRepo.push(ori_remote, refname) diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 6c48615..1e89014 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -2184,13 +2184,11 @@ class PagureFlaskRepotests(tests.Modeltests): tests.add_commit_git_repo( os.path.join(self.path, 'repos', 'test.git'), ncommits=1) c1 = repo.revparse_single('HEAD') - time.sleep(1) # Add another commit to git repo tests.add_commit_git_repo( os.path.join(self.path, 'repos', 'test.git'), ncommits=1) c2 = repo.revparse_single('HEAD') - time.sleep(1) # Add one more commit to git repo tests.add_commit_git_repo( @@ -4912,20 +4910,9 @@ index 0000000..fb7093d folder = os.path.join(upload_dir, 'test') checksum_file = os.path.join(folder, 'CHECKSUMS') - # Wait for the worker to create the checksums file - cnt = 0 - while not os.path.exists(checksum_file): - print(os.listdir(os.path.join(upload_dir, 'test'))) - cnt += 1 - if cnt == 40: - raise ValueError( - 'The worker did not create the checksums file ' - 'in a timely manner') - time.sleep(0.5) - - self.assertEqual(len(os.listdir(folder)), 2) - + # Check the checksums file self.assertTrue(os.path.exists(checksum_file)) + self.assertEqual(len(os.listdir(folder)), 2) # Check the content of the checksums file with open(checksum_file) as stream: @@ -4991,19 +4978,9 @@ index 0000000..fb7093d folder = os.path.join(upload_dir, 'test') checksum_file = os.path.join(folder, 'CHECKSUMS') - # Wait for the worker to create the checksums file - cnt = 0 - while not os.path.exists(checksum_file): - cnt += 1 - if cnt == 40: - raise ValueError( - 'The worker did not create the checksums file ' - 'in a timely manner') - time.sleep(0.5) - - self.assertEqual(len(os.listdir(folder)), 3) - + # Check the checksums file self.assertTrue(os.path.exists(checksum_file)) + self.assertEqual(len(os.listdir(folder)), 3) # Check the content of the checksums file with open(checksum_file) as stream: diff --git a/tests/test_pagure_lib_git_diff_pr.py b/tests/test_pagure_lib_git_diff_pr.py index eeece16..d9fc3a9 100644 --- a/tests/test_pagure_lib_git_diff_pr.py +++ b/tests/test_pagure_lib_git_diff_pr.py @@ -106,7 +106,6 @@ class PagureFlaskForkPrtests(tests.Modeltests): # list of binary strings representing parents of the new commit parents ) - time.sleep(1) # Push to the main repo refname = 'refs/heads/master:refs/heads/master' @@ -142,7 +141,6 @@ class PagureFlaskForkPrtests(tests.Modeltests): # list of binary strings representing parents of the new commit [last_commit.oid.hex] ) - time.sleep(1) # Push to the main repo refname = 'refs/heads/master:refs/heads/master' ori_remote = clone_repo.remotes[0] @@ -175,7 +173,6 @@ class PagureFlaskForkPrtests(tests.Modeltests): # list of binary strings representing parents of the new commit [last_commit.oid.hex] ) - time.sleep(1) with open(os.path.join(repopath, 'sources'), 'w') as stream: stream.write('foo\n bar\nbaz\n') @@ -305,13 +302,10 @@ class PagureFlaskForkPrtests(tests.Modeltests): # we don't know the task id but we'll give it 30 sec to finish cnt = 0 repo = PagureRepo(gitrepo) - while 1: - if 'refs/pull/1/head' in list(repo.listall_references()): - break - cnt += 1 - if cnt == 60: - break - time.sleep(0.5) + self.assertIn( + 'refs/pull/1/head', + list(repo.listall_references()) + ) self.assertTrue(cnt < 60) @@ -348,13 +342,10 @@ class PagureFlaskForkPrtests(tests.Modeltests): # we don't know the task id but we'll give it 30 sec to finish cnt = 0 repo = PagureRepo(gitrepo) - while 1: - if 'refs/pull/1/head' in list(repo.listall_references()): - break - cnt += 1 - if cnt == 60: - break - time.sleep(0.5) + self.assertIn( + 'refs/pull/1/head', + list(repo.listall_references()) + ) self.assertTrue(cnt < 60) @@ -414,13 +405,10 @@ class PagureFlaskForkPrtests(tests.Modeltests): # we don't know the task id but we'll give it 30 sec to finish cnt = 0 repo = PagureRepo(gitrepo) - while 1: - if 'refs/pull/1/head' in list(repo.listall_references()): - break - cnt += 1 - if cnt == 60: - break - time.sleep(0.5) + self.assertIn( + 'refs/pull/1/head', + list(repo.listall_references()) + ) self.assertTrue(cnt < 60) @@ -461,13 +449,10 @@ class PagureFlaskForkPrtests(tests.Modeltests): # we don't know the task id but we'll give it 30 sec to finish cnt = 0 repo = PagureRepo(gitrepo) - while 1: - if 'refs/pull/1/head' in list(repo.listall_references()): - break - cnt += 1 - if cnt == 60: - break - time.sleep(0.5) + self.assertIn( + 'refs/pull/1/head', + list(repo.listall_references()) + ) self.assertTrue(cnt < 60) @@ -496,13 +481,10 @@ class PagureFlaskForkPrtests(tests.Modeltests): # we don't know the task id but we'll give it 30 sec to finish cnt = 0 repo = PagureRepo(gitrepo) - while 1: - if 'refs/pull/1/head' in list(repo.listall_references()): - break - cnt += 1 - if cnt == 60: - break - time.sleep(0.5) + self.assertIn( + 'refs/pull/1/head', + list(repo.listall_references()) + ) self.assertTrue(cnt < 60) diff --git a/tests/test_pagure_repospanner.py b/tests/test_pagure_repospanner.py index 6bdad4d..d8f12aa 100644 --- a/tests/test_pagure_repospanner.py +++ b/tests/test_pagure_repospanner.py @@ -205,9 +205,6 @@ class PagureRepoSpannerTests(tests.Modeltests): stderr=subprocess.STDOUT, ) - # Give repoSpanner time to start - time.sleep(1) - # Wait for the instance to become available resp = requests.get( 'https://nodea.regiona.repospanner.local:%d/'