Esempio n. 1
0
	void brm_dumb_1()
	{
		DBRM brm;
		vector<LBID_t> lbids;
		int allocdSize, err;
		const uint32_t extentSize = brm.getExtentSize();

 		err = brm.createExtent(extentSize, 1, lbids, allocdSize);
		CPPUNIT_ASSERT(err == 0);
 		err = brm.markExtentInvalid(lbids[0]);
		CPPUNIT_ASSERT(err == 0);
		int64_t min;	
		int64_t max;	
		int32_t seq;
 		err = brm.getExtentMaxMin(lbids[0], max, min, seq);
#ifdef SAFE_CP
		CPPUNIT_ASSERT(err == 0);
#else
		CPPUNIT_ASSERT(err == 1);
#endif

 		err = brm.setExtentMaxMin(lbids[0], max, min, seq);
		CPPUNIT_ASSERT(err == 0);

		err = brm.deleteOID(1);
		CPPUNIT_ASSERT(err == 0);
	}	
Esempio n. 2
0
	void brm_markExtentsInvalid()
	{
		
		DBRM brm;
		int i, err, allocdSize, iterations = 100;  // (EM_INITIAL_SIZE + 3*EM_INCREMENT)
		vector<LBID_t> lbids;
		int64_t min, max;
		int32_t seqNum;
		const uint32_t extentSize = brm.getExtentSize();
		
		cerr << "brm_markExtentsInvalid" << endl;

		err = brm.createExtent(extentSize * iterations, 1, lbids, allocdSize);
		CPPUNIT_ASSERT(lbids.size() == iterations);
		CPPUNIT_ASSERT(err == 0);

		// mark all extents valid
		for (i = 0; i < iterations; i++) {
			err = brm.setExtentMaxMin(lbids[i], 1, 0, 0);
			CPPUNIT_ASSERT(err == 0);
		}

		err = brm.markExtentsInvalid(lbids);
		CPPUNIT_ASSERT(err == 0);

		// check that they are all invalid/updating/whatever.
		// != CP_VALID is what we're looking for
		for (i = 0; i < iterations; i++) {
			err = brm.getExtentMaxMin(lbids[i], max, min, seqNum);
			CPPUNIT_ASSERT(err == CP_UPDATING);
		}

		// cleanup
		err = brm.deleteOID(1);
	}
Esempio n. 3
0
	void brm_extentmap_good_1()
	{
		
		DBRM brm;
		int i, err, oid, allocdSize, 
			iterations = 100;  // (EM_INITIAL_SIZE + 3*EM_INCREMENT)
		uint32_t fbo, hwm;
		vector<LBID_t> lbids;
		HWM_t hwm2;
		VER_t txnID;
		const uint32_t extentSize = brm.getExtentSize();
		
 		cerr << "brm_extentmap_good_1" << endl;

		for (i = 1; i < iterations; i++) {
			err = brm.createExtent(extentSize, i, lbids, allocdSize);
			CPPUNIT_ASSERT(err == 0);
			CPPUNIT_ASSERT(lbids.back() == static_cast<LBID_t>((i-1)*extentSize));

			err=brm.markExtentInvalid(lbids[0]);
			CPPUNIT_ASSERT(err==0);

			int64_t min;	
			int64_t max;	
			int32_t seq;
 			err = brm.getExtentMaxMin(lbids[0], max, min, seq);
#ifdef SAFE_CP
			CPPUNIT_ASSERT(err == 0);
#else
			CPPUNIT_ASSERT(err == 1);
#endif

 			err = brm.setExtentMaxMin(lbids[0], max, min, seq);
			CPPUNIT_ASSERT(err == 0);

		}

		CPPUNIT_ASSERT(err==0);

		for (i = 1; i < iterations; i++) {
			err = brm.lookup(static_cast<LBID_t>((i-1)*extentSize), 0, false, oid, fbo);
			CPPUNIT_ASSERT(err == 0);
			CPPUNIT_ASSERT(oid == i);
			CPPUNIT_ASSERT(fbo == 0);
			if (i != 1) {
				err = brm.lookup(static_cast<LBID_t>((i-1)*extentSize - 1), 0, false, oid, fbo);
				CPPUNIT_ASSERT(err == 0);
				CPPUNIT_ASSERT(oid == i-1);
				CPPUNIT_ASSERT(fbo == extentSize - 1);
			}
			if (i != iterations) {
				err = brm.lookup(static_cast<LBID_t>((i-1)*extentSize + 1), 0, false, oid, fbo);
				CPPUNIT_ASSERT(err == 0);
				CPPUNIT_ASSERT(oid == i);
				CPPUNIT_ASSERT(fbo == 1);
			}
			err = brm.markExtentInvalid(oid);
			CPPUNIT_ASSERT(err==0);
			err = brm.markExtentInvalid(lbids[0]);
			CPPUNIT_ASSERT(err==0);
			int64_t min;	
			int64_t max;	
			int32_t seq;
 			err = brm.getExtentMaxMin(lbids[0], max, min, seq);
#ifdef SAFE_CP
			CPPUNIT_ASSERT(err == 0);
#else
			CPPUNIT_ASSERT(err == 1);
#endif

 			err = brm.setExtentMaxMin(lbids[0], max, min, seq);
			CPPUNIT_ASSERT(err == 0);
		}
		
 		CPPUNIT_ASSERT(brm.checkConsistency() == 0);

		err = brm.lookup(static_cast<LBID_t>((i-1)*extentSize), 0, false, oid, fbo);
		CPPUNIT_ASSERT(err == -1);
		
		for (i = 1; i < iterations; i++) {
			err = brm.getBulkInsertVars(static_cast<LBID_t>((i-1)*extentSize),
									   hwm2, txnID);
			CPPUNIT_ASSERT(err == 0);
			CPPUNIT_ASSERT(hwm2 == 0);
			CPPUNIT_ASSERT(txnID == 0);
			err = brm.setBulkInsertVars(static_cast<LBID_t>((i-1)*extentSize),
									   i, i + 1);
			CPPUNIT_ASSERT(err == 0);
			err = brm.getBulkInsertVars(static_cast<LBID_t>((i-1)*extentSize),
									   hwm2, txnID);
			CPPUNIT_ASSERT(err == 0);
			CPPUNIT_ASSERT(hwm2 == static_cast<BRM::LBID_t>(i));
			CPPUNIT_ASSERT(txnID == static_cast<BRM::VER_t>(i+1));
			
			err = brm.getHWM(i, hwm);
			CPPUNIT_ASSERT(err == 0);
			CPPUNIT_ASSERT(hwm == 0);
			err = brm.setHWM(i, ((uint32_t)i > extentSize - 1 ? extentSize - 1 : i));
			CPPUNIT_ASSERT(err == 0);
			err = brm.getHWM(i, hwm);
			CPPUNIT_ASSERT(err == 0);
			CPPUNIT_ASSERT(hwm == static_cast<uint32_t>((uint32_t)i > extentSize - 1 ? extentSize - 1 : i));
		}
		
 		CPPUNIT_ASSERT(brm.checkConsistency() == 0);

#ifdef BRM_DEBUG
		err = brm.setHWM(i, hwm);
		CPPUNIT_ASSERT(err != 0);
#endif

		for (i = 1; i < iterations; i++) {
			err = brm.deleteOID(i);
			CPPUNIT_ASSERT(err == 0);
		}
 
		err = brm.deleteOID(i);
		CPPUNIT_ASSERT(err != 0);
		
 		CPPUNIT_ASSERT(brm.checkConsistency() == 0);

		err = brm.saveState();
		CPPUNIT_ASSERT(err==0);

	}