2 # This script aims to help to run locktests with several clients.
4 # Report bugs to Vincent ROQUETA : vincent.roqueta@ext.bull.net
16 NFS4_PATH
="/mnt/nfsv4"
18 TEST_HOME
="/home/vincent/locks/"
19 testfile
=NFS4_PATH
+"/testfile"
22 SRC
="locktests-2.tar.gz"
24 install
="'tar xzf "+SRC
+"; cd locks; make `"
34 self
.command
="mkdir -p "+dir
37 self
.command
="rm -rf "+dir
41 print "->"+self
.command
44 class Client(Machine
):
46 def __init__(self
, machine
):
49 self
.mountPath
=NFS4_PATH
52 self
.command
="ssh "+user
+"@"+self
.machine
+" "+self
.command
53 os
.system(self
.command
)
55 def isomount(self
, dir):
58 self
.command
="'mkdir -p "+mntpoint
+"; mount -t nfs4 "+export
+" "+mntpoint
+"'"
61 def umount(self
, dir):
62 mntpoint
=self
.mountPath
+"/"+dir
63 self
.command
="umount "+mntpoint
65 def install(self
, path
):
66 self
.command
="'cd "+path
+"; tar xzf "+SRC
+"; cd locks; make'"
72 def cp(self
, fichier
, path
):
73 command
="scp "+fichier
+" "+user
+"@"+self
.machine
+":"+path
77 class Serveur(Machine
):
79 def __init__(self
, ip
, exportPath
):
81 self
.exportPath
=exportPath
84 self
.command
="ssh "+self
.SERVEUR
+" "+self
.command
85 os
.system(self
.command
)
87 def configure(self
, dir):
88 exportDir
=self
.exportPath
+'/'+dir
89 self
. mkdir(exportDir
)
91 self
.export(exportDir
)
94 unexportDir
=self
.exportPath
+'/'+dir
95 self
.unexport(unexportDir
)
96 self
.rmdir(unexportDir
)
100 print "locktests.py <-n process -f testfile ><--setup -s fs_server> -c host1, host2, host3 ... "
101 print "--setup : setup the configuration, deploy test on other test machines; This option also requires -c and -s"
102 print "-c <machine> : host list to deploy/run/clean the test"
103 print "-s <machine> : NFS server to use to setup the test"
104 print "-n <num> : number of processes each test machine will lauch to perform the test"
105 print "-f <file> : test file. This must be the same on each machine"
109 print "*Setup machines for testing"
110 print "./locktests.py --setup -c testmachine1 testmachine2 testmachine3 -s my_nfs_server:/"
112 print "*Run test on testmachine1,testmachine2 with 50 process on each machine using /mnt/nfsv4/testfile"
113 print "./locktests.py -n 50 -f /mnt/nfsv4/testfile -c testmachine1 testmachine2"
115 print "_________________________________"
116 print "Vincent ROQUETA - Bull SA - 2005\n"
123 path
=os
.path
.abspath(".")
124 fichier
=SRC_PATH
+"/"+SRC
127 print "Setting up machine "+i
132 c
.isomount(NFS4_PATH
)
134 print "Setting up localhost"
135 commande
="make; mkdir -p "+NFS4_PATH
+" ; mount -t nfs4 "+NFS4_SERVER
+" "+NFS4_PATH
+" &"
140 path
=os
.path
.abspath(".")
141 nbreClients
=len(clients
)
142 hostname
=socket
.gethostname()
143 # Lancement du serveur en local
144 # Launch the server locally
145 commande
=path
+"/"+app
+" -n "+nbreProcess
+" -f "+filename
+" -c "+str(nbreClients
)+" &"
147 commande
=path
+"/locks/"+app
+" --server "+hostname
154 client
.umount(NFS4_PATH
)
172 if args
[i
] in ("--install", "-i", "--setup"):
176 if args
[i
] in ("-s", "--server"):
180 if args
[i
] in ("-h", "--help"):
183 if args
[i
] in ("--clients", "-c"):
197 clients
.append(args
[i
])
213 if (not c
) or (not nfsServer
):
219 print "Setup complete"
222 if (not c
) or (not f
) or (not n
):