Skip to content

Commit 8484015

Browse files
committed
PRODENG-3446: upgrade smoke test + documentation overhaul
## Smoke test Added TestUpgradeLegacyToModern (test/smoke/upgrade_test.go): - Provisions RHEL8/Rocky8/Ubuntu22, installs MCR stable-25.0 / MKE 3.8.8, then upgrades in place to MCR stable-29.2 / MKE 3.9.2 via a second Apply(). - runUpgradeTest() helper mirrors runSmokeTest() structure (defer destroy, resource tagging, temp SSH dir). - bumpVersions() unmarshals Terraform-generated launchpad_yaml, updates spec.mcr.channel and spec.mke.version, re-marshals — preserving host addresses, SANs, LB names, and install flags verbatim. - make smoke-upgrade target (90m timeout). - smoke-upgrade CI job in .github/workflows/smoke-tests.yaml, gated by smoke-upgrade or smoke-test PR label. CI result: PASS (run 25721416884, 1320s). ## Documentation AGENTS.md (replaces CLAUDE.md + AI_AGENTS.md): - Consolidated into the AGENTS.md open standard (Linux Foundation, supported by Claude Code, Cursor, Windsurf, Codex, Gemini CLI, Aider, and others). - Covers: project overview, non-negotiable rules, build/test commands, phase manager architecture, config schema (v1.6 with example), smoke test reference table, contributing guidelines, multi-engineer workflow guidance, and documentation index. docs/development/smoke-tests.md (new): - Complete authoring guide for new smoke tests: framework mechanics, all 14 available platforms, runSmokeTest / runUpgradeTest / bumpVersions usage with annotated examples, Windows-specific requirements, CI wiring (Makefile + workflow + PR label), timeout guidance, Reset best-effort rationale, and a pre-submission checklist. docs/development/workflow.md: - Replace stale smoke-small/smoke-full with actual four targets. - Add --tags testing note for unit tests. - Remove non-existent make build-release / make sign-release. - Add current apiVersion to schema safety guideline. docs/specifications/architecture.md: - Fix package path: pkg/product/mke/api -> pkg/product/mke/config. - Add current apiVersion and full spec structure. - Add abridged Apply and Reset phase sequences. - Document UninstallMKE swarm dissolution fallback (PRODENG-3442). Signed-off-by: James Nesbitt <jnesbitt@mirantis.com>
1 parent 5224c5d commit 8484015

9 files changed

Lines changed: 745 additions & 197 deletions

File tree

.github/workflows/smoke-tests.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,20 @@ jobs:
6868
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
6969
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
7070
run: make smoke-windows
71+
72+
smoke-upgrade:
73+
runs-on: ubuntu-latest
74+
if: |
75+
github.event_name == 'push' ||
76+
contains(github.event.pull_request.labels.*.name, 'smoke-test') ||
77+
contains(github.event.pull_request.labels.*.name, 'smoke-upgrade')
78+
steps:
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
- name: Setup Terraform
82+
uses: hashicorp/setup-terraform@v3
83+
- name: Run upgrade smoke test
84+
env:
85+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
86+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
87+
run: make smoke-upgrade

