def test_chr_compute_ring_position(self): hosts = [ ("127.0.0.1", "cache0"), ("127.0.0.1", "cache1"), ("127.0.0.1", "cache2"), ] hashring = ConsistentHashRing(hosts) self.assertEqual(hashring.compute_ring_position('hosts.worker1.cpu'), 64833) self.assertEqual(hashring.compute_ring_position('hosts.worker2.cpu'), 38509)
def test_chr_compute_ring_position_fnv1a(self): hosts = [ ("127.0.0.1", "ba603c36342304ed77953f84ac4d357b"), ("127.0.0.2", "5dd63865534f84899c6e5594dba6749a"), ("127.0.0.3", "866a18b81f2dc4649517a1df13e26f28"), ] hashring = ConsistentHashRing(hosts, hash_type='fnv1a_ch') self.assertEqual(hashring.compute_ring_position('hosts.worker1.cpu'), 59573) self.assertEqual(hashring.compute_ring_position('hosts.worker2.cpu'), 35749)