Example #1
0
    def test_iput_large_file(self):
        # pick session(s) for the test
        test_session = self.user_sessions[0]

        # make test file
        filename = "iput_test_file"
        filesize = self.config["large_file_size"]
        filepath = os.path.join(self.local_test_dir_path, filename)
        lib.make_file(filepath, filesize)

        # test specific parameters
        parameters = self.config.copy()
        parameters["filepath"] = filepath
        parameters["filename"] = filename
        parameters["user_name"] = test_session.username
        parameters["remote_home_collection"] = "/{remote_zone}/home/{user_name}#{local_zone}".format(**parameters)

        # put file in remote collection, ask for 6 threads
        test_session.assert_icommand(
            "iput -v -N 6 {filepath} {remote_home_collection}/".format(**parameters), "STDOUT_SINGLELINE", "6 thr"
        )

        # file should be there
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{filename}".format(**parameters), "STDOUT_SINGLELINE", filename
        )
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{filename}".format(**parameters), "STDOUT_SINGLELINE", str(filesize)
        )

        # cleanup
        test_session.assert_icommand("irm -f {remote_home_collection}/{filename}".format(**parameters))
        os.remove(filepath)
Example #2
0
 def test_parallel_write(self):
     num_files = 4
     files = [
         tempfile.NamedTemporaryFile(prefix='test_fuse.test_parallel_copy')
         for i in range(num_files)
     ]
     with contextlib.nested(*files):
         hashes = []
         for f in files:
             lib.make_file(f.name, pow(10, 8), 'arbitrary')
             hashes.append(lib.md5_hex_file(f.name))
         proc_pool = multiprocessing.Pool(len(files))
         proc_pool_results = [
             proc_pool.apply_async(
                 shutil.copyfile,
                 (f.name,
                  os.path.join(self.mount_point, os.path.basename(f.name))))
             for f in files
         ]
         for r in proc_pool_results:
             r.get()
         for f, h in zip(files, hashes):
             self.admin.assert_icommand(['ils', '-L'], 'STDOUT_SINGLELINE',
                                        os.path.basename(f.name))
             with tempfile.NamedTemporaryFile(
                     prefix='test_fuse.test_parallel_copy_get') as fget:
                 self.admin.assert_icommand(
                     ['iget', '-f',
                      os.path.basename(f.name), fget.name])
                 assert lib.md5_hex_file(fget.name) == h
Example #3
0
 def test_iphymv_invalid_resource__2821(self):
     filepath = os.path.join(self.admin.local_session_dir, 'file')
     lib.make_file(filepath, 1)
     dest_path = self.admin.session_collection + '/file'
     self.admin.assert_icommand('iput ' + filepath)
     self.admin.assert_icommand('iphymv -S invalidResc -R demoResc '+dest_path, 'STDERR_SINGLELINE', 'SYS_RESC_DOES_NOT_EXIST')
     self.admin.assert_icommand('iphymv -S demoResc -R invalidResc '+dest_path, 'STDERR_SINGLELINE', 'SYS_RESC_DOES_NOT_EXIST')
Example #4
0
    def test_irm_f(self):
        # pick session(s) for the test
        test_session = self.user_sessions[0]

        # make test file
        filename = "irm_test_file"
        filesize = self.config["test_file_size"]
        filepath = os.path.join(self.local_test_dir_path, filename)
        lib.make_file(filepath, filesize)

        # test specific parameters
        parameters = self.config.copy()
        parameters["filepath"] = filepath
        parameters["filename"] = filename
        parameters["user_name"] = test_session.username
        parameters["remote_home_collection"] = "/{remote_zone}/home/{user_name}#{local_zone}".format(**parameters)

        # put file in remote collection
        test_session.assert_icommand("iput {filepath} {remote_home_collection}/".format(**parameters))

        # file should be there
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{filename}".format(**parameters), "STDOUT_SINGLELINE", filename
        )

        # delete remote file
        test_session.assert_icommand("irm -f {remote_home_collection}/{filename}".format(**parameters))

        # file should be gone
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{filename}".format(**parameters), "STDERR_SINGLELINE", "does not exist"
        )

        # cleanup
        os.remove(filepath)
Example #5
0
    def test_ils_l(self):
        # make test file
        filename = 'ils_test_file'
        filesize = self.config['test_file_size']
        filepath = os.path.abspath(filename)
        lib.make_file(filename, filesize)

        kwargs = {'filename': filename,
                  'collection': self.config['remote_home_coll']}
        kwargs.update(self.config)

        # list remote home collection
        self.admin_sessions[0].assert_icommand(
            "ils -L {collection}".format(**kwargs), 'STDOUT_SINGLELINE', kwargs['collection'])

        # put file in remote collection
        self.admin_sessions[0].assert_icommand(
            "iput {filename} {collection}/".format(**kwargs))

        # list file info
        self.admin_sessions[0].assert_icommand(
            "ils -L {collection}/{filename}".format(**kwargs), 'STDOUT_SINGLELINE', filename)
        self.admin_sessions[0].assert_icommand(
            "ils -L {collection}/{filename}".format(**kwargs), 'STDOUT_SINGLELINE', str(filesize))
        self.admin_sessions[0].assert_icommand(
            "ils -L {collection}/{filename}".format(**kwargs), 'STDOUT_SINGLELINE', kwargs['remote_resc'])
        self.admin_sessions[0].assert_icommand(
            "ils -L {collection}/{filename}".format(**kwargs), 'STDOUT_SINGLELINE', kwargs['remote_vault'])

        # cleanup
        self.admin_sessions[0].assert_icommand(
            "irm -f {collection}/{filename}".format(**kwargs))
        os.remove(filepath)
    def test_auth_pep(self):
        rules_to_prepend = """
pep_resource_resolve_hierarchy_pre(*A,*B,*OUT,*E,*F,*G,*H){
*OUT = "THIS IS AN OUT VARIABLE"
}
pep_resource_resolve_hierarchy_post(*A,*B,*OUT,*E,*F,*G,*H){
writeLine( 'serverLog', '*OUT')
}
"""
        corefile = lib.get_core_re_dir() + "/core.re"

        with lib.file_backed_up(corefile):
            time.sleep(1)  # remove once file hash fix is commited #2279
            lib.prepend_string_to_file(rules_to_prepend, corefile)
            time.sleep(1)  # remove once file hash fix is commited #2279

            initial_size_of_server_log = lib.get_log_size('server')

            filename = "test_re_serialization.txt"
            lib.make_file(filename, 1000)

            self.admin.assert_icommand("iput -f --metadata ATTR;VALUE;UNIT " +
                                       filename)

            out_count = lib.count_occurrences_of_string_in_log(
                'server',
                'THIS IS AN OUT VARIABLE',
                start_index=initial_size_of_server_log)
        output = commands.getstatusoutput('rm ' + filename)

        print("counts: " + str(out_count))

        assert 1 == out_count