AGENTS.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Mirantis Launchpad — Agent Instructions
2+
3+
This file follows the [AGENTS.md](https://agents.md/) open standard and is read by Claude Code, Cursor, Windsurf, Codex, Gemini CLI, and compatible agents. Instructions here take precedence over general tool defaults.
4+
5+
---
6+
7+
## Project Overview
8+
9+
Launchpad is a Go CLI that installs, upgrades, and resets Mirantis Kubernetes Engine (MKE) and Mirantis Container Runtime (MCR) clusters on provisioned compute nodes. It is **stateless** between runs — all cluster state is discovered by querying hosts directly at the start of each operation.
10+
11+
---
12+
13+
## Non-Negotiable Rules
14+
15+
- **NEVER** commit to, push to, or merge into `main`. All work goes on feature branches.
16+
- **All commits MUST be signed**: `git commit -s`.
17+
- Use `GOTOOLCHAIN=auto` for all `go` commands (already set in `Makefile` via `export`).
18+
- Read `docs/guidance/project.md` before implementing features or bug fixes.
19+
- **NEVER** auto-generate this file or any documentation file. Write it from actual project knowledge.
20+
21+
---
22+
23+
## Build & Test
24+
25+
```bash
26+
# Build (current platform → dist/launchpad_GOOS_GOARCH)
27+
make local
28+
29+
# Lint & security
30+
make lint # golangci-lint run
31+
make security-scan # govulncheck ./...
32+
33+
# Unit tests — require --tags 'testing' build tag
34+
make unit-test
35+
go test -v --tags 'testing' ./pkg/...
36+
go test -v --tags 'testing' ./pkg/config/... -run TestFoo # single test
37+
38+
# Functional & integration
39+
make functional-test # test/functional/ — component level, may need network
40+
make integration-test # test/integration/ — requires real nodes
41+
42+
# Smoke tests — require AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY
43+
make smoke-modern # RHEL9/Ubuntu24/Rocky9, MCR stable-29.2, MKE 3.9.2 (50m)
44+
make smoke-legacy # RHEL8/Rocky8/Ubuntu22, MCR stable-25.0, MKE 3.8.8 (50m)
45+
make smoke-windows # Ubuntu24 mgr + Win2019/2022/2025, MCR stable-25.0 (60m)
46+
make smoke-upgrade # Install 3.8.8 → upgrade to 3.9.2, same infra (90m)
47+
```
48+
49+
---
50+
51+
## Architecture: Phase Manager Pattern
52+
53+
All operations (apply, reset, describe) are ordered sequences of **phases** run by `phase.Manager`. This is the central pattern — new features belong in a new phase or an addition to an existing one.
54+
55+
```
56+
cmd/apply.go
57+
└── pkg/product/mke/mke.go (Apply)
58+
└── phase.Manager.Run()
59+
└── [Phase1, Phase2, ..., PhaseN] sequential
60+
```
61+
62+
Each phase implements `Run() error` and `Title() string`. Optional: `Prepare(config)`, `ShouldRun()`, `CleanUp()`, `DisableCleanup()`.
63+
64+
**Key packages:**
65+
66+
| Package | Role |
67+
|---|---|
68+
| `pkg/phase/` | Phase Manager orchestration |
69+
| `pkg/product/mke/` | Apply / reset / describe entry points |
70+
| `pkg/product/mke/phase/` | 30+ phase implementations |
71+
| `pkg/product/mke/config/` | Config structs: `ClusterConfig`, `Host`, `Hosts`, `MCRConfig`, `MKEConfig`, `MSRConfig` |
72+
| `pkg/config/` | YAML parsing, schema migrations v1–v16 |
73+
| `pkg/configurer/` | OS-specific MCR install/upgrade (EL, Ubuntu, SLES, Windows) |
74+
| `pkg/mcr/` | MCR runtime helpers (version detect, ensure-running) |
75+
| `pkg/swarm/` | Docker Swarm helpers (node ID, cluster ID) |
76+
| `pkg/kubeclient/` | Kubernetes client |
77+
| `pkg/docker/` | Image handling and auth |
78+
| `pkg/analytics/` | Segment telemetry |
79+
80+
---
81+
82+
## Configuration Schema
83+
84+
Current: `apiVersion: launchpad.mirantis.com/mke/v1.6`
85+
86+
MCR is selected by **channel** (e.g. `stable-29.2`), not by specific version number. Migrations for older schemas live in `pkg/config/migration/` and run automatically on load.
87+
88+
```yaml
89+
apiVersion: launchpad.mirantis.com/mke/v1.6
90+
kind: mke
91+
metadata:
92+
name: my-cluster
93+
spec:
94+
hosts:
95+
- role: manager
96+
ssh:
97+
address: 1.2.3.4
98+
user: ubuntu
99+
keyPath: ~/.ssh/id_rsa
100+
mcr:
101+
channel: stable-29.2
102+
mke:
103+
version: 3.9.2
104+
adminUsername: admin
105+
adminPassword: secret
106+
```
107+
108+
If you change the config schema: bump `apiVersion`, add a migration in `pkg/config/migration/`, add unit tests for it.
109+
110+
---
111+
112+
## Smoke Tests
113+
114+
Smoke tests (`test/smoke/`) use [Terratest](https://terratest.gruntwork.io/) to provision real AWS infrastructure via `examples/terraform/aws-simple/`, run the full Launchpad lifecycle, and destroy everything unconditionally via `defer terraform.Destroy`. All resources are tagged `launchpad-smoke-test: true`.
115+
116+
| Make target | Test function | Timeout | What it tests |
117+
|---|---|---|---|
118+
| `smoke-modern` | `TestModernCluster` | 50m | Install on RHEL9/Ubuntu24/Rocky9 |
119+
| `smoke-legacy` | `TestLegacyCluster` | 50m | Install on RHEL8/Rocky8/Ubuntu22 |
120+
| `smoke-windows` | `TestWindowsCluster` | 60m | Install with Windows 2019/2022/2025 workers |
121+
| `smoke-upgrade` | `TestUpgradeLegacyToModern` | 90m | Install 3.8.8 then upgrade to 3.9.2 in place |
122+
123+
CI jobs are gated by PR labels: `smoke-test` (all jobs), or individual labels `smoke-modern`, `smoke-legacy`, `smoke-windows`, `smoke-upgrade`.
124+
125+
**To add a new smoke test**, read `docs/development/smoke-tests.md` — it documents the full framework: available platforms, helper functions, how to write install/reset and upgrade tests, CI wiring, and a pre-submission checklist.
126+
127+
---
128+
129+
## Contributing
130+
131+
- Feature branches only — never `main`.
132+
- Signed commits: `git commit -s`.
133+
- New functionality → new phase, not inline logic.
134+
- Run `make lint` and `make unit-test` before opening a PR.
135+
- PR description must explain trade-offs and link any relevant Jira ticket (PRODENG-XXXX).
136+
137+
---
138+
139+
## Collaborative / Multi-Engineer Workflows
140+
141+
When multiple engineers or agents work on the same initiative:
142+
143+
- Communicate before modifying shared files (smoke tests, Terraform examples, CI workflow).
144+
- Prefer additive changes (new test functions, new phases) to reduce merge conflicts.
145+
- Use a separate file per concern in `test/smoke/` (e.g. `upgrade_test.go`) rather than growing `smoke_test.go`.
146+
- Coordinate PR labels to avoid running expensive smoke jobs unnecessarily.
147+
- Tag all AWS resources with `launchpad-smoke-test: true` and a descriptive `launchpad-smoke-test-name` value so each engineer's resources are identifiable in the console.
148+
149+
---
150+
151+
## Documentation
152+
153+
| File | Purpose |
154+
|---|---|
155+
| `docs/guidance/project.md` | Core architectural principles |
156+
| `docs/specifications/architecture.md` | Phase Manager, apply/reset sequences, design decisions |
157+
| `docs/development/workflow.md` | Build, test, and contribution workflow |
158+
| `docs/requirements/launchpad-prd.md` | Product requirements |
159+
| `docs/usage/getting-started.md` | User-facing getting started guide |
160+
| `docs/development/smoke-tests.md` | How to write new smoke tests (framework, platforms, CI wiring) |

AI_AGENTS.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

CLAUDE.md

Lines changed: 0 additions & 107 deletions
This file was deleted.

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ smoke-legacy:
6363
.PHONY: smoke-windows
6464
smoke-windows:
6565
go test -count=1 -v ./test/smoke/... -run TestWindowsCluster -timeout 60m
66+
.PHONY: smoke-upgrade
67+
smoke-upgrade:
68+
go test -count=1 -v ./test/smoke/... -run TestUpgrade -timeout 90m
6669
.PHONY: clean-launchpad-chart
6770
clean-launchpad-chart:
6871
terraform -chdir=./examples/tf-aws/launchpad apply --auto-approve --destroy

0 commit comments

Comments
 (0)