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 #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
    def test_api_plugin(self):
        rules_to_prepend = """
pep_rs_hello_world_pre(*INST,*OUT,*COMM,*HELLO_IN,*HELLO_OUT) {
    writeLine("serverLog", "pep_rs_hello_world_pre - *INST *OUT *HELLO_IN, *HELLO_OUT");
}
pep_rs_hello_world_post(*INST,*OUT,*COMM,*HELLO_IN,*HELLO_OUT) {
    writeLine("serverLog", "pep_rs_hello_world_post - *INST *OUT *HELLO_IN, *HELLO_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')
            self.admin.assert_icommand("iapitest", 'STDOUT_SINGLELINE', 'this')

            pre_count = lib.count_occurrences_of_string_in_log(
                'server',
                'pep_rs_hello_world_pre - api_instance <unconvertible> that=hello, world.++++this=42, null_value',
                start_index=initial_size_of_server_log)
            hello_count = lib.count_occurrences_of_string_in_log(
                'server',
                'HELLO WORLD',
                start_index=initial_size_of_server_log)
            post_count = lib.count_occurrences_of_string_in_log(
                'server',
                'pep_rs_hello_world_post - api_instance <unconvertible> that=hello, world.++++this=42, that=hello, world.++++this=42++++value=128',
                start_index=initial_size_of_server_log)

        assert 1 == pre_count
        assert 1 == hello_count
        assert 1 == post_count
Example #4
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 #5
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
Example #6
0
    def test_client_server_negotiation__2564(self):
        corefile = lib.get_core_re_dir() + "/core.re"
        with lib.file_backed_up(corefile):
            client_update = {
                'irods_client_server_policy': 'CS_NEG_REFUSE'
            }

            session_env_backup = copy.deepcopy(self.admin.environment_file_contents)
            self.admin.environment_file_contents.update(client_update)

            time.sleep(2)  # remove once file hash fix is commited #2279
            lib.prepend_string_to_file('\nacPreConnect(*OUT) { *OUT="CS_NEG_REQUIRE"; }\n', corefile)
            time.sleep(2)  # remove once file hash fix is commited #2279

            self.admin.assert_icommand( 'ils','STDERR_SINGLELINE','CLIENT_NEGOTIATION_ERROR')

            self.admin.environment_file_contents = session_env_backup
    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
    def test_iput_bulk_check_acpostprocforput__2841(self):
        # prepare test directory
        number_of_files = 5
        dirname = self.admin.local_session_dir + '/files'
        corefile = lib.get_core_re_dir() + "/core.re"
        # files less than 4200000 were failing to trigger the writeLine
        for filesize in range(5000, 6000000, 500000):
            files = lib.make_large_local_tmp_dir(dirname, number_of_files, filesize)
            # manipulate core.re and check the server log
            with lib.file_backed_up(corefile):
                initial_size_of_server_log = lib.get_log_size('server')
                rules_to_prepend = '''
acBulkPutPostProcPolicy { msiSetBulkPutPostProcPolicy("on"); }
acPostProcForPut { writeLine("serverLog", "acPostProcForPut called for $objPath"); }
            '''
                time.sleep(1)  # remove once file hash fix is committed #2279
                lib.prepend_string_to_file(rules_to_prepend, corefile)
                time.sleep(1)  # remove once file hash fix is committed #2279
                self.admin.assert_icommand(['iput', '-frb', dirname])
                assert number_of_files == lib.count_occurrences_of_string_in_log(
                    'server', 'writeLine: inString = acPostProcForPut called for', start_index=initial_size_of_server_log)
                shutil.rmtree(dirname)
    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)