Example #7
0
    def test_iget(self):
        # make test file
        filename = 'iget_test_file'
        filesize = self.config['test_file_size']
        filepath = os.path.abspath(filename)
        lib.make_file(filename, filesize)

        kwargs = {'filename': filename,
                  'collection': self.config['remote_home_coll']}

        # checksum local file
        orig_md5 = commands.getoutput('md5sum ' + filepath)

        # put file in remote collection
        self.admin_sessions[0].assert_icommand(
            "iput {filename} {collection}/".format(**kwargs))

        # remove local file
        os.remove(filepath)

        # get file back
        self.admin_sessions[0].assert_icommand(
            "iget {collection}/{filename}".format(**kwargs))

        # compare checksums
        new_md5 = commands.getoutput('md5sum ' + filepath)
        self.assertEqual(orig_md5, new_md5)

        # cleanup
        self.admin_sessions[0].assert_icommand(
            "irm -f {collection}/{filename}".format(**kwargs))
        os.remove(filepath)
Example #8
0
    def test_irm_f(self):
        # make test file
        filename = 'irm_test_file'
        filesize = self.config['test_file_size']
        filepath = os.path.abspath(filename)
        lib.make_file(filename, filesize)

        kwargs = {'filename': filename,
                  'collection': self.config['remote_home_coll']}

        # put file in remote collection
        self.admin_sessions[0].assert_icommand(
            "iput {filename} {collection}/".format(**kwargs))

        # file should be there
        self.admin_sessions[0].assert_icommand(
            "ils -L {collection}/{filename}".format(**kwargs), 'STDOUT_SINGLELINE', filename)

        # delete remote file
        self.admin_sessions[0].assert_icommand(
            "irm -f {collection}/{filename}".format(**kwargs))

        # file should be gone
        self.admin_sessions[0].assert_icommand(
            "ils -L {collection}/{filename}".format(**kwargs), 'STDERR_SINGLELINE', 'does not exist')

        # cleanup
        os.remove(filepath)
Example #9
0
    def test_iget_large_file(self):
        # make test file
        filename = 'iget_test_file'
        filesize = self.config['large_file_size']
        filepath = os.path.abspath(filename)
        lib.make_file(filename, filesize)

        kwargs = {'filename': filename,
                  'collection': self.config['remote_home_coll']}

        # checksum local file
        orig_md5 = commands.getoutput('md5sum ' + filepath)

        # put file in remote collection
        self.admin_sessions[0].assert_icommand(
            "iput {filename} {collection}/".format(**kwargs))

        # remove local file
        os.remove(filepath)

        # get file back, ask for too many threads (should be capped)
        self.admin_sessions[0].assert_icommand(
            "iget -v -N 600 {collection}/{filename}".format(**kwargs), 'STDOUT_SINGLELINE', '16 thr')

        # compare checksums
        new_md5 = commands.getoutput('md5sum ' + filepath)
        self.assertEqual(orig_md5, new_md5)

        # cleanup
        self.admin_sessions[0].assert_icommand(
            "irm -f {collection}/{filename}".format(**kwargs))
        os.remove(filepath)
Example #10
0
 def test_iquota__3044(self):
     myfile = 'quotafile'
     corefile = lib.get_core_re_dir() + "/core.re"
     with lib.file_backed_up(corefile):
         rules_to_prepend = 'acRescQuotaPolicy {msiSetRescQuotaPolicy("on"); }\n'
         time.sleep(2)  # remove once file hash fix is commited #2279
         lib.prepend_string_to_file(rules_to_prepend, corefile)
         time.sleep(2)  # remove once file hash fix is commited #2279
         for quotatype in [['suq',self.admin.username], ['sgq','public']]: # user and group
             for quotaresc in [self.testresc, 'total']: # resc and total
                 cmd = 'iadmin {0} {1} {2} 8000'.format(quotatype[0], quotatype[1], quotaresc) # set high quota
                 self.admin.assert_icommand(cmd.split())
                 cmd = 'irepl -R {0} {1}'.format(self.testresc, self.testfile)
                 self.admin.assert_icommand(cmd.split())
                 cmd = 'iadmin cu' # calculate, update db
                 self.admin.assert_icommand(cmd.split())
                 cmd = 'iquota'
                 self.admin.assert_icommand(cmd.split(), 'STDOUT_SINGLELINE', 'Nearing quota') # not over yet
                 cmd = 'iadmin {0} {1} {2} 40'.format(quotatype[0], quotatype[1], quotaresc) # set low quota
                 self.admin.assert_icommand(cmd.split())
                 cmd = 'iquota'
                 self.admin.assert_icommand(cmd.split(), 'STDOUT_SINGLELINE', 'OVER QUOTA') # confirm it's over
                 lib.make_file(myfile, 30, contents='arbitrary')
                 cmd = 'iput -R {0} {1}'.format(self.testresc, myfile) # should fail
                 self.admin.assert_icommand(cmd.split(), 'STDERR_SINGLELINE', 'SYS_RESC_QUOTA_EXCEEDED')
                 cmd = 'iadmin {0} {1} {2} 0'.format(quotatype[0], quotatype[1], quotaresc) # remove quota
                 self.admin.assert_icommand(cmd.split())
                 cmd = 'iadmin cu' # update db
                 self.admin.assert_icommand(cmd.split())
                 cmd = 'iput -R {0} {1}'.format(self.testresc, myfile) # should succeed again
                 self.admin.assert_icommand(cmd.split())
                 cmd = 'irm -rf {0}'.format(myfile) # clean up
                 self.admin.assert_icommand(cmd.split())
         time.sleep(2)  # remove once file hash fix is commited #2279
Example #11
0
 def test_iput_options(self):
     self.admin.assert_icommand('ichmod read ' + self.user0.username + ' ' + self.admin.session_collection)
     self.admin.assert_icommand('ichmod read ' + self.user1.username + ' ' + self.admin.session_collection)
     zero_filepath = os.path.join(self.admin.local_session_dir, 'zero')
     lib.touch(zero_filepath)
     self.admin.assert_icommand('iput --metadata "a;v;u;a0;v0" --acl "read ' + self.user0.username + ';'
                                + 'write ' + self.user1.username + ';" -- ' + zero_filepath)
     self.admin.assert_icommand('imeta ls -d zero', 'STDOUT',
                                '(attribute: *a0?\nvalue: *v0?\nunits: *u?(\n-+ *\n)?){2}', use_regex=True)
     self.admin.assert_icommand('iget -- ' + self.admin.session_collection + '/zero ' + self.admin.local_session_dir + '/newzero')
     self.user0.assert_icommand('iget -- ' + self.admin.session_collection + '/zero ' + self.user0.local_session_dir + '/newzero')
     filepath = os.path.join(self.admin.local_session_dir, 'file')
     lib.make_file(filepath, 1)
     self.admin.assert_icommand('iput --metadata "a;v;u;a2;v2" --acl "read ' + self.user0.username + ';'
                                + 'write ' + self.user1.username + ';" -- ' + filepath)
     self.admin.assert_icommand('imeta ls -d file', 'STDOUT',
                                '(attribute: *a2?\nvalue: *v2?\nunits: *u?(\n-+ *\n)?){2}', use_regex=True)
     self.admin.assert_icommand('ils -l', 'STDOUT')
     self.admin.assert_icommand('iget -- ' + self.admin.session_collection + '/file ' + self.admin.local_session_dir + '/newfile')
     self.user0.assert_icommand('iget -- ' + self.admin.session_collection + '/file ' + self.user0.local_session_dir + '/newfile')
     new_filepath = os.path.join(self.user1.local_session_dir, 'file')
     # skip the end until the iput -f of unowned files is resolved
     lib.make_file(new_filepath, 2)
     self.admin.assert_icommand('iput -f -- ' + filepath + ' ' + self.admin.session_collection + '/file')
     self.user1.assert_icommand('iput -f -- ' + new_filepath + ' ' + self.admin.session_collection + '/file')
