|
| 1 | +--- |
| 2 | +description: Run all kitchen suites and fix failures iteratively |
| 3 | +auto_execution_mode: 3 |
| 4 | +--- |
| 5 | + |
| 6 | +# Kitchen Test and Fix Workflow |
| 7 | + |
| 8 | +This workflow runs all Test Kitchen suites, aggregates failures, and iteratively fixes common issues. |
| 9 | + |
| 10 | +## Steps |
| 11 | + |
| 12 | +### 1. Get Your Bearings |
| 13 | + |
| 14 | +Run `kitchen list` to see all available test suites and their current state. |
| 15 | + |
| 16 | +```bash |
| 17 | +chef exec kitchen list |
| 18 | +``` |
| 19 | + |
| 20 | +Review the output to understand: |
| 21 | + |
| 22 | +- Which suites exist (installer-mysql, installer-postgresql, standalone-mysql, standalone-postgresql) |
| 23 | +- Which platforms are configured |
| 24 | +- Current state of any existing instances |
| 25 | + |
| 26 | +### 2. Run Kitchen Tests |
| 27 | + |
| 28 | +Run all kitchen tests in parallel with destroy on completion: |
| 29 | + |
| 30 | +```bash |
| 31 | +# Run a single suite first to validate |
| 32 | +chef exec kitchen test installer-mysql-ubuntu-2404 --destroy=always |
| 33 | + |
| 34 | +# Or run all tests (this takes a long time) |
| 35 | +chef exec kitchen test --concurrency=4 --destroy=always |
| 36 | +``` |
| 37 | + |
| 38 | +For faster iteration, test one platform per suite first: |
| 39 | + |
| 40 | +```bash |
| 41 | +chef exec kitchen test installer-mysql-ubuntu-2404 --destroy=always |
| 42 | +chef exec kitchen test installer-postgresql-ubuntu-2404 --destroy=always |
| 43 | +chef exec kitchen test standalone-mysql-ubuntu-2404 --destroy=always |
| 44 | +chef exec kitchen test standalone-postgresql-ubuntu-2404 --destroy=always |
| 45 | +``` |
| 46 | + |
| 47 | +### 3. Aggregate Failures |
| 48 | + |
| 49 | +When tests fail, collect and categorize the errors: |
| 50 | + |
| 51 | +1. **Converge failures** - Recipe compilation or resource execution errors |
| 52 | +2. **Verify failures** - InSpec/Serverspec test failures |
| 53 | +3. **Platform-specific failures** - Issues only on certain OS families |
| 54 | + |
| 55 | +For each failure, note: |
| 56 | + |
| 57 | +- Suite name |
| 58 | +- Platform |
| 59 | +- Error message |
| 60 | +- Stack trace location |
| 61 | + |
| 62 | +### 4. Apply Common Fixes |
| 63 | + |
| 64 | +Address failures by category: |
| 65 | + |
| 66 | +#### Converge Failures |
| 67 | + |
| 68 | +- Check recipe syntax and resource availability |
| 69 | +- Verify cookbook dependencies in `metadata.rb` and `Berksfile` |
| 70 | +- Review attribute precedence issues |
| 71 | +- Check for deprecated Chef APIs |
| 72 | + |
| 73 | +#### Verify Failures |
| 74 | + |
| 75 | +- Review test expectations in `test/integration/*/serverspec/` |
| 76 | +- Ensure services are running and ports are listening |
| 77 | +- Check file permissions and ownership |
| 78 | + |
| 79 | +#### Platform-Specific Failures |
| 80 | + |
| 81 | +- Add platform conditionals where needed |
| 82 | +- Check package names differ between distros |
| 83 | +- Verify service names (systemd vs init) |
| 84 | + |
| 85 | +### 5. Iterate |
| 86 | + |
| 87 | +After applying fixes: |
| 88 | + |
| 89 | +// turbo |
| 90 | +1. Re-run the failing tests: |
| 91 | + |
| 92 | +```bash |
| 93 | +chef exec kitchen test <suite-platform> --destroy=always |
| 94 | +``` |
| 95 | + |
| 96 | +2. If new failures appear, return to step 3 |
| 97 | +3. Continue until all tests pass |
| 98 | + |
| 99 | +### 6. Verify All Suites Pass |
| 100 | + |
| 101 | +Once individual fixes are applied, run the full test matrix: |
| 102 | + |
| 103 | +```bash |
| 104 | +chef exec kitchen test --concurrency=4 --destroy=always |
| 105 | +``` |
| 106 | + |
| 107 | +### 7. Cleanup |
| 108 | + |
| 109 | +Destroy any remaining kitchen instances: |
| 110 | + |
| 111 | +// turbo |
| 112 | +```bash |
| 113 | +chef exec kitchen destroy |
| 114 | +``` |
| 115 | + |
| 116 | +## Common Issues Reference |
| 117 | + |
| 118 | +| Error | Cause | Fix | |
| 119 | +|-----------------------|---------------------------------|---------------------------------| |
| 120 | +| `undefined method` | Missing cookbook dependency | Add to `metadata.rb` depends | |
| 121 | +| `package not found` | Wrong package name for platform | Use platform conditionals | |
| 122 | +| `service not running` | Service failed to start | Check logs, add retries | |
| 123 | +| `port not listening` | App not configured correctly | Review configuration templates | |
| 124 | +| `Chef::Platform.set` | Deprecated API in dependency | Update cookbook version or stub | |
0 commit comments