def unfs_stop(self): """ Stop UNFS. """ unfs.stop() time.sleep(1)
def setUp(self): """ Setup test data dir, mountpoint, node mountpoint, mount nodes and start UNFS. """ # setup env self.testDir = os.getcwd() + '/testdata' unfs.base = self.testDir unfs.mountPoint = self.testDir + '/unfs' unfs.nodeMountPoint = self.testDir + '/fs' # test data self.testFile = os.getcwd() + '/test/blah.txt' self.testFileDest = unfs.mountPoint + '/blah.txt' self.testBigFileDest = unfs.mountPoint + '/bigfile' self.tar = os.getcwd () + '/test/linux-2.6.23.tar.gz' # make sure unfs is stopped unfs.stop() # clean old testdir os.system('rm -rf %s' % self.testDir) os.mkdir(self.testDir) # make sure mountpoint exists # set mountpoint locally for testing if not os.path.exists(unfs.mountPoint): os.mkdir(unfs.mountPoint) # nodes os.mkdir(unfs.nodeMountPoint) # local nodes self.nodes = { 't1':unfs.nodeMountPoint + '/t1', 't2':unfs.nodeMountPoint + '/t2', 't3':unfs.nodeMountPoint + '/t3', 't4':unfs.nodeMountPoint + '/t4', } for nodeName, nodePath in self.nodes.iteritems(): os.mkdir(nodePath) # t1 has some data that noone else has # t3 has some data in a dir that t1 has os.mkdir(unfs.nodeMountPoint + '/t1/media') os.mkdir(unfs.nodeMountPoint + '/t1/media/tv') shutil.copyfile(self.tar, unfs.nodeMountPoint + '/t1/media/tv/sdf.avi') os.mkdir(unfs.nodeMountPoint + '/t3/media') os.mkdir(unfs.nodeMountPoint + '/t3/media/music') shutil.copyfile(self.tar, unfs.nodeMountPoint + '/t3/media/music/mp3') # remote fs nodes #self.remoteNodes = { # 'triton':'triton:/export/unfs', # 'nereid':'nereid:/giga/unfs', # 'romulus':'romulus:/rom/unfs', #} #for nodeName, nodePath in self.nodes.iteritems(): # self.mount(nodePath, unfs.nodeMountPoint + '/' + nodeName) # self.assertTrue(self.mounted(nodePath, \ # unfs.nodeMountPoint + '/' + nodeName)) # start unfs self.unfs_start()