Пример #1
0
def testNLM4LockAsync(t, env):
    """ Asynchronously lock and unlock

    FLAGS: nsv3 nlm
    DEPEND: NLM0
    CODE: NLM3
    """

    mnt_fh = homedir_fh(env.mc, env.c1)
    lock = nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)
    event = threading.Event()

    env.nlm.lock_msg(lock, 'cookie', False, True, False, 1, None, event)
    if event.wait(10.0):
        raise FailureException("NLM Async lock request timed out!")
    else:
        res = env.nlm.cb_server.get_cb_res('cookie')
        if res:
            nlm4check(res.stat, msg="Async LOCK")
        else:
            raise FailureException("NLM Async lock request timed out!")

    env.nlm.unlock_msg(lock, 'cookie', None, event)
    if event.wait(10.0):
        raise FailureException("NLM Async unlock request timed out!")
    else:
        res = env.nlm.cb_server.get_cb_res('cookie')
        if res:
            nlm4check(res.stat, msg="Async UNLOCK")
        else:
            raise FailureException("NLM Async lock request timed out!")
Пример #2
0
def testNLM4Lock(t, env):
    """ Lock and unlock a directory.


     FLAGS: nfsv3 nlm
     DEPEND: NLM0 NLM1
     CODE: NLM2
     """
    ### Setup Phase ###
    mnt_fh = homedir_fh(env.mc, env.c1)
    lock = nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)
    res = env.nlm.test(lock, 'cookie', True)
    nlm4check(res.stat, msg="Initial TEST of unlocked dir")

    ### Execution Phase ###
    res = env.nlm.lockk(lock, 'cookie', False, True, False, 1)
    nlm4check(res.stat, msg="LOCK")

    ### Verification Phase ###
    res = env.nlm.test(lock, 'cookie', True)
    nlm4check(res.stat, msg="TEST of previously locked dir")

    lock2 = nlm4_lock(t.name + 'bad', mnt_fh, 'owner', env.pid, 0, 1024)
    res = env.nlm.test(lock2, 'badcookie', True)
    nlm4check(res.stat,
              msg="TEST of previously locked dir with bad creds",
              stat=NLM4_DENIED)

    res = env.nlm.unlock(lock, 'cookie')
    nlm4check(res.stat, msg="UNLOCK")

    res = env.nlm.test(lock, 'cookie', True)
    nlm4check(res.stat, msg="Final TEST of unlocked dir")
Пример #3
0
def testNLM4LoopTestExclusive2(t, env):
    """ Loop, sending NLM4TEST(Exclusive) messages. This is to find a specific
         LK bug (related to SAS escalation bug 85961).

         To run, use multiple clients to run this test against multiple nodes.

         This test should be SAFE to run alongside itself or NLMLOOP1 or
         NLMLOOPLOCK2.

     FLAGS: nfsv3 nlm
     DEPEND: NLM0
     CODE: NLMLOOP2
     """

    failed = False
    count = 0
    mnt_fh = homedir_fh(env.mc, env.c1)
    lock = nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)

    for i in range(10000):
        # Do an EXCLUSIVE Test
        res = env.nlm.test(lock, 'cookie', True)
        if res.stat.stat != NLM4_GRANTED:
            count = count + 1
            if res.holder.exclusive:
                print "(%d) res.stat = %s" % (i, nlm4_stats[res.stat.stat])
                print res
                failed = True

    if count > 0:
        print "Got %d shared BLOCKED messages (which may be a bug " \
            "depending on what other tests are running)" % (count)

    if failed:
        t.fail("FAILED TestExclusive test")
Пример #4
0
def testNfs3Create_SizeSet(t, env):
    """ Create a file with file_mode_set=1 and Size

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE3
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777, size_set=1, size_val=9876543210)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    
    ### Verification Phase ###
    check(res, msg="CREATE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.size == 9876543210,   \
      "CREATE - file %s (size=%d expected %d)" %    \
      (test_file, res.attributes.size, 9876543210))    
Пример #5
0
def testNfs3FSInfo(t, env):
    """Retrieve the information of a file via the FSINFO rpc 
    
    
    FLAGS: nfsv3 fsinfo all
    DEPEND: 
    CODE: FSINFO1
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.fsinfo(test_file_fh)

    ### Verification Phase ###s
    check(res, msg="FSINFO - file %s" % test_file)
Пример #6
0
def testNfs3SymLink(t, env):
    """ Create a symlink to a file via the SYMLINK rpc 
       
    
    FLAGS: nfsv3 symlink all
    DEPEND:
    CODE: SLINK1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    test_link=t.name + "_link_1"
    mount_path='/' + '/'.join(env.mc.opts.path[:-1])
    link_path='/'.join([mount_path, test_dir, test_file])
    mnt_fh = homedir_fh(env.mc, env.c1)
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    # once bug 76982 is closed, drop the mode arguments
    res = env.c1.symlink(test_dir_fh, test_link, mode_set=1, mode_val=0777, 
        size_set=1, size_val=len(link_path), data=link_path)
        
    ### Verification Phase ###
    check(res, msg="SYMLINK - link %s" % test_link)
    res = env.c1.lookup(test_dir_fh, test_link)
    check(res, msg="LOOKUP - link %s" % test_link)
    if res.status != NFS3_OK:
        t.fail_support("SYMLINK FAILED:  File [%] still exists." % test_link)
Пример #7
0
def testNfs3Rename(t, env):
    """ Rename a file with the RENAME rpc 
    
    
    FLAGS: nfsv3 rename all
    DEPEND:
    CODE: RENAME1
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    new_test_file = test_file + "_renamed"

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)

    ### Execution Phase ###
    res = env.c1.rename(test_dir_fh, test_file, test_dir_fh, new_test_file)

    ### Verification Phase ###
    check_msg = "RENAME - file %s" % test_file
    check(res, msg=check_msg)
    res = env.c1.lookup(test_dir_fh, new_test_file)
    check(res, msg="LOOKUP - file %s" % new_test_file)
    if res.status != NFS3_OK:
        t.fail_support("RENAME FAILED: File [%s] does not exist." % new_test_file)
