bitbake: tests/runqueue: Fix hashserve shutdown race

The hashserve can delete its socket whilst the cleanup us happening leading to
backtraces and test failures.

Add code to avoid this race condition.

[YOCTO #13542]

(Bitbake rev: efd7b025cee25d0ee668c09476395d08fcf5ae1a)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2019-10-02 10:14:24 +01:00
parent 0b9f2ac2e1
commit 562de41ce7

View File

@@ -12,6 +12,7 @@ import os
import tempfile
import subprocess
import sys
import time
#
# TODO:
@@ -257,6 +258,8 @@ class RunQueueTests(unittest.TestCase):
'a1:package_write_ipk_setscene', 'a1:package_qa_setscene']
self.assertEqual(set(tasks), set(expected))
self.shutdown(tempdir)
@unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required')
def test_hashserv_double(self):
with tempfile.TemporaryDirectory(prefix="runqueuetest") as tempdir:
@@ -280,6 +283,7 @@ class RunQueueTests(unittest.TestCase):
'a1:package_write_rpm_setscene', 'b1:package_write_ipk_setscene', 'a1:packagedata_setscene']
self.assertEqual(set(tasks), set(expected))
self.shutdown(tempdir)
@unittest.skipIf(sys.version_info < (3, 5, 0), 'Python 3.5 or later required')
def test_hashserv_multiple_setscene(self):
@@ -309,3 +313,11 @@ class RunQueueTests(unittest.TestCase):
for i in expected:
self.assertEqual(tasks.count(i), 1, "%s not in task list once" % i)
self.shutdown(tempdir)
def shutdown(self, tempdir):
# Wait for the hashserve socket to disappear else we'll see races with the tempdir cleanup
while os.path.exists(tempdir + "/hashserve.sock"):
time.sleep(0.5)