Example #12
0
 def test_ichmod_r(self):
     self.admin.assert_icommand('imkdir -p sub_dir1\\\\%/subdir2/')
     self.admin.assert_icommand('ichmod read ' + self.user0.username + ' -r sub_dir1\\\\%/')
     self.admin.assert_icommand('ichmod inherit -r sub_dir1\\\\%/')
     filepath = os.path.join(self.admin.local_session_dir, 'file')
     lib.make_file(filepath, 1)
     self.admin.assert_icommand('iput ' + filepath + ' sub_dir1\\\\%/subdir2/')
     self.user0.assert_icommand('iget ' + self.admin.session_collection + '/sub_dir1\\\\%/subdir2/file ' + os.path.join(self.user0.local_session_dir, ''))
Example #13
0
 def helper_irodsFs_cp_into_mount_point(self, target_dir, filesize):
     with tempfile.NamedTemporaryFile(prefix=sys._getframe().f_code.co_name) as f:
         lib.make_file(f.name, filesize, 'arbitrary')
         hash_ = lib.md5_hex_file(f.name)
         shutil.copy(f.name, target_dir)
     fullpath = os.path.join(target_dir, os.path.basename(f.name))
     assert os.stat(fullpath).st_size == filesize
     return fullpath, hash_
Example #14
0
 def helper_irodsFs_cp_into_mount_point(self, target_dir, filesize):
     with tempfile.NamedTemporaryFile(
             prefix=sys._getframe().f_code.co_name) as f:
         lib.make_file(f.name, filesize, 'arbitrary')
         hash_ = lib.md5_hex_file(f.name)
         shutil.copy(f.name, target_dir)
     fullpath = os.path.join(target_dir, os.path.basename(f.name))
     assert os.stat(fullpath).st_size == filesize
     return fullpath, hash_
Example #15
0
 def test_local_iput_with_really_big_file__ticket_1623(self):
     filename = "reallybigfile.txt"
     # file size larger than 32 bit int
     lib.make_file(filename, pow(2, 31) + 100)
     print "file size = [" + str(os.stat(filename).st_size) + "]"
     # should not be listed
     self.admin.assert_icommand("ils -L " + filename, 'STDERR', [filename, "does not exist"])
     self.admin.assert_icommand("iput " + filename)  # iput
     self.admin.assert_icommand("ils -L " + filename, 'STDOUT', filename)  # should be listed
     output = commands.getstatusoutput('rm ' + filename)
Example #16
0
    def test_iphymv_unable_to_unlink__2820(self):
        filepath = os.path.join(self.admin.local_session_dir, 'file')
        lib.make_file(filepath, 1)
        dest_path = self.admin.session_collection + '/file'
        self.admin.assert_icommand('ireg '+filepath+' '+dest_path)

        os.chmod(filepath, 0444)
        self.admin.assert_icommand('iphymv -S demoResc -R pydevtest_TestResc '+dest_path, 'STDERR_SINGLELINE', 'SYS_USER_NO_PERMISSION')
        
        os.chmod(filepath, 0666)
        self.admin.assert_icommand('iphymv -S demoResc -R pydevtest_TestResc '+dest_path)
Example #17
0
 def test_ireg_new_replica__2847(self):
     filename = 'regfile.txt'
     filename2 = filename+'2'
     os.system('rm -f {0} {1}'.format(filename, filename2))
     lib.make_file(filename, 234)
     os.system('cp {0} {1}'.format(filename, filename2))
     self.admin.assert_icommand('ireg -Kk -R {0} {1} {2}'.format(self.testresc, os.path.abspath(filename), self.admin.session_collection+'/'+filename))
     self.admin.assert_icommand('ils -L', 'STDOUT_SINGLELINE', [' 0 '+self.testresc, '& '+filename])
     self.admin.assert_icommand('ireg -Kk --repl -R {0} {1} {2}'.format(self.anotherresc, os.path.abspath(filename2), self.admin.session_collection+'/'+filename))
     self.admin.assert_icommand('ils -L', 'STDOUT_SINGLELINE', [' 1 '+self.anotherresc, '& '+filename])
     os.system('rm -f {0} {1}'.format(filename, filename2))
Example #18
0
 def ticket_bytes_put(self, ticket, data_obj, filepath):
     lib.make_file(filepath, 2)
     self.admin.assert_icommand('iticket mod ' + ticket + ' write-byte 6')
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj)
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj)
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj)
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj, 'STDERR')
     self.admin.assert_icommand('iticket mod ' + ticket + ' write-byte 8')
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj)
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj, 'STDERR')
     self.admin.assert_icommand('iticket mod ' + ticket + ' write-byte 0')
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj)
Example #19
0
 def ticket_bytes_put(self, ticket, data_obj, filepath):
     lib.make_file(filepath, 2)
     self.admin.assert_icommand('iticket mod ' + ticket + ' write-byte 6')
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj)
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj)
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj)
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj, 'STDERR')
     self.admin.assert_icommand('iticket mod ' + ticket + ' write-byte 8')
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj)
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj, 'STDERR')
     self.admin.assert_icommand('iticket mod ' + ticket + ' write-byte 0')
     self.user.assert_icommand('iput -ft ' + ticket + ' ' + filepath + ' ' + data_obj)
Example #20
0
def helper_irodsFs_iput_to_mv(self, filesize):
    with tempfile.NamedTemporaryFile(prefix=sys._getframe().f_code.co_name + '_0') as f:
        lib.make_file(f.name, filesize, 'arbitrary')
        hash0 = lib.md5_hex_file(f.name)
        self.admin.assert_icommand(['iput', f.name])
    basename = os.path.basename(f.name)
    self.helper_irodsFs_stat(basename, self.mount_point, self.admin.session_collection, filesize)
    with tempfile.NamedTemporaryFile(prefix=sys._getframe().f_code.co_name + '_1') as f:
        shutil.move(os.path.join(self.mount_point, basename), f.name)
        assert basename not in os.listdir(self.mount_point)
        self.admin.assert_icommand_fail(['ils'], 'STDOUT_SINGLELINE', basename)
        hash1 = lib.md5_hex_file(f.name)
        assert hash0 == hash1