Пример #8
0
def testNfs3PathConf(t, env):
    """Retrieve the pathconf information of a file via the PATHCONF rpc 
    
        
    FLAGS: nfsv3 pathconf all
    DEPEND:
    CODE: PTHCNF1
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.pathconf(test_file_fh)

    ### Verification Phase ###
    check(res, msg="PATHCONF - file %s" % test_file)
Пример #9
0
def testNfs3Lookup(t, env):
    """ Get the handle for a file via the LOOKUP rpc
    

    FLAGS: nfsv3 lookup all
    DEPEND:
    CODE: LOOKUP1 
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, file_mode_val=0777)
    check(res, msg="CREATE - file %s " % test_file)
    test_file_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.lookup(test_dir_fh, test_file)

    check(res, msg="LOOKUP - file %s" % test_file)
    if res.object.data != test_file_fh:
        t.fail.support(
            " ".join(
                [
                    "LOOKUP - file handle returned [%s]" % res.object.data,
                    "is different than return of CREATE [%s]" % test_file_fh,
                ]
            )
        )
Пример #10
0
def testNfs3Access_Read(t, env):
    """ Create a file, and check access permissions with ACCESS rpc 
        
    FLAGS: nfsv3 access all
    DEPEND:
    CODE: ACCESS1
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.access(test_file_fh, ACCESS3_READ)

    ### Verification Phase ###
    check(res, msg="ACCESS - file %s" % test_file)
    if res.resok.access != ACCESS3_READ:
        t.fail_support(" ".join([
            "ACCESS - response: access bit mask [%s]" % res.resok.access,
            "is not the correct value [%s]" % ACCESS3_READ
        ]))
Пример #11
0
def testNfs3Remove(t, env):
    """ Create a file and remove it with the REMOVE rpc 
        
        
    FLAGS: nfsv3 remove all
    DEPEND:
    CODE: REMOVE1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s " % test_file)
        
    ### Execution Phase ###
    res = env.c1.remove(test_dir_fh, test_file)
        
    ### Verification Phase ###
    check(res, msg="REMOVE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    if res.status == NFS3_OK:
        t.fail_support("REMOVE FAILED:  File [%] still exists." % test_file)
Пример #12
0
def testNfs3Access_Read(t, env):
    """ Create a file, and check access permissions with ACCESS rpc 
        
    FLAGS: nfsv3 access all
    DEPEND:
    CODE: ACCESS1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.access(test_file_fh, ACCESS3_READ)
    
    ### Verification Phase ###
    check(res, msg="ACCESS - file %s" % test_file)
    if res.resok.access != ACCESS3_READ:
        t.fail_support(" ".join([
            "ACCESS - response: access bit mask [%s]" % res.resok.access,
            "is not the correct value [%s]" % ACCESS3_READ]))
Пример #13
0
def testNfs3FSInfo(t, env):
    """Retrieve the information of a file via the FSINFO rpc 
    
    
    FLAGS: nfsv3 fsinfo all
    DEPEND: 
    CODE: FSINFO1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.fsinfo(test_file_fh)

    ### Verification Phase ###s
    check(res, msg="FSINFO - file %s" % test_file)
Пример #14
0
def testNfs3GetAttr(t, env):
    """ Get the attributes of a file via the GETATTR rpc
    

    FLAGS: nfsv3 getattr all
    DEPEND:
    CODE: GATTR1
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s " % test_file)
    test_file_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.getattr(test_file_fh)

    ### Verification Phase ###
    check(res, msg="GETATTR - %s" % test_file)
Пример #15
0
def testNfs3Create_UidAdminFail(t, env):
    """ Create a file with uid_set=1 as second user

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE8
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c3.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777,
                        uid_set=1, uid_val=1234,
                        gid_set=1, gid_val=5678)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    
    ### Verification Phase ###
    check(res, msg="CREATE - file %s" % test_file)
    res = env.c3.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c3.getattr(test_file_fh)
    checkvalid(res.attributes.uid == 10,      \
      "CREATE - file %s (uid=%d expected %d)" \
      % (test_file, res.attributes.uid, 10))
    checkvalid(res.attributes.gid == 10 or    \
      res.attributes.gid == 0,                \
      "CREATE - file %s (gid=%d expected %d)" \
      % (test_file, res.attributes.gid, 10))
Пример #16
0
def testNfs3Link(t, env):
    """ Create a hard-link to a file via LINK rpc 

        
    FLAGS: nfsv3 link all
    DEPEND:
    CODE: LINK1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    test_link=t.name + "_link_1"
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.link(test_file_fh, test_dir_fh, test_link)
        
    ### Verification Phase ###
    check(res, msg="LINK - file %s" % test_file)
Пример #17
0
def testNLM4LoopTestExclusive(t, env):
    """ Loop, sending NLM4TEST(Exclusive) messages. This is to find a specific
         LK bug (related to SAS escalation bug 85961).

         To run, use multiple clients to run this test against multiple nodes.

         This test should be SAFE to run alongside itself or NLMLOOP2.

     FLAGS: nfsv3 nlm
     DEPEND: NLM0
     CODE: NLMLOOP1
     """

    failed = False

    for i in range(10000):
        # Do an EXCLUSIVE Test
        mnt_fh = homedir_fh(env.mc, env.c1)
        lock = nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)
        res = env.nlm.test(lock, 'cookie', True)
        if res.stat.stat != NLM4_GRANTED:
            print "(%d) res.stat = %s" % (i, nlm4_stats[res.stat.stat])
            print res
            failed = True

    if failed:
        t.fail("FAILED TestExclusive test")
Пример #18
0
def testNfs3PathConf(t, env):
    """Retrieve the pathconf information of a file via the PATHCONF rpc 
    
        
    FLAGS: nfsv3 pathconf all
    DEPEND:
    CODE: PTHCNF1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.pathconf(test_file_fh)
    
    ### Verification Phase ###
    check(res, msg="PATHCONF - file %s" % test_file)
