scenarios.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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.zippy.all_actions import Action, ValidateAll # noqa
  10. from materialize.zippy.backup_and_restore_actions import BackupAndRestore
  11. from materialize.zippy.balancerd_actions import (
  12. BalancerdRestart,
  13. BalancerdStart,
  14. BalancerdStop,
  15. )
  16. from materialize.zippy.blob_store_actions import BlobStoreRestart, BlobStoreStart
  17. from materialize.zippy.crdb_actions import CockroachRestart, CockroachStart
  18. from materialize.zippy.debezium_actions import CreateDebeziumSource, DebeziumStart
  19. from materialize.zippy.framework import ActionFactory, ActionOrFactory # noqa
  20. from materialize.zippy.kafka_actions import (
  21. CreateTopicParameterized,
  22. Ingest,
  23. KafkaInsertParallel,
  24. KafkaStart,
  25. )
  26. from materialize.zippy.kafka_capabilities import Envelope
  27. from materialize.zippy.mysql_actions import (
  28. CreateMySqlTable,
  29. MySqlDML,
  30. MySqlRestart,
  31. MySqlStart,
  32. )
  33. from materialize.zippy.mysql_cdc_actions import CreateMySqlCdcTable
  34. from materialize.zippy.mz_actions import (
  35. KillClusterd,
  36. Mz0dtDeploy,
  37. MzRestart,
  38. MzStart,
  39. MzStop,
  40. )
  41. from materialize.zippy.peek_actions import PeekCancellation
  42. from materialize.zippy.pg_cdc_actions import CreatePostgresCdcTable
  43. from materialize.zippy.postgres_actions import (
  44. CreatePostgresTable,
  45. PostgresDML,
  46. PostgresRestart,
  47. PostgresStart,
  48. )
  49. from materialize.zippy.replica_actions import (
  50. CreateReplica,
  51. DropDefaultReplica,
  52. DropReplica,
  53. )
  54. from materialize.zippy.sink_actions import CreateSinkParameterized
  55. from materialize.zippy.source_actions import (
  56. AlterSourceConnectionParameterized,
  57. CreateSourceParameterized,
  58. )
  59. from materialize.zippy.storaged_actions import (
  60. StoragedKill,
  61. StoragedRestart,
  62. StoragedStart,
  63. )
  64. from materialize.zippy.table_actions import DML, CreateTableParameterized, ValidateTable
  65. from materialize.zippy.view_actions import CreateViewParameterized, ValidateView
  66. class Scenario:
  67. def bootstrap(self) -> list[ActionOrFactory]:
  68. return [
  69. KafkaStart,
  70. CockroachStart,
  71. BlobStoreStart,
  72. MzStart,
  73. StoragedStart,
  74. BalancerdStart,
  75. ]
  76. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  77. raise RuntimeError
  78. def finalization(self) -> list[ActionOrFactory]:
  79. return [
  80. MzStart,
  81. BalancerdStart,
  82. StoragedStart,
  83. ValidateAll(),
  84. BackupAndRestore,
  85. ValidateAll(),
  86. ]
  87. class KafkaSources(Scenario):
  88. """A Zippy test using Kafka sources exclusively."""
  89. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  90. return {
  91. MzStart: 5,
  92. MzStop: 1,
  93. Mz0dtDeploy: 5,
  94. KillClusterd: 5,
  95. # Disabled because a separate clusterd is not supported by Mz0dtDeploy yet
  96. # StoragedKill: 5,
  97. # StoragedStart: 5,
  98. CreateTopicParameterized(): 5,
  99. CreateSourceParameterized(): 5,
  100. CreateViewParameterized(max_inputs=2): 5,
  101. CreateSinkParameterized(): 5,
  102. ValidateView: 10,
  103. Ingest: 100,
  104. PeekCancellation: 5,
  105. }
  106. class AlterConnectionWithKafkaSources(Scenario):
  107. """A Zippy test using Kafka sources and alter connections."""
  108. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  109. return {
  110. MzStart: 5,
  111. MzStop: 1,
  112. Mz0dtDeploy: 1,
  113. KillClusterd: 5,
  114. # Disabled because a separate clusterd is not supported by Mz0dtDeploy yet
  115. # StoragedKill: 5,
  116. # StoragedStart: 5,
  117. CreateTopicParameterized(): 5,
  118. CreateSourceParameterized(): 5,
  119. CreateViewParameterized(max_inputs=2): 5,
  120. CreateSinkParameterized(): 5,
  121. AlterSourceConnectionParameterized(): 5,
  122. ValidateView: 10,
  123. Ingest: 100,
  124. PeekCancellation: 5,
  125. }
  126. class UserTables(Scenario):
  127. """A Zippy test using user tables exclusively."""
  128. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  129. return {
  130. MzStart: 5,
  131. BalancerdStart: 1,
  132. MzStop: 10,
  133. Mz0dtDeploy: 10,
  134. BalancerdStop: 1,
  135. BalancerdRestart: 1,
  136. BackupAndRestore: 1,
  137. KillClusterd: 10,
  138. # Disabled because a separate clusterd is not supported by Mz0dtDeploy yet
  139. # StoragedRestart: 5,
  140. CreateTableParameterized(): 10,
  141. CreateViewParameterized(): 10,
  142. CreateSinkParameterized(): 10,
  143. ValidateTable: 20,
  144. ValidateView: 20,
  145. DML: 30,
  146. }
  147. class DebeziumPostgres(Scenario):
  148. """A Zippy test using Debezium Postgres exclusively."""
  149. def bootstrap(self) -> list[ActionOrFactory]:
  150. return super().bootstrap() + [
  151. DebeziumStart,
  152. PostgresStart,
  153. ]
  154. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  155. return {
  156. CreatePostgresTable: 10,
  157. CreateDebeziumSource: 10,
  158. KillClusterd: 5,
  159. StoragedKill: 5,
  160. StoragedStart: 5,
  161. CreateViewParameterized(): 10,
  162. ValidateView: 20,
  163. PostgresDML: 100,
  164. }
  165. class PostgresCdc(Scenario):
  166. """A Zippy test using Postgres CDC exclusively."""
  167. def bootstrap(self) -> list[ActionOrFactory]:
  168. return super().bootstrap() + [PostgresStart]
  169. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  170. return {
  171. CreatePostgresTable: 10,
  172. CreatePostgresCdcTable: 10,
  173. KillClusterd: 5,
  174. StoragedKill: 5,
  175. StoragedStart: 5,
  176. PostgresRestart: 10,
  177. CreateViewParameterized(): 10,
  178. ValidateView: 20,
  179. PostgresDML: 100,
  180. }
  181. def finalization(self) -> list[ActionOrFactory]:
  182. # Postgres sources can't be backup up and restored since Postgres
  183. # refuses to re-read previously confirmed LSNs
  184. return [
  185. MzStart,
  186. BalancerdStart,
  187. StoragedStart,
  188. ValidateAll(),
  189. ]
  190. class MySqlCdc(Scenario):
  191. """A Zippy test using MySQL CDC exclusively."""
  192. def bootstrap(self) -> list[ActionOrFactory]:
  193. return super().bootstrap() + [MySqlStart]
  194. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  195. return {
  196. CreateMySqlTable: 10,
  197. CreateMySqlCdcTable: 10,
  198. KillClusterd: 5,
  199. StoragedKill: 5,
  200. StoragedStart: 5,
  201. MySqlRestart: 10,
  202. CreateViewParameterized(): 10,
  203. ValidateView: 20,
  204. MySqlDML: 100,
  205. }
  206. class ClusterReplicas(Scenario):
  207. """A Zippy test that uses CREATE / DROP REPLICA and random killing."""
  208. def bootstrap(self) -> list[ActionOrFactory]:
  209. return super().bootstrap() + [
  210. DropDefaultReplica,
  211. CreateReplica,
  212. ]
  213. # Due to gh#13235 it is not possible to have MzStop/MzStart in this scenario
  214. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  215. return {
  216. KillClusterd: 5,
  217. StoragedRestart: 5,
  218. CreateReplica: 30,
  219. DropReplica: 10,
  220. CreateTopicParameterized(): 10,
  221. CreateSourceParameterized(): 10,
  222. CreateTableParameterized(): 10,
  223. CreateViewParameterized(): 20,
  224. CreateSinkParameterized(): 10,
  225. ValidateView: 20,
  226. Ingest: 50,
  227. DML: 50,
  228. PeekCancellation: 5,
  229. }
  230. class KafkaParallelInsert(Scenario):
  231. """A Zippy test using simple views over Kafka sources with parallel insertion."""
  232. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  233. return {
  234. KillClusterd: 5,
  235. StoragedKill: 5,
  236. StoragedStart: 5,
  237. CreateTopicParameterized(): 10,
  238. CreateSourceParameterized(): 10,
  239. CreateViewParameterized(expensive_aggregates=False, max_inputs=1): 5,
  240. ValidateView: 10,
  241. KafkaInsertParallel: 50,
  242. }
  243. class CrdbBlobStoreRestart(Scenario):
  244. """A Zippy test that restarts CRDB and BlobStore."""
  245. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  246. return {
  247. CreateTopicParameterized(): 5,
  248. CreateSourceParameterized(): 5,
  249. CreateViewParameterized(max_inputs=2): 5,
  250. CreateSinkParameterized(): 5,
  251. Ingest: 50,
  252. CreateTableParameterized(): 10,
  253. DML: 50,
  254. ValidateView: 15,
  255. MzRestart: 5,
  256. Mz0dtDeploy: 5,
  257. KillClusterd: 5,
  258. # Disabled because a separate clusterd is not supported by Mz0dtDeploy yet
  259. # StoragedRestart: 10,
  260. CockroachRestart: 15,
  261. BlobStoreRestart: 15,
  262. }
  263. class CrdbRestart(Scenario):
  264. """A Zippy test that restarts Cockroach."""
  265. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  266. return {
  267. CreateTopicParameterized(): 5,
  268. CreateSourceParameterized(): 5,
  269. CreateViewParameterized(max_inputs=2): 5,
  270. CreateSinkParameterized(): 5,
  271. Ingest: 50,
  272. CreateTableParameterized(): 10,
  273. DML: 50,
  274. ValidateView: 15,
  275. MzRestart: 5,
  276. Mz0dtDeploy: 5,
  277. KillClusterd: 5,
  278. # Disabled because a separate clusterd is not supported by Mz0dtDeploy yet
  279. # StoragedRestart: 10,
  280. CockroachRestart: 15,
  281. }
  282. class KafkaSourcesLarge(Scenario):
  283. """A Zippy test using a large number of Kafka sources, views and sinks (no killings)."""
  284. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  285. return {
  286. CreateTopicParameterized(max_topics=5): 10,
  287. CreateSourceParameterized(max_sources=25): 10,
  288. CreateViewParameterized(
  289. max_views=50, expensive_aggregates=False, max_inputs=1
  290. ): 5,
  291. CreateSinkParameterized(max_sinks=25): 10,
  292. ValidateView: 10,
  293. Ingest: 100,
  294. PeekCancellation: 5,
  295. }
  296. class DataflowsLarge(Scenario):
  297. """A Zippy test using a smaller number but more complex dataflows."""
  298. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  299. return {
  300. CreateReplica: 2,
  301. CreateTopicParameterized(
  302. max_topics=2, envelopes_with_weights={Envelope.UPSERT: 100}
  303. ): 10,
  304. CreateSourceParameterized(max_sources=10): 10,
  305. CreateViewParameterized(
  306. max_views=5, expensive_aggregates=True, max_inputs=5
  307. ): 10,
  308. ValidateView: 10,
  309. Ingest: 50,
  310. DML: 50,
  311. }
  312. class UserTablesLarge(Scenario):
  313. """A Zippy scenario over tables (no killing)."""
  314. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  315. return {
  316. CreateTableParameterized(max_tables=2): 10,
  317. CreateViewParameterized(
  318. max_views=5, expensive_aggregates=True, max_inputs=5
  319. ): 10,
  320. CreateSinkParameterized(max_sinks=10): 10,
  321. ValidateView: 10,
  322. DML: 50,
  323. }
  324. class BackupAndRestoreLarge(Scenario):
  325. """A Zippy scenario with the occasional Backup+Restore."""
  326. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  327. return {
  328. CreateTableParameterized(max_tables=2): 10,
  329. CreateViewParameterized(
  330. max_views=5, expensive_aggregates=True, max_inputs=5
  331. ): 10,
  332. CreateSinkParameterized(max_sinks=10): 10,
  333. ValidateView: 10,
  334. DML: 50,
  335. BackupAndRestore: 0.1,
  336. }
  337. class PostgresCdcLarge(Scenario):
  338. """A Zippy test using Postgres CDC exclusively (Pg not killed)."""
  339. def bootstrap(self) -> list[ActionOrFactory]:
  340. return super().bootstrap() + [PostgresStart]
  341. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  342. return {
  343. CreatePostgresTable: 10,
  344. CreatePostgresCdcTable: 10,
  345. KillClusterd: 5,
  346. StoragedKill: 5,
  347. StoragedStart: 5,
  348. CreateViewParameterized(): 10,
  349. ValidateView: 20,
  350. PostgresDML: 100,
  351. }
  352. def finalization(self) -> list[ActionOrFactory]:
  353. # Postgres sources can't be backup up and restored since Postgres
  354. # refuses to re-read previously confirmed LSNs
  355. return [
  356. MzStart,
  357. BalancerdStart,
  358. StoragedStart,
  359. ValidateAll(),
  360. ]
  361. class MySqlCdcLarge(Scenario):
  362. """A Zippy test using MySQL CDC exclusively (MySQL not killed)."""
  363. def bootstrap(self) -> list[ActionOrFactory]:
  364. return super().bootstrap() + [MySqlStart]
  365. def actions_with_weight(self) -> dict[ActionOrFactory, float]:
  366. return {
  367. CreateMySqlTable: 10,
  368. CreateMySqlCdcTable: 10,
  369. KillClusterd: 5,
  370. StoragedKill: 5,
  371. StoragedStart: 5,
  372. CreateViewParameterized(): 10,
  373. ValidateView: 20,
  374. MySqlDML: 100,
  375. }