Example #21
0
 def test_ichmod_r(self):
     self.admin.assert_icommand('imkdir -p sub_dir1\\\\%/subdir2/')
     self.admin.assert_icommand('ichmod read ' + self.user0.username +
                                ' -r sub_dir1\\\\%/')
     self.admin.assert_icommand('ichmod inherit -r sub_dir1\\\\%/')
     filepath = os.path.join(self.admin.local_session_dir, 'file')
     lib.make_file(filepath, 1)
     self.admin.assert_icommand('iput ' + filepath +
                                ' sub_dir1\\\\%/subdir2/')
     self.user0.assert_icommand(
         'iget ' + self.admin.session_collection +
         '/sub_dir1\\\\%/subdir2/file ' +
         os.path.join(self.user0.local_session_dir, ''))
Example #22
0
 def test_iput_options(self):
     filepath = os.path.join( self.admin.local_session_dir, 'file' )
     lib.make_file( filepath, 1 )
     self.admin.assert_icommand('iput --metadata "a;v;u;a2;v2" --acl "read ' + self.user0.username + ';" ' + filepath )
             #+ 'write ' + self.user1.username + ';" -- ' + filepath )
     self.admin.assert_icommand('ichmod read ' + self.user0.username + ' ' + self.admin.session_collection )
     self.admin.assert_icommand('ichmod read ' + self.user1.username + ' ' + self.admin.session_collection )
     self.admin.assert_icommand('imeta ls -d file', 'STDOUT',
             '(attribute: *a2?\nvalue: *v2?\nunits: *u?(\n-+ *\n)?){2}', use_regex=True )
     self.admin.assert_icommand('ils -l', 'STDOUT')
     self.admin.assert_icommand('iget -- ' + self.admin.session_collection + '/file ' + self.admin.local_session_dir + '/newfile' )
     self.user0.assert_icommand('iget -- ' + self.admin.session_collection + '/file ' + self.user0.local_session_dir + '/newfile' )
     new_filepath = os.path.join( self.user1.local_session_dir, 'file' )
Example #23
0
    def test_icp(self):
        # pick session(s) for the test
        test_session = self.user_sessions[0]

        # make test file
        filename = "icp_test_file"
        filesize = self.config["test_file_size"]
        filepath = os.path.join(self.local_test_dir_path, filename)
        lib.make_file(filepath, filesize)

        # test specific parameters
        parameters = self.config.copy()
        parameters["filepath"] = filepath
        parameters["filename"] = filename
        parameters["user_name"] = test_session.username
        parameters["local_home_collection"] = test_session.home_collection
        parameters["remote_home_collection"] = "/{remote_zone}/home/{user_name}#{local_zone}".format(**parameters)

        # checksum local file
        orig_md5 = commands.getoutput("md5sum " + filepath)

        # put file in local collection
        test_session.assert_icommand("iput {filepath} {local_home_collection}/".format(**parameters))

        # remove local file
        os.remove(filepath)

        # copy file to remote home collection
        test_session.assert_icommand(
            "icp {local_home_collection}/{filename} {remote_home_collection}/".format(**parameters)
        )

        # file should show up in remote zone
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{filename}".format(**parameters), "STDOUT_SINGLELINE", filename
        )
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{filename}".format(**parameters), "STDOUT_SINGLELINE", str(filesize)
        )

        # get file back from remote zone
        test_session.assert_icommand("iget {remote_home_collection}/{filename} {filepath}".format(**parameters))

        # compare checksums
        new_md5 = commands.getoutput("md5sum " + filepath)
        self.assertEqual(orig_md5, new_md5)

        # cleanup
        test_session.assert_icommand("irm -f {local_home_collection}/{filename}".format(**parameters))
        test_session.assert_icommand("irm -f {remote_home_collection}/{filename}".format(**parameters))
        os.remove(filepath)
Example #24
0
    def test_iticket_put(self):
        filename = 'TicketTestFile'
        filepath = os.path.join(self.admin.local_session_dir, filename)
        lib.make_file(filepath, 1)
        collection = self.admin.session_collection + '/dir'
        data_obj = collection + '/' + filename

        self.admin.assert_icommand('imkdir ' + collection)
        self.admin.assert_icommand('iput ' + filepath + ' ' + data_obj)
        self.admin.assert_icommand('ils -l ' + collection, 'STDOUT')
        self.user.assert_icommand('ils -l ' + collection, 'STDERR')
        self.anon.assert_icommand('ils -l ' + collection, 'STDERR')
        self.ticket_put_on(data_obj, data_obj, filepath)
        self.ticket_put_on(collection, data_obj, filepath)
    def test_rule_engine_2309(self):
        corefile = lib.get_core_re_dir() + "/core.re"
        coredvm = lib.get_core_re_dir() + "/core.dvm"
        with lib.file_backed_up(coredvm):
            lib.prepend_string_to_file('oprType||rei->doinp->oprType\n',
                                       coredvm)
            with lib.file_backed_up(corefile):
                initial_size_of_server_log = lib.get_log_size('server')
                rules_to_prepend = '''
 acSetNumThreads() {
     writeLine("serverLog","test_rule_engine_2309: put: acSetNumThreads oprType [$oprType]");
 }
 '''
                time.sleep(1)  # remove once file hash fix is commited #2279
                lib.prepend_string_to_file(rules_to_prepend, corefile)
                time.sleep(1)  # remove once file hash fix is commited #2279
                trigger_file = 'file_to_trigger_acSetNumThreads'
                lib.make_file(trigger_file, 4 * pow(10, 7))
                self.admin.assert_icommand('iput {0}'.format(trigger_file))
                assert 1 == lib.count_occurrences_of_string_in_log(
                    'server',
                    'writeLine: inString = test_rule_engine_2309: put: acSetNumThreads oprType [1]',
                    start_index=initial_size_of_server_log)
                assert 0 == lib.count_occurrences_of_string_in_log(
                    'server',
                    'RE_UNABLE_TO_READ_SESSION_VAR',
                    start_index=initial_size_of_server_log)
                os.unlink(trigger_file)

            with lib.file_backed_up(corefile):
                initial_size_of_server_log = lib.get_log_size('server')
                rules_to_prepend = '''
acSetNumThreads() {
    writeLine("serverLog","test_rule_engine_2309: get: acSetNumThreads oprType [$oprType]");
}
'''
                time.sleep(1)  # remove once file hash fix is commited #2279
                lib.prepend_string_to_file(rules_to_prepend, corefile)
                time.sleep(1)  # remove once file hash fix is commited #2279
                self.admin.assert_icommand('iget {0}'.format(trigger_file),
                                           use_unsafe_shell=True)
                assert 1 == lib.count_occurrences_of_string_in_log(
                    'server',
                    'writeLine: inString = test_rule_engine_2309: get: acSetNumThreads oprType [2]',
                    start_index=initial_size_of_server_log)
                assert 0 == lib.count_occurrences_of_string_in_log(
                    'server',
                    'RE_UNABLE_TO_READ_SESSION_VAR',
                    start_index=initial_size_of_server_log)
                os.unlink(trigger_file)
