コード例 #1
0
    def test_retry(self):
        rec_norm = []
        rec_err = []

        class CustomizedError(Exception):
            pass

        def _action(node, raises=False):
            if raises:
                rec_err.append(node.message)
                raise CustomizedError("Error")
            else:
                rec_norm.append(node.message)

        options.runner.retry_times = 3
        options.runner.dry_run = False
        self.create_ionosphere(IONOSPHERE_TABLE)
        df1 = DataFrame(self.odps.get_table(IONOSPHERE_TABLE))

        set_retry_mode(False)
        df2 = self.mock_action(df1, 1, "DF2", _action)
        df3 = self.mock_action(df2, 1, "DF3", partial(_action, raises=True))
        self.assertRaises(CustomizedError, lambda: df3.persist("out_table"))
        self.assertEqual(rec_norm, ["DF2"])
        self.assertEqual(rec_err, ["DF3"] * 3)

        rec_norm = []
        rec_err = []
        set_retry_mode(True)
        df2 = self.mock_action(df1, 1, "DF2", _action)
        df3 = self.mock_action(df2, 1, "DF3", _action)
        df3.persist("out_table")
        self.assertEqual(rec_norm, ["DF3"])
        self.assertEqual(rec_err, [])
コード例 #2
0
    def test_retry(self):
        rec_norm = []
        rec_err = []

        class CustomizedError(Exception):
            pass

        def _action(node, raises=False):
            if raises:
                rec_err.append(node.message)
                raise CustomizedError('Error')
            else:
                rec_norm.append(node.message)

        options.runner.retry_times = 3
        options.runner.dry_run = False
        self.create_ionosphere(IONOSPHERE_TABLE)
        df1 = DataFrame(self.odps.get_table(IONOSPHERE_TABLE))

        set_retry_mode(False)
        df2 = self.mock_action(df1, 1, 'DF2', _action)
        df3 = self.mock_action(df2, 1, 'DF3', partial(_action, raises=True))
        self.assertRaises(CustomizedError, lambda: df3.persist('out_table'))
        self.assertEqual(rec_norm, [
            'DF2',
        ])
        self.assertEqual(rec_err, [
            'DF3',
        ] * 3)

        rec_norm = []
        rec_err = []
        set_retry_mode(True)
        df2 = self.mock_action(df1, 1, 'DF2', _action)
        df3 = self.mock_action(df2, 1, 'DF3', _action)
        df3.persist('out_table')
        self.assertEqual(rec_norm, [
            'DF3',
        ])
        self.assertEqual(rec_err, [])
コード例 #3
0
 def tearDown(self):
     super(Test, self).tearDown()
     set_retry_mode(False)
コード例 #4
0
 def tearDown(self):
     super(Test, self).tearDown()
     set_retry_mode(False)