Beispiel #1
0
    def test_bc_scan(self):
        print ""
        print "test bc scan broken data"
        self.backend1.start()
        self._gen_data("some value", prefix='test1', loop_num=1024, sector=0)
        tempered_key = None
        for key in self.backend1.generate_key(prefix="test2",
                                              count=1,
                                              sector=0):
            tempered_key = key
            store = MCStore(self.backend1_addr)
            store.set(tempered_key, string_large)
            store.close()
        self._gen_data("other value", prefix='test3', loop_num=1024, sector=0)
        self.assertEqual(self.backend1.item_count(), 2049)
        self.backend1.stop()

        #make sure we produce a crc error
        assert temper_with_key_value(self.backend1.db_home,
                                     self.backend1.db_depth,
                                     tempered_key,
                                     delete_hint=True)
        delete_hint_and_htree(self.backend1.db_home, self.backend1.db_depth)

        self.backend1.start()
        self.assertEqual(self.backend1.item_count(), 2048)
        self._check_data("some value", prefix="test1", loop_num=1024, sector=0)
        self._check_data("other value",
                         prefix="test3",
                         loop_num=1024,
                         sector=0)
        self.backend1.stop()
Beispiel #2
0
    def test_bc_scan(self):
        print ""
        print "test bc scan broken data"
        self.backend1.start()
        self._gen_data("some value", prefix='test1', loop_num=1024, sector=0)
        tempered_key = None
        for key in self.backend1.generate_key(prefix="test2", count=1, sector=0):
            tempered_key = key
            store = MCStore(self.backend1_addr)
            store.set(tempered_key, string_large)
            store.close()
        self._gen_data("other value", prefix='test3', loop_num=1024, sector=0)
        self.assertEqual(self.backend1.item_count(), 2049)
        self.backend1.stop()

        #make sure we produce a crc error
        assert temper_with_key_value(self.backend1.db_home, self.backend1.db_depth, tempered_key, delete_hint=True)
        delete_hint_and_htree(self.backend1.db_home, self.backend1.db_depth)

        self.backend1.start()
        self.assertEqual(self.backend1.item_count(), 2048)
        self._check_data("some value", prefix="test1", loop_num=1024, sector=0)
        self._check_data("other value", prefix="test3", loop_num=1024, sector=0)
        self.backend1.stop()
Beispiel #3
0
        store = MCStore(self.backend1_addr)
        for i in xrange(loop_num):
            key = "test%s" % (i)
            try:
                self.assertEqual(store.get(key), 2)
            except Exception, e:
                print key, "error", e
                return self.fail("fail")
        print "done get"
        print "check data & hint"
        check_data_hint_integrity(self.backend1.db_home, self.backend1.db_depth)
        self.assertEqual(self.backend1.item_count(), loop_num + 1)

        self.backend1.stop()
        print "delete .hint and .htree, should regenerate"
        delete_hint_and_htree(self.backend1.db_home, self.backend1.db_depth)
        self.backend1.start()
        print "check data & hint"
        check_data_hint_integrity(self.backend1.db_home, self.backend1.db_depth)
        self.assertEqual(self.backend1.item_count(), loop_num + 1)

    def tearDown(self):
        self.backend1.stop()

class TestGenerateData2(TestGenerateData):

    def setUp(self):
        self._clear_dir()
        self._init_dir()
        self.backend1 = BeansdbInstance(self.data_base_path, 57901, db_depth=2)