Example #1
0
    def test_check_writer_consistency(self):
        # given
        options = self.get_writer_config()
        options['options']['check_consistency'] = True

        # when:
        writer = FSWriter(options, meta())
        try:
            writer.write_batch(self.get_batch())
            writer.flush()

        finally:
            writer.close()

        # Consistency check passes
        writer.finish_writing()

        with open(os.path.join(self.tmp_dir, 'exporter_test0000.jl.gz'), 'w'):
            with self.assertRaisesRegexp(InconsistentWriteState,
                                         'Wrong size for file'):
                writer.finish_writing()

        os.remove(os.path.join(self.tmp_dir, 'exporter_test0000.jl.gz'))
        with self.assertRaisesRegexp(InconsistentWriteState,
                                     'file is not present at destination'):
            writer.finish_writing()
Example #2
0
    def test_check_writer_consistency(self):
        # given
        options = self.get_writer_config()
        options['options']['check_consistency'] = True

        # when:
        writer = FSWriter(options, meta())
        try:
            writer.write_batch(self.get_batch())
            writer.flush()

        finally:
            writer.close()

        # Consistency check passes
        writer.finish_writing()

        with open(os.path.join(self.tmp_dir, 'exporter_test0000.jl.gz'), 'w'):
            with self.assertRaisesRegexp(InconsistentWriteState, 'Wrong size for file'):
                writer.finish_writing()

        os.remove(os.path.join(self.tmp_dir, 'exporter_test0000.jl.gz'))
        with self.assertRaisesRegexp(InconsistentWriteState, 'file is not present at destination'):
            writer.finish_writing()