|
| 1 | +# Podman Machine Setup Scripts |
| 2 | + |
| 3 | +This directory contains automated scripts for setting up and running acceptance tests on macOS with Podman machine. |
| 4 | + |
| 5 | +## Location |
| 6 | +These scripts are located in `hack/macos/` and should be run from the repository root. |
| 7 | + |
| 8 | +## Scripts Overview |
| 9 | + |
| 10 | +### 1. `setup-podman-machine.sh` |
| 11 | +**Purpose**: Complete automated setup of Podman machine for acceptance tests |
| 12 | + |
| 13 | +**What it does**: |
| 14 | +- Checks prerequisites (podman, kind, kubectl) |
| 15 | +- Cleans up existing podman machine |
| 16 | +- Creates new podman machine with optimal settings (4 CPUs, 8GB RAM, 500GB disk) |
| 17 | +- Fixes keyring quota issue (critical for avoiding "Disk quota exceeded" errors) |
| 18 | +- Creates required networks (testcontainers) |
| 19 | +- Configures DNS resolution (rekor.localhost, apiserver.localhost, tuf.localhost) |
| 20 | +- Creates environment setup script |
| 21 | +- Tests the setup |
| 22 | + |
| 23 | +**Usage**: |
| 24 | +```bash |
| 25 | +# From repository root |
| 26 | +./hack/macos/setup-podman-machine.sh |
| 27 | +``` |
| 28 | + |
| 29 | +### 2. `run-acceptance-tests.sh` |
| 30 | +**Purpose**: Run acceptance tests with proper environment setup |
| 31 | + |
| 32 | +**What it does**: |
| 33 | +- Checks if setup was completed |
| 34 | +- Loads environment variables |
| 35 | +- Optionally cleans up test resources |
| 36 | +- Runs tests with configurable parallelism and timeout |
| 37 | +- Supports running specific test patterns |
| 38 | + |
| 39 | +**Usage**: |
| 40 | +```bash |
| 41 | +# From repository root |
| 42 | +# Run all tests |
| 43 | +./hack/macos/run-acceptance-tests.sh |
| 44 | + |
| 45 | +# Run with custom settings |
| 46 | +./hack/macos/run-acceptance-tests.sh -p 2 -t 30m |
| 47 | + |
| 48 | +# Run specific tests |
| 49 | +./hack/macos/run-acceptance-tests.sh "TestFeatures/conftest" |
| 50 | + |
| 51 | +# Clean up and run |
| 52 | +./hack/macos/run-acceptance-tests.sh -c "TestFeatures/OPA" |
| 53 | +``` |
| 54 | + |
| 55 | +## Quick Start |
| 56 | + |
| 57 | +1. **Initial Setup** (run once): |
| 58 | + ```bash |
| 59 | + ./hack/macos/setup-podman-machine.sh |
| 60 | + ``` |
| 61 | + |
| 62 | +2. **Run Tests**: |
| 63 | + ```bash |
| 64 | + ./hack/macos/run-acceptance-tests.sh |
| 65 | + ``` |
| 66 | + |
| 67 | +## Environment Variables |
| 68 | + |
| 69 | +The setup script creates `setup-test-env.sh` with these variables: |
| 70 | +- `KIND_EXPERIMENTAL_PROVIDER=podman` |
| 71 | +- `TESTCONTAINERS_RYUK_DISABLED=true` |
| 72 | +- `TESTCONTAINERS_HOST_OVERRIDE=localhost` |
| 73 | +- `DOCKER_HOST=unix:///var/run/docker.sock` |
| 74 | + |
| 75 | +## Troubleshooting |
| 76 | + |
| 77 | +### Quick Fixes |
| 78 | + |
| 79 | +1. **"Disk quota exceeded" errors**: |
| 80 | + - The setup script automatically fixes this with `kernel.keys.maxkeys=20000` |
| 81 | + - If you still get errors, run: `podman machine ssh "sudo sysctl -w kernel.keys.maxkeys=20000"` |
| 82 | + |
| 83 | +2. **"Network not found" errors**: |
| 84 | + - The setup script creates the required `testcontainers` network |
| 85 | + - If missing, run: `podman network create testcontainers` |
| 86 | + |
| 87 | +3. **DNS resolution issues**: |
| 88 | + - The setup script adds required entries to `/etc/hosts` |
| 89 | + - If missing, add: `127.0.0.1 rekor.localhost`, `127.0.0.1 apiserver.localhost`, and `127.0.0.1 tuf.localhost` |
| 90 | + |
| 91 | +4. **TLS handshake timeouts**: |
| 92 | + - These are usually from stale Kubernetes connections |
| 93 | + - Clean up with: `kind delete cluster --all` |
| 94 | + |
| 95 | +### Comprehensive Troubleshooting |
| 96 | + |
| 97 | +For detailed troubleshooting, performance optimization, and advanced configuration, see: |
| 98 | +**[TROUBLESHOOTING.md](TROUBLESHOOTING.md)** - Complete guide to manual setup, troubleshooting, and optimization |
| 99 | + |
| 100 | +### Manual Cleanup |
| 101 | + |
| 102 | +If you need to start over: |
| 103 | +```bash |
| 104 | +# Stop and remove podman machine |
| 105 | +podman machine stop |
| 106 | +podman machine rm podman-machine-default |
| 107 | + |
| 108 | +# Clean up system |
| 109 | +podman system prune -a -f |
| 110 | + |
| 111 | +# Re-run setup |
| 112 | +./hack/macos/setup-podman-machine.sh |
| 113 | +``` |
| 114 | + |
| 115 | +## Script Features |
| 116 | + |
| 117 | +- **Colorized output** for easy reading |
| 118 | +- **Error handling** with proper exit codes |
| 119 | +- **Prerequisite checking** before setup |
| 120 | +- **Automatic cleanup** of existing resources |
| 121 | +- **Environment validation** after setup |
| 122 | +- **Flexible test execution** with various options |
| 123 | + |
| 124 | +## Dependencies |
| 125 | + |
| 126 | +- `podman` (installed via Homebrew) |
| 127 | +- `kind` (installed via Homebrew) |
| 128 | +- `kubectl` (installed via Homebrew) |
| 129 | +- `sudo` access (for /etc/hosts modification) |
| 130 | + |
| 131 | +Install missing dependencies: |
| 132 | +```bash |
| 133 | +brew install podman kind kubectl |
| 134 | +``` |
0 commit comments