Esempio n. 1
0
 def test_some_combination(self):
     # some combinations of the previous 4, this will require building a test suite
     # and running that test suite with the TINCTextTestResult
     suite = tinctest.TINCTestSuite()
     suite.addTest(MockTINCTestCaseForResults('test_success'))
     suite.addTest(MockTINCTestCaseForResults('test_failure'))
     suite.addTest(MockTINCTestCaseForResults('test_error'))
     suite.addTest(MockTINCTestCaseForResults('test_skip'))
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = TINCTestResultSet(buffer, True, 1)
         suite.run(tinc_test_result)
         text = buffer.getvalue()
     self.assertEqual(tinc_test_result.testsRun, 4)
     self.assertEqual(len(tinc_test_result.failures), 1)
     self.assertEqual(len(tinc_test_result.errors), 1)
     self.assertEqual(len(tinc_test_result.skipped), 1)
     self.assertRegexpMatches(
         text,
         'MockTINCTestCaseForResults.test_success \.\.\. .* \.\.\. ok')
     self.assertRegexpMatches(
         text,
         'MockTINCTestCaseForResults.test_failure \.\.\. .* \.\.\. FAIL')
     self.assertRegexpMatches(
         text,
         'MockTINCTestCaseForResults.test_error \.\.\. .* \.\.\. ERROR')
     self.assertRegexpMatches(
         text,
         'MockTINCTestCaseForResults.test_skip \.\.\. .* \.\.\. skipped .*')
Esempio n. 2
0
    def test_run_sql_test_optimizer_both(self):
        test_loader = tinctest.TINCTestLoader()
        # For data provider test cases, we have to use loadTestsFromName, since loadTestsFromTestCase won't filter and expand
        test_suite = test_loader.loadTestsFromName(
            "mpp.models.regress.sql_related.regress_sql_test_case.regress_sql_test_case.MockSQLTestCaseWithOptimizerBoth"
        )

        # Find our desired test case in test_suite.
        test_case = None
        new_test_suite = tinctest.TINCTestSuite()
        for temp in test_suite._tests:
            if "MockSQLTestCaseWithOptimizerBoth.test_query03" in temp.name:
                new_test_suite.addTest(temp)
                temp.__class__.__unittest_skip__ = False
                test_case = temp

        self.assertIsNotNone(new_test_suite)
        self.assertEquals(new_test_suite.countTestCases(), 2)

        test_result = unittest.TestResult()
        new_test_suite.run(test_result)
        self.assertEqual(test_result.testsRun, 2)
        self.assertEqual(len(test_result.errors), 0)
        self.assertEqual(len(test_result.skipped), 0)
        self.assertEqual(len(test_result.failures), 0)
        self.assertTrue(
            os.path.exists(
                os.path.join(test_case.get_out_dir(), 'query03_planner.sql')))
        self.assertTrue(
            os.path.exists(
                os.path.join(test_case.get_out_dir(), 'query03_planner.out')))
        self.assertTrue(
            self._check_str_in_file(
                "SET optimizer=off;",
                os.path.join(temp.get_out_dir(), 'query03_planner.sql')))
        self.assertTrue(
            self._check_str_in_file(
                "SET optimizer=off;",
                os.path.join(test_case.get_out_dir(), 'query03_planner.out')))

        self.assertTrue(
            os.path.exists(
                os.path.join(test_case.get_out_dir(), 'query03_orca.sql')))
        self.assertTrue(
            os.path.exists(
                os.path.join(test_case.get_out_dir(), 'query03_orca.out')))
        self.assertTrue(
            self._check_str_in_file(
                "SET optimizer=on;",
                os.path.join(test_case.get_out_dir(), 'query03_orca.sql')))
        self.assertTrue(
            self._check_str_in_file(
                "SET optimizer=on;",
                os.path.join(test_case.get_out_dir(), 'query03_orca.out')))

        shutil.rmtree(test_case.get_out_dir())
Esempio n. 3
0
    def test_run_sql_test_optimizer_minidump_on_failure2(self):
        """
        Test whether we gather minidumps on failures when the test is exeucted with optimizer_mode both.
        """
        test_loader = tinctest.TINCTestLoader()
        test_suite = test_loader.loadTestsFromName('mpp.models.regress.sql_related.regress_sql_test_case.' + \
                                                       'regress_sql_test_case.' + \
                                                       'MockSQLTestCaseWithOptimizerBoth.test_query02')
        self.assertIsNotNone(test_suite)
        new_test_suite = tinctest.TINCTestSuite()

        self.assertEquals(test_suite.countTestCases(), 2)

        test_result = None
        test_case = None

        for test in test_suite._tests:
            if 'test_query02_orca' in test.name:
                test.__class__.__unittest_skip__ = False
                test_case = test
                new_test_suite.addTest(test)

        self.assertIsNotNone(test_case)

        if os.path.exists(test_case.get_out_dir()):
            shutil.rmtree(test_case.get_out_dir())

        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream=buffer,
                                              descriptions=True,
                                              verbosity=1)
            test_result = tinc_test_runner.run(new_test_suite)
            self.assertEqual(test_result.testsRun, 1)
            self.assertEqual(len(test_result.errors), 0)
            self.assertEqual(len(test_result.skipped), 0)
            self.assertEqual(len(test_result.failures), 1)

        self.assertTrue(
            os.path.exists(
                os.path.join(test_case.get_out_dir(), 'query02_orca.sql')))
        self.assertTrue(
            os.path.exists(
                os.path.join(test_case.get_out_dir(), 'query02_orca.out')))
        self.assertTrue(
            self._check_str_in_file(
                "SET optimizer=on;",
                os.path.join(test_case.get_out_dir(), 'query02_orca.sql')))
        self.assertTrue(
            self._check_str_in_file(
                "SET optimizer=on;",
                os.path.join(test_case.get_out_dir(), 'query02_orca.out')))
        # Verify that we collect minidump on failure for optimizer execution mode
        self.assertTrue(
            os.path.exists(
                os.path.join(test_case.get_out_dir(), 'query02_minidump.mdp')))
Esempio n. 4
0
 def test_sanity_run(self):
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_result = tinctest.TINCTextTestResult(buffer, True, 1)
         tinc_test_suite = tinctest.TINCTestSuite()
         tinc_test_suite.addTest(MockTINCTestCase('test_do_stuff'))
         tinc_test_suite.run(tinc_test_result)