• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2'''
3	Access Control Lists testing based on newpynfs framework
4	Aurelien Charbon - Bull SA
5'''
6from random_gen import *
7import subprocess
8import os
9import threading
10import time
11import random
12
13alphabet='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789_-() ~'
14t_alphabet=len(alphabet)
15
16def test_acl_default(path):
17
18# set default acl on the test directory
19	u = subprocess.getoutput('mkdir ' + path + "/" + testdir)
20	u = subprocess.getoutput('getfacl ' + path + "/" + testdir)
21	acl=[]
22	for i in range (len(splitedresult)-1):
23		splitedline = splitedresult[i].split('::')
24		name = splitedline[0]
25		entry = splitedline[1]
26		acl.append(name,entry)
27# create a file in this directory
28	u = subprocess.getoutput('touch ' + path + "/" + testdir + testfile)
29# get the file's ACL and verify
30	u = subprocess.getoutput('getfacl ' + path + "/" + testdir + testfile)
31	splitedresult = u.split('\n')
32	acl2=[]
33	for i in range (len(splitedresult)-1):
34		splitedline = splitedresult[i].split('::')
35		name = splitedline[0]
36		entry = splitedline[1]
37		acl2.append(name,entry)
38
39	result_final = True
40	while i < len(acl2):
41		result = False
42		while j < len(acl2) and result == False:
43			if acl2[i] == acl[j]:
44				result = True
45		if result == False:
46			result_final = False
47
48''' Measuring time to add an ACE to a list regarding the number of ACE already in the list'''
49''' Doing the measurement on 100 files '''
50def test_acl_long():
51	path = '/mnt/nfs/test-acl'
52	test = RandomGen()
53	test.createFile(path,100)
54	test.getUserList()
55	t0=time.time()
56	for test_file in test.fList:
57		for user in test.uList:
58			mode = test.createRandomMode()
59			u = subprocess.getoutput('setfacl -m u:' + user + ':' + mode + " " + path + "/" + test_file)
60	t1=time.time()
61	print(t1-t0)
62
63def test_nfs_acl():
64	print("test acl 10000\n")
65	test = RandomGen()
66	f = open('/tmp/acl-result-10000','w')
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 = subprocess.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 = subprocess.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
83def test_nfs_getfacl():
84	# mesures sur le getfacl
85	test = RandomGen()
86
87	path = '/mnt/nfs/test-acl' # NFS mounted directory
88	u = subprocess.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 = subprocess.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 = subprocess.getoutput('setfacl -m u:' + user + ':' + mode + " " + path + "/" + testfile)
102
103		t1=time.time()
104		u = subprocess.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
111def main():
112	# test getFileList
113	path = '/mnt/nfs/test-acl'
114	test = RandomGen()
115	test.getFileList(path)
116	print(test.fList)
117main()
118
119
120
121
122
123