Ejemplo n.º 1
0
//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerTest::EresUnittest_RunAllNegativeTests
//
//	@doc:
//		Run all negative tests for parsing DXL documents into DXL trees.
//
//---------------------------------------------------------------------------
GPOS_RESULT
CParseHandlerTest::EresUnittest_RunAllNegativeTests()
{
	CAutoMemoryPool amp(CAutoMemoryPool::ElcNone);
	IMemoryPool *pmp = amp.Pmp();

	// loop over all test files
	for (ULONG ulFileNum = 0;
			ulFileNum < GPOS_ARRAY_SIZE(m_rgszNegativeTestsFileNames);
			ulFileNum++)
	{
		GPOS_TRY
		{
			// try running the test for the current file
			EresParseAndSerializePlan(
							pmp,
							m_rgszNegativeTestsFileNames[ulFileNum],
							true /* fValidate */
			);
			// if it does not throw an exception, then it failed
			return GPOS_FAILED;
		}
		GPOS_CATCH_EX(ex)
		{
			// these tests are supposed to throw exceptions, so if
			// the test throws an exception, then it is good
			GPOS_RESET_EX;
		}
		GPOS_CATCH_END;
	}

	return GPOS_OK;
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerTest::EresUnittest
//
//	@doc:
//		Unittest for DXL parsing
//
//---------------------------------------------------------------------------
GPOS_RESULT
CParseHandlerTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CParseHandlerTest::EresUnittest_ScalarExpr),
		GPOS_UNITTEST_FUNC(CParseHandlerTest::EresUnittest_Statistics),
		GPOS_UNITTEST_FUNC(CParseHandlerTest::EresUnittest_Metadata),
		GPOS_UNITTEST_FUNC(CParseHandlerTest::EresUnittest_MDRequest),
		GPOS_UNITTEST_FUNC(CParseHandlerTest::EresUnittest_RunPlanTests),
		// tests involving dxl representation of queries.
		GPOS_UNITTEST_FUNC(CParseHandlerTest::EresUnittest_RunQueryTests),

		// test that throw XML validation exception
		GPOS_UNITTEST_FUNC_THROW
			(
			CParseHandlerTest::EresUnittest_ErrSAXParseException,
			gpdxl::ExmaDXL,
			gpdxl::ExmiDXLValidationError
			),

		// tests that should throw an exception
		GPOS_UNITTEST_FUNC(CParseHandlerTest::EresUnittest_RunAllNegativeTests),
		};

	// skip OOM and Abort simulation for this test, it takes hours
	if (ITask::PtskSelf()->FTrace(EtraceSimulateOOM) || ITask::PtskSelf()->FTrace(EtraceSimulateAbort))
	{
		return GPOS_OK;
	}

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 3
0
//---------------------------------------------------------------------------
//	@function:
//		CMDAccessorTest::EresUnittest
//
//	@doc:
//		
//
//---------------------------------------------------------------------------
GPOS_RESULT
CMDAccessorTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CMDAccessorTest::EresUnittest_Basic),
		GPOS_UNITTEST_FUNC(CMDAccessorTest::EresUnittest_Datum),
#ifdef GPOS_DEBUG
		GPOS_UNITTEST_FUNC_ASSERT(CMDAccessorTest::EresUnittest_DatumGeneric),
