예제 #1
0
    def test_insert_fetch_replicas(self):
        self.accessor.shard = bg_accessor.pack_shard(replica=0, writer=0)
        self.accessor.insert_points(_METRIC, _POINTS)
        self.accessor.shard = bg_accessor.pack_shard(replica=3, writer=0xFFFF)
        self.accessor.insert_points(_METRIC, _POINTS)
        self.flush()

        # TODO: Test fetch at different stages for a given metric.
        fetched = self.fetch(_METRIC, _QUERY_START, _QUERY_END)
        # assertEqual is very slow when the diff is huge, so we give it a chance of
        # failing early to avoid imprecise test timeouts.
        self.assertEqual(_QUERY_RANGE, len(fetched))
        self.assertEqual(_USEFUL_POINTS[:10], fetched[:10])
        self.assertEqual(_USEFUL_POINTS[-10:], fetched[-10:])
        self.assertEqual(_USEFUL_POINTS, fetched)
예제 #2
0
    def test_insert_fetch_replicas(self):
        self.accessor.shard = bg_accessor.pack_shard(replica=0, writer=0)
        self.accessor.insert_points(_METRIC, _POINTS)
        self.accessor.shard = bg_accessor.pack_shard(replica=3, writer=0xFFFF)
        self.accessor.insert_points(_METRIC, _POINTS)
        self.flush()

        # TODO: Test fetch at different stages for a given metric.
        fetched = self.fetch(_METRIC, _QUERY_START, _QUERY_END)
        # assertEqual is very slow when the diff is huge, so we give it a chance of
        # failing early to avoid imprecise test timeouts.
        self.assertEqual(_QUERY_RANGE, len(fetched))
        self.assertEqual(_USEFUL_POINTS[:10], fetched[:10])
        self.assertEqual(_USEFUL_POINTS[-10:], fetched[-10:])
        self.assertEqual(_USEFUL_POINTS, fetched)
예제 #3
0
 def test_pack_shard(self):
     self.assertEqual(bg_accessor.pack_shard(0, 0), 0)
     self.assertEqual(bg_accessor.pack_shard(0, 1), 1)
     self.assertEqual(bg_accessor.pack_shard(1, 0), 0x4000)
     self.assertEqual(bg_accessor.pack_shard(1, 1), 0x4001)
예제 #4
0
 def test_pack_shard(self):
     self.assertEquals(bg_accessor.pack_shard(0, 0), 0)
     self.assertEquals(bg_accessor.pack_shard(0, 1), 1)
     self.assertEquals(bg_accessor.pack_shard(1, 0), 0x4000)
     self.assertEquals(bg_accessor.pack_shard(1, 1), 0x4001)