Пример #19
0
def testNfs3Create_AllUnset(t, env):
    """ Create a file with all _set bits = 0
        Failure is expected due to bug #76982

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=0, 
                        file_mode_val=0777)
    #print "###DEBUG - CREATE_ALLUNSET RESULTS:", res, "\n"
    
    ### Verification Phase ###
    check(res, msg="CREATE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
Пример #20
0
def testNfs3Create_FileModeReset(t, env):
    """ Create a file with one mode and then recreate it with another mode.
    Expect the first mode to remain. (Unchecked is the default creation type.)

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE2R
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1,
                        file_mode_val=0321)
    check(res, msg="CREATE(1) - file %s" % test_file)
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1,
                        file_mode_val=0654)
    check(res, msg="CREATE(2) - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    
    ### Verification Phase ###
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.mode == 0321,
               "CREATE - file %s (mode=%d expected %d)" %
               (test_file, res.attributes.mode, 0321))
Пример #21
0
def testNfs3Create_UidAdminFail(t, env):
    """ Create a file with uid_set=1 as second user

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE8
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c3.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777,
                        uid_set=1, uid_val=1234,
                        gid_set=1, gid_val=5678)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    
    ### Verification Phase ###
    check(res, msg="CREATE - file %s" % test_file)
    res = env.c3.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c3.getattr(test_file_fh)
    checkvalid(res.attributes.uid == 10,      \
      "CREATE - file %s (uid=%d expected %d)" \
      % (test_file, res.attributes.uid, 10))
    checkvalid(res.attributes.gid == 10 or    \
      res.attributes.gid == 0,                \
      "CREATE - file %s (gid=%d expected %d)" \
      % (test_file, res.attributes.gid, 10))
Пример #22
0
def testNfs3Create_FileModeSet(t, env):
    """ Create a file with file_mode_set=1
        Use this as a work around until bug #76982 is closed 

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE2
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"

    ### Verification Phase ###
    check(res, msg="CREATE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(
        res.attributes.mode == 0777, "CREATE - file %s (mode=%d expected %d)" %
        (test_file, res.attributes.mode, 0777))
Пример #23
0
def testNfs3Create_AtimeSet(t, env):
    """ Create a file with atime_set=2

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE5
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777,
                        mtime_set=2, mtime_val=nfstime3(1234, 5678),
                        atime_set=2, atime_val=nfstime3(1234, 5678))
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    
    ### Verification Phase ###
    check(res, msg="CREATE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.atime.seconds == 1234 and \
       res.attributes.atime.nseconds == 5678,           \
      "CREATE - file %s (atime=%s expected %s)"         \
      % (test_file, str(res.attributes.atime),          \
      str(nfstime3(1234, 5678))))
Пример #24
0
def testNfs3Create_FileModeSet(t, env):
    """ Create a file with file_mode_set=1
        Use this as a work around until bug #76982 is closed 

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE2
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    
    ### Verification Phase ###
    check(res, msg="CREATE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.mode == 0777,
               "CREATE - file %s (mode=%d expected %d)" %
               (test_file, res.attributes.mode, 0777))
Пример #25
0
def testNfs3Create_EmptyFileName(t, env):
    """ Create a file with all _set bits = 0
        Failure is expected due to bug #76982

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE10
    """
    ### Setup Phase ###
    test_file = b""
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=0,
                        file_mode_val=0777)
    # print "###DEBUG - CREATE_ALLUNSET RESULTS:", res, "\n"

    ### Verification Phase ###
    check(res, NFS3ERR_ACCES, msg="CREATE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, NFS3ERR_ACCES, msg="LOOKUP - file %s" % test_file)
Пример #26
0
def testNfs3CommitLargeValuesNoWrite(t, env):
    """ Tests COMMIT with large values. No reason to write beforehand. This
    repros bug 77753.

    FLAGS: nfsv3 commit all
    DEPEND:
    CODE: COMMIT3
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    offset = 3500000000
    datalen = 4000000000
    res = env.c1.commit(test_file_fh, offset, datalen)
    check(res, msg="COMMIT of test file %s" % test_file)
Пример #27
0
def testNfs3Commit(t, env):
    """Commits changes to a file via the COMMIT rpc 
    
    
    FLAGS: nfsv3 commit all
    DEPEND: 
    CODE: COMMIT1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    test_data = "Test String"
    mnt_fh = homedir_fh(env.mc, env.c1)
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    res = env.c1.write(test_file_fh, offset=0, count=len(test_data), stable=FILE_SYNC, data=test_data)
    check(res, msg="WRITE - file %s" % test_file)
        
    ### Execution Phase ###
    res = env.c1.commit(test_file_fh)
    
    ### Verification Phase ###
    check(res, msg="COMMIT of test file %s" % test_file)
Пример #28
0
def testNfs3CommitLargeValuesNoWrite(t, env):
    """ Tests COMMIT with large values. No reason to write beforehand. This
    repros bug 77753.

    FLAGS: nfsv3 commit all
    DEPEND:
    CODE: COMMIT3
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    offset = 3500000000
    datalen = 4000000000
    res = env.c1.commit(test_file_fh, offset, datalen)
    check(res, msg="COMMIT of test file %s" % test_file)
Пример #29
0
def testNfs3Rename(t, env):
    """ Rename a file with the RENAME rpc 
    
    
    FLAGS: nfsv3 rename all
    DEPEND:
    CODE: RENAME1
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    new_test_file = test_file + "_renamed"

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)

    ### Execution Phase ###
    res = env.c1.rename(test_dir_fh, test_file, test_dir_fh, new_test_file)

    ### Verification Phase ###
    check_msg = "RENAME - file %s" % test_file
    check(res, msg=check_msg)
    res = env.c1.lookup(test_dir_fh, new_test_file)
    check(res, msg="LOOKUP - file %s" % new_test_file)
    if res.status != NFS3_OK:
        t.fail_support("RENAME FAILED: File [%s] does not exist." \
                       % new_test_file)
