Exemplo n.º 1
0
    def test_sql_test_case_with_discovery_queries(self):
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'sql_pattern')
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir], patterns = ['sql_pattern.py'],
                                                    top_level_dir = None, query_handler = TINCDiscoveryQueryHandler(['method=test_functional_*']))

        test_case = None
        test_result = None
            
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            test_result = tinc_test_runner.run(tinc_test_suite)
            self.assertEqual(test_result.testsRun, 6)
            self.assertEqual(len(test_result.skipped), 6)


        # Queries using metadata from sql files
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'sql_pattern')
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir], patterns = ['sql_pattern.py'],
                                                    top_level_dir = None,
                                                    query_handler = TINCDiscoveryQueryHandler(['method=test_functional_* and tags != long']))

        test_case = None
        test_result = None
            
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            test_result = tinc_test_runner.run(tinc_test_suite)
            self.assertEqual(test_result.testsRun, 3)
            self.assertEqual(len(test_result.skipped), 3)
 def test_runner(self):
     test_loader = tinctest.TINCTestLoader()
     tinc_test_suite = test_loader.loadTestsFromName('tinctest.models.concurrency.test.test_concurrency_test_case.MockConcurrencyTestCase')
     for test in tinc_test_suite._tests:
         if not 'test_skip' in test.name:
             test.__class__.__unittest_skip__ = False
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
         tinc_test_runner.run(tinc_test_suite)
Exemplo 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')))
Exemplo n.º 4
0
    def test_scenario_with_custom_result_fail(self):
        test_loader = tinctest.TINCTestLoader()
        tinc_test_suite = test_loader.loadTestsFromName('tinctest.models.scenario.test.test_scenario_test_case.MockScenarioTestCaseWithCustomResult.test_with_custom_result_fail')
        for test in tinc_test_suite._tests:
            test.__class__.__unittest_skip__ = False
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            tinc_test_runner.run(tinc_test_suite)

        for test in tinc_test_suite._tests:
            if 'test_with_custom_result_fail' in test.name:
                self.assertEqual(test.s, 0)
                self.assertEqual(test.f, 1)
    def test_scenario_with_custom_result_fail(self):
        test_loader = tinctest.TINCTestLoader()
        tinc_test_suite = test_loader.loadTestsFromName('tinctest.models.scenario.test.test_scenario_test_case.MockScenarioTestCaseWithCustomResult.test_with_custom_result_fail')
        for test in tinc_test_suite._tests:
            test.__class__.__unittest_skip__ = False
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            tinc_test_runner.run(tinc_test_suite)

        for test in tinc_test_suite._tests:
            if 'test_with_custom_result_fail' in test.name:
                self.assertEqual(test.s, 0)
                self.assertEqual(test.f, 1)
Exemplo n.º 6
0
 def test_runner(self):
     test_loader = tinctest.TINCTestLoader()
     tinc_test_suite = test_loader.loadTestsFromName(
         'tinctest.models.concurrency.test.test_concurrency_test_case.MockConcurrencyTestCase'
     )
     for test in tinc_test_suite._tests:
         if not 'test_skip' in test.name:
             test.__class__.__unittest_skip__ = False
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_runner = TINCTestRunner(stream=buffer,
                                           descriptions=True,
                                           verbosity=1)
         tinc_test_runner.run(tinc_test_suite)
Exemplo n.º 7
0
    def test_sql_test_case_discovery_with_pattern_matching(self):
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'sql_pattern')
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir], patterns = ['sql_pattern.py'],
                                                    top_level_dir = None, query_handler = None)

        test_case = None
        test_result = None
            
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            test_result = tinc_test_runner.run(tinc_test_suite)
            self.assertEqual(test_result.testsRun, 12)
            self.assertEqual(len(test_result.skipped), 12)