Example #26
0
    def test_iticket_put(self):
        filename = 'TicketTestFile'
        filepath = os.path.join(self.admin.local_session_dir, filename)
        lib.make_file(filepath, 1)
        collection = self.admin.session_collection + '/dir'
        data_obj = collection + '/' + filename

        self.admin.assert_icommand('imkdir ' + collection)
        self.admin.assert_icommand('iput ' + filepath + ' ' + data_obj)
        self.admin.assert_icommand('ils -l ' + collection, 'STDOUT')
        self.user.assert_icommand('ils -l ' + collection, 'STDERR')
        self.anon.assert_icommand('ils -l ' + collection, 'STDERR')
        self.ticket_put_on(data_obj, data_obj, filepath)
        self.ticket_put_on(collection, data_obj, filepath)
Example #27
0
 def test_irm_repeated_many_times(self):
     # repeat count
     many_times = 50
     # create file
     filename = "originalfile.txt"
     filepath = os.path.abspath(filename)
     lib.make_file(filepath, 15)
     # define
     trashpath = "/" + self.admin.zone_name + "/trash/home/" + self.admin.username + \
         "/" + self.admin._session_id
     # loop
     for i in range(many_times):
         self.admin.assert_icommand("iput " + filename, "EMPTY")  # put the file
         self.admin.assert_icommand("irm " + filename, "EMPTY")  # delete the file
         self.admin.assert_icommand("ils -L " + trashpath, "STDOUT", filename)
Example #28
0
    def test_icp_f_large(self):
        # test settings
        remote_zone = self.config["remote_zone"]
        test_session = self.user_sessions[0]
        local_zone = test_session.zone_name
        user_name = test_session.username
        local_home_collection = test_session.home_collection
        remote_home_collection = "/{remote_zone}/home/{user_name}#{local_zone}".format(**locals())

        # make test file
        filename = "icp_test_file"
        filesize = self.config["large_file_size"]
        filepath = os.path.join(self.local_test_dir_path, filename)
        lib.make_file(filepath, filesize)

        # checksum local file
        orig_md5 = commands.getoutput("md5sum " + filepath)

        # put file in local collection
        test_session.assert_icommand("iput {filepath} {local_home_collection}/".format(**locals()))

        # remove local file
        os.remove(filepath)

        # copy file to remote home collection
        test_session.assert_icommand(
            "icp -f {local_home_collection}/{filename} {remote_home_collection}/".format(**locals())
        )

        # file should show up in remote zone
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{filename}".format(**locals()), "STDOUT_SINGLELINE", filename
        )
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{filename}".format(**locals()), "STDOUT_SINGLELINE", str(filesize)
        )

        # get file back from remote zone
        test_session.assert_icommand("iget {remote_home_collection}/{filename} {filepath}".format(**locals()))

        # compare checksums
        new_md5 = commands.getoutput("md5sum " + filepath)
        self.assertEqual(orig_md5, new_md5)

        # cleanup
        test_session.assert_icommand("irm -f {local_home_collection}/{filename}".format(**locals()))
        test_session.assert_icommand("irm -f {remote_home_collection}/{filename}".format(**locals()))
        os.remove(filepath)
Example #29
0
def helper_irodsFs_iput_to_mv(self, filesize):
    with tempfile.NamedTemporaryFile(prefix=sys._getframe().f_code.co_name +
                                     '_0') as f:
        lib.make_file(f.name, filesize, 'arbitrary')
        hash0 = lib.md5_hex_file(f.name)
        self.admin.assert_icommand(['iput', f.name])
    basename = os.path.basename(f.name)
    self.helper_irodsFs_stat(basename, self.mount_point,
                             self.admin.session_collection, filesize)
    with tempfile.NamedTemporaryFile(prefix=sys._getframe().f_code.co_name +
                                     '_1') as f:
        shutil.move(os.path.join(self.mount_point, basename), f.name)
        assert basename not in os.listdir(self.mount_point)
        self.admin.assert_icommand_fail(['ils'], 'STDOUT_SINGLELINE', basename)
        hash1 = lib.md5_hex_file(f.name)
        assert hash0 == hash1
Example #30
0
    def test_iget_large_file(self):
        # pick session(s) for the test
        test_session = self.user_sessions[0]

        # make test file
        filename = "iget_test_file"
        filesize = self.config["large_file_size"]
        filepath = os.path.join(self.local_test_dir_path, filename)
        lib.make_file(filepath, filesize)

        # test specific parameters
        parameters = self.config.copy()
        parameters["filepath"] = filepath
        parameters["filename"] = filename
        parameters["user_name"] = test_session.username
        parameters["remote_home_collection"] = "/{remote_zone}/home/{user_name}#{local_zone}".format(**parameters)

        # checksum local file
        orig_md5 = commands.getoutput("md5sum " + filepath)

        # put file in remote collection
        test_session.assert_icommand("iput {filepath} {remote_home_collection}/".format(**parameters))

        # remove local file
        os.remove(filepath)

        # for the next transfer we expect the number of threads
        # to be capped at max_threads or max_threads+1,
        # e.g: we will look for '16 thr' or '17 thr' in stdout
        parameters["max_threads_plus_one"] = parameters["max_threads"] + 1
        expected_output_regex = "[{max_threads}|{max_threads_plus_one}] thr".format(**parameters)

        # get file back, ask for too many threads (should be capped)
        test_session.assert_icommand(
            "iget -v -N 600 {remote_home_collection}/{filename} {filepath}".format(**parameters),
            "STDOUT_SINGLELINE",
            expected_output_regex,
            use_regex=True,
        )

        # compare checksums
        new_md5 = commands.getoutput("md5sum " + filepath)
        self.assertEqual(orig_md5, new_md5)

        # cleanup
        test_session.assert_icommand("irm -f {remote_home_collection}/{filename}".format(**parameters))
        os.remove(filepath)