Пример #30
0
def testNfs3ACL_BasicACLv3Operations(t, env):
    """ Create a file with all _set bits = 0
        Failure is expected due to bug #76982

    FLAGS: nfsv3 acl all
    DEPEND:
    CODE: POSIXACL01
    """
    ### Setup Phase ###
    test_file = b"_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=0,
                        file_mode_val=0777)
    test_file_fh = res.resok.obj.handle.data

    ### Verification Phase ###
    check(res, msg="CREATE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    env.acl_c3.acl_null()
    env.acl_c3.acl_setacl(test_file_fh, [(0x1, 1000, 0o777), (0x2, 2000, 0o777), (0x3, 0, 0o777)],
                          mask=0x0)
    res = env.acl_c3.acl_getacl(test_file_fh, 0x1)
    print "###DEBUG - GETACL3 RESULTS:", res, "\n"
    try:
        res = env.acl_c3.acl_getxattrdir(test_file_fh, True)
    except Exception as e:
        print("{}".format(e))
Пример #31
0
def testNLM4LoopTestExclusive(t,env):
     """ Loop, sending NLM4TEST(Exclusive) messages. This is to find a specific
         LK bug (related to SAS escalation bug 85961).

         To run, use multiple clients to run this test against multiple nodes.

         This test should be SAFE to run alongside itself or NLMLOOP2.

     FLAGS: nfsv3 nlm
     DEPEND: NLM0
     CODE: NLMLOOP1
     """

     failed = False

     for i in range(10000):
         # Do an EXCLUSIVE Test
         mnt_fh = homedir_fh(env.mc, env.c1)
         lock = nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)
         res = env.nlm.test(lock, 'cookie', True)
         if res.stat.stat != NLM4_GRANTED:
             print "(%d) res.stat = %s" % (i, nlm4_stats[res.stat.stat])
             print res
             failed = True

     if failed:
         t.fail("FAILED TestExclusive test")
Пример #32
0
def testNfs3Remove(t, env):
    """ Create a file and remove it with the REMOVE rpc 
        
        
    FLAGS: nfsv3 remove all
    DEPEND:
    CODE: REMOVE1
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s " % test_file)

    ### Execution Phase ###
    res = env.c1.remove(test_dir_fh, test_file)

    ### Verification Phase ###
    check(res, msg="REMOVE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    if res.status == NFS3_OK:
        t.fail_support("REMOVE FAILED:  File [%] still exists." % test_file)
Пример #33
0
def testNfs3Commit(t, env):
    """Commits changes to a file via the COMMIT rpc 
    
    
    FLAGS: nfsv3 commit all
    DEPEND: 
    CODE: COMMIT1
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    test_data = "Test String"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    res = env.c1.write(test_file_fh,
                       offset=0,
                       count=len(test_data),
                       stable=FILE_SYNC,
                       data=test_data)
    check(res, msg="WRITE - file %s" % test_file)

    ### Execution Phase ###
    res = env.c1.commit(test_file_fh)

    ### Verification Phase ###
    check(res, msg="COMMIT of test file %s" % test_file)
Пример #34
0
def testNLM4Lock(t,env):
     """ Lock and unlock a directory.


     FLAGS: nfsv3 nlm
     DEPEND: NLM0 NLM1
     CODE: NLM2
     """
     ### Setup Phase ###
     mnt_fh = homedir_fh(env.mc, env.c1)
     lock = nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)
     res = env.nlm.test(lock, 'cookie', True)
     nlm4check(res.stat, msg="Initial TEST of unlocked dir")

     ### Execution Phase ###
     res = env.nlm.lockk(lock, 'cookie', False, True, False, 1)
     nlm4check(res.stat,msg="LOCK")

     ### Verification Phase ###
     res = env.nlm.test(lock, 'cookie', True)
     nlm4check(res.stat, msg="TEST of previously locked dir")

     lock2 = nlm4_lock(t.name + 'bad', mnt_fh, 'owner', env.pid, 0, 1024)
     res = env.nlm.test(lock2, 'badcookie', True)
     nlm4check(res.stat, msg="TEST of previously locked dir with bad creds", stat=NLM4_DENIED)

     res = env.nlm.unlock(lock, 'cookie')
     nlm4check(res.stat,msg="UNLOCK")

     res = env.nlm.test(lock, 'cookie', True)
     nlm4check(res.stat, msg="Final TEST of unlocked dir")
Пример #35
0
def testNfs3Create_SizeSet(t, env):
    """ Create a file with file_mode_set=1 and Size

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE3
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777,
                        size_set=1,
                        size_val=9876543210)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"

    ### Verification Phase ###
    check(res, msg="CREATE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.size == 9876543210,   \
      "CREATE - file %s (size=%d expected %d)" %    \
      (test_file, res.attributes.size, 9876543210))
Пример #36
0
def testNLM4LockAsync(t,env):
    """ Asynchronously lock and unlock

    FLAGS: nsv3 nlm
    DEPEND: NLM0
    CODE: NLM3
    """

    mnt_fh = homedir_fh(env.mc, env.c1)
    lock = nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)
    event = threading.Event()

    env.nlm.lock_msg(lock, 'cookie', False, True, False, 1, None, event)
    if event.wait(10.0):
        raise FailureException("NLM Async lock request timed out!")
    else:
        res = env.nlm.cb_server.get_cb_res('cookie')
        if res:
            nlm4check(res.stat, msg="Async LOCK")
        else:
            raise FailureException("NLM Async lock request timed out!")

    env.nlm.unlock_msg(lock, 'cookie', None, event)
    if event.wait(10.0):
        raise FailureException("NLM Async unlock request timed out!")
    else:
        res = env.nlm.cb_server.get_cb_res('cookie')
        if res:
            nlm4check(res.stat, msg="Async UNLOCK")
        else:
            raise FailureException("NLM Async lock request timed out!")
Пример #37
0
def testNfs3Lookup(t, env):
    """ Get the handle for a file via the LOOKUP rpc
    

    FLAGS: nfsv3 lookup all
    DEPEND:
    CODE: LOOKUP1 
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s " % test_file)
    test_file_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.lookup(test_dir_fh, test_file)

    check(res, msg="LOOKUP - file %s" % test_file)
    if res.object.data != test_file_fh:
        t.fail.support(" ".join([
            "LOOKUP - file handle returned [%s]" % res.object.data,
            "is different than return of CREATE [%s]" % test_file_fh
        ]))
