Example #1
0
    def test_posix_destination_w_error(self):
        with stor.NamedTemporaryDirectory() as tmp_d:
            invalid_source = tmp_d / 'source'
            dest = tmp_d / 'my' / 'dest'

            with self.assertRaises(OSError):
                utils.copytree(invalid_source, dest)
Example #2
0
    def test_posix_destination_already_exists(self):
        with stor.NamedTemporaryDirectory() as tmp_d:
            source = tmp_d / '1'
            source.makedirs_p()

            with self.assertRaisesRegexp(OSError, 'exists'):
                utils.copytree(source, tmp_d)
Example #3
0
    def test_ambigious_swift_resource_destination(self):
        with stor.NamedTemporaryDirectory() as tmp_d:
            source = tmp_d / '1'
            with open(source, 'w') as tmp_file:
                tmp_file.write('1')

            dest = 'swift://tenant/container/ambiguous-resource'
            with self.assertRaisesRegexp(ValueError, 'OBS destination'):
                utils.copy(source, dest)
Example #4
0
    def test_posix_destination_w_cmd(self):
        with stor.NamedTemporaryDirectory() as tmp_d:
            source = tmp_d / 'source'
            os.mkdir(source)
            with open(source / '1', 'w') as tmp_file:
                tmp_file.write('1')

            dest = tmp_d / 'my' / 'dest'
            utils.copytree(source, dest, copy_cmd='cp -r')
            self.assertTrue((dest / '1').exists())
Example #5
0
    def test_tenant_swift_destination(self):
        with stor.NamedTemporaryDirectory() as tmp_d:
            source = tmp_d / 'source'
            os.mkdir(source)
            with open(source / '1', 'w') as tmp_file:
                tmp_file.write('1')

            dest = 'swift://tenant/'
            with self.assertRaisesRegexp(ValueError, 'copy to tenant'):
                utils.copy(source / '1', dest)
Example #6
0
    def test_posix_file_destination(self):
        with stor.NamedTemporaryDirectory() as tmp_d:
            source = tmp_d / 'source'
            os.mkdir(source)
            with open(source / '1', 'w') as tmp_file:
                tmp_file.write('1')

            dest = tmp_d / 'my' / 'dest' / '1'
            dest.parent.makedirs_p()
            utils.copy(source / '1', dest)
            self.assertTrue(dest.exists())
            self.assertEquals(dest.open().read(), '1')
Example #7
0
 def test_broken_symlink_file_name_truncation(self):
     with stor.NamedTemporaryDirectory(dir=self.swift_dir) as tmp_dir:
         # finally make enough symlinks to trigger log trimming (currently
         # untested but we want to make sure we don't error) + hits some
         # issues if path to the test file is so long that even 1 file is >
         # 50 characters, so we skip coverage check because it's not
         # worth the hassle to get full branch coverage for big edge case
         super_long_name = tmp_dir / 'abcdefghijklmnopqrstuvwxyzrsjexcasdfawefawefawefawefaef'
         for x in range(5):
             os.symlink(super_long_name, super_long_name + str(x))
         # have no errors! yay!
         self.assert_(utils.walk_files_and_dirs([self.swift_dir]))
         for x in range(5, 20):
             os.symlink(super_long_name, super_long_name + str(x))
         # have no errors! yay!
         self.assert_(utils.walk_files_and_dirs([self.swift_dir]))
Example #8
0
 def setUp(self):
     super(FilesystemIntegrationTest, self).setUp()
     ntp_obj = stor.NamedTemporaryDirectory()
     # ensure that it's empty and does not exist to start
     self.test_dir = stor.join(ntp_obj.__enter__(), 'parent')
     self.addCleanup(ntp_obj.__exit__, None, None, None)