#endif
		GPOS_UNITTEST_FUNC(CMDAccessorTest::EresUnittest_Navigate),
		GPOS_UNITTEST_FUNC_THROW
			(
			CMDAccessorTest::EresUnittest_Negative,
			gpdxl::ExmaMD,
			gpdxl::ExmiMDCacheEntryNotFound
			),
		GPOS_UNITTEST_FUNC(CMDAccessorTest::EresUnittest_Indexes),
		GPOS_UNITTEST_FUNC(CMDAccessorTest::EresUnittest_CheckConstraint),
		GPOS_UNITTEST_FUNC(CMDAccessorTest::EresUnittest_IndexPartConstraint),
		GPOS_UNITTEST_FUNC(CMDAccessorTest::EresUnittest_Cast),
		GPOS_UNITTEST_FUNC(CMDAccessorTest::EresUnittest_ScCmp),
		GPOS_UNITTEST_FUNC(CMDAccessorTest::EresUnittest_ConcurrentAccessSingleMDA),
		GPOS_UNITTEST_FUNC(CMDAccessorTest::EresUnittest_ConcurrentAccessMultipleMDA)
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 4
0
//---------------------------------------------------------------------------
//	@function:
//		CTreeMapTest::EresUnittest_FailedPlanEnumerationTests
//
//	@doc:
//		Run Minidump-based tests that fail during plan enumeration because
//		of large plan space
//
//---------------------------------------------------------------------------
GPOS_RESULT
CTreeMapTest::EresUnittest_FailedPlanEnumerationTests()
{
	CAutoMemoryPool amp;
	IMemoryPool *pmp = amp.Pmp();

	BOOL fMatchPlans = false;
	BOOL fTestSpacePruning = false;
#if defined(GPOS_Darwin) || defined(GPOS_Linux)
	// restrict plan matching to OsX and Linux to avoid arithmetic operations differences
	// across systems
	fMatchPlans = true;
	fTestSpacePruning = true;
#endif // GPOS_Darwin || GPOS_Linux

	// enable plan enumeration only if we match plans
	CAutoTraceFlag atf1(EopttraceEnumeratePlans, fMatchPlans);

	// enable stats derivation for DPE
	CAutoTraceFlag atf2(EopttraceDeriveStatsForDPE, true /*fVal*/);

	const ULONG ulTests = GPOS_ARRAY_SIZE(rgszFailedPlanEnumerationTests);
	GPOS_RESULT eres = GPOS_OK;
	for (ULONG ul = 0; eres == GPOS_OK && ul < ulTests; ul++)
	{
		GPOS_TRY
		{
			eres =
				CTestUtils::EresRunMinidumps
								(
								pmp,
								&rgszFailedPlanEnumerationTests[ul],
								1, // ulTests
								&m_ulTestCounter,
								1, // ulSessionId
								1,  // ulCmdId
								fMatchPlans,
								fTestSpacePruning
								);
		}
		GPOS_CATCH_EX(ex)
		{
			if (GPOS_MATCH_EX(ex, CException::ExmaSystem, CException::ExmiOverflow))
			{
				eres = GPOS_OK;
				GPOS_RESET_EX;
			}
			else
			{
				GPOS_RETHROW(ex);

				eres = GPOS_FAILED;
			}
		}
		GPOS_CATCH_END;
	}

	return eres;
}
Ejemplo n.º 5
0
//---------------------------------------------------------------------------
//	@function:
//		CCNFConverterTest::EresUnittest_Basic
//
//	@doc:
//		Basic test
//
//---------------------------------------------------------------------------
GPOS_RESULT
CCNFConverterTest::EresUnittest_Basic()
{
	CAutoMemoryPool amp;
	IMemoryPool *pmp = amp.Pmp();

	// setup a file-based provider
	CMDProviderMemory *pmdp = CTestUtils::m_pmdpf;
	pmdp->AddRef();
	CMDAccessor mda(pmp, CMDCache::Pcache(), CTestUtils::m_sysidDefault, pmdp);

	typedef CExpression *(*Pfpexpr)(IMemoryPool*);
	Pfpexpr rgpf[] =
		{
		CTestUtils::PexprLogicalSelectWithNestedAnd,
		CTestUtils::PexprLogicalSelectWithNestedOr,
		CTestUtils::PexprLogicalSelectWithEvenNestedNot,
		CTestUtils::PexprLogicalSelectWithOddNestedNot,
		CTestUtils::PexprLogicalSelectWithNestedAndOrNot
		};

	for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgpf); i++)
	{
		// install opt context in TLS
		CAutoOptCtxt aoc
						(
						pmp,
						&mda,
						NULL,  /* pceeval */
						CTestUtils::Pcm(pmp)
						);

		// generate expression
		CExpression *pexpr = rgpf[i](pmp);
		CExpression *pexprPreprocessed = CExpressionPreprocessor::PexprPreprocess(pmp, pexpr);

		CWStringDynamic str(pmp);
		COstreamString oss(&str);

		oss	<< std::endl << "SCALAR EXPR:" << std::endl << *(*pexpr)[1] << std::endl;
		GPOS_TRACE(str.Wsz());
		str.Reset();

		if (1 < pexprPreprocessed->UlArity())
		{
			CExpression *pexprCNF = CCNFConverter::Pexpr2CNF(pmp, (*pexprPreprocessed)[1]);
			oss	<< std::endl << "CNF REPRESENTATION:" << std::endl << *pexprCNF << std::endl;
			GPOS_TRACE(str.Wsz());
			str.Reset();
			pexprCNF->Release();
		}

		pexpr->Release();
		pexprPreprocessed->Release();
	}

	return GPOS_OK;
}
Ejemplo n.º 6
0
//---------------------------------------------------------------------------
//	@function:
//		CCorrelatedExecutionTest::EresUnittest
//
//	@doc:
//		Unittest for converting correlated Apply expressions to NL joins
//
//---------------------------------------------------------------------------
GPOS_RESULT
CCorrelatedExecutionTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CCorrelatedExecutionTest::EresUnittest_RunAllPositiveTests),
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 7
0
//---------------------------------------------------------------------------
//	@function:
//		CColRefSetIterTest::EresUnittest
//
//	@doc:
//		Unittest for bit vectors
//
//---------------------------------------------------------------------------
GPOS_RESULT
CColRefSetIterTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CColRefSetIterTest::EresUnittest_Basics)
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 8
0
//---------------------------------------------------------------------------
//	@function:
//		COrderSpecTest::EresUnittest
//
//	@doc:
//		Unittest for order spec classes
//
//---------------------------------------------------------------------------
GPOS_RESULT
COrderSpecTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(COrderSpecTest::EresUnittest_Basics)
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 9
0
//---------------------------------------------------------------------------
//	@function:
//		CTableDescriptorTest::EresUnittest
//
//	@doc:
//		Unittest for metadata names
//
//---------------------------------------------------------------------------
GPOS_RESULT
CTableDescriptorTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CTableDescriptorTest::EresUnittest_Basic)
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 10
0
//---------------------------------------------------------------------------
//	@function:
//		CContradictionTest::EresUnittest
//
//	@doc:
//		Unittest for contradiction detection
//
//---------------------------------------------------------------------------
GPOS_RESULT
CContradictionTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CContradictionTest::EresUnittest_Constraint),
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 11
0
//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerTest::EresUnittest_ScalarExpr
//
//	@doc:
//		Tests parsing of a scalar expression.
//
//---------------------------------------------------------------------------
GPOS_RESULT
CParseHandlerTest::EresUnittest_ScalarExpr()
{
	return EresUnittest_RunAllPositiveTests
		(
		m_rgszScalarExprDXLFileNames,
		GPOS_ARRAY_SIZE(m_rgszScalarExprDXLFileNames),
		&EresParseAndSerializeScalarExpr,
		false/* fValidate */
		);
}
Ejemplo n.º 12
0
//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerTest::EresUnittest_RunQueryTests
//
//	@doc:
//		Tests involving dxl representation of queries
//
//---------------------------------------------------------------------------
GPOS_RESULT
CParseHandlerTest::EresUnittest_RunQueryTests()
{
	return EresUnittest_RunAllPositiveTests
		(
		m_rgszQueryDXLFileNames,
		GPOS_ARRAY_SIZE(m_rgszQueryDXLFileNames),
		&EresParseAndSerializeQuery,
		false/* fValidate */
		);
}
Ejemplo n.º 13
0
//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerTest::EresUnittest_Statistics
//
//	@doc:
//		Tests parsing of a statistics entry
//
//---------------------------------------------------------------------------
GPOS_RESULT
CParseHandlerTest::EresUnittest_Statistics()
{
	return EresUnittest_RunAllPositiveTests
		(
		m_rgszStatsDXLFileNames,
		GPOS_ARRAY_SIZE(m_rgszStatsDXLFileNames),
		&EresParseAndSerializeStatistics,
		false/* fValidate */
		);
}
Ejemplo n.º 14
0
//---------------------------------------------------------------------------
//	@function:
//		CMiniDumperDXLTest::EresUnittest
//
//	@doc:
//		Unittest for DXL minidumps
//
//---------------------------------------------------------------------------
GPOS_RESULT
CMiniDumperDXLTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CMiniDumperDXLTest::EresUnittest_Basic),
		GPOS_UNITTEST_FUNC(CMiniDumperDXLTest::EresUnittest_Load),
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 15
0
//---------------------------------------------------------------------------
//	@function:
//		CCNFConverterTest::EresUnittest
//
//	@doc:
//		Unittest driver
//
//---------------------------------------------------------------------------
GPOS_RESULT
CCNFConverterTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		//GPOS_UNITTEST_FUNC(CCNFConverterTest::EresUnittest_Basic),
		GPOS_UNITTEST_FUNC(CCNFConverterTest::EresUnittest_AvoidCNFConversion),
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 16
0
// run minidump tests
GPOS_RESULT
CSubqueryHandlerTest::EresUnittest_RunMinidumpTests()
{
	return CTestUtils::EresUnittest_RunTestsWithoutAdditionalTraceFlags
						(
						rgszSubqueryHandlerMinidumpFileNames,
						&m_ulSubqueryHandlerMinidumpTestCounter,
						GPOS_ARRAY_SIZE(rgszSubqueryHandlerMinidumpFileNames),
						true, /* fMatchPlans */
						true /* fTestSpacePruning */
						);
}
Ejemplo n.º 17
0
//---------------------------------------------------------------------------
//	@function:
//		CJoinOrderTest::EresUnittest
//
//	@doc:
//		Unittest for predicate utilities
//
//---------------------------------------------------------------------------
GPOS_RESULT
CJoinOrderTest::EresUnittest()
{

	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CJoinOrderTest::EresUnittest_Expand),
		GPOS_UNITTEST_FUNC(EresUnittest_ExpandMinCard)
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 18
0
//---------------------------------------------------------------------------
//	@function:
//		CTreeMapTest::PtmapLoad
//
//	@doc:
//		Create a semantically meaningful tree map by simulating a MEMO 
//		layout
//
//---------------------------------------------------------------------------
CTreeMapTest::TestMap *
CTreeMapTest::PtmapLoad
	(
	IMemoryPool *pmp
	)
{
	TestMap *ptmap = GPOS_NEW(pmp) TestMap(pmp, &Pnd);
	
	// init raw data
	for (ULONG ulPos = 0; ulPos < ulElems; ulPos++)
	{
		rgul[ulPos] = ulPos;
	}

	
	// simulate the following MEMO with individual edge insertions
	struct SEdge
	{
		// number of parent node
		ULONG m_ulParent;
		
		// position of child
		ULONG m_ulPos;
		
		// number of child node
		ULONG m_ulChild;
	}
	rgedge[]=
	{
		// root group: Join [4,3], HashJoin[4,3]{8}, HashJoin[3,4]{9}
		{9, 1, 7}, {9, 0, 6}, {9, 0, 5},
		{8, 0, 7}, {8, 1, 5}, {8, 1, 6},
		
		// group 4: C, TabScan{7} 
		
		// group 3: Join[1,2], HashJoin[1,2]{5}, SortMergeJoin[1,2]{6}
		{5, 0, 0}, {5, 0, 1}, {5, 1, 2}, {5, 1, 3}, {5, 1, 4},
		{6, 0, 1}, {6, 1, 3}, {6, 1, 4},
		
		// group 2: B, TabScan{2}, IndexScan{3}, Sort[2]{4}
		{4, 0, 2}
		
		// group 1: A, TabScan{0}, IndexScan{1}
	};
		
	for (ULONG ul = 0; ul < GPOS_ARRAY_SIZE(rgedge); ul++)
	{
		SEdge &edge = rgedge[ul];
		ptmap->Insert(&rgul[edge.m_ulParent], edge.m_ulPos, &rgul[edge.m_ulChild]);
	}

	return ptmap;
}
	GPOS_RESULT
	CJoinCardinalityNDVBasedEqPredTest::EresUnittest()
	{
		CUnittest rgut[] =
				{
						GPOS_UNITTEST_FUNC(EresUnittest_NDVEqCardEstimation),
						GPOS_UNITTEST_FUNC(EresUnittest_NDVCardEstimationNotApplicableMultipleIdents),
						GPOS_UNITTEST_FUNC(EresUnittest_NDVCardEstimationNotApplicableInequalityRange)
				};

		GPOS_RESULT eres = CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));

		return eres;
	}