Пример #38
0
def testNLM4LoopTestExclusive2(t,env):
     """ Loop, sending NLM4TEST(Exclusive) messages. This is to find a specific
         LK bug (related to SAS escalation bug 85961).

         To run, use multiple clients to run this test against multiple nodes.

         This test should be SAFE to run alongside itself or NLMLOOP1 or
         NLMLOOPLOCK2.

     FLAGS: nfsv3 nlm
     DEPEND: NLM0
     CODE: NLMLOOP2
     """

     failed = False
     count = 0
     mnt_fh = homedir_fh(env.mc, env.c1)
     lock = nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)

     for i in range(10000):
         # Do an EXCLUSIVE Test
         res = env.nlm.test(lock, 'cookie', True)
         if res.stat.stat != NLM4_GRANTED:
             count = count + 1
             if res.holder.exclusive:
                 print "(%d) res.stat = %s" % (i, nlm4_stats[res.stat.stat])
                 print res
                 failed = True

     if count > 0:
         print "Got %d shared BLOCKED messages (which may be a bug " \
             "depending on what other tests are running)" % (count)

     if failed:
         t.fail("FAILED TestExclusive test")
Пример #39
0
def testNfs3MkNod(t, env):
    """Create a special device file via the MKNOD rpc.
        ... requires nfs root user to be mapped to root instead of nobody
        
    FLAGS: nfsv3 mknod all
    DEPEND:
    CODE: MKNOD1
    """
    ### Setup Phase ###
    test_dir=t.name + "_dir_1"
    type_list = [NF3BLK, NF3CHR, NF3SOCK, NF3FIFO]
    mnt_fh = homedir_fh(env.mc, env.c1)
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR of new test dir %s" % test_dir)
    res = env.c1.lookup(mnt_fh, test_dir)
    check(res, msg="LOOKUP of new dir %s" % test_dir)
    test_dir_fh = res.object.data
    
    ### Execution Phase ###
    for type in type_list:
        # remove mode_set and _val args once bug #76982 is closed
        test_file = "".join([t.name, "_", ftype3[type]])
        #test_file = "".join([mount_path, "/", test_dir, "/", t.name, "_", ftype3[type], "/"])
        res = env.c1.mknod(test_dir_fh, test_file, type, mode_set=1, mode_val=0777)
        #res = env.c1.mknod(mnt_fh, test_file, type, mode_set=1, mode_val=0777)
        check(res, msg="MKNOD of test file %s" % test_file)
    
    ### Verification Phase ###
    for type in type_list:
        test_file = "".join([t.name, "_", ftype3[type]])
        res = env.c1.lookup(test_dir_fh, test_file)
        #res = env.c1.lookup(mnt_fh, test_file)
        check(res, msg="LOOKUP test file %s" % test_file)
Пример #40
0
def testNfs3Create_FileModeReset(t, env):
    """ Create a file with one mode and then recreate it with another mode.
    Expect the first mode to remain. (Unchecked is the default creation type.)

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE2R
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1,
                        file_mode_val=0321)
    check(res, msg="CREATE(1) - file %s" % test_file)
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1,
                        file_mode_val=0654)
    check(res, msg="CREATE(2) - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    
    ### Verification Phase ###
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.mode == 0321,
               "CREATE - file %s (mode=%d expected %d)" %
               (test_file, res.attributes.mode, 0321))
Пример #41
0
def testNfs3Create_MtimeSet(t, env):
    """ Create a file with mtime_set=2

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE4
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777,
                        mtime_set=2,
                        mtime_val=nfstime3(1234, 5678))
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"

    ### Verification Phase ###
    check(res, msg="CREATE - file %s" % test_file)
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.mtime.seconds == 1234 and \
       res.attributes.mtime.nseconds == 5678,           \
      "CREATE - file %s (mtime=%s expected %s)"         \
      % (test_file, str(res.attributes.mtime),          \
      str(nfstime3(1234, 5678))))
Пример #42
0
def testNfs3GetAttr(t, env):
    """ Get the attributes of a file via the GETATTR rpc
    

    FLAGS: nfsv3 getattr all
    DEPEND:
    CODE: GATTR1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                file_mode_val=0777)
    check(res, msg="CREATE - file %s " % test_file)
    test_file_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.getattr(test_file_fh)
    
    ### Verification Phase ###
    check(res, msg="GETATTR - %s" % test_file)
Пример #43
0
def testNfs3ReadLink(t, env):
    """ Create a symlink to a file and read the link via the READLINK rpc 

        
    FLAGS: nfsv3 readlink all
    DEPEND:
    CODE: RDLINK1
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    test_link = t.name + "_link_1"
    mount_path = '/' + '/'.join(env.mc.opts.path[:-1])
    link_path = '/'.join([mount_path, test_dir, test_file])
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s " % test_file)
    res = env.c1.symlink(test_dir_fh,
                         test_link,
                         mode_set=1,
                         mode_val=0777,
                         size_set=1,
                         size_val=len(link_path),
                         data=link_path)
    check(res, msg="SYMLINK - link %s" % test_link)
    res = env.c1.lookup(test_dir_fh, test_link)
    check(res, msg="LOOKUP of test symlink %s" % test_link)
    test_link_fh = res.object.data

    ### Execution Phase ###
    res = env.c1.readlink(test_link_fh)

    ### Verification Phase ###
    check(res, msg="READLINK on existing file %s" % test_file)
    if res.resok.type != NF3LNK:
        t.fail_support(" ".join([
            "READLINK - data type returned [%s]" % res.resok.type,
            "does not match expected NF3LNK[%s]." % NF3LNK
        ]))
    if res.resok.data != link_path:
        t.fail_support(" ".join([
            "READLINK - data returned [%s]" % res.resok.data,
            "does not match expected [%s]." % link_path
        ]))
    if len(res.resok.data) != len(link_path):
        t.fail_support(" ".join([
            "READLINK - bytes returned [%d]" % len(res.resok.data),
            "does not match expected bytes [%d]." % len(link_path)
        ]))