Example #31
0
 def test_ireg_new_replica__2847(self):
     filename = 'regfile.txt'
     filename2 = filename + '2'
     os.system('rm -f {0} {1}'.format(filename, filename2))
     lib.make_file(filename, 234)
     os.system('cp {0} {1}'.format(filename, filename2))
     self.admin.assert_icommand('ireg -Kk -R {0} {1} {2}'.format(
         self.testresc, os.path.abspath(filename),
         self.admin.session_collection + '/' + filename))
     self.admin.assert_icommand('ils -L', 'STDOUT_SINGLELINE',
                                [' 0 ' + self.testresc, '& ' + filename])
     self.admin.assert_icommand('ireg -Kk --repl -R {0} {1} {2}'.format(
         self.anotherresc, os.path.abspath(filename2),
         self.admin.session_collection + '/' + filename))
     self.admin.assert_icommand('ils -L', 'STDOUT_SINGLELINE',
                                [' 1 ' + self.anotherresc, '& ' + filename])
     os.system('rm -f {0} {1}'.format(filename, filename2))
    def test_re_serialization(self):
        rules_to_prepend = """
pep_resource_resolve_hierarchy_pre(*A,*B,*OUT,*E,*F,*G,*H){
writeLine("serverLog", "pep_resource_resolve_hierarchy_pre - [*A] [*B] [*OUT] [*E] [*F] [*G] [*H]");
}
"""
        corefile = lib.get_core_re_dir() + "/core.re"

        with lib.file_backed_up(corefile):
            time.sleep(1)  # remove once file hash fix is commited #2279
            lib.prepend_string_to_file(rules_to_prepend, corefile)
            time.sleep(1)  # remove once file hash fix is commited #2279

            initial_size_of_server_log = lib.get_log_size('server')

            filename = "test_re_serialization.txt"
            lib.make_file(filename, 1000)

            self.admin.assert_icommand("iput -f --metadata ATTR;VALUE;UNIT " +
                                       filename)

            auth_count = lib.count_occurrences_of_string_in_log(
                'server',
                'user_auth_info_auth_flag=5',
                start_index=initial_size_of_server_log)
            zone_count = lib.count_occurrences_of_string_in_log(
                'server',
                'user_rods_zone=tempZone',
                start_index=initial_size_of_server_log)
            user_count = lib.count_occurrences_of_string_in_log(
                'server',
                'user_user_name=otherrods',
                start_index=initial_size_of_server_log)
            mdata_count = lib.count_occurrences_of_string_in_log(
                'server',
                'ATTR;VALUE;UNIT',
                start_index=initial_size_of_server_log)
        output = commands.getstatusoutput('rm ' + filename)

        print("counts: " + str(auth_count) + " " + str(zone_count) + " " +
              str(user_count) + " " + str(mdata_count))

        assert 1 == auth_count
        assert 1 == zone_count
        assert 1 == user_count
        assert 1 == mdata_count
Example #33
0
    def test_icp(self):
        # make test file
        filename = 'icp_test_file'
        filesize = self.config['test_file_size']
        filepath = os.path.abspath(filename)
        lib.make_file(filename, filesize)

        kwargs = {'filename': filename,
                  'remote_collection': self.config['remote_home_coll'],
                  'local_collection': self.config['local_home_coll']}

        # checksum local file
        orig_md5 = commands.getoutput('md5sum ' + filepath)

        # put file in local collection
        self.admin_sessions[0].assert_icommand(
            "iput {filename} {local_collection}/".format(**kwargs))

        # remove local file
        os.remove(filepath)

        # copy file to remote home collection
        self.admin_sessions[0].assert_icommand(
            "icp {local_collection}/{filename} {remote_collection}/".format(**kwargs))

        # file should show up in remote zone
        self.admin_sessions[0].assert_icommand(
            "ils -L {remote_collection}/{filename}".format(**kwargs), 'STDOUT_SINGLELINE', filename)
        self.admin_sessions[0].assert_icommand(
            "ils -L {remote_collection}/{filename}".format(**kwargs), 'STDOUT_SINGLELINE', str(filesize))

        # get file back from remote zone
        self.admin_sessions[0].assert_icommand(
            "iget {remote_collection}/{filename}".format(**kwargs))

        # compare checksums
        new_md5 = commands.getoutput('md5sum ' + filepath)
        self.assertEqual(orig_md5, new_md5)

        # cleanup
        self.admin_sessions[0].assert_icommand(
            "irm -f {local_collection}/{filename}".format(**kwargs))
        self.admin_sessions[0].assert_icommand(
            "irm -f {remote_collection}/{filename}".format(**kwargs))
        os.remove(filepath)
Example #34
0
    def test_imv(self):
        """
        remote-remote imv test
        (SYS_CROSS_ZONE_MV_NOT_SUPPORTED)
        """
        # pick session(s) for the test
        test_session = self.user_sessions[0]

        # make test file
        filename = "imv_test_file"
        filesize = self.config["test_file_size"]
        filepath = os.path.join(self.local_test_dir_path, filename)
        lib.make_file(filepath, filesize)

        # test specific parameters
        parameters = self.config.copy()
        parameters["filepath"] = filepath
        parameters["filename"] = filename
        parameters["new_name"] = filename = "_new"
        parameters["user_name"] = test_session.username
        parameters["local_home_collection"] = test_session.home_collection
        parameters["remote_home_collection"] = "/{remote_zone}/home/{user_name}#{local_zone}".format(**parameters)

        # put file in remote collection
        test_session.assert_icommand("iput {filepath} {remote_home_collection}/".format(**parameters))

        # move (rename) remote file
        test_session.assert_icommand(
            "imv {remote_home_collection}/{filename} {remote_home_collection}/{new_name}".format(**parameters)
        )

        # file should have been renamed
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{filename}".format(**parameters), "STDERR_SINGLELINE", "does not exist"
        )
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{new_name}".format(**parameters), "STDOUT_SINGLELINE", filename
        )
        test_session.assert_icommand(
            "ils -L {remote_home_collection}/{new_name}".format(**parameters), "STDOUT_SINGLELINE", str(filesize)
        )

        # cleanup
        test_session.assert_icommand("irm -f {remote_home_collection}/{new_name}".format(**parameters))
        os.remove(filepath)
Example #35
0
 def test_parallel_write(self):
     num_files = 4
     files = [tempfile.NamedTemporaryFile(prefix='test_fuse.test_parallel_copy') for i in range(num_files)]
     with contextlib.nested(*files):
         hashes = []
         for f in files:
             lib.make_file(f.name, pow(10,8), 'arbitrary')
             hashes.append(lib.md5_hex_file(f.name))
         proc_pool = multiprocessing.Pool(len(files))
         proc_pool_results = [proc_pool.apply_async(shutil.copyfile, (f.name, os.path.join(self.mount_point, os.path.basename(f.name))))
                              for f in files]
         for r in proc_pool_results:
             r.get()
         for f, h in zip(files, hashes):
             self.admin.assert_icommand(['ils', '-L'], 'STDOUT_SINGLELINE', os.path.basename(f.name))
             with tempfile.NamedTemporaryFile(prefix='test_fuse.test_parallel_copy_get') as fget:
                 self.admin.assert_icommand(['iget', '-f', os.path.basename(f.name), fget.name])
                 assert lib.md5_hex_file(fget.name) == h
Example #36
0
    def test_iphymv_to_resc_hier__2933(self):
        self.admin.assert_icommand("iadmin mkresc rrResc roundrobin", 'STDOUT_SINGLELINE', 'roundrobin')
        self.admin.assert_icommand("iadmin mkresc unix1Resc 'unixfilesystem' " + configuration.HOSTNAME_1 + ":" +
                                      lib.get_irods_top_level_dir() + "/unix1RescVault", 'STDOUT_SINGLELINE', 'unixfilesystem')
        self.admin.assert_icommand("iadmin mkresc unix2Resc 'unixfilesystem' " + configuration.HOSTNAME_2 + ":" +
                                      lib.get_irods_top_level_dir() + "/unix2RescVault", 'STDOUT_SINGLELINE', 'unixfilesystem')
        self.admin.assert_icommand("iadmin addchildtoresc rrResc unix1Resc")
        self.admin.assert_icommand("iadmin addchildtoresc rrResc unix2Resc")

        filepath = os.path.join(self.admin.local_session_dir, 'file')
        lib.make_file(filepath, 1)
        dest_path = self.admin.session_collection + '/file'
        self.admin.assert_icommand('iput -fR rrResc ' + filepath + ' ' + dest_path)

        self.admin.assert_icommand('ils -L ' + dest_path, 'STDOUT_SINGLELINE', 'rrResc')
        self.admin.assert_icommand('iphymv -S "rrResc;unix1Resc" -R "rrResc;unix2Resc" ' + dest_path)

        self.admin.assert_icommand('irm -f ' + dest_path)
        self.admin.assert_icommand("iadmin rmchildfromresc rrResc unix2Resc")
        self.admin.assert_icommand("iadmin rmchildfromresc rrResc unix1Resc")
        self.admin.assert_icommand("iadmin rmresc unix2Resc")
        self.admin.assert_icommand("iadmin rmresc unix1Resc")
        self.admin.assert_icommand("iadmin rmresc rrResc")
Example #37
0
 def test_local_iput_interrupt_largefile(self):
     # local setup
     datafilename = 'bigfile'
     file_size = int(4*pow(10, 8))
     lib.make_file(datafilename, file_size)
     rf = 'bigrestartfile'
     iputcmd = 'iput --lfrestart {0} {1}'.format(rf, datafilename)
     if os.path.exists(rf):
         os.unlink(rf)
     self.admin.interrupt_icommand(iputcmd, rf, 10)  # once restartfile reaches 10 bytes
     time.sleep(2)  # wait for all interrupted threads to exit
     assert os.path.exists(rf), rf + " should now exist, but did not"
     output = commands.getstatusoutput('cat ' + rf)
     print "  restartfile [" + rf + "] contents --> [" + output[1] + "]"
     today = datetime.date.today()
     # length should not be zero
     self.admin.assert_icommand_fail("ils -L " + datafilename, 'STDOUT', [" 0 " + today.isoformat(), datafilename])
     # confirm the restart
     self.admin.assert_icommand(iputcmd, 'STDOUT', datafilename + " was restarted successfully")
     self.admin.assert_icommand("ils -L " + datafilename, 'STDOUT',
                [" " + str(os.stat(datafilename).st_size) + " " + today.isoformat(), datafilename])  # length should be size on disk
     # local cleanup
     output = commands.getstatusoutput('rm ' + datafilename)
     output = commands.getstatusoutput('rm ' + rf)
Example #38
0
    def test_imv(self):
        '''
        remote-remote imv test
        (SYS_CROSS_ZONE_MV_NOT_SUPPORTED)
        '''
        # make test file
        filename = 'imv_test_file'
        filesize = self.config['test_file_size']
        filepath = os.path.abspath(filename)
        lib.make_file(filename, filesize)

        kwargs = {'filename': filename,
                  'new_name': filename + '_new',
                  'remote_collection': self.config['remote_home_coll'],
                  'local_collection': self.config['local_home_coll']}

        # put file in remote collection
        self.admin_sessions[0].assert_icommand(
            "iput {filename} {remote_collection}/".format(**kwargs))

        # move (rename) remote file
        self.admin_sessions[0].assert_icommand(
            "imv {remote_collection}/{filename} {remote_collection}/{new_name}".format(**kwargs))

        # file should have been renamed
        self.admin_sessions[0].assert_icommand(
            "ils -L {remote_collection}/{filename}".format(**kwargs), 'STDERR_SINGLELINE', 'does not exist')
        self.admin_sessions[0].assert_icommand(
            "ils -L {remote_collection}/{new_name}".format(**kwargs), 'STDOUT_SINGLELINE', filename)
        self.admin_sessions[0].assert_icommand(
            "ils -L {remote_collection}/{new_name}".format(**kwargs), 'STDOUT_SINGLELINE', str(filesize))

        # cleanup
        self.admin_sessions[0].assert_icommand(
            "irm -f {remote_collection}/{new_name}".format(**kwargs))
        os.remove(filepath)
Example #39
0
    def test_iput_large_file(self):
        # make test file
        filename = 'iput_test_file'
        filesize = self.config['large_file_size']
        filepath = os.path.abspath(filename)
        lib.make_file(filename, filesize)

        kwargs = {'filename': filename,
                  'collection': self.config['remote_home_coll']}

        # put file in remote collection, ask for 6 threads
        self.admin_sessions[0].assert_icommand(
            "iput -v -N 6 {filename} {collection}/".format(**kwargs), 'STDOUT_SINGLELINE', '6 thr')

        # file should be there
        self.admin_sessions[0].assert_icommand(
            "ils -L {collection}/{filename}".format(**kwargs), 'STDOUT_SINGLELINE', filename)
        self.admin_sessions[0].assert_icommand(
            "ils -L {collection}/{filename}".format(**kwargs), 'STDOUT_SINGLELINE', str(filesize))

        # cleanup
        self.admin_sessions[0].assert_icommand(
            "irm -f {collection}/{filename}".format(**kwargs))
        os.remove(filepath)