Ejemplo n.º 20
0
//---------------------------------------------------------------------------
//	@function:
//		CPredicateUtilsTest::EresUnittest
//
//	@doc:
//		Unittest for predicate utilities
//
//---------------------------------------------------------------------------
GPOS_RESULT
CPredicateUtilsTest::EresUnittest()
{

	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CPredicateUtilsTest::EresUnittest_Conjunctions),
		GPOS_UNITTEST_FUNC(CPredicateUtilsTest::EresUnittest_Disjunctions),
		GPOS_UNITTEST_FUNC(CPredicateUtilsTest::EresUnittest_PlainEqualities),
		GPOS_UNITTEST_FUNC(CPredicateUtilsTest::EresUnittest_Implication),
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 21
0
//---------------------------------------------------------------------------
//	@function:
//		CXformTest::EresUnittest
//
//	@doc:
//		Unittest driver
//
//---------------------------------------------------------------------------
GPOS_RESULT
CXformTest::EresUnittest()
{
	CUnittest rgut[] =
	{
		GPOS_UNITTEST_FUNC(CXformTest::EresUnittest_ApplyXforms),
		GPOS_UNITTEST_FUNC(CXformTest::EresUnittest_ApplyXforms_CTE),
#ifdef GPOS_DEBUG
		GPOS_UNITTEST_FUNC(CXformTest::EresUnittest_Mapping),
#endif // GPOS_DEBUG
	};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 22
0
//---------------------------------------------------------------------------
//	@function:
//		CSubqueryHandlerTest::EresUnittest
//
//	@doc:
//		Unittest for predicate utilities
//
//---------------------------------------------------------------------------
GPOS_RESULT
CSubqueryHandlerTest::EresUnittest()
{

	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CSubqueryHandlerTest::EresUnittest_Subquery2Apply),
		GPOS_UNITTEST_FUNC(CSubqueryHandlerTest::EresUnittest_SubqueryWithDisjunction),
		GPOS_UNITTEST_FUNC(CSubqueryHandlerTest::EresUnittest_RunMinidumpTests),
#ifdef GPOS_DEBUG
		GPOS_UNITTEST_FUNC_ASSERT(CSubqueryHandlerTest::EresUnittest_SubqueryWithConstSubqueries),
#endif // GPOS_DEBUG
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 23
0
//---------------------------------------------------------------------------
//	@function:
//		CCostTest::EresUnittest
//
//	@doc:
//		Driver for unittests
//
//---------------------------------------------------------------------------
GPOS_RESULT
CCostTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CCostTest::EresUnittest_Bool),
		GPOS_UNITTEST_FUNC(CCostTest::EresUnittest_Arithmetic),
		GPOS_UNITTEST_FUNC(CCostTest::EresUnittest_Params),
		GPOS_UNITTEST_FUNC(CCostTest::EresUnittest_Parsing),
		GPOS_UNITTEST_FUNC(EresUnittest_SetParams),

		// TODO: : re-enable test after resolving exception throwing problem on OSX
		// GPOS_UNITTEST_FUNC_THROW(CCostTest::EresUnittest_ParsingWithException, gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag),
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 24
0
//---------------------------------------------------------------------------
//	@function:
//		CCorrelatedExecutionTest::EresUnittest_RunAllPositiveTests
//
//	@doc:
//		Run all tests that are expected to pass without any exceptions
//		for parsing DXL documents into DXL trees.
//
//---------------------------------------------------------------------------
GPOS_RESULT
CCorrelatedExecutionTest::EresUnittest_RunAllPositiveTests()
{
	CAutoMemoryPool amp;
	IMemoryPool *pmp = amp.Pmp();

	// setup a file-based provider
	CMDProviderMemory *pmdp = CTestUtils::m_pmdpf;
	pmdp->AddRef();
	CMDAccessor mda(pmp, CMDCache::Pcache(), CTestUtils::m_sysidDefault, pmdp);

	// install opt context in TLS
	CAutoOptCtxt aoc
					(
					pmp,
					&mda,
					NULL, /* pceeval */
					CTestUtils::Pcm(pmp)
					);

	// loop over all test files
	for (ULONG ul = m_ulTestCounter; ul < GPOS_ARRAY_SIZE(rgszPositiveTests); ul++)
	{
		// TODO:  06/15/2012; enable plan matching
		GPOS_RESULT eres =
				CTestUtils::EresTranslate
									(
									pmp,
									rgszPositiveTests[ul],
									NULL /* plan file */,
									true /*fIgnoreMismatch*/
									);

		m_ulTestCounter++;

		if (GPOS_OK != eres)
		{
			return eres;
		}
	}

	// reset test counter
	m_ulTestCounter = 0;

	return GPOS_OK;
}
Ejemplo n.º 25
0
//---------------------------------------------------------------------------
//	@function:
//		CTreeMapTest::EresUnittest
//
//	@doc:
//		Unittest for state machine
//
//---------------------------------------------------------------------------
GPOS_RESULT
CTreeMapTest::EresUnittest()
{
	CUnittest rgut[] =
		{
		GPOS_UNITTEST_FUNC(CTreeMapTest::EresUnittest_Basic),
		GPOS_UNITTEST_FUNC(CTreeMapTest::EresUnittest_Count),
		GPOS_UNITTEST_FUNC(CTreeMapTest::EresUnittest_Unrank),
		GPOS_UNITTEST_FUNC(CTreeMapTest::EresUnittest_Memo),

#ifndef GPOS_DEBUG
		GPOS_UNITTEST_FUNC(EresUnittest_FailedPlanEnumerationTests),
#endif // GPOS_DEBUG

#ifdef GPOS_DEBUG
		GPOS_UNITTEST_FUNC_ASSERT(CTreeMapTest::EresUnittest_Cycle),
#endif // GPOS_DEBUG
		};

	return CUnittest::EresExecute(rgut, GPOS_ARRAY_SIZE(rgut));
}
Ejemplo n.º 26
0
//---------------------------------------------------------------------------
//	@function:
//		CJoinOrderDPTest::EresUnittest
//
//	@doc:
//		Unittest for testing guc for disabling dynamic join order algorithm
//
//---------------------------------------------------------------------------
gpos::GPOS_RESULT
CJoinOrderDPTest::EresUnittest()
{

	ULONG ulTestCounter = 0;
	const CHAR *rgszFileNames[] =
	{
			"../data/dxl/minidump/CJoinOrderDPTest/JoinOrderWithDP.mdp",
			"../data/dxl/minidump/CJoinOrderDPTest/JoinOrderWithOutDP.mdp",
			"../data/dxl/minidump/JoinOptimizationLevelQuery3WayHashJoinPartTbl.mdp"
	};

	return CTestUtils::EresUnittest_RunTestsWithoutAdditionalTraceFlags
				(
					rgszFileNames,
					&ulTestCounter,
					GPOS_ARRAY_SIZE(rgszFileNames),
					true,
					true
				);
}
Ejemplo n.º 27
0
//---------------------------------------------------------------------------
//	@function:
//		CCostTest::EresUnittest_CalibratedCostModel
//
//	@doc:
//		GPDB's calibrated cost model test
//
//---------------------------------------------------------------------------
GPOS_RESULT
CCostTest::EresUnittest_CalibratedCostModel()
{
	CAutoTraceFlag atf1(EtraceSimulateOOM, false);
	CAutoTraceFlag atf2(EtraceSimulateAbort, false);
	CAutoTraceFlag atf3(EtraceSimulateIOError, false);
	CAutoTraceFlag atf4(EtraceSimulateNetError, false);

	CAutoMemoryPool amp;
	IMemoryPool *pmp = amp.Pmp();

	// setup a file-based provider
	CMDProviderMemory *pmdp = CTestUtils::m_pmdpf;
	pmdp->AddRef();
	CMDAccessor mda(pmp, CMDCache::Pcache(), CTestUtils::m_sysidDefault, pmdp);

	ICostModel *pcm = GPOS_NEW(pmp) CCostModelGPDB(pmp, GPOPT_TEST_SEGMENTS);
	pcm->AddRef();

	{
		// install opt context in TLS
		CAutoOptCtxt aoc
						(
						pmp,
						&mda,
						NULL, /* pceeval */
						pcm
						);


		TestParams(pmp, true /*fCalibrated*/);
	}

	// minidump files
	const CHAR *rgszFileNamesCalibratedCostModel[] =
	{
		"../data/dxl/minidump/PartTbl-MultiWayJoinWithDPE.mdp",
		"../data/dxl/tpch/q2.mdp",
		"../data/dxl/minidump/CTE-4.mdp",
		"../data/dxl/minidump/Lead-Lag-WinFuncs.mdp",
	};

	COptimizerConfig* poconf = COptimizerConfig::PoconfDefault(pmp, pcm);

	for (ULONG ul = 0; ul < GPOS_ARRAY_SIZE(rgszFileNamesCalibratedCostModel); ul++)
	{
		CDXLNode *pdxlnPlan = CMinidumperUtils::PdxlnExecuteMinidump
							(
							pmp,
							rgszFileNamesCalibratedCostModel[ul],
							GPOPT_TEST_SEGMENTS,
							1 /*ulSessionId*/,
							1 /*ulCmdId*/,
							poconf,
							NULL /*pceeval*/
							);
		pdxlnPlan->Release();
	}

	poconf->Release();

	return GPOS_OK;
}
Ejemplo n.º 28
0
//---------------------------------------------------------------------------
//	@function:
//		CMDAccessorTest::PvInitMDAAndLookup
//
//	@doc:
//		Task which initializes a MD accessor and looks up multiple objects through
//		that accessor
//
//---------------------------------------------------------------------------
void *
CMDAccessorTest::PvInitMDAAndLookup
	(
	void * pv
	)
{
	GPOS_ASSERT(NULL != pv);
	
	CMDAccessor::MDCache *pcache = (CMDAccessor::MDCache *) pv;

	CAutoMemoryPool amp;
	IMemoryPool *mp = amp.Pmp();
	CWorkerPoolManager *pwpm = CWorkerPoolManager::WorkerPoolManager();
	
	// task memory pool
	CAutoMemoryPool ampTask;
	IMemoryPool *pmpTask = ampTask.Pmp();
	
	// scope for MD accessor
	{			
		// Setup an MD cache with a file-based provider
		CMDProviderMemory *pmdp = CTestUtils::m_pmdpf;
		pmdp->AddRef();
		CMDAccessor mda(mp, pcache, CTestUtils::m_sysidDefault, pmdp);
		
		// task parameters
		SMDCacheTaskParams mdtaskparams(pmpTask, &mda);

		// scope for ATP
		{	
			CAutoTaskProxy atp(mp, pwpm);
	
			CTask *rgPtsk[GPOPT_MDCACHE_LOOKUP_THREADS];
	
			TaskFuncPtr rgPfuncTask[] =
				{
				CMDAccessorTest::PvLookupSingleObj,
				CMDAccessorTest::PvLookupMultipleObj
				};
	
			const ULONG ulNumberOfTaskTypes = GPOS_ARRAY_SIZE(rgPfuncTask);
	
			// create tasks
			for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
			{
				rgPtsk[i] = atp.Create
							(
							rgPfuncTask[i % ulNumberOfTaskTypes],
							&mdtaskparams
							);
	
				GPOS_CHECK_ABORT;
			}
			
			for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
			{	
				atp.Schedule(rgPtsk[i]);
			}
			
			GPOS_CHECK_ABORT;
	
			// wait for completion
			for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
			{
				atp.Wait(rgPtsk[i]);
				GPOS_CHECK_ABORT;
	
			}
		}
	
	}
	
	return NULL;
}
Ejemplo n.º 29
0
//---------------------------------------------------------------------------
//	@function:
//		CMDAccessorTest::EresUnittest_ConcurrentAccessMultipleMDA
//
//	@doc:
//		Test concurrent access through multiple MD accessors from different threads
//
//---------------------------------------------------------------------------
GPOS_RESULT
CMDAccessorTest::EresUnittest_ConcurrentAccessMultipleMDA()
{
	CAutoMemoryPool amp;
	IMemoryPool *mp = amp.Pmp();
	CWorkerPoolManager *pwpm = CWorkerPoolManager::WorkerPoolManager();

#ifdef GPOS_DEBUG
	BOOL fOld = IWorker::m_enforce_time_slices;
	IWorker::m_enforce_time_slices = false;
#endif

	GPOS_TRY
	{	
		CAutoTaskProxy atp(mp, pwpm);
	
		// create multiple tasks eash of which will init a separate MD accessor and use it to
		// lookup objects from the respective accessor using different threads
		CTask *rgPtsk[GPOPT_MDCACHE_MDAS];
		
		// create tasks
		for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
		{
			rgPtsk[i] = atp.Create
						(
						PvInitMDAAndLookup,
						CMDCache::Pcache()	// task arg
						);
	
			GPOS_CHECK_ABORT;
		}
			
		for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
		{
			atp.Schedule(rgPtsk[i]);
		}
			
		GPOS_CHECK_ABORT;

		// wait for completion
		for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
		{
			atp.Wait(rgPtsk[i]);
			GPOS_CHECK_ABORT;
	
		}
	}
	GPOS_CATCH_EX(ex)
	{
#ifdef GPOS_DEBUG
		IWorker::m_enforce_time_slices = fOld;
#endif

		GPOS_RETHROW(ex);
	}
	GPOS_CATCH_END;
	
#ifdef GPOS_DEBUG
	IWorker::m_enforce_time_slices = fOld;
#endif

	return GPOS_OK;
}
Ejemplo n.º 30
0
//---------------------------------------------------------------------------
//	@function:
//		CMDAccessorTest::EresUnittest_ConcurrentAccessSingleMDA
//
//	@doc:
//		Test concurrent access through a single MD accessor from different threads
//
//---------------------------------------------------------------------------
GPOS_RESULT
CMDAccessorTest::EresUnittest_ConcurrentAccessSingleMDA()
{
	CAutoMemoryPool amp;
	IMemoryPool *mp = amp.Pmp();
	CWorkerPoolManager *pwpm = CWorkerPoolManager::WorkerPoolManager();
	
	// task memory pool
	CAutoMemoryPool ampTask;
	IMemoryPool *pmpTask = ampTask.Pmp();
	
	// setup a file-based provider
	// Setup an MD cache with a file-based provider
	CMDProviderMemory *pmdp = CTestUtils::m_pmdpf;
	pmdp->AddRef();
	CMDAccessor mda(mp, CMDCache::Pcache(), CTestUtils::m_sysidDefault, pmdp);

	// task parameters
	SMDCacheTaskParams mdtaskparams(pmpTask, &mda);

	// scope for ATP
	{
		CAutoTaskProxy atp(mp, pwpm);
	
		CTask *rgPtsk[GPOPT_MDCACHE_LOOKUP_THREADS];
	
		TaskFuncPtr rgPfuncTask[] =
			{
			CMDAccessorTest::PvLookupSingleObj,
			CMDAccessorTest::PvLookupMultipleObj
			};
	
		const ULONG ulNumberOfTaskTypes = GPOS_ARRAY_SIZE(rgPfuncTask);
	
		// create tasks
		for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
		{
			rgPtsk[i] = atp.Create
						(
						rgPfuncTask[i % ulNumberOfTaskTypes],
						&mdtaskparams
						);
	
			GPOS_CHECK_ABORT;
		}
			
		for (ULONG i = 0; i < GPOPT_MDCACHE_LOOKUP_THREADS; i++)
		{
			atp.Schedule(rgPtsk[i]);
		}
			
		GPOS_CHECK_ABORT;

		// wait for completion
		for (ULONG i = 0; i < GPOS_ARRAY_SIZE(rgPtsk); i++)
		{
			atp.Wait(rgPtsk[i]);
			GPOS_CHECK_ABORT;
	
		}
	}
	
	return GPOS_OK;
}