Пример #44
0
def testNfs3ReadDirPlus(t, env):
    """ Retrieve entries sequentially from a dir via the READDIRPLUS rpc 
    
    
    FLAGS: nfsv3 readdirplus all
    DEPEND: 
    CODE: RDDIRPLS1
    #ToDo:  switch depend to create1 once bug #76982 is closed
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    created_files = []
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    cookie = 0
    cookie_verf = 0
    dir_count = 150
    max_count = 1200
    test_file_count = 15

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data

    for i in range(1, test_file_count + 1):
        temp_name = "%s_%s" % (test_file, i)
        res = env.c1.create(test_dir_fh, temp_name, file_mode_set=1, file_mode_val=0777)
        check(res, msg="CREATE - file %s" % temp_name)
        created_files.append(temp_name)

    ### Execution Phase ###
    entries = env.c1.do_readdirplus(test_dir_fh, cookie, cookie_verf, dir_count, max_count)

    ### Verification Phase ###
    # Add 2 to the count to account for "." and ".." entries
    if len(entries) != test_file_count + 2:
        t.fail_support(
            " ".join(
                [
                    "READDIR - number of dir entries returned [%s]" % len(entries),
                    "does not match number created [%s]" % (test_file_count + 2),
                ]
            )
        )
    for e in entries:
        if e.name not in created_files:
            if e.name != "." and e.name != "..":
                t.fail_support(
                    " ".join(
                        [
                            "READDIR - returned entry name [%s]" % e.name,
                            "was not in the list of created files [%s]" % ("\n".join(created_files)),
                        ]
                    )
                )
Пример #45
0
def testNfs3CommitLarge(t, env):
    """ Tests COMMIT with large amounts of writes beforehand. Dial up the
    datalen for an even larger filesize.

    FLAGS: nfsv3 commit all
    DEPEND:
    CODE: COMMIT2
    """
    ### Setup Phase ###
    datalen = 512 * 1024 * 1024
    writesize = 512 * 1024
    test_data = "a" * writesize

    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data

    # WRITE in a loop until we write datalen
    offset = 0
    wlen = writesize
    while (offset < datalen):
        if (datalen - offset < writesize):
            wlen = datalen - offset
            test_data = "a" * wlen

        print "Writing offset = %ld, length = %d" % (offset, wlen)
        res = env.c1.write(test_file_fh,
                           offset=offset,
                           count=wlen,
                           stable=UNSTABLE,
                           data=test_data)
        check(res,
              msg="WRITE - file %s - offset=%ld - len=%d" %
              (test_file, offset, wlen))

        offset = offset + wlen

    ### Execution Phase ###
    offset = 0
    print "Committing %d data at offset %d" % (datalen, offset)
    res = env.c1.commit(test_file_fh, offset, datalen)

    ### Verification Phase ###
    check(res, msg="COMMIT of test file %s" % test_file)
Пример #46
0
def testNfs3Null(t, env):
    """ NFSPROC3_NULL

    FLAGS: nfsv3 all
    DEPEND:
    CODE: NULL1
    """
    ### Setup Phase ###
    mnt_fh = homedir_fh(env.mc, env.c1)
    
    ### Execution Phase ###
    res = env.c1.null()
Пример #47
0
def testNfs3Null(t, env):
    """ NFSPROC3_NULL

    FLAGS: nfsv3 all
    DEPEND:
    CODE: NULL1
    """
    ### Setup Phase ###
    mnt_fh = homedir_fh(env.mc, env.c1)

    ### Execution Phase ###
    res = env.c1.null()
Пример #48
0
def testNfs3Create_Exclusive(t, env):
    """ Create a file in exclusive mode

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE9
    """
    ### Setup Phase ###
    #verf = '12345678'
    verf = str(0x3B9ACA01)
    wrongverf = '87654321'
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file,
        nfs3_mode=EXCLUSIVE, exclusive_verf=verf)
    check(res, msg="CREATE - file %s" % test_file)
    fh1 = res.resok.obj.handle.data

    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)

    # Create with same verifier should return same object
    res = env.c1.create(test_dir_fh, test_file,
        nfs3_mode=EXCLUSIVE, exclusive_verf=verf)
    check(res, msg="2nd CREATE with correct verifier")
    fh2 = res.resok.obj.handle.data

    # Compare file handles
    checkvalid(fh1 == fh2, "Filehandle changed on 2nd exclusive create"
        "(fh1 = %s, fh2 = %s)" % (fh1, fh2))

    # Create the file again, should return an error
    res = env.c1.create(test_dir_fh, test_file,
        nfs3_mode=EXCLUSIVE, exclusive_verf=wrongverf)
    check(res, NFS3ERR_EXIST, msg="3rd CREATE with wrong verifier")

    # Create with same verifier should return same object
    res = env.c1.create(test_dir_fh, test_file,
        nfs3_mode=EXCLUSIVE, exclusive_verf=verf)
    check(res, msg="3rd CREATE with correct verifier")
    fh2 = res.resok.obj.handle.data

    # Compare file handles
    checkvalid(fh1 == fh2, "Filehandle changed on 3rd exclusive create"
        "(fh1 = %s, fh2 = %s)" % (fh1, fh2))
Пример #49
0
def testNfs3Create_Exclusive(t, env):
    """ Create a file in exclusive mode

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE9
    """
    ### Setup Phase ###
    #verf = '12345678'
    verf = str(0x3B9ACA01)
    wrongverf = '87654321'
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file,
        nfs3_mode=EXCLUSIVE, exclusive_verf=verf)
    check(res, msg="CREATE - file %s" % test_file)
    fh1 = res.resok.obj.handle.data

    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)

    # Create with same verifier should return same object
    res = env.c1.create(test_dir_fh, test_file,
        nfs3_mode=EXCLUSIVE, exclusive_verf=verf)
    check(res, msg="2nd CREATE with correct verifier")
    fh2 = res.resok.obj.handle.data

    # Compare file handles
    checkvalid(fh1 == fh2, "Filehandle changed on 2nd exclusive create"
        "(fh1 = %s, fh2 = %s)" % (fh1, fh2))

    # Create the file again, should return an error
    res = env.c1.create(test_dir_fh, test_file,
        nfs3_mode=EXCLUSIVE, exclusive_verf=wrongverf)
    check(res, NFS3ERR_EXIST, msg="3rd CREATE with wrong verifier")

    # Create with same verifier should return same object
    res = env.c1.create(test_dir_fh, test_file,
        nfs3_mode=EXCLUSIVE, exclusive_verf=verf)
    check(res, msg="3rd CREATE with correct verifier")
    fh2 = res.resok.obj.handle.data

    # Compare file handles
    checkvalid(fh1 == fh2, "Filehandle changed on 3rd exclusive create"
        "(fh1 = %s, fh2 = %s)" % (fh1, fh2))
Пример #50
0
def testNfs3ReadDirPlus(t, env):
    """ Retrieve entries sequentially from a dir via the READDIRPLUS rpc 
    
    
    FLAGS: nfsv3 readdirplus all
    DEPEND: 
    CODE: RDDIRPLS1
    #ToDo:  switch depend to create1 once bug #76982 is closed
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    created_files = []
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    cookie = 0
    cookie_verf = 0
    dir_count = 150
    max_count = 1200
    test_file_count = 15

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data

    for i in range(1, test_file_count + 1):
        temp_name = "%s_%s" % (test_file, i)
        res = env.c1.create(test_dir_fh,
                            temp_name,
                            file_mode_set=1,
                            file_mode_val=0777)
        check(res, msg="CREATE - file %s" % temp_name)
        created_files.append(temp_name)

    ### Execution Phase ###
    entries = env.c1.do_readdirplus(test_dir_fh, cookie, cookie_verf,
                                    dir_count, max_count)

    ### Verification Phase ###
    # Add 2 to the count to account for "." and ".." entries
    if len(entries) != test_file_count + 2:
        t.fail_support(" ".join([
            "READDIR - number of dir entries returned [%s]" % len(entries),
            "does not match number created [%s]" % (test_file_count + 2)
        ]))
    for e in entries:
        if e.name not in created_files:
            if e.name != "." and e.name != "..":
                t.fail_support(" ".join([
                    "READDIR - returned entry name [%s]" % e.name,
                    "was not in the list of created files [%s]" %\
                        ("\n".join(created_files))
                    ]))
