Ejemplo n.º 1
0
 def test_target_path_exists_rename_fails_snakebite(self, remove, rename):
     rename.side_effect = hdfs.get_autoconfig_client(
         threading.local()).rename
     with hdfs.HdfsAtomicWritePipe(self.path) as fobj:
         fobj.write(b'test1')
     fobj = hdfs.HdfsAtomicWriteDirPipe(self.path)
     self.assertRaises(HdfsAtomicWriteError, fobj.close)
Ejemplo n.º 2
0
    def test_target_path_exists(self):
        with hdfs.HdfsAtomicWriteDirPipe(self.path) as fobj:
            fobj.write(b'test1')
        with hdfs.HdfsAtomicWritePipe(self.path) as fobj:
            fobj.write(b'test2')

        with HdfsReadPipe(self.path) as read_pipe:
            contents = read_pipe.read()

        self.assertEqual(b'test2', contents)
Ejemplo n.º 3
0
 def test_readback(self):
     pipe = hdfs.HdfsAtomicWriteDirPipe(self.path)
     self.assertFalse(self.fs.exists(self.path))
     pipe.write(b"foo\nbar")
     pipe.close()
     self.assertTrue(hdfs.exists(self.path))
     dirlist = hdfs.listdir(self.path)
     datapath = '%s/data' % self.path
     returnlist = [d for d in dirlist]
     self.assertTrue(returnlist[0].endswith(datapath))
     pipe = hdfs.HdfsReadPipe(datapath)
     self.assertEqual(pipe.read(), b"foo\nbar")
Ejemplo n.º 4
0
 def test_target_path_exists_rename_fails_hadoopcli(self, remove):
     with hdfs.HdfsAtomicWritePipe(self.path) as fobj:
         fobj.write(b'test1')
     fobj = hdfs.HdfsAtomicWriteDirPipe(self.path)
     self.assertRaises(hdfs.HDFSCliError, fobj.close)
Ejemplo n.º 5
0
 def test_rename_into_existing_subdir_after_failed_remove(self, remove):
     with hdfs.HdfsAtomicWriteDirPipe(self.path) as fobj:
         fobj.write(b'test1')
     fobj = hdfs.HdfsAtomicWriteDirPipe(self.path)
     self.assertRaises(HdfsAtomicWriteError, fobj.close)
Ejemplo n.º 6
0
 def test_atomicity(self):
     pipe = hdfs.HdfsAtomicWriteDirPipe(self.path)
     self.assertFalse(self.fs.exists(self.path))
     pipe.close()
     self.assertTrue(self.fs.exists(self.path))