示例#1
0
文件: tester.py 项目: ialzuru/ncfs
 def test_consistency(self):
     # Test the upload and download consistency:
     print "Test consistency of upload and download."
     tempfilepath = self.setting.mirrordir + "/" + tempfilename
     # Copy infile to tempfile in mirror dir:
     shutil.copyfile(infilename, tempfilepath)
     filesize = os.path.getsize(tempfilepath)
     # Upload tempfile:
     metadata = common.FileMetadata(tempfilename, filesize, self.setting.totalnode, self.setting.coding)
     workflow.uploadFile(self.setting, metadata)
     print "Upload finishes."
     # Clean temporary directories:
     clean.cleanAll()
     print "Clean finishes."
     # Download tempfile:
     metadata = common.FileMetadata(tempfilename, 0, self.setting.totalnode, self.setting.coding)
     workflow.downloadFile(self.setting, metadata)
     print "Download finishes."
     # Copy tempfile to outfile:
     shutil.copyfile(tempfilepath, outfilename)
     # Clean data in cloud and temporary directories:
     metadata = common.FileMetadata(tempfilename, 0, self.setting.totalnode, self.setting.coding)
     workflow.deleteFile(self.setting, metadata)
     clean.cleanAll()
     # Check if infile is same as outfile:
     print "test file difference"
     self.assertEqual(filecmp.cmp(infilename, outfilename), 1)
     # Delete outfile:
     os.unlink(outfilename)
示例#2
0
 def test_consistency(self):
     #Test the upload and download consistency:
     print "Test consistency of upload and download."
     tempfilepath = self.setting.mirrordir + "/" + tempfilename
     #Copy infile to tempfile in mirror dir:
     shutil.copyfile(infilename, tempfilepath)
     filesize = os.path.getsize(tempfilepath)
     #Upload tempfile:
     metadata = common.FileMetadata(tempfilename, filesize,
                                    self.setting.totalnode,
                                    self.setting.coding)
     workflow.uploadFile(self.setting, metadata)
     print "Upload finishes."
     #Clean temporary directories:
     clean.cleanAll()
     print "Clean finishes."
     #Download tempfile:
     metadata = common.FileMetadata(tempfilename, 0, self.setting.totalnode,
                                    self.setting.coding)
     workflow.downloadFile(self.setting, metadata)
     print "Download finishes."
     #Copy tempfile to outfile:
     shutil.copyfile(tempfilepath, outfilename)
     #Clean data in cloud and temporary directories:
     metadata = common.FileMetadata(tempfilename, 0, self.setting.totalnode,
                                    self.setting.coding)
     workflow.deleteFile(self.setting, metadata)
     clean.cleanAll()
     #Check if infile is same as outfile:
     print "test file difference"
     self.assertEqual(filecmp.cmp(infilename, outfilename), 1)
     #Delete outfile:
     os.unlink(outfilename)
示例#3
0
文件: cloudncfs.py 项目: ialzuru/ncfs
 def flush(self):
     global settingpath
     self._fflush()
     os.close(os.dup(self.fd))
     setting = common.Setting()
     setting.read(settingpath)#cq update setting before unlink. repair operation may change setting.cfg
     if setting.testmode == True:
         if ("a" in self.file.mode) or ("w" in self.file.mode) or ("+" in self.file.mode):
             self.metadata.totalnode = setting.totalnode
             #Encode and upload file to clouds:
             workflow.uploadFile(setting, self.metadata)
示例#4
0
文件: cloudncfs.py 项目: ialzuru/ncfs
 def release(self, flags):
     '''File close. Upload file to cloud for write mode.'''
     global settingpath
     self.file.close()
     setting = common.Setting()
     setting.read(settingpath)#cq update setting before unlink. repair operation may change setting.cfg
     if setting.testmode == False:
         if ("a" in self.file.mode) or ("w" in self.file.mode) or ("+" in self.file.mode):
             self.metadata.totalnode = setting.totalnode
             #Encode and upload file to clouds:
             print "upload file in cloudncfs"
             workflow.uploadFile(setting, self.metadata)
示例#5
0
 def flush(self):
     global settingpath
     self._fflush()
     os.close(os.dup(self.fd))
     setting = common.Setting()
     setting.read(
         settingpath
     )  #cq update setting before unlink. repair operation may change setting.cfg
     if setting.testmode == True:
         if ("a" in self.file.mode) or ("w" in self.file.mode) or (
                 "+" in self.file.mode):
             self.metadata.totalnode = setting.totalnode
             #Encode and upload file to clouds:
             workflow.uploadFile(setting, self.metadata)
示例#6
0
 def release(self, flags):
     '''File close. Upload file to cloud for write mode.'''
     global settingpath
     self.file.close()
     setting = common.Setting()
     setting.read(
         settingpath
     )  #cq update setting before unlink. repair operation may change setting.cfg
     if setting.testmode == False:
         if ("a" in self.file.mode) or ("w" in self.file.mode) or (
                 "+" in self.file.mode):
             self.metadata.totalnode = setting.totalnode
             #Encode and upload file to clouds:
             print "upload file in cloudncfs"
             workflow.uploadFile(setting, self.metadata)