diff --git a/lib/filesystem/test_rwlock_smb.py b/lib/filesystem/test_rwlock_smb.py new file mode 100644 index 00000000..0d70e0bd --- /dev/null +++ b/lib/filesystem/test_rwlock_smb.py @@ -0,0 +1,82 @@ +__doc__ = """ +This test is to reproduce the read write lock with samba on windows +""" + +from smashbox.utilities import * +from smashbox.utilities.hash_files import * +import time + +nfiles = int(config.get('rwlock_smb_nfiles',4)) # The number of files to be created should be 4-1000 +delay = int(config.get('rwlock_smb_delay',1)) # this is the delay used to keep files open +smbpath = config.get('rwlock_smb_smbpath',"Z:/smb-rw-lock/") +leave_open = int(config.get('rwlock_leave_open',10)) + +clean_previous_run = True +path = smbpath + "/officeSimulation_word/" + +config.expected_result = do_not_report_as_failure("smb implements a special locking mechanism that corrupts files when trying to open them in read/write mode... ") + +restrict_execution(current_platform="Windows") # Restrict the execution to be run only in Windows + +def count_office_files(path): + n=0 + for filename in os.listdir(path): + if not filename.endswith("tmp"): + n = n + 1 + return n + +def open_office_files(mode): + try: + for filename in os.listdir(path): + if not filename.endswith("tmp"): + file = path + filename + process = subprocess.Popen( + os.getcwd()[:-3] + "\win-tools\KeepOfficeOpen\KeepItOpen.exe " + mode + " delay1" + " " + str( + delay) + " " + "s" + " " + "file" + " " + file) + + except Exception as e: + logger.exception('Error opening the word file to ' + mode + 'on it ') + + +@add_worker +def worker0(step): + + step(1, 'Preparation') + k0 = count_office_files(path) + + step(2, 'Create nfiles office files and write some content on it') + process = subprocess.Popen(os.getcwd()[:-3] + "/win-tools/OfficeUsersSimulation/OfficeUsersSimulation_C.exe nof" + " " + str(nfiles) + " " + "crtfls usewd wrkdir " + smbpath) + + k1=0 + while(abs(k1-k0) != nfiles): + k1=count_office_files(path) + time.sleep(1) + + process.kill() # Avoid this test to be locked by the execution of the program + + step(4, 'Open the nfiles office files with delay to write on it') + + open_office_files("w") + + time.sleep(leave_open) # Leave the program open. If the process is killed office will leave the file in DENY_READ + + step(5, 'Open the nfiles office files with delay to read on it') + + open_office_files("r") + + time.sleep(leave_open) + +@add_worker +def worker1(step): + + step(1, 'Preparation') + + k0 = count_office_files(path) + + step(3, 'Resync and check files added by worker0') + + ncorrupt = analyse_hashfiles(path)[2] + k1 = count_office_files(path) + + error_check(k1 - k0 == nfiles, 'Expecting to have %d files more: see k1=%d k0=%d' % (abs(k1 - 1), k1, k0)) + fatal_check(ncorrupt == 0, 'Corrupted files (%d) found' % ncorrupt) \ No newline at end of file diff --git a/win-tools/KeepOfficeOpen/KeepItOpen.exe b/win-tools/KeepOfficeOpen/KeepItOpen.exe new file mode 100644 index 00000000..84196bf2 Binary files /dev/null and b/win-tools/KeepOfficeOpen/KeepItOpen.exe differ diff --git a/win-tools/KeepOfficeOpen/README.txt b/win-tools/KeepOfficeOpen/README.txt new file mode 100644 index 00000000..cbb695fe --- /dev/null +++ b/win-tools/KeepOfficeOpen/README.txt @@ -0,0 +1,37 @@ +• In 'Debug' folder you can run the file "KeepItOpen.exe". + +• In 'publish' folder you can find the installation file. +You do NOT need to install the software, I just include the files in case you want them. + + +Instructions: + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Available arguments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +1) r (or) w : file in 'read' or 'write' mode +2) file + : path to word OR excel file to keep open +3) delay1 + : delay in seconds that file will be kept open +4) delay2 + : extra delay in seconds (ONLY in 'w' mode) +5) s : silent mode - no confirmation asked + +1) Open the file in either READ (r) or WRITE (w) mode. + In READ mode, the file will be kept open for as many seconds as defined by + parameter 'delay1'. Parameter 'delay2' is ignored. + Then the file is closed and the software exits. + + In WRITE mode, the file opens and stays open for as many seconds as defined + by parameter 'delay1'. Then some random Lorem Ipsum text is written. + Keep in mind that any text inside the file will be OVERWRITTEN! + If set, additional delay 'delay2' is applied in that point. + Then the file is closed and the software exits. + +2) Give the path to the office file that will be kept open. + Accepted formats: .doc .docx .xls .xlsx + +5) If this argument is added, the software will not ask for confirmation. + In case this argument is missing, you will be presented a sum of the arguments + and will be asked to confirm. + +Arguments (1) , (2) & (3) are mandatory. Arguments (4) & (5) can be skipped. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Check "args tests.txt" file for some examples. \ No newline at end of file diff --git a/win-tools/KeepOfficeOpen/args tests.txt b/win-tools/KeepOfficeOpen/args tests.txt new file mode 100644 index 00000000..7c36a87f --- /dev/null +++ b/win-tools/KeepOfficeOpen/args tests.txt @@ -0,0 +1,45 @@ +~~ Read mode word, delay 10 seconds + + r delay1 10 file "\\cernbox-smb.cern.ch\eos\user\a\asmyrnak\KeepOfficeOpen\testWord_1.docx" + +~~ Read mode, delay 10 seconds, SILENT + + r delay1 10 s file "\\cernbox-smb.cern.ch\eos\user\a\asmyrnak\KeepOfficeOpen\testWord_1.docx" + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +~~ Read mode word, delay 5 seconds, 2nd delay 10 seconds (software skips delay2) + + r delay1 5 delay2 10 file "\\cernbox-smb.cern.ch\eos\user\a\asmyrnak\KeepOfficeOpen\testWord_1.docx" + +~~ Read mode word, delay 5 seconds, 2nd delay 10 seconds (software skips delay2), SILENT + + r delay1 5 delay2 10 s file "\\cernbox-smb.cern.ch\eos\user\a\asmyrnak\KeepOfficeOpen\testWord_1.docx" + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +~~ Write mode word, delay 5 seconds + + w delay1 5 file "\\cernbox-smb.cern.ch\eos\user\a\asmyrnak\KeepOfficeOpen\testWord_1.docx" + +~~ Write mode word, delay 5 seconds, 2nd delay 10 seconds + + w delay1 5 delay2 10 file "\\cernbox-smb.cern.ch\eos\user\a\asmyrnak\KeepOfficeOpen\testWord_1.docx" + +~~ Write mode word, delay 5 seconds, 2nd delay 3 seconds, SILENT + + w delay1 5 delay2 3 s file "\\cernbox-smb.cern.ch\eos\user\a\asmyrnak\KeepOfficeOpen\testWord_1.docx" + +// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +~~ Write mode excel, delay 5 seconds + + w delay1 5 file "\\cernbox-smb.cern.ch\eos\user\a\asmyrnak\KeepOfficeOpen\testExcel_1.xlsx" + +~~ Write mode excel, delay 2 seconds, 2nd delay 5 seconds + + w delay1 2 delay2 5 file "\\cernbox-smb.cern.ch\eos\user\a\asmyrnak\KeepOfficeOpen\testExcel_1.xlsx" + +~~ Write mode excel, delay 5 seconds, 2nd delay 3 seconds, SILENT + + w delay1 5 delay2 3 s file "\\cernbox-smb.cern.ch\eos\user\a\asmyrnak\KeepOfficeOpen\testExcel_1.xlsx" \ No newline at end of file diff --git a/win-tools/OfficeUsersSimulation/Multiple Office Users simulation.docx b/win-tools/OfficeUsersSimulation/Multiple Office Users simulation.docx new file mode 100644 index 00000000..861a1b13 Binary files /dev/null and b/win-tools/OfficeUsersSimulation/Multiple Office Users simulation.docx differ diff --git a/win-tools/OfficeUsersSimulation/OfficeUsersSimulation_C.exe b/win-tools/OfficeUsersSimulation/OfficeUsersSimulation_C.exe new file mode 100644 index 00000000..885add80 Binary files /dev/null and b/win-tools/OfficeUsersSimulation/OfficeUsersSimulation_C.exe differ diff --git a/win-tools/OfficeUsersSimulation/README.txt b/win-tools/OfficeUsersSimulation/README.txt new file mode 100644 index 00000000..76932d5b --- /dev/null +++ b/win-tools/OfficeUsersSimulation/README.txt @@ -0,0 +1,20 @@ +• In the 'Debug' folder you can run the file "OfficeUsersSimulation_C.exe". + +• In the 'publish' folder you can find the installation file. +You do NOT need to isntall the software, I just include the files in case you want them. + + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Version 2: + ~ bug fix: - continuously loading defaults (or last) values + - could start empty files creation, even with no "use word/excel" selection + - while empty files running "use word/excel" could be changed + - if word/excel operations finish before "empty files" creation, button remains at "STOP" state + (restoreAfterRun() do not run before empty files creation is also completed) + + ~ add: - "autoDelete" option deletes also "empty files" folder (if user doesn't choose to open + the folder containing the files) + + ~ known issues: - at manual STOP (or Empty creation stop), excel instance remains (sometimes) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + \ No newline at end of file diff --git a/win-tools/README.txt b/win-tools/README.txt new file mode 100644 index 00000000..37e7fedb --- /dev/null +++ b/win-tools/README.txt @@ -0,0 +1,2 @@ +https://github.com/cernbox/wintools.git + \ No newline at end of file