Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:MaterializeInc Materialize Upgrade Scenario Selection

From Leeroopedia


Knowledge Sources misc/python/materialize/checks/scenarios.py, misc/python/materialize/checks/scenarios_upgrade.py
Domains Upgrade Testing, Scenario-Based Testing, Test Composition
Last Updated 2026-02-08

Overview

Scenario-based testing defines upgrade paths as composable sequences of typed actions, allowing a single set of checks to be exercised under many different real-world upgrade patterns.

Description

The Upgrade Scenario Selection principle captures the idea that an upgrade test framework must model the diversity of upgrade paths that users encounter in production. A single upgrade path (e.g., "stop old version, start new version") is insufficient because real deployments involve:

  • Multi-version hops — upgrading through two, three, or four intermediate versions.
  • Component-level upgrades — upgrading compute clusterds separately from environmentd.
  • Rolling upgrades with preflight checks — starting a read-only instance of the new version, waiting for readiness, then promoting.
  • Rollbacks — starting the new version in preflight mode and then reverting to the old version.
  • Infrastructure restarts — restarting Cockroach, Redpanda, or PostgreSQL sources mid-upgrade.

Rather than writing separate test suites for each path, the framework defines a Scenario abstraction. Each scenario is a class whose actions() method returns a list of Action objects that describe, in order, what should happen:

  • StartMz — launch Materialize at a specific version.
  • KillMz — stop the running instance.
  • Initialize, Manipulate, Validate — drive the check lifecycle.
  • Infrastructure actions like WaitReadyMz, PromoteMz, RestartCockroach, etc.

By composing these actions, a scenario author can model arbitrary upgrade topologies without modifying the check implementations. Every Check subclass is automatically run inside every compatible scenario, producing a cross-product of (checks x scenarios) coverage.

Usage

Apply this principle when you need to:

  • Add a new upgrade path to the test suite (e.g., a new multi-hop version sequence).
  • Model a new operational event during upgrades (e.g., a storage node restart).
  • Understand which scenarios exist and what upgrade paths they cover.
  • Filter checks based on scenario requirements (e.g., external idempotence, forced migration support).

Theoretical Basis

This principle derives from scenario-based testing in software engineering, where test scenarios are first-class objects that describe end-to-end workflows. The key theoretical properties are:

Composability — Actions are typed, independent building blocks. A scenario is nothing more than an ordered list of actions. This makes it trivial to create new scenarios by rearranging existing action types.

Orthogonality — Checks and scenarios are orthogonal dimensions. Adding a new check automatically increases coverage across all scenarios, and adding a new scenario automatically exercises all existing checks.

Filtering — The _include_check_class() method on Scenario enables declarative filtering. For example, scenarios that require external idempotence (because validate() is called multiple times) automatically exclude checks that are not externally idempotent.

The design follows the Strategy pattern: the Scenario base class defines the algorithm skeleton (initialize checks, run actions, validate), while each concrete scenario provides a different strategy via its actions() method.

Scenario Type Upgrade Path Key Characteristic
UpgradeEntireMz last → current Single-hop upgrade
UpgradeEntireMzTwoVersions previous → last → current Two-hop upgrade
UpgradeEntireMzFourVersions X-4 → X-3 → X-2 → X-1 → current Four-hop upgrade
PreflightCheckContinue last → current (with preflight) 0dt upgrade with promotion
PreflightCheckRollback last → current → last (rollback) 0dt upgrade with rollback

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment