scenarios_backup_restore.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from materialize.checks.actions import Action, Initialize, Manipulate, Validate
  10. from materialize.checks.backup_actions import (
  11. Backup,
  12. Restore,
  13. )
  14. from materialize.checks.mzcompose_actions import (
  15. KillMz,
  16. StartMz,
  17. )
  18. from materialize.checks.scenarios import Scenario
  19. class BackupAndRestoreAfterManipulate(Scenario):
  20. """Backup and Restore Materialize after manipulate(phase=2) has run.
  21. Only validate() is run post-restore.
  22. """
  23. def actions(self) -> list[Action]:
  24. return [
  25. StartMz(self),
  26. Initialize(self),
  27. Manipulate(self, phase=1),
  28. Manipulate(self, phase=2),
  29. Backup(),
  30. KillMz(),
  31. Restore(),
  32. Validate(self),
  33. ]
  34. class BackupAndRestoreBeforeManipulate(Scenario):
  35. """Backup and Restore Materialize before manipulate(phase=2) has run."""
  36. def actions(self) -> list[Action]:
  37. return [
  38. StartMz(self),
  39. Initialize(self),
  40. Manipulate(self, phase=1),
  41. Backup(),
  42. KillMz(),
  43. Restore(),
  44. Manipulate(self, phase=2),
  45. Validate(self),
  46. ]
  47. class BackupAndRestoreToPreviousState(Scenario):
  48. """Backup, run more workloads, and then Restore to a previous state."""
  49. def requires_external_idempotence(self) -> bool:
  50. # This scenario will run manipulate(#2) twice, so only compatible
  51. # Checks are allowed to participate
  52. return True
  53. def actions(self) -> list[Action]:
  54. return [
  55. StartMz(self),
  56. Initialize(self),
  57. Manipulate(self, phase=1),
  58. Backup(),
  59. Manipulate(self, phase=2), # Those updates will be lost here ..
  60. KillMz(),
  61. Restore(),
  62. Manipulate(self, phase=2), # ... and redone here
  63. Validate(self),
  64. ]
  65. class BackupAndRestoreMulti(Scenario):
  66. """Repeated Backup and Restore operations."""
  67. def actions(self) -> list[Action]:
  68. return [
  69. StartMz(self),
  70. Initialize(self),
  71. Backup(),
  72. KillMz(),
  73. Restore(),
  74. Manipulate(self, phase=1),
  75. Backup(),
  76. KillMz(),
  77. Restore(),
  78. Manipulate(self, phase=2),
  79. Backup(),
  80. KillMz(),
  81. Restore(),
  82. Validate(self),
  83. Backup(),
  84. KillMz(),
  85. Restore(),
  86. Validate(self),
  87. ]