Home | History | Annotate | Download | only in acl
      1 '''
      2 	Access Control Lists testing based on newpynfs framework
      3 	Aurelien Charbon - Bull SA
      4 '''
      5 from random_gen import *
      6 import commands
      7 import os
      8 import threading
      9 import time
     10 import random
     11 
     12 alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789_-() ~'
     13 t_alphabet=len(alphabet)
     14 
     15 def test_acl_default(path):
     16 
     17 # set default acl on the test directory
     18 	u = commands.getoutput('mkdir ' + path + "/" + testdir)
     19 	u = commands.getoutput('getfacl ' + path + "/" + testdir)
     20 	acl=[]
     21 	for i in range (len(splitedresult)-1)
     22 		splitedline = splitedresult[i].split('::')
     23 		name = splitedline[0]
     24 		entry = splitedline[1]
     25 		acl.append(name,entry)
     26 # create a file in this directory
     27 	u = commands.getoutput('touch ' + path + "/" + testdir + testfile)
     28 # get the file's ACL and verify
     29 	u = commands.getoutput('getfacl ' + path + "/" + testdir + testfile)
     30 	splitedresult = u.split('\n')
     31 	acl2=[]
     32 	for i in range (len(splitedresult)-1):
     33 		splitedline = splitedresult[i].split('::')
     34 		name = splitedline[0]
     35 		entry = splitedline[1]
     36 		acl2.append(name,entry)
     37 
     38 	result_final = True
     39 	while i < len(acl2):
     40 		result = False:
     41 		while j < len(acl2) and result = False:
     42 			if acl2[i] == acl[j]:
     43 			result = True
     44 		if result == False:
     45 			result_final = False
     46 
     47 ''' Measuring time to add an ACE to a list regarding the number of ACE already in the list'''
     48 ''' Doing the measurement on 100 files '''
     49 def test_acl_long():
     50 	path = '/mnt/nfs/test-acl'
     51 	test = RandomGen()
     52 	test.createFile(path,100)
     53 	test.getUserList()
     54 	t0=time.time()
     55 	for test_file in test.fList:
     56 		for user in test.uList:
     57 			mode = test.createRandomMode()
     58 			u = commands.getoutput('setfacl -m u:' + user + ':' + mode + " " + path + "/" + test_file)
     59 	t1=time.time()
     60 	print t1-t0
     61 
     62 def test_nfs_acl():
     63 	print "test acl 10000\n"
     64 	test = RandomGen()
     65 	f = open('/tmp/acl-result-10000','w')
     66 
     67         path = '/mnt/nfs/test-acl'
     68 	for i in range(10000):
     69 		print "test avec " + str(i) + " ACE"
     70 		test.getUserList()
     71 		testfile = 'testfile' + str(i)
     72 		u = commands.getoutput('touch ' + path + "/" + testfile)
     73 		t0=time.time()
     74                 for j in range(i):
     75 			user = test.uList.pop()
     76 			mode = test.createRandomMode()
     77                         u = commands.getoutput('setfacl -m u:' + user + ':' + mode + " " + path + "/" + testfile)
     78 		t1=time.time()
     79                 f.write(str(i) + "\t" + str(t1-t0)+"\n")
     80         f.close()
     81 
     82 
     83 def test_nfs_getfacl():
     84 	# mesures sur le getfacl
     85 	test = RandomGen()
     86 
     87 	path = '/mnt/nfs/test-acl' # NFS mounted directory
     88 	u = commands.getoutput('rm ' + path + "/*")	# clean directory
     89 	print "test acl getfacl\n"
     90 	f = open('/tmp/acl-result-getfacl','w')
     91 	for i in range(37):
     92 
     93 		test.getUserList()
     94 		testfile = 'testfile' + str(i)
     95 
     96 		u = commands.getoutput('touch ' + path + "/" + testfile)
     97 		print "setfacl " + str(i) + " " + u
     98 		for j in range(i):
     99 			user = test.uList.pop()
    100 			mode = test.createRandomMode()
    101                         u = commands.getoutput('setfacl -m u:' + user + ':' + mode + " " + path + "/" + testfile)
    102 
    103 		t1=time.time()
    104 		u = commands.getoutput('getfacl ' + path + "/" + testfile)
    105 		print "getfacl - " + str(i) + u + "\n"
    106 		t2=time.time()
    107 		f.write(str(i) + "\t" + str(t2-t1)+"\n")
    108 	f.close()
    109 
    110 
    111 def main():
    112 	# test getFileList
    113 	path = '/mnt/nfs/test-acl'
    114 	test = RandomGen()
    115 	test.getFileList(path)
    116 	print test.fList
    117 main()
    118 
    119 
    120 
    121 
    122 
    123