Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions .github/workflows/test-framework-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,132 @@ jobs:
run: |
cat ~/.moose/*-cli.log

test-e2e-backward-compatibility-typescript:
needs:
[detect-changes, check, test-cli, test-ts-moose-lib, test-py-moose-lib]
if: needs.detect-changes.outputs.should_run == 'true'
name: Test E2E Backward Compatibility - TypeScript (Node 20)
runs-on: ubuntu-latest
permissions:
contents: read
env:
RUST_BACKTRACE: full
steps:
- name: Install Protoc (Needed for Temporal)
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: "23.x"

- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}

- uses: pnpm/action-setup@v4

- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: Get system info
id: system
run: |
echo "version=$(lsb_release -rs)" >> $GITHUB_OUTPUT
echo "distro=$(lsb_release -is)" >> $GITHUB_OUTPUT

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
cache-shared-key: ${{ runner.os }}-${{ steps.system.outputs.distro }}-${{ steps.system.outputs.version }}-${{ runner.arch }}-rust
cache-on-failure: true
cache-all-crates: true
cache-workspace-crates: true

- name: Run TypeScript Backward Compatibility Test
run: pnpm install --frozen-lockfile && pnpm --filter=framework-cli-e2e run test -- --grep "TypeScript Tests Template - Upgrade"
env:
MOOSE_TELEMETRY_ENABLED: false
# Add test credentials for S3Queue tests
TEST_AWS_ACCESS_KEY_ID: "test-access-key-id"
TEST_AWS_SECRET_ACCESS_KEY: "test-secret-access-key"

- name: Inspect Logs
if: always()
run: |
cat ~/.moose/*-cli.log

test-e2e-backward-compatibility-python:
needs:
[detect-changes, check, test-cli, test-ts-moose-lib, test-py-moose-lib]
if: needs.detect-changes.outputs.should_run == 'true'
name: Test E2E Backward Compatibility - Python (Node 20, Python 3.13)
runs-on: ubuntu-latest
permissions:
contents: read
env:
RUST_BACKTRACE: full
steps:
- name: Install Protoc (Needed for Temporal)
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: "23.x"

- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}

- uses: pnpm/action-setup@v4

- name: Install node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: Get system info
id: system
run: |
echo "version=$(lsb_release -rs)" >> $GITHUB_OUTPUT
echo "distro=$(lsb_release -is)" >> $GITHUB_OUTPUT

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
cache-shared-key: ${{ runner.os }}-${{ steps.system.outputs.distro }}-${{ steps.system.outputs.version }}-${{ runner.arch }}-rust
cache-on-failure: true
cache-all-crates: true
cache-workspace-crates: true

- name: Setup Python 3.13 for E2E tests
uses: actions/setup-python@v4
with:
python-version: "3.13"

- name: Upgrade Python build tools
run: pip install --upgrade pip setuptools wheel

- name: Run Python Backward Compatibility Test
run: pnpm install --frozen-lockfile && pnpm --filter=framework-cli-e2e run test -- --grep "Python Tests Template - Upgrade"
env:
MOOSE_TELEMETRY_ENABLED: false
# Add test credentials for S3Queue tests
TEST_AWS_ACCESS_KEY_ID: "test-access-key-id"
TEST_AWS_SECRET_ACCESS_KEY: "test-secret-access-key"

- name: Inspect Logs
if: always()
run: |
cat ~/.moose/*-cli.log

lints:
needs: detect-changes
if: needs.detect-changes.outputs.should_run == 'true'
Expand Down Expand Up @@ -614,6 +740,8 @@ jobs:
test-e2e-typescript-tests,
test-e2e-python-default,
test-e2e-python-tests,
test-e2e-backward-compatibility-typescript,
test-e2e-backward-compatibility-python,
lints,
]
if: always()
Expand Down Expand Up @@ -641,6 +769,8 @@ jobs:
[[ "${{ needs.test-e2e-typescript-tests.result }}" == "failure" ]] || \
[[ "${{ needs.test-e2e-python-default.result }}" == "failure" ]] || \
[[ "${{ needs.test-e2e-python-tests.result }}" == "failure" ]] || \
[[ "${{ needs.test-e2e-backward-compatibility-typescript.result }}" == "failure" ]] || \
[[ "${{ needs.test-e2e-backward-compatibility-python.result }}" == "failure" ]] || \
[[ "${{ needs.lints.result }}" == "failure" ]]; then
echo "One or more required jobs failed"
exit 1
Expand All @@ -654,6 +784,8 @@ jobs:
[[ "${{ needs.test-e2e-typescript-tests.result }}" == "success" ]] && \
[[ "${{ needs.test-e2e-python-default.result }}" == "success" ]] && \
[[ "${{ needs.test-e2e-python-tests.result }}" == "success" ]] && \
[[ "${{ needs.test-e2e-backward-compatibility-typescript.result }}" == "success" ]] && \
[[ "${{ needs.test-e2e-backward-compatibility-python.result }}" == "success" ]] && \
[[ "${{ needs.lints.result }}" == "success" ]]; then
echo "All required jobs succeeded"
exit 0
Expand Down
147 changes: 147 additions & 0 deletions BACKWARD_COMPATIBILITY_TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Backward Compatibility Testing

## Overview

This branch includes a new end-to-end test suite that verifies backward compatibility when upgrading the MooseStack CLI from version n-1 (latest published) to version n (current build).

## What Was Added

### 1. Backward Compatibility Test Suite
**File**: `apps/framework-cli-e2e/test/backward-compatibility.test.ts`

This test suite:
- Initializes projects using the **latest published CLI** from npm/pypi
- Starts the project with `moose dev` to create infrastructure
- Stops the project
- Runs `moose plan` with the **new CLI** from the current build
- Asserts that no breaking changes are detected

The test runs for both:
- TypeScript tests template
- Python tests template

### 2. Documentation
**File**: `apps/framework-cli-e2e/BACKWARD_COMPATIBILITY_TEST.md`

Detailed documentation about:
- What the test does
- How to run it
- Expected behavior
- How to debug failures

## Why This Test Is Important

This test catches **breaking changes in infrastructure map format**, particularly:

### The Problem This Branch Fixes
This branch changes how table IDs are generated in the infrastructure map:
- **Old format**: `"TableName_1_0_0"`
- **New format**: `"local_db_TableName_1_0_0"` (includes database prefix)

Without backward compatibility, upgrading would cause:
- ❌ Existing tables not recognized (seen as "missing")
- ❌ New tables created with same name (data duplication)
- ❌ Old tables dropped (data loss)

### The Solution
The code includes migration logic in:
- `apps/framework-cli/src/framework/core/plan.rs` - Fixes up old IDs during reconciliation
- `apps/framework-cli/src/framework/core/infra_reality_checker.rs` - Finds tables with old or new ID format
- `apps/framework-cli/src/framework/core/infrastructure_map.rs` - Handles both ID formats in diffs

The backward compatibility test **verifies** that this migration logic works correctly.

## Running the Tests

```bash
# From repository root
cd apps/framework-cli-e2e
pnpm test -- --grep "Backward Compatibility"
```

The `pretest` script automatically builds the CLI and packages before running tests.

### Run Specific Language
```bash
# TypeScript only
pnpm test -- --grep "TypeScript.*Backward Compatibility"

# Python only
pnpm test -- --grep "Python.*Backward Compatibility"
```

## Expected Output

### Success (Backward Compatible)
```
✅ No changes detected - backward compatibility verified!
```

### Failure (Breaking Change)
```
Error: Unexpected table drop detected in plan output.
This indicates a backward incompatible change:

DROP TABLE local_db_TableName_1_0_0
```

or

```
Error: Unexpected table creation detected in plan output.
This indicates tables weren't recognized:

CREATE TABLE local_db_TableName_1_0_0 (...)
```

## Test Timeouts

The test has extended timeouts because it:
- Downloads the latest CLI via `npx` (network I/O)
- Starts full infrastructure twice (Docker, ClickHouse, Kafka)
- Installs dependencies twice (npm/pip)

**Typical runtime**: 3-5 minutes per language template

## CI Integration

This test runs automatically in CI as the `test-e2e-backward-compatibility` job in `.github/workflows/test-framework-cli.yaml`.

It runs:
- ✅ On all PRs (when `detect-changes` determines tests should run)
- ✅ After all library tests pass
- ✅ Tests both TypeScript and Python templates in a single job

## Debugging

If the test fails, see the detailed debugging guide in:
`apps/framework-cli-e2e/BACKWARD_COMPATIBILITY_TEST.md`

## Files Modified/Added

```
apps/framework-cli-e2e/
├── test/
│ └── backward-compatibility.test.ts (NEW - Test suite)
├── BACKWARD_COMPATIBILITY_TEST.md (NEW - Detailed docs)

BACKWARD_COMPATIBILITY_TESTING.md (NEW - This file)
```

## Related Changes

This test is specifically designed to verify the infrastructure map migration changes in:
- `infrastructure_map.rs` - Table ID format changes
- `plan.rs` - Reconciliation with old format
- `infra_reality_checker.rs` - Finding tables with either format
- `infrastructure_map.proto` - Added default_database field

## Future Improvements

Potential enhancements:
1. Test more infrastructure components (topics, APIs, etc.)
2. Test upgrades across multiple versions (n-2 → n-1 → n)
3. Add rollback testing (n → n-1)
4. Cache the published CLI to speed up test runs
5. Add to CI pipeline as a required check

Loading
Loading