Example #40
0
    def test_ils_l(self):
        # pick session(s) for the test
        test_session = self.user_sessions[0]

        # make test file
        with tempfile.NamedTemporaryFile() as f:
            filename = os.path.basename(f.name)
            filesize = configuration.FEDERATION.TEST_FILE_SIZE
            lib.make_file(f.name, filesize, "arbitrary")
            remote_home_collection = test_session.remote_home_collection(configuration.FEDERATION.REMOTE_ZONE)

            test_session.assert_icommand(
                ["ils", "-L", remote_home_collection], "STDOUT_SINGLELINE", remote_home_collection
            )
            test_session.assert_icommand(["iput", f.name, remote_home_collection])

            # list file info
            test_session.assert_icommand(
                ["ils", "-L", "{0}/{1}".format(remote_home_collection, filename)], "STDOUT_SINGLELINE", filename
            )
            test_session.assert_icommand(
                ["ils", "-L", "{0}/{1}".format(remote_home_collection, filename)], "STDOUT_SINGLELINE", str(filesize)
            )
            test_session.assert_icommand(
                ["ils", "-L", "{0}/{1}".format(remote_home_collection, filename)],
                "STDOUT_SINGLELINE",
                configuration.FEDERATION.REMOTE_DEF_RESOURCE,
            )
            test_session.assert_icommand(
                ["ils", "-L", "{0}/{1}".format(remote_home_collection, filename)],
                "STDOUT_SINGLELINE",
                configuration.FEDERATION.REMOTE_VAULT,
            )

            # cleanup
            test_session.assert_icommand(["irm", "-f", "{0}/{1}".format(remote_home_collection, filename)])
Example #41
0
    def test_iscan_data_object(self):
        # test that rodsusers can't use iscan -d
        self.user0.assert_icommand('iscan -d non_existent_file', 'STDOUT_SINGLELINE', 'Could not find the requested data object or collection in iRODS.')
        existent_file = os.path.join(self.user0.local_session_dir, 'existent_file')
        lib.make_file(existent_file, 1)
        self.user0.assert_icommand('iput ' + existent_file)
        output = self.admin.run_icommand('iquest "SELECT DATA_PATH WHERE DATA_NAME = \'existent_file\'"')[1]
        data_path = output.strip().strip('-').strip()[12:]
        self.user0.assert_icommand('iscan -d existent_file', 'STDOUT_SINGLELINE', 'User must be a rodsadmin to scan iRODS data objects.')
        os.remove(data_path)
        self.user0.assert_icommand('iscan -d existent_file', 'STDOUT_SINGLELINE', 'User must be a rodsadmin to scan iRODS data objects.')
        lib.make_file(data_path, 1)
        self.user0.assert_icommand('irm -f existent_file')
        zero_file = os.path.join(self.user0.local_session_dir, 'zero_file')
        lib.touch(zero_file)
        self.user0.assert_icommand('iput ' + zero_file)
        self.user0.assert_icommand('iscan -d zero_file', 'STDOUT_SINGLELINE', 'User must be a rodsadmin to scan iRODS data objects.')
        self.user0.assert_icommand('irm -f zero_file')

        # test that rodsadmins can use iscan -d
        self.admin.assert_icommand('iscan -d non_existent_file', 'STDOUT_SINGLELINE', 'Could not find the requested data object or collection in iRODS.')
        existent_file = os.path.join(self.admin.local_session_dir, 'existent_file')
        lib.make_file(existent_file, 1)
        self.admin.assert_icommand('iput ' + existent_file)
        output = self.admin.run_icommand('''iquest "SELECT DATA_PATH WHERE DATA_NAME = 'existent_file'"''' )[1]
        data_path = output.strip().strip('-').strip()[12:]
        self.admin.assert_icommand('iscan -d existent_file')
        os.remove(data_path)
        self.admin.assert_icommand('iscan -d existent_file', 'STDOUT_SINGLELINE', 'is missing, corresponding to iRODS object')
        lib.make_file(data_path, 1)
        self.admin.assert_icommand('irm -f existent_file')
        zero_file = os.path.join(self.admin.local_session_dir, 'zero_file')
        lib.touch(zero_file)
        self.admin.assert_icommand('iput ' + zero_file)
        self.admin.assert_icommand('iscan -d zero_file')
        self.admin.assert_icommand('irm -f zero_file')
Example #42
0
 def test_irsync(self):
     filepath = os.path.join(self.admin.local_session_dir, 'file')
     lib.make_file(filepath, 1)
     self.admin.assert_icommand('iput ' + filepath)
     self.admin.assert_icommand('irsync -l ' + filepath + ' i:file')
Example #43
0
    def test_irodsFs(self):
        # =-=-=-=-=-=-=-
        # set up a fuse mount
        mount_point = "fuse_mount_point"

        if not os.path.isdir(mount_point):
            os.mkdir(mount_point)
        os.system("irodsFs " + mount_point)

        # =-=-=-=-=-=-=-
        # put some test data
        test_file = "irodsfs_test_file"
        lib.make_file(test_file, 10)
        cmd = "iput " + test_file + " foo0"
        output = commands.getstatusoutput(cmd)

        # =-=-=-=-=-=-=-
        # see if the data object is actually in the mount point
        # using the system ls
        cmd = "ls -l " + mount_point
        output = commands.getstatusoutput(cmd)
        out_str = str(output)
        print("mount ls results [" + out_str + "]")
        assert(-1 != out_str.find("foo0"))

        # =-=-=-=-=-=-=-
        # use system copy to put some data into the mount mount
        # and verify that it shows up in the ils
        cmd = "cp " + test_file + " " + mount_point + "/baz ; ils -l baz"
        output = commands.getstatusoutput(cmd)
        out_str = str(output)
        print("results[" + out_str + "]")
        assert(-1 != out_str.find("baz"))

        # =-=-=-=-=-=-=-
        # now irm the file and verify that it is not visible
        # via the fuse mount
        cmd = "irm -f baz ; ils -l baz"
        output = commands.getstatusoutput(cmd)
        out_str = str(output)
        print("results[" + out_str + "]")
        assert(-1 != out_str.find("baz does not exist"))

        output = commands.getstatusoutput("ls -l " + mount_point)
        out_str = str(output)
        print("mount ls results [" + out_str + "]")
        assert(-1 != out_str.find("foo0"))

        # =-=-=-=-=-=-=-
        # now rm the foo0 file and then verify it doesnt show
        # up in the ils
        cmd = "rm " + mount_point + "/foo0; ils -l foo0"
        print("cmd: [" + cmd + "]")
        output = commands.getstatusoutput(cmd)
        out_str = str(output)
        print("results[" + out_str + "]")
        assert(-1 != out_str.find("foo0 does not exist"))

        # =-=-=-=-=-=-=-
        # now run bonnie++ and then verify it reports a summary
        if (os.path.isfile("/usr/sbin/bonnie++")):
            # ubuntu and centos
            bonniecmd = "/usr/sbin/bonnie++"
        else:
            # suse
            bonniecmd = "/usr/bin/bonnie++"
        cmd = bonniecmd + " -r 1024 -d " + mount_point
        print("cmd: [" + cmd + "]")
        output = commands.getstatusoutput(cmd)
        out_str = str(output)
        print("results[" + out_str + "]")
        assert(-1 != out_str.find("-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--"))
        assert(-1 != out_str.find("-Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--"))

        # tear down the fuse mount
        os.system("fusermount -uz " + mount_point)
        if os.path.isdir(mount_point):
            os.rmdir(mount_point)