Exemplo n.º 1
0
 def test_itrim_with_admin_mode(self):
     lib.touch("file.txt")
     for i in range(100):
         self.user0.assert_icommand("iput file.txt " + str(i) + ".txt", "EMPTY")
     homepath = self.user0.session_collection
     self.user0.assert_icommand("irepl -R " + self.testresc + " -r " + homepath, "EMPTY")  # creates replica
     self.admin.assert_icommand("itrim -M -N1 -r " + homepath, 'STDOUT', "Number of files trimmed = 100.")
Exemplo n.º 2
0
    def test_acPostProcForPut_replicate_to_multiple_resources(self):
        # create new resources
        hostname = socket.gethostname()
        self.admin.assert_icommand(
            "iadmin mkresc r1 unixfilesystem " + hostname + ":/tmp/irods/r1",
            'STDOUT_SINGLELINE', "Creating")
        self.admin.assert_icommand(
            "iadmin mkresc r2 unixfilesystem " + hostname + ":/tmp/irods/r2",
            'STDOUT_SINGLELINE', "Creating")

        corefile = os.path.join(lib.get_core_re_dir(), 'core.re')
        with lib.file_backed_up(corefile):
            time.sleep(2)  # remove once file hash fix is commited #2279
            lib.prepend_string_to_file(
                '\nacPostProcForPut { replicateMultiple( \"r1,r2\" ); }\n',
                corefile)
            time.sleep(2)  # remove once file hash fix is commited #2279

            # add new rule to end of core.re
            newrule = """
# multiple replication rule
replicateMultiple(*destRgStr) {
    *destRgList = split(*destRgStr, ',');
    writeLine("serverLog", " acPostProcForPut multiple replicate $objPath $filePath -> *destRgStr");
    foreach (*destRg in *destRgList) {
        writeLine("serverLog", " acPostProcForPut replicate $objPath $filePath -> *destRg");
        *e = errorcode(msiSysReplDataObj(*destRg,"null"));
        if (*e != 0) {
            if(*e == -808000) {
                writeLine("serverLog", "$objPath cannot be found");
                $status = 0;
                succeed;
            } else {
                fail(*e);
            }
        }
    }
}
"""

            time.sleep(2)  # remove once file hash fix is commited #2279
            lib.prepend_string_to_file(newrule, corefile)
            time.sleep(2)  # remove once file hash fix is commited #2279

            # put data
            tfile = "rulebasetestfile"
            lib.touch(tfile)
            self.admin.assert_icommand(['iput', tfile])

            # check replicas
            self.admin.assert_icommand(['ils', '-L', tfile],
                                       'STDOUT_MULTILINE',
                                       [' demoResc ', ' r1 ', ' r2 '])

            # clean up and remove new resources
            self.admin.assert_icommand("irm -rf " + tfile)
            self.admin.assert_icommand("iadmin rmresc r1")
            self.admin.assert_icommand("iadmin rmresc r2")

        time.sleep(2)  # remove once file hash fix is commited #2279
Exemplo n.º 3
0
 def test_irepl_with_admin_mode(self):
     lib.touch("file.txt")
     for i in range(0, 100):
         self.user0.assert_icommand("iput file.txt " + str(i) + ".txt", "EMPTY")
     homepath = "/" + self.admin.zone_name + "/home/" + \
         self.user0.username + "/" + self.user0._session_id
     self.admin.assert_icommand("irepl -r -M -R " + self.testresc + " " + homepath, "EMPTY")  # creates replica
Exemplo n.º 4
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')
Exemplo n.º 5
0
 def test_iscan_local_file(self):
     self.user0.assert_icommand('iscan non_existent_file', 'STDERR_SINGLELINE', 'ERROR: scanObj: non_existent_file does not exist')
     existent_file = os.path.join(self.user0.local_session_dir, 'existent_file')
     lib.touch(existent_file)
     self.user0.assert_icommand('iscan ' + existent_file, 'STDOUT_SINGLELINE', existent_file + ' is not registered in iRODS')
     self.user0.assert_icommand('iput ' + existent_file)
     output = self.user0.run_icommand('''iquest "SELECT DATA_PATH WHERE DATA_NAME = 'existent_file'"''' )[1]
     data_path = output.strip().strip('-').strip()[12:]
     self.user0.assert_icommand('iscan ' + data_path)
     self.user0.assert_icommand('irm -f existent_file')