Exemplo n.º 8
0
    def test_sql_test_case_discovery_with_pattern_matching(self):
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'sql_pattern')
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir], patterns = ['sql_pattern.py'],
                                                    top_level_dir = None, query_handler = None)

        test_case = None
        test_result = None
            
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            test_result = tinc_test_runner.run(tinc_test_suite)
            self.assertEqual(test_result.testsRun, 12)
            self.assertEqual(len(test_result.skipped), 12)
Exemplo n.º 9
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')))
Exemplo n.º 10
0
    def test_sql_test_case_with_discovery_queries(self):
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'sql_pattern')
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir], patterns = ['sql_pattern.py'],
                                                    top_level_dir = None, query_handler = TINCDiscoveryQueryHandler(['method=test_functional_*']))

        test_case = None
        test_result = None
            
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            test_result = tinc_test_runner.run(tinc_test_suite)
            self.assertEqual(test_result.testsRun, 6)
            self.assertEqual(len(test_result.skipped), 6)


        # Queries using metadata from sql files
        tinc_test_loader = tinctest.TINCTestLoader()
        pwd = os.path.dirname(inspect.getfile(self.__class__))
        test_dir = os.path.join(pwd, 'sql_pattern')
        tinc_test_suite = tinc_test_loader.discover(start_dirs = [test_dir], patterns = ['sql_pattern.py'],
                                                    top_level_dir = None,
                                                    query_handler = TINCDiscoveryQueryHandler(['method=test_functional_* and tags != long']))

        test_case = None
        test_result = None
            
        with closing(_WritelnDecorator(StringIO())) as buffer:
            tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
            test_result = tinc_test_runner.run(tinc_test_suite)
            self.assertEqual(test_result.testsRun, 3)
            self.assertEqual(len(test_result.skipped), 3)
Exemplo n.º 11
0
 def test_custom_result_add_success(self):
     test_loader = tinctest.TINCTestLoader()
     tinc_test_suite = test_loader.loadTestsFromName(
         'tinctest.test.test_core.MockTINCTestCaseWithCustomResult')
     for test in tinc_test_suite._tests:
         if not 'test_skip' in test.name:
             test.__class__.__unittest_skip__ = False
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_runner = TINCTestRunner(stream=buffer,
                                           descriptions=True,
                                           verbosity=1)
         tinc_test_runner.run(tinc_test_suite)
     count = 0
     for test in tinc_test_suite._tests:
         if 'test_success' in test.name:
             self.assertEqual(test._my_result._my_pass, 1)
             self.assertEqual(test._my_result._my_errors, 0)
             self.assertEqual(test._my_result._my_failure, 0)
             self.assertEqual(test._my_result._my_skip, 0)
             self.assertEqual(test._my_result._my_expected_failure, 0)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('success' in test._my_result.result_detail)
             count += 1
         if 'test_failure' in test.name:
             self.assertEqual(test._my_result._my_pass, 0)
             self.assertEqual(test._my_result._my_errors, 0)
             self.assertEqual(test._my_result._my_failure, 1)
             self.assertEqual(test._my_result._my_skip, 0)
             self.assertEqual(test._my_result._my_expected_failure, 0)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('failures' in test._my_result.result_detail)
             count += 1
         if 'test_error' in test.name:
             self.assertEqual(test._my_result._my_pass, 0)
             self.assertEqual(test._my_result._my_errors, 1)
             self.assertEqual(test._my_result._my_failure, 0)
             self.assertEqual(test._my_result._my_skip, 0)
             self.assertEqual(test._my_result._my_expected_failure, 0)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('errors' in test._my_result.result_detail)
             count += 1
         if 'test_expectedfailure' in test.name:
             self.assertEqual(test._my_result._my_pass, 0)
             self.assertEqual(test._my_result._my_errors, 0)
             self.assertEqual(test._my_result._my_failure, 0)
             self.assertEqual(test._my_result._my_skip, 0)
             self.assertEqual(test._my_result._my_expected_failure, 1)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue(
                 'expected_failure' in test._my_result.result_detail)
             count += 1
         if 'test_error' in test.name:
             self.assertEqual(test._my_result._my_pass, 0)
             self.assertEqual(test._my_result._my_errors, 1)
             self.assertEqual(test._my_result._my_failure, 0)
             self.assertEqual(test._my_result._my_skip, 0)
             self.assertEqual(test._my_result._my_expected_failure, 0)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('errors' in test._my_result.result_detail)
             count += 1
         if 'test_skip' in test.name:
             self.assertEqual(test._my_result._my_pass, 0)
             self.assertEqual(test._my_result._my_errors, 0)
             self.assertEqual(test._my_result._my_failure, 0)
             self.assertEqual(test._my_result._my_skip, 1)
             self.assertEqual(test._my_result._my_expected_failure, 0)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             count += 1
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('skip' in test._my_result.result_detail)
     self.assertEqual(count, 6)
