summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/hashserv/tests.py
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2024-02-18 15:59:48 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-02-19 11:58:12 +0000
commit3bd2c69e70853584beaaa5a4fd62589fa051d911 (patch)
tree3dc6469a1895cc7a31a58e4fc9dc43cef9a82cfb /bitbake/lib/hashserv/tests.py
parentbe909636c608d5ba24a41327c53d6a4ba3b70151 (diff)
downloadpoky-3bd2c69e70853584beaaa5a4fd62589fa051d911.tar.gz
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>
Diffstat (limited to 'bitbake/lib/hashserv/tests.py')
-rw-r--r--bitbake/lib/hashserv/tests.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/bitbake/lib/hashserv/tests.py b/bitbake/lib/hashserv/tests.py
index aeedab3575..fbbe81512a 100644
--- a/bitbake/lib/hashserv/tests.py
+++ b/bitbake/lib/hashserv/tests.py
@@ -442,6 +442,11 @@ class HashEquivalenceCommonTests(object):
442 self.assertEqual(result['taskhash'], taskhash9, 'Server failed to copy unihash from upstream') 442 self.assertEqual(result['taskhash'], taskhash9, 'Server failed to copy unihash from upstream')
443 self.assertEqual(result['method'], self.METHOD) 443 self.assertEqual(result['method'], self.METHOD)
444 444
445 def test_unihash_exsits(self):
446 taskhash, outhash, unihash = self.create_test_hash(self.client)
447 self.assertTrue(self.client.unihash_exists(unihash))
448 self.assertFalse(self.client.unihash_exists('6662e699d6e3d894b24408ff9a4031ef9b038ee8'))
449
445 def test_ro_server(self): 450 def test_ro_server(self):
446 rw_server = self.start_server() 451 rw_server = self.start_server()
447 rw_client = self.start_client(rw_server.address) 452 rw_client = self.start_client(rw_server.address)
@@ -1031,6 +1036,40 @@ class TestHashEquivalenceClient(HashEquivalenceTestSetup, unittest.TestCase):
1031 def test_stress(self): 1036 def test_stress(self):
1032 self.run_hashclient(["--address", self.server_address, "stress"], check=True) 1037 self.run_hashclient(["--address", self.server_address, "stress"], check=True)
1033 1038
1039 def test_unihash_exsits(self):
1040 taskhash, outhash, unihash = self.create_test_hash(self.client)
1041
1042 p = self.run_hashclient([
1043 "--address", self.server_address,
1044 "unihash-exists", unihash,
1045 ], check=True)
1046 self.assertEqual(p.stdout.strip(), "true")
1047
1048 p = self.run_hashclient([
1049 "--address", self.server_address,
1050 "unihash-exists", '6662e699d6e3d894b24408ff9a4031ef9b038ee8',
1051 ], check=True)
1052 self.assertEqual(p.stdout.strip(), "false")
1053
1054 def test_unihash_exsits_quiet(self):
1055 taskhash, outhash, unihash = self.create_test_hash(self.client)
1056
1057 p = self.run_hashclient([
1058 "--address", self.server_address,
1059 "unihash-exists", unihash,
1060 "--quiet",
1061 ])
1062 self.assertEqual(p.returncode, 0)
1063 self.assertEqual(p.stdout.strip(), "")
1064
1065 p = self.run_hashclient([
1066 "--address", self.server_address,
1067 "unihash-exists", '6662e699d6e3d894b24408ff9a4031ef9b038ee8',
1068 "--quiet",
1069 ])
1070 self.assertEqual(p.returncode, 1)
1071 self.assertEqual(p.stdout.strip(), "")
1072
1034 def test_remove_taskhash(self): 1073 def test_remove_taskhash(self):
1035 taskhash, outhash, unihash = self.create_test_hash(self.client) 1074 taskhash, outhash, unihash = self.create_test_hash(self.client)
1036 self.run_hashclient([ 1075 self.run_hashclient([