diff --git a/.github/workflows/windows-build-test.yml b/.github/workflows/windows-build-test.yml index 23c6a0ece528..9ce6205661ef 100644 --- a/.github/workflows/windows-build-test.yml +++ b/.github/workflows/windows-build-test.yml @@ -349,6 +349,11 @@ jobs: - run: Start-Sleep -Seconds 10 timeout-minutes: 1 + - run: '& "C:\Program Files\OpenZFS On Windows\zfs.exe" mount' + timeout-minutes: 1 + - run: Start-Sleep -Seconds 10 + timeout-minutes: 1 + - run: '& "C:\Program Files\OpenZFS On Windows\zpool.exe" destroy -f test01' timeout-minutes: 1 - run: Start-Sleep -Seconds 10 @@ -1935,3 +1940,401 @@ jobs: - name: run tests run: robocopy ${{ steps.drive2.outputs.drive }}\curtin ${{ steps.drive.outputs.drive }}curtin /E /b /R:0 /W:0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + test5_py: + needs: [build_windows] #, build_wsl] + timeout-minutes: 30 + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: windows-latest + + steps: + + - uses: actions/checkout@v3 + + + - uses: actions/download-artifact@v3 + with: + name: dev_build_inno + +# - uses: actions/download-artifact@v3 +# with: +# name: build result + +# - name: get files +# run: Get-ChildItem -Recurse + + - name: get diskdrive + run: wmic diskdrive list + + + #- uses: suisei-cn/actions-download-file@v1.3.0 + # #id: innoinstaller + # with: + # url: 'https://github.com/andrewc12/zfsfiledump/raw/main/OpenZFSOnWindowsaa' + # target: ${{github.workspace}}/ + + + + #- uses: suisei-cn/actions-download-file@v1.3.0 + # #id: innoinstaller + # with: + # url: 'https://github.com/andrewc12/zfsfiledump/raw/main/OpenZFSOnWindowsab' + # target: ${{github.workspace}}/ + + + + #- uses: suisei-cn/actions-download-file@v1.3.0 + # #id: innoinstaller + # with: + # url: 'https://github.com/andrewc12/zfsfiledump/raw/main/OpenZFSOnWindowsac' + # target: ${{github.workspace}}/ + + + + #- uses: suisei-cn/actions-download-file@v1.3.0 + # #id: innoinstaller + # with: + # url: 'https://github.com/andrewc12/zfsfiledump/raw/main/OpenZFSOnWindowsad' + # target: ${{github.workspace}}/ + + + + + + + + +# - name: Download +# uses: suisei-cn/actions-download-file@v1.3.0 +# #id: innoinstaller +# with: +# url: 'https://github.com/andrewc12/zfsfiledump/raw/main/testdrives.zip' +# target: ${{github.workspace}}/ +# +# +# - name: make disk +# run: | +# Expand-Archive -LiteralPath ${{github.workspace}}/testdrives.zip -DestinationPath D:\ +# +# - name: Download +# uses: suisei-cn/actions-download-file@v1.3.0 +# #id: innoinstaller +# with: +# url: 'https://github.com/andrewc12/zfsfiledump/raw/main/scriptname.txt' +# target: ${{github.workspace}}/ +# +# - name: make disk +# run: | +# diskpart /s scriptname.txt +# +# +# +# - name: get diskdrive +# run: wmic diskdrive list +# +# +# - name: get files +# run: Get-ChildItem -Recurse + + #- run: copy /b OpenZFSOnWindowsaa+OpenZFSOnWindowsab+OpenZFSOnWindowsac+OpenZFSOnWindowsad OpenZFSOnWindows-a.exe + # shell: cmd + + + + - name: get zfsexename + id: zfsinstaller + run: | + $p = Get-ChildItem | Where-Object {$_.Name -like 'OpenZFSOnWindows-*.exe'} | Select-Object -first 1 + echo $p + $f = (Get-Item $p ).Name + echo $f + echo "filename=$f" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append + + + + + + + # https://github.com/MicrosoftDocs/windows-powershell-docs/issues/266 + - name: Import root certificate + run: | + $plaintextpwd = 'password1234' + $pwd = ConvertTo-SecureString -String $plaintextpwd -Force -AsPlainText + Import-PfxCertificate -FilePath ${{github.workspace}}/contrib/windows/TestCert/test_sign_cert_pass.pfx -CertStoreLocation Cert:\LocalMachine\Root -Password $pwd + Import-PfxCertificate -FilePath ${{github.workspace}}/contrib/windows/TestCert/test_sign_cert_pass.pfx -CertStoreLocation Cert:\LocalMachine\TrustedPublisher -Password $pwd + + - name: debug - echo filename + run: echo ${{ steps.zfsinstaller.outputs.filename }} + +# - name: debug - list +# run: ls ${{github.workspace}}\ + + - name: debug - list + run: ls ${{github.workspace}}\${{ steps.zfsinstaller.outputs.filename }} + + #- name: install zfs + # run: ${{github.workspace}}\${{ steps.zfsinstaller.outputs.filename }} /NORESTART /ALLUSERS /VERYSILENT /LOG="${{github.workspace}}\InnoSetup-Install.log" + + - name: install zfs + run: 'Start-Process -FilePath "${{github.workspace}}\${{ steps.zfsinstaller.outputs.filename }}" -Wait -ArgumentList "/NORESTART /ALLUSERS /VERYSILENT /LOG=`"${{github.workspace}}\InnoSetup-Install.log`""' + + #- name: Wait for install to finish + # run: Start-Sleep -Seconds 30 + # uses: iFaxity/wait-on-action@v1 + # with: + # resource: 'C:\Program Files\OpenZFS On Windows\zpool.exe' + +# - name: debug - print log +# run: cat "${{github.workspace}}\InnoSetup-Install.log" +# +# - name: debug - list +# run: ls "C:\Program Files" +# +# - name: debug - list +# run: ls "C:\Program Files\OpenZFS On Windows" + + - name: debug - get status + run: '& "C:\Program Files\OpenZFS On Windows\zpool.exe" status' + + + + - name: test + run: 'python.exe -u "${{github.workspace}}\contrib\windows\tests\tests.py" -path ${{github.workspace}}\' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# This is a basic workflow to help you get started with Actions +# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/ + + test6_pywinbtrfs: + needs: [build_windows] #, build_wsl] + timeout-minutes: 30 + runs-on: windows-latest +# if: ${{ inputs.run-failing }} + steps: + + - uses: actions/checkout@v3 + + + - uses: actions/download-artifact@v3 + with: + name: dev_build_inno + +# - uses: actions/download-artifact@v3 +# with: +# name: build result + +# - name: get files +# run: Get-ChildItem -Recurse + + - name: get diskdrive + run: wmic diskdrive list + +# - name: Download +# uses: suisei-cn/actions-download-file@v1.3.0 +# #id: innoinstaller +# with: +# url: 'https://github.com/andrewc12/zfsfiledump/raw/main/testdrives.zip' +# target: ${{github.workspace}}/ +# +# +# - name: make disk +# run: | +# Expand-Archive -LiteralPath ${{github.workspace}}/testdrives.zip -DestinationPath D:\ +# +# - name: Download +# uses: suisei-cn/actions-download-file@v1.3.0 +# #id: innoinstaller +# with: +# url: 'https://github.com/andrewc12/zfsfiledump/raw/main/scriptname.txt' +# target: ${{github.workspace}}/ +# +# - name: make disk +# run: | +# diskpart /s scriptname.txt +# +# +# +# - name: get diskdrive +# run: wmic diskdrive list +# +# +# - name: get files +# run: Get-ChildItem -Recurse + + + - name: get zfsexename + id: zfsinstaller + run: | + $p = Get-ChildItem | Where-Object {$_.Name -like 'OpenZFSOnWindows-*.exe'} | Select-Object -first 1 + echo $p + $f = (Get-Item $p ).Name + echo $f + echo "filename=$f" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append + + # https://github.com/MicrosoftDocs/windows-powershell-docs/issues/266 + - name: Import root certificate + run: | + $plaintextpwd = 'password1234' + $pwd = ConvertTo-SecureString -String $plaintextpwd -Force -AsPlainText + Import-PfxCertificate -FilePath ${{github.workspace}}/contrib/windows/TestCert/test_sign_cert_pass.pfx -CertStoreLocation Cert:\LocalMachine\Root -Password $pwd + Import-PfxCertificate -FilePath ${{github.workspace}}/contrib/windows/TestCert/test_sign_cert_pass.pfx -CertStoreLocation Cert:\LocalMachine\TrustedPublisher -Password $pwd + + - name: debug - echo filename + run: echo ${{ steps.zfsinstaller.outputs.filename }} + +# - name: debug - list +# run: ls ${{github.workspace}}\ + + - name: debug - list + run: ls ${{github.workspace}}\${{ steps.zfsinstaller.outputs.filename }} + + #- name: install zfs + # run: ${{github.workspace}}\${{ steps.zfsinstaller.outputs.filename }} /NORESTART /ALLUSERS /VERYSILENT /LOG="${{github.workspace}}\InnoSetup-Install.log" + + - name: install zfs + run: 'Start-Process -FilePath "${{github.workspace}}\${{ steps.zfsinstaller.outputs.filename }}" -Wait -ArgumentList "/NORESTART /ALLUSERS /VERYSILENT /LOG=`"${{github.workspace}}\InnoSetup-Install.log`""' + + #- name: Wait for install to finish + # run: Start-Sleep -Seconds 30 + # uses: iFaxity/wait-on-action@v1 + # with: + # resource: 'C:\Program Files\OpenZFS On Windows\zpool.exe' + +# - name: debug - print log +# run: cat "${{github.workspace}}\InnoSetup-Install.log" +# +# - name: debug - list +# run: ls "C:\Program Files" +# +# - name: debug - list +# run: ls "C:\Program Files\OpenZFS On Windows" + + - name: debug - get status + run: '& "C:\Program Files\OpenZFS On Windows\zpool.exe" status' + + + + + + + + - name: Download winbtrfs + uses: suisei-cn/actions-download-file@v1.3.0 + id: winbtrs # Remember to give an ID if you need the output filename + with: + url: "https://github.com/andrewc12/btrfs/releases/download/v1.8/x64-Debug.zip" + target: ${{github.workspace}}/ + + - name: extract + run: Expand-Archive -LiteralPath '${{ steps.winbtrs.outputs.filename }}' -DestinationPath ${{github.workspace}}\winbtrfs + + - name: debug - list + run: ls ${{github.workspace}}\ + + - name: debug - list + run: ls ${{github.workspace}}\winbtrfs + + + + + + + + + - name: test + run: 'python.exe -u "${{github.workspace}}\contrib\windows\tests\btrfstests.py" -path ${{github.workspace}}\' + + - name: Adding markdown + run: | + cat ${{github.workspace}}\winbtrfs.log | Out-File $env:GITHUB_STEP_SUMMARY + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.0 + with: + name: build_output + path: ${{github.workspace}}/winbtrfs.log + + + + + + + + + + + + + diff --git a/contrib/windows/tests/btrfstests.py b/contrib/windows/tests/btrfstests.py new file mode 100644 index 000000000000..871fa7ec1f6b --- /dev/null +++ b/contrib/windows/tests/btrfstests.py @@ -0,0 +1,270 @@ +import os +import argparse + +import subprocess + +from pathlib import Path, PurePosixPath, PureWindowsPath, WindowsPath + +from pprint import pprint + +import time + + +import json + +import logging + +logging.basicConfig(level=logging.DEBUG) + + +print("Printed immediately.") +def parse_arguments(): + parser = argparse.ArgumentParser(description='Process command line arguments.') + parser.add_argument('-path', type=dir_path, required=True) + return parser.parse_args() +def dir_path(path): + if os.path.isdir(path): + return path + else: + raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid path") + + + +def get_DeviceId(): + magic_number_process = subprocess.run( + ["wmic", "diskdrive", "get", "DeviceId"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + #https://github.com/sir-ragna/dddddd + #get DeviceId + + a=magic_number_process.stdout.decode(encoding='UTF-8',errors='strict').replace("\r\r\n", "\r\n") + + c = a.splitlines() + + d = [x.split() for x in c] + + e = [x[0] for x in d if len(x) > 0 and x[0] not in "DeviceID"] + + e.sort() + + #print(e) + + #print([x.encode(encoding='UTF-8') for x in e]) + + #import csv + + #with open('csv_file.csv', 'w', encoding='UTF8') as f: + # writer = csv.writer(f, dialect='excel', quoting=csv.QUOTE_ALL) + # + # for row in e: + # writer.writerow([row]) + + return e + +def allocate_file(name, size): + with open(name, 'wb') as f: + f.seek(size) + f.write(b'0') + +def delete_file(name): + if os.path.exists(name): + os.remove(name) + else: + print("The file does not exist") + + +def get_driveletters(): + magic_number_process = subprocess.run( + ["C:\\Program Files\\OpenZFS On Windows\\zfs.exe", "mount"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + #b'test01 H:\\ \r\ntest02 I:\\ \r\n' + + + a=magic_number_process.stdout.decode(encoding='UTF-8',errors='strict') + + c = a.splitlines() + + logging.debug("get_driveletters() {}".format(c)) + + #print("get_driveletters() debug",c) + + d = [x.split() for x in c] + + logging.debug("get_driveletters() {}".format(d)) + + return d + +# run: '& "C:\Program Files\OpenZFS On Windows\zfs.exe" mount' + + + +def create_pool(name, file): + magic_number_process = subprocess.run( + ["C:\\Program Files\\OpenZFS On Windows\\zpool.exe", "create", "-f", name, file], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + + +def destroy_pool(name): + magic_number_process = subprocess.run( + ["C:\\Program Files\\OpenZFS On Windows\\zpool.exe", "destroy", "-f", name], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + +def zpool(*args): + magic_number_process = subprocess.run( + ["C:\\Program Files\\OpenZFS On Windows\\zpool.exe", *args], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + return magic_number_process + + +def zfs(*args): + magic_number_process = subprocess.run( + ["C:\\Program Files\\OpenZFS On Windows\\zfs.exe", *args], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + return magic_number_process + + +def run(args): + d = {"zfs": "C:\\Program Files\\OpenZFS On Windows\\zfs.exe", "zpool": "C:\\Program Files\\OpenZFS On Windows\\zpool.exe"} + l = list(args) + try: + cmd = d[l[0]] + except: + cmd = l[0] + result = subprocess.run( + [cmd, *l[1:]], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + return result + + + +def tounc(name): + q = "\\\\?\\" + str(name) + return q + + + + + +def runWithPrint(cmd): + print(" ".join(cmd)) + ret = run(cmd) + logging.debug(str("args={}".format(" ".join(ret.args)))) + logging.debug(str("returncode={}".format(ret.returncode))) + logging.debug(str("stdout={}".format(ret.stdout))) + logging.debug(str("stderr={}".format(ret.stderr))) + + + return ret + +def preTest(testName = None): + print("=" * 20) + if testName is not None: + print("Name:", testName) + + get_driveletters() + +def postTest(): + get_driveletters() + print("=" * 20) + +def main(): + parsed_args = parse_arguments() + + print("Path:", parsed_args.path) + + p = PureWindowsPath(parsed_args.path) + + print("Path object:", p) + + print("Physical devices", get_DeviceId()) + + if p.is_absolute(): + + f1 = PureWindowsPath(p, "test01.dat") + allocate_file(f1, 1024*1024*1024) + + + with open(str(p.joinpath("winbtrfs.log")), "w") as log_file: + + preTest() + ret = runWithPrint(["zpool", "create", "-f", "test01", tounc(f1)]) + time.sleep(10) + if ret.returncode != 0: + print("FAIL") + print("Drive letters after pool create:", get_driveletters()) + time.sleep(10) + postTest() + + + + for test in ['create', 'supersede', 'overwrite', 'open_id', 'io', 'mmap', 'rename', 'rename_ex', 'delete', 'delete_ex', 'links', 'links_ex', 'oplock_i', 'oplock_ii', 'oplock_batch', 'oplock_filter', 'oplock_r', 'oplock_rw', 'oplock_rh', 'oplock_rwh', 'cs', 'reparse', 'streams', 'fileinfo', 'ea']: + preTest(str(test) +" tests:") + f = PureWindowsPath(get_driveletters()[0][1]) + ret = runWithPrint([str(p.joinpath("winbtrfs", "test.exe")), str(test), str(f)]) + time.sleep(10) + if ret.returncode != 0: + print("FAIL") + postTest() + + print(ret.stdout.decode()) + + out = " ".join([str(test), ret.stdout.decode().splitlines()[-1]]) + + print(out) + log_file.write(out) + log_file.write("\n") + + preTest() + #runWithPrint(["zpool", "destroy", "-f", "test01"]) + time.sleep(10) + postTest() + + + + + + #delete_file(f1) + + + + + + + + + + + + + + + + + +if __name__ == "__main__": + main() + + + + + diff --git a/contrib/windows/tests/tests.py b/contrib/windows/tests/tests.py new file mode 100644 index 000000000000..ac1c79707493 --- /dev/null +++ b/contrib/windows/tests/tests.py @@ -0,0 +1,527 @@ +import os +import argparse + +import subprocess + +from pathlib import Path, PurePosixPath, PureWindowsPath, WindowsPath + +from pprint import pprint + +import time + + +import json + +import logging + +logging.basicConfig(level=logging.DEBUG) + + +print("Printed immediately.") +def parse_arguments(): + parser = argparse.ArgumentParser(description='Process command line arguments.') + parser.add_argument('-path', type=dir_path, required=True) + return parser.parse_args() +def dir_path(path): + if os.path.isdir(path): + return path + else: + raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid path") + + + +def get_DeviceId(): + magic_number_process = subprocess.run( + ["wmic", "diskdrive", "get", "DeviceId"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + #https://github.com/sir-ragna/dddddd + #get DeviceId + + a=magic_number_process.stdout.decode(encoding='UTF-8',errors='strict').replace("\r\r\n", "\r\n") + + c = a.splitlines() + + d = [x.split() for x in c] + + e = [x[0] for x in d if len(x) > 0 and x[0] not in "DeviceID"] + + e.sort() + + #print(e) + + #print([x.encode(encoding='UTF-8') for x in e]) + + #import csv + + #with open('csv_file.csv', 'w', encoding='UTF8') as f: + # writer = csv.writer(f, dialect='excel', quoting=csv.QUOTE_ALL) + # + # for row in e: + # writer.writerow([row]) + + return e + +def allocate_file(name, size): + with open(name, 'wb') as f: + f.seek(size) + f.write(b'0') + +def delete_file(name): + if os.path.exists(name): + os.remove(name) + else: + print("The file does not exist") + + +def get_driveletters(): + magic_number_process = subprocess.run( + ["C:\\Program Files\\OpenZFS On Windows\\zfs.exe", "mount"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + #b'test01 H:\\ \r\ntest02 I:\\ \r\n' + + + a=magic_number_process.stdout.decode(encoding='UTF-8',errors='strict') + + c = a.splitlines() + + logging.debug("get_driveletters() {}".format(c)) + + #print("get_driveletters() debug",c) + + d = [x.split() for x in c] + + logging.debug("get_driveletters() {}".format(d)) + + return d + +# run: '& "C:\Program Files\OpenZFS On Windows\zfs.exe" mount' + + + +def create_pool(name, file): + magic_number_process = subprocess.run( + ["C:\\Program Files\\OpenZFS On Windows\\zpool.exe", "create", "-f", name, file], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + + +def destroy_pool(name): + magic_number_process = subprocess.run( + ["C:\\Program Files\\OpenZFS On Windows\\zpool.exe", "destroy", "-f", name], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + +def zpool(*args): + magic_number_process = subprocess.run( + ["C:\\Program Files\\OpenZFS On Windows\\zpool.exe", *args], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + return magic_number_process + + +def zfs(*args): + magic_number_process = subprocess.run( + ["C:\\Program Files\\OpenZFS On Windows\\zfs.exe", *args], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + return magic_number_process + + +def run(args): + d = {"zfs": "C:\\Program Files\\OpenZFS On Windows\\zfs.exe", "zpool": "C:\\Program Files\\OpenZFS On Windows\\zpool.exe"} + l = list(args) + cmd = d[l[0]] + result = subprocess.run( + [cmd, *l[1:]], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE + ) + + return result + + + +def tounc(name): + q = "\\\\?\\" + str(name) + return q + + + + + +def runWithPrint(cmd): + print(" ".join(cmd)) + ret = run(cmd) + logging.debug(str("args={}".format(" ".join(ret.args)))) + logging.debug(str("returncode={}".format(ret.returncode))) + logging.debug(str("stdout={}".format(ret.stdout))) + logging.debug(str("stderr={}".format(ret.stderr))) + + + return ret + +def preTest(testName = None): + print("=" * 20) + if testName is not None: + print("Name:", testName) + + get_driveletters() + +def postTest(): + get_driveletters() + print("=" * 20) + +def main(): + parsed_args = parse_arguments() + + print("Path:", parsed_args.path) + + p = PureWindowsPath(parsed_args.path) + + print("Path object:", p) + + print("Physical devices", get_DeviceId()) + + if p.is_absolute(): + + f1 = PureWindowsPath(p, "test01.dat") + allocate_file(f1, 1024*1024*1024) + f2 = PureWindowsPath(p, "test02.dat") + allocate_file(f2, 1024*1024*1024) + f3 = PureWindowsPath(p, "test03.dat") + allocate_file(f3, 1024*1024*1024) + + + + + + + + preTest() + ret = runWithPrint(["zpool", "create", "-f", "test01", tounc(f1)]) + time.sleep(10) + if ret.returncode != 0: + print("FAIL") + print("Drive letters after pool create:", get_driveletters()) + runWithPrint(["zpool", "destroy", "-f", "test01"]) + time.sleep(10) + postTest() + + + + + + preTest() + ret = runWithPrint(["zpool", "create", "-f", "test02", tounc(f1), tounc(f2)]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + print("Drive letters after pool create:", get_driveletters()) + runWithPrint(["zpool", "destroy", "-f", "test02"]) + time.sleep(10) + postTest() + + + + + + preTest() + ret = runWithPrint(["zpool", "create", "-f", "test03", tounc(f1), tounc(f2), tounc(f3)]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + print("Drive letters after pool create:", get_driveletters()) + runWithPrint(["zpool", "destroy", "-f", "test03"]) + time.sleep(10) + postTest() + + + + + + preTest() + ret = runWithPrint(["zpool", "create", "-f", "test04", "mirror", tounc(f1), tounc(f2)]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + print("Drive letters after pool create:", get_driveletters()) + runWithPrint(["zpool", "destroy", "-f", "test04"]) + time.sleep(10) + postTest() + + + + + + preTest() + ret = runWithPrint(["zpool", "create", "-f", "test05", "mirror", tounc(f1), tounc(f2), tounc(f3)]) + time.sleep(10) + if ret.returncode != 0: + print("FAIL") + print("Drive letters after pool create:", get_driveletters()) + runWithPrint(["zpool", "destroy", "-f", "test05"]) + time.sleep(10) + postTest() + + + + + + preTest() + ret = runWithPrint(["zpool", "create", "-f", "test06", "raidz", tounc(f1), tounc(f2), tounc(f3)]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + print("Drive letters after pool create:", get_driveletters()) + runWithPrint(["zpool", "destroy", "-f", "test06"]) + time.sleep(10) + postTest() + + + + + + preTest() + ret = runWithPrint(["zpool", "create", "-f", "test07", "raidz1", tounc(f1), tounc(f2), tounc(f3)]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + print("Drive letters after pool create:", get_driveletters()) + runWithPrint(["zpool", "destroy", "-f", "test07"]) + time.sleep(10) + postTest() + + + + + + + + + + + + + + + + + + + preTest("snapshot no hang:") + + ret = runWithPrint(["zpool", "create", "-f", "testsn01", tounc(f1)]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + print("Drive letters after pool create:", get_driveletters()) + + f = PureWindowsPath(get_driveletters()[0][1], "test01.file") + allocate_file(f, 1024) + + ret = runWithPrint(["zfs", "snapshot", "testsn01@friday"]) + if ret.returncode != 0: + print("FAIL") + + f = PureWindowsPath(get_driveletters()[0][1], "test02.file") + allocate_file(f, 1024) + + ret = runWithPrint(["zpool", "export", "-a"]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + + runWithPrint(["zpool", "destroy", "-f", "testsn01"]) + + time.sleep(10) + postTest() + + + + + + + # preTest("snapshot hang") + # + # ret = runWithPrint(["zpool", "create", "-f", "testsn02", tounc(f1)]) + # if ret.returncode != 0: + # print("FAIL") + # time.sleep(10) + # print("Drive letters after pool create:", get_driveletters()) + # + # f = PureWindowsPath(get_driveletters()[0][1], "test01.file") + # allocate_file(f, 1024) + # + # ret = runWithPrint(["zfs", "snapshot", "testsn02@friday"]) + # if ret.returncode != 0: + # print("FAIL") + # + # + # f = PureWindowsPath(get_driveletters()[0][1], "test02.file") + # allocate_file(f, 1024) + # + # ret = runWithPrint(["zfs", "mount", "testsn02@friday"]) + # if ret.returncode != 0: + # print("FAIL") + # + # + # ret = runWithPrint(["zpool", "export", "-a"]) + # if ret.returncode != 0: + # print("FAIL") + # time.sleep(10) + # + # runWithPrint(["zpool", "destroy", "-f", "testsn02"]) + # time.sleep(10) + # postTest() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + preTest("regex for key file") + + random_bytearray = bytearray(os.urandom(32)) + + key01 = PureWindowsPath(p, "key01.key") + + with open(key01, 'wb') as f: + f.write(random_bytearray) + + nx ="file://" + tounc(key01).replace("\\", "/") + print(nx) + + + ret = runWithPrint(["zpool", "create", "-f", "-O", "encryption=aes-256-ccm", "-O", "keylocation=" + nx, "-O", "keyformat=raw", "tank", tounc(f1)]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + print("Drive letters after pool create:", get_driveletters()) + + ret = runWithPrint(["zfs", "get", "keylocation", "tank"]) + if ret.returncode != 0: + print("FAIL") + + ret = runWithPrint(["zpool", "export", "tank"]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + + + + + + + + print("Drive letters before pool create:", get_driveletters()) + ret = runWithPrint(["zpool", "import", "-f", "-l", "-O", "encryption=aes-256-ccm", "-O", "keylocation=" + nx, "-O", "keyformat=raw", tounc(f1)]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + + + print("Drive letters after pool create:", get_driveletters()) + runWithPrint(["zpool", "destroy", "-f", "tank"]) + time.sleep(10) + postTest() + + + + + + + + + + + + + + preTest("run out of drive letters") + + for i in range(1, 26): + ret = runWithPrint(["zpool", "create", "-f", "tank" + str(i), tounc(f1)]) + if ret.returncode != 0: + print("FAIL") + time.sleep(10) + + print("Drive letters after pool create:", get_driveletters()) + + f = PureWindowsPath(get_driveletters()[0][1], "test01.file") + try: + allocate_file(f, 1024) + except: + print("FAIL") + + runWithPrint(["zpool", "destroy", "-f", "tank" + str(i)]) + time.sleep(10) + + + postTest() + + + + + + + + + delete_file(f1) + delete_file(f2) + delete_file(f3) + + + + +if __name__ == "__main__": + main() + + + + +