Exemplo n.º 12
0
 def test_custom_result_add_success(self):
     test_loader = tinctest.TINCTestLoader()
     tinc_test_suite = test_loader.loadTestsFromName('tinctest.test.test_core.MockTINCTestCaseWithCustomResult')
     for test in tinc_test_suite._tests:
         if not 'test_skip' in test.name:
             test.__class__.__unittest_skip__ = False
     with closing(_WritelnDecorator(StringIO())) as buffer:
         tinc_test_runner = TINCTestRunner(stream = buffer, descriptions = True, verbosity = 1)
         tinc_test_runner.run(tinc_test_suite)
     count = 0
     for test in tinc_test_suite._tests:
         if 'test_success' in test.name:
             self.assertEqual(test._my_result._my_pass, 1)
             self.assertEqual(test._my_result._my_errors, 0)
             self.assertEqual(test._my_result._my_failure, 0)
             self.assertEqual(test._my_result._my_skip, 0)
             self.assertEqual(test._my_result._my_expected_failure, 0)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('success' in test._my_result.result_detail)
             count += 1
         if 'test_failure' in test.name:
             self.assertEqual(test._my_result._my_pass, 0)
             self.assertEqual(test._my_result._my_errors, 0)
             self.assertEqual(test._my_result._my_failure, 1)
             self.assertEqual(test._my_result._my_skip, 0)
             self.assertEqual(test._my_result._my_expected_failure, 0)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('failures' in test._my_result.result_detail)
             count += 1
         if 'test_error' in test.name:
             self.assertEqual(test._my_result._my_pass, 0)
             self.assertEqual(test._my_result._my_errors, 1)
             self.assertEqual(test._my_result._my_failure, 0)
             self.assertEqual(test._my_result._my_skip, 0)
             self.assertEqual(test._my_result._my_expected_failure, 0)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('errors' in test._my_result.result_detail)
             count += 1
         if 'test_expectedfailure' in test.name:
             self.assertEqual(test._my_result._my_pass, 0)
             self.assertEqual(test._my_result._my_errors, 0)
             self.assertEqual(test._my_result._my_failure, 0)
             self.assertEqual(test._my_result._my_skip, 0)
             self.assertEqual(test._my_result._my_expected_failure, 1)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('expected_failure' in test._my_result.result_detail)
             count += 1
         if 'test_error' in test.name:
             self.assertEqual(test._my_result._my_pass, 0)
             self.assertEqual(test._my_result._my_errors, 1)
             self.assertEqual(test._my_result._my_failure, 0)
             self.assertEqual(test._my_result._my_skip, 0)
             self.assertEqual(test._my_result._my_expected_failure, 0)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('errors' in test._my_result.result_detail)
             count += 1
         if 'test_skip' in test.name:
             self.assertEqual(test._my_result._my_pass, 0)
             self.assertEqual(test._my_result._my_errors, 0)
             self.assertEqual(test._my_result._my_failure, 0)
             self.assertEqual(test._my_result._my_skip, 1)
             self.assertEqual(test._my_result._my_expected_failure, 0)
             self.assertEqual(test._my_result._my_unexpected_success, 0)
             count += 1
             self.assertEqual(len(test._my_result.result_detail), 1)
             self.assertTrue('skip' in test._my_result.result_detail)
     self.assertEqual(count, 6)