Пример #51
0
def testNfs3SetAttr(t, env):
    """ Set the attributes of a file via the SETATTR rpc 
        and verify they change correctly 

    FLAGS: nfsv3 setattr all
    DEPEND:
    CODE: SATTR1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    old_mode=0777
    new_mode=0755
    old_size=111
    new_size=333
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, 
                        file_mode_set=1, file_mode_val=old_mode, 
                        size_set=1, size_val=old_size)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    res = env.c1.getattr(test_file_fh)
    check(res, msg="GETATTR - file %s" % test_file)
    if res.attributes.size != old_size:
        t.fail_support(" ".join([
            "GETATTR - Initial file size [%s]" % res.attributes.size,
            "does not match specified value [%s]" % old_size]))
    if res.attributes.mode != old_mode:
        t.fail_support(" ".join([
            "GETATTR - Initial file mode [%s]" % res.attributes.mode, 
            "does not match specified value [%s]" % old_mode]))
    
    ### Execution Phase ###
    res = env.c1.setattr(test_file_fh, 
                         mode_set=1, mode_val=new_mode, 
                         size_set=1, size_val=new_size)
    
    ### Verification Phase ###
    check(res, msg="SETATTR - file %s" % test_file)
    if res.wcc.after.attributes.mode != new_mode:
        t.fail_support(" ".join([
            "SETATTR - mode value [%s]" % res.wcc.after.attributes.mode, 
            "does not match specified value [%s]" % new_mode]))
    if res.wcc.after.attributes.size != new_size:
        t.fail_support(" ".join([
            "SETATTR - size attr value [%s]" % res.wcc.after.attributes.size,
            "does not match specified value [%s]" % new_size]))
Пример #52
0
def testNfs3Write(t, env):
    """ Write test data into a file via WRITE rpc, 
        read the file and verify the output 
        
    FLAGS: nfsv3 write all
    DEPEND:
    CODE: WRITE1
    """
    ### Setup Phase ###
    test_file = t.name + "_file_1"
    test_dir = t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    test_data = "Test String"

    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh,
                        test_file,
                        file_mode_set=1,
                        file_mode_val=0777)
    check(res, msg="CREATE - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data

    ### Execution Phase ###
    res = env.c1.write(test_file_fh,
                       offset=0,
                       count=len(test_data),
                       stable=FILE_SYNC,
                       data=test_data)

    ### Verification Phase ###
    check(res, msg="WRITE - file %s" % test_file)
    if res.resok.count != len(test_data):
        t.fail_support(" ".join([
            "WRITE - response: data returned [%d]" % res.resok.count,
            "bytes of data written.  [%d] bytes expected" % len(test_data)
        ]))
    res = env.c1.read(test_file_fh, offset=0, count=len(test_data))
    check(res, msg="READ - file %s" % test_file)
    if res.resok.data != test_data:
        t.fail.support(" ".join([
            "WRITE - operation returned [%s]." % res.resok.data,
            "[%s] expected." % test_data
        ]))
    if res.resok.count != len(test_data):
        t.fail_support(" ".join([
            "WRITE - operation returned [%d] bytes." % res.resok.count,
            "[%d] bytes expected." % len(test_data)
        ]))
Пример #53
0
def testNfs3Create_SizeTruncate(t, env):
    """ Create a file with a specified size and then truncate it with
    another create. (Unchecked is the default creation type.)

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE3T
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777, size_set=1, size_val=9876543210)
    check(res, msg="CREATE(1) - file %s" % test_file)
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1,
                        file_mode_val=0777, size_set=1, size_val=1234567890)
    check(res, msg="CREATE(2) - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    
    ### Verification Phase ###
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.size == 9876543210,
               "CREATE - file %s (size=%d expected %d)" %
               (test_file, res.attributes.size, 9876543210))

    ### Execution Phase 2 ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1,
                        file_mode_val=0777, size_set=1, size_val=0)
    check(res, msg="CREATE(3) - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"

    ### Verification Phase 2 ###
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.size == 0,
               "CREATE - file %s (size=%d expected %d)" %
               (test_file, res.attributes.size, 0))
Пример #54
0
def testNfs3Create_SizeTruncate(t, env):
    """ Create a file with a specified size and then truncate it with
    another create. (Unchecked is the default creation type.)

    FLAGS: nfsv3 create all
    DEPEND:
    CODE: CREATE3T
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    mnt_fh = homedir_fh(env.mc, env.c1)
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - test dir %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    
    ### Execution Phase ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                        file_mode_val=0777, size_set=1, size_val=9876543210)
    check(res, msg="CREATE(1) - file %s" % test_file)
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1,
                        file_mode_val=0777, size_set=1, size_val=1234567890)
    check(res, msg="CREATE(2) - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"
    
    ### Verification Phase ###
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.size == 9876543210,
               "CREATE - file %s (size=%d expected %d)" %
               (test_file, res.attributes.size, 9876543210))

    ### Execution Phase 2 ###
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1,
                        file_mode_val=0777, size_set=1, size_val=0)
    check(res, msg="CREATE(3) - file %s" % test_file)
    test_file_fh = res.resok.obj.handle.data
    #print "###DEBUG - CREATE_FILEMODESET RESULTS:", res, "\n"

    ### Verification Phase 2 ###
    res = env.c1.lookup(test_dir_fh, test_file)
    check(res, msg="LOOKUP - file %s" % test_file)
    res = env.c1.getattr(test_file_fh)
    checkvalid(res.attributes.size == 0,
               "CREATE - file %s (size=%d expected %d)" %
               (test_file, res.attributes.size, 0))
Пример #55
0
def testNLM4Cancel(t, env):
    """ Send LOCK and then CANCEL RPC.


    FLAGS: nfsv3 nlm
    DEPEND: NLM0
    CODE: NLMCANCEL1
    """
    mnt_fh = homedir_fh(env.mc, env.c1)
    lock = nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)
    res = env.nlm.lockk(lock, 'cookie', True)
    lock = env.nlm.cancel(lock,
                          netobj_cookie='cookie123',
                          block=True,
                          exclusive=True)
Пример #56
0
def testNLMathon(t, env):
    """ NLM it up!

    FLAGS: nfsv3 nlm
    DEPEND: NLM0
    CODE: NLM4
    """
    print "Running NLM Stress..."
    mnt_fh = homedir_fh(env.mc, env.c1)
    lock = nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)
    threads = []
    for i in range(0,1000):
        threads.append(threading.Thread(target=runRandomProc,args=(lock,i,env)))
        threads[i].start()
    for i in range(0,1000):
        threads[i].join()
Пример #57
0
def testNfs3ReadLink(t, env):
    """ Create a symlink to a file and read the link via the READLINK rpc 

        
    FLAGS: nfsv3 readlink all
    DEPEND:
    CODE: RDLINK1
    """
    ### Setup Phase ###
    test_file=t.name + "_file_1"
    test_dir=t.name + "_dir_1"
    test_link=t.name + "_link_1"
    mount_path='/' + '/'.join(env.mc.opts.path[:-1])
    link_path='/'.join([mount_path, test_dir, test_file])
    mnt_fh = homedir_fh(env.mc, env.c1)
    
    res = env.c1.mkdir(mnt_fh, test_dir, dir_mode_set=1, dir_mode_val=0777)
    check(res, msg="MKDIR - %s" % test_dir)
    test_dir_fh = res.resok.obj.handle.data
    res = env.c1.create(test_dir_fh, test_file, file_mode_set=1, 
                file_mode_val=0777)
    check(res, msg="CREATE - file %s " % test_file)
    res = env.c1.symlink(test_dir_fh, test_link, mode_set=1, mode_val=0777, 
        size_set=1, size_val=len(link_path), data=link_path)
    check(res, msg="SYMLINK - link %s" % test_link)
    res = env.c1.lookup(test_dir_fh, test_link)
    check(res, msg="LOOKUP of test symlink %s" % test_link)
    test_link_fh = res.object.data
    
    ### Execution Phase ###
    res = env.c1.readlink(test_link_fh)
        
    ### Verification Phase ###
    check(res, msg="READLINK on existing file %s" % test_file)
    if res.resok.type != NF3LNK:
        t.fail_support(" ".join([
            "READLINK - data type returned [%s]" % res.resok.type,
            "does not match expected NF3LNK[%s]." % NF3LNK]))
    if res.resok.data != link_path:
        t.fail_support(" ".join([
            "READLINK - data returned [%s]" % res.resok.data,
            "does not match expected [%s]."  % link_path]))
    if len(res.resok.data) != len(link_path):
        t.fail_support(" ".join([
            "READLINK - bytes returned [%d]" % len(res.resok.data),
            "does not match expected bytes [%d]." % len(link_path)]))
Пример #58
0
def testNLM4Test(t, env):
     """ Test the NLM TEST op.
         It's a test to test TEST.

     FLAGS: nfsv3 nlm
     DEPEND: NLM0
     CODE: NLM1
     """
     ### Setup Phase ###
     mnt_fh = homedir_fh(env.mc, env.c1)

     ### Execution Phase ###
     res = env.nlm.test(nlm4_lock(t.name, mnt_fh, 'owner', env.pid, 0, 1024)
          ,'cookie', True)

     ### Verification Phase ###
     nlm4check(res.stat, msg="TEST")