/tests/zfs-tests/tests/functional/cli_root/zpool_split/zpool_split_encryption.ksh

https://github.com/adilger/zfs · Korn Shell · 59 lines · 25 code · 10 blank · 24 comment · 2 complexity · d109213144ddf5346747ea314fc9cd1d MD5 · raw file

  1. #!/bin/ksh -p
  2. #
  3. # This file and its contents are supplied under the terms of the
  4. # Common Development and Distribution License ("CDDL"), version 1.0.
  5. # You may only use this file in accordance with the terms of version
  6. # 1.0 of the CDDL.
  7. #
  8. # A full copy of the text of the CDDL should have accompanied this
  9. # source. A copy of the CDDL is also available via the Internet at
  10. # http://www.illumos.org/license/CDDL.
  11. #
  12. #
  13. # Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
  14. #
  15. . $STF_SUITE/include/libtest.shlib
  16. . $STF_SUITE/tests/functional/cli_root/zpool_split/zpool_split.cfg
  17. #
  18. # DESCRIPTION:
  19. # 'zpool split' should be able to split encrypted pools
  20. #
  21. # STRATEGY:
  22. # 1. Create an encrypted pool
  23. # 2. Split and re-import the pool, verify altroot is mounted.
  24. #
  25. verify_runnable "both"
  26. function cleanup
  27. {
  28. destroy_pool $TESTPOOL
  29. destroy_pool $TESTPOOL2
  30. rm -f $DEVICE1 $DEVICE2
  31. }
  32. log_assert "'zpool split' should be able to split encrypted pools"
  33. log_onexit cleanup
  34. DEVICE1="$TEST_BASE_DIR/device-1"
  35. DEVICE2="$TEST_BASE_DIR/device-2"
  36. passphrase="password"
  37. altroot="$TESTDIR/zpool-split-$RANDOM"
  38. # 1. Create an encrypted pool
  39. truncate -s $SPA_MINDEVSIZE $DEVICE1
  40. truncate -s $SPA_MINDEVSIZE $DEVICE2
  41. log_must eval "echo "$passphrase" | zpool create -O encryption=aes-256-ccm " \
  42. "-O keyformat=passphrase $TESTPOOL mirror $DEVICE1 $DEVICE2"
  43. # 2. Split and re-import the pool, verify altroot is mounted.
  44. log_must eval "echo "$passphrase" | zpool split -l -R $altroot " \
  45. "$TESTPOOL $TESTPOOL2"
  46. log_must test "$(get_prop 'encryption' $TESTPOOL2)" == "aes-256-ccm"
  47. log_must test "$(get_pool_prop 'altroot' $TESTPOOL2)" == "$altroot"
  48. log_must mounted $altroot/$TESTPOOL2
  49. log_pass "'zpool split' can split encrypted pools"