Exemplo n.º 6
0
    def test_acPostProcForPut_replicate_to_multiple_resources(self):
        # create new resources
        hostname = socket.gethostname()
        self.admin.assert_icommand("iadmin mkresc r1 unixfilesystem " + hostname + ":/tmp/irods/r1", 'STDOUT_SINGLELINE', "Creating")
        self.admin.assert_icommand("iadmin mkresc r2 unixfilesystem " + hostname + ":/tmp/irods/r2", 'STDOUT_SINGLELINE', "Creating")

        corefile = os.path.join(lib.get_core_re_dir(), 'core.re')
        with lib.file_backed_up(corefile):
            time.sleep(2)  # remove once file hash fix is commited #2279
            lib.prepend_string_to_file('\nacPostProcForPut { replicateMultiple( \"r1,r2\" ); }\n', corefile)
            time.sleep(2)  # remove once file hash fix is commited #2279

            # add new rule to end of core.re
            newrule = """
# multiple replication rule
replicateMultiple(*destRgStr) {
    *destRgList = split(*destRgStr, ',');
    writeLine("serverLog", " acPostProcForPut multiple replicate $objPath $filePath -> *destRgStr");
    foreach (*destRg in *destRgList) {
        writeLine("serverLog", " acPostProcForPut replicate $objPath $filePath -> *destRg");
        *e = errorcode(msiSysReplDataObj(*destRg,"null"));
        if (*e != 0) {
            if(*e == -808000) {
                writeLine("serverLog", "$objPath cannot be found");
                $status = 0;
                succeed;
            } else {
                fail(*e);
            }
        }
    }
}
"""

            time.sleep(2)  # remove once file hash fix is commited #2279
            lib.prepend_string_to_file(newrule, corefile)
            time.sleep(2)  # remove once file hash fix is commited #2279

            # put data
            tfile = "rulebasetestfile"
            lib.touch(tfile)
            self.admin.assert_icommand(['iput', tfile])

            # check replicas
            self.admin.assert_icommand(['ils', '-L', tfile], 'STDOUT_MULTILINE', [' demoResc ', ' r1 ', ' r2 '])

            # clean up and remove new resources
            self.admin.assert_icommand("irm -rf " + tfile)
            self.admin.assert_icommand("iadmin rmresc r1")
            self.admin.assert_icommand("iadmin rmresc r2")

        time.sleep(2)  # remove once file hash fix is commited #2279
Exemplo n.º 7
0
def format_import(references, tmpdir, dstdir, rev, poi=[]):
    assert len(poi) == 0 # todo
    args = ("git", "format-patch", "--output-directory", tmpdir, "--notes",
            "--max-count=1", "--subject-prefix=", "--no-numbered", rev,)
    src = subprocess.check_output(args).decode().strip()
    # remove number prefix
    name = os.path.basename(src)[5:]
    dst = os.path.join(dstdir, name)
    if os.path.exists(os.path.join("patches", dst)):
        name = "%s-%s.patch" % (name[:-6], rev[:8],)
        dst = os.path.join(dstdir, name)

    subprocess.check_call((os.path.join(lib.libdir(), "clean_header.sh"),
                           "--commit=%s" % rev, "--reference=%s" % references,
                           src,))
    subprocess.check_call(("quilt", "import", "-P", dst, src,))
    # This will remind the user to run refresh_patch.sh
    lib.touch(".pc/%s~refresh" % (dst,))

    return 0
Exemplo n.º 8
0
def format_import(references, tmpdir, dstdir, rev, poi=[]):
    assert len(poi) == 0  # todo
    args = (
        "git",
        "format-patch",
        "--output-directory",
        tmpdir,
        "--notes",
        "--max-count=1",
        "--subject-prefix=",
        "--no-numbered",
        rev,
    )
    src = subprocess.check_output(args).decode().strip()
    # remove number prefix
    name = os.path.basename(src)[5:]
    dst = os.path.join(dstdir, name)
    if os.path.exists(os.path.join("patches", dst)):
        name = "%s-%s.patch" % (
            name[:-6],
            rev[:8],
        )
        dst = os.path.join(dstdir, name)

    subprocess.check_call((
        os.path.join(lib.libdir(), "clean_header.sh"),
        "--commit=%s" % rev,
        "--reference=%s" % references,
        src,
    ))
    subprocess.check_call((
        "quilt",
        "import",
        "-P",
        dst,
        src,
    ))
    # This will remind the user to run refresh_patch.sh
    lib.touch(".pc/%s~refresh" % (dst, ))

    return 0
Exemplo n.º 9
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')
Exemplo n.º 10
0
 def test_iphymv_admin_mode(self):
     lib.touch("file.txt")
     for i in range(0, 100):
         self.user0.assert_icommand("iput file.txt " + str(i) + ".txt", "EMPTY")
     self.admin.assert_icommand("iphymv -r -M -R " + self.testresc + " " + self.admin.session_collection)  # creates replica