1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 00:59:48 +00:00

bitbake: hashserv: Add unihash-exists API

Adds API to check if the server is aware of the existence of a given
unihash. This can be used as an optimization for sstate where a client
can query the hash equivalence server to check if a unihash exists
before querying the sstate cache. If the hash server isn't aware of the
existence of a unihash, then there is very likely not a matching sstate
object, so this should be able to significantly cut down on the number
of negative hits on the sstate cache.

(Bitbake rev: cfe0ac071cfb998e4a1dd263f8860b140843361a)

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Watt
2024-02-18 15:59:48 -07:00
committed by Richard Purdie
parent be909636c6
commit 3bd2c69e70
6 changed files with 151 additions and 33 deletions
+39
View File
@@ -442,6 +442,11 @@ class HashEquivalenceCommonTests(object):
self.assertEqual(result['taskhash'], taskhash9, 'Server failed to copy unihash from upstream')
self.assertEqual(result['method'], self.METHOD)
def test_unihash_exsits(self):
taskhash, outhash, unihash = self.create_test_hash(self.client)
self.assertTrue(self.client.unihash_exists(unihash))
self.assertFalse(self.client.unihash_exists('6662e699d6e3d894b24408ff9a4031ef9b038ee8'))
def test_ro_server(self):
rw_server = self.start_server()
rw_client = self.start_client(rw_server.address)
@@ -1031,6 +1036,40 @@ class TestHashEquivalenceClient(HashEquivalenceTestSetup, unittest.TestCase):
def test_stress(self):
self.run_hashclient(["--address", self.server_address, "stress"], check=True)
def test_unihash_exsits(self):
taskhash, outhash, unihash = self.create_test_hash(self.client)
p = self.run_hashclient([
"--address", self.server_address,
"unihash-exists", unihash,
], check=True)
self.assertEqual(p.stdout.strip(), "true")
p = self.run_hashclient([
"--address", self.server_address,
"unihash-exists", '6662e699d6e3d894b24408ff9a4031ef9b038ee8',
], check=True)
self.assertEqual(p.stdout.strip(), "false")
def test_unihash_exsits_quiet(self):
taskhash, outhash, unihash = self.create_test_hash(self.client)
p = self.run_hashclient([
"--address", self.server_address,
"unihash-exists", unihash,
"--quiet",
])
self.assertEqual(p.returncode, 0)
self.assertEqual(p.stdout.strip(), "")
p = self.run_hashclient([
"--address", self.server_address,
"unihash-exists", '6662e699d6e3d894b24408ff9a4031ef9b038ee8',
"--quiet",
])
self.assertEqual(p.returncode, 1)
self.assertEqual(p.stdout.strip(), "")
def test_remove_taskhash(self):
taskhash, outhash, unihash = self.create_test_hash(self.client)
self.run_hashclient([