|
| 1 | +# QualityMax Local Agent - Installation Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +The QualityMax Local Agent (`qamax-agent`) is a single binary CLI that: |
| 6 | +- Runs as a daemon to poll and execute Playwright tests from QualityMax cloud |
| 7 | +- Authenticates via browser-based OAuth login |
| 8 | +- Captures browser cookies for authenticated test scenarios |
| 9 | +- Manages projects and credentials locally |
| 10 | + |
| 11 | +## Quick Start (macOS/Linux) |
| 12 | + |
| 13 | +### Prerequisites |
| 14 | + |
| 15 | +- Node.js and npm (for Playwright test execution) |
| 16 | +- Google Chrome (for the `capture` command) |
| 17 | + |
| 18 | +### Installation |
| 19 | + |
| 20 | +1. **Run the installer:** |
| 21 | + ```bash |
| 22 | + cd local-agent |
| 23 | + ./install.sh |
| 24 | + ``` |
| 25 | + |
| 26 | +2. **Log in:** |
| 27 | + ```bash |
| 28 | + qamax-agent login |
| 29 | + ``` |
| 30 | + |
| 31 | +3. **Start the agent:** |
| 32 | + ```bash |
| 33 | + qamax-agent run --cloud-url https://app.qamax.co --registration-secret YOUR_SECRET |
| 34 | + ``` |
| 35 | + |
| 36 | +### Building from Source |
| 37 | + |
| 38 | +Requires Go 1.22+: |
| 39 | + |
| 40 | +```bash |
| 41 | +cd local-agent/go |
| 42 | +go build -o qamax-agent . |
| 43 | +``` |
| 44 | + |
| 45 | +Cross-compile for all platforms: |
| 46 | + |
| 47 | +```bash |
| 48 | +cd local-agent/go |
| 49 | +make build-all |
| 50 | +``` |
| 51 | + |
| 52 | +## Commands |
| 53 | + |
| 54 | +### `qamax-agent login` |
| 55 | + |
| 56 | +Authenticate with QualityMax via browser OAuth. |
| 57 | + |
| 58 | +```bash |
| 59 | +qamax-agent login # Uses default port 9876 |
| 60 | +qamax-agent login --port 8080 # Custom callback port |
| 61 | +qamax-agent login --api-url URL # Custom QualityMax URL |
| 62 | +``` |
| 63 | + |
| 64 | +Opens your browser to log in. The token is saved to `~/.qamax/config.json`. |
| 65 | + |
| 66 | +### `qamax-agent run` |
| 67 | + |
| 68 | +Start the agent daemon to poll for and execute test assignments. |
| 69 | + |
| 70 | +```bash |
| 71 | +qamax-agent run --cloud-url https://app.qamax.co |
| 72 | +qamax-agent run --cloud-url https://app.qamax.co --registration-secret SECRET |
| 73 | +qamax-agent run --poll-interval 10 --heartbeat-interval 30 |
| 74 | +``` |
| 75 | + |
| 76 | +After the first successful registration, credentials are saved to config. Subsequent runs will use saved values as defaults. |
| 77 | + |
| 78 | +**Backward compatibility:** The old flag-based invocation still works: |
| 79 | +```bash |
| 80 | +qamax-agent --cloud-url https://app.qamax.co --registration-secret SECRET |
| 81 | +``` |
| 82 | + |
| 83 | +### `qamax-agent capture` |
| 84 | + |
| 85 | +Launch Chrome, navigate to a URL, wait for manual login, then capture cookies and upload them as authentication data. |
| 86 | + |
| 87 | +```bash |
| 88 | +qamax-agent capture https://example.com --project-id UUID --name "Production Auth" |
| 89 | +qamax-agent capture https://example.com --project-id UUID --name "Staging Auth" --output cookies.json |
| 90 | +``` |
| 91 | + |
| 92 | +Requires: |
| 93 | +- Prior `qamax-agent login` (uses OAuth token for API upload) |
| 94 | +- Google Chrome installed |
| 95 | + |
| 96 | +### `qamax-agent projects` |
| 97 | + |
| 98 | +List available projects. |
| 99 | + |
| 100 | +```bash |
| 101 | +qamax-agent projects |
| 102 | +``` |
| 103 | + |
| 104 | +### `qamax-agent status` |
| 105 | + |
| 106 | +Show current authentication and agent registration status. |
| 107 | + |
| 108 | +```bash |
| 109 | +qamax-agent status |
| 110 | +``` |
| 111 | + |
| 112 | +### `qamax-agent token` |
| 113 | + |
| 114 | +Print the saved OAuth token to stdout (useful for piping). |
| 115 | + |
| 116 | +```bash |
| 117 | +qamax-agent token |
| 118 | +qamax-agent token | pbcopy # Copy to clipboard on macOS |
| 119 | +``` |
| 120 | + |
| 121 | +### `qamax-agent logout` |
| 122 | + |
| 123 | +Remove saved credentials. |
| 124 | + |
| 125 | +```bash |
| 126 | +qamax-agent logout |
| 127 | +``` |
| 128 | + |
| 129 | +## Configuration |
| 130 | + |
| 131 | +Config is stored at `~/.qamax/config.json` (mode 0600): |
| 132 | + |
| 133 | +```json |
| 134 | +{ |
| 135 | + "token": "eyJ...", |
| 136 | + "api_url": "https://app.qamax.co", |
| 137 | + "agent_id": "uuid", |
| 138 | + "api_key": "hex-key", |
| 139 | + "registration_secret": "" |
| 140 | +} |
| 141 | +``` |
| 142 | + |
| 143 | +- `token` — OAuth JWT from `login`, used by `capture` and `projects` |
| 144 | +- `agent_id` / `api_key` — Agent daemon credentials, saved after first `run` registration |
| 145 | +- Both auth flows coexist and serve different purposes |
| 146 | + |
| 147 | +## Running as a Service |
| 148 | + |
| 149 | +### macOS (LaunchAgent) |
| 150 | + |
| 151 | +Create `~/Library/LaunchAgents/com.qamax.agent.plist`: |
| 152 | + |
| 153 | +```xml |
| 154 | +<?xml version="1.0" encoding="UTF-8"?> |
| 155 | +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 156 | +<plist version="1.0"> |
| 157 | +<dict> |
| 158 | + <key>Label</key> |
| 159 | + <string>com.qamax.agent</string> |
| 160 | + <key>ProgramArguments</key> |
| 161 | + <array> |
| 162 | + <string>/Users/YOUR_USERNAME/.qamax-agent/qamax-agent</string> |
| 163 | + <string>run</string> |
| 164 | + <string>--cloud-url</string> |
| 165 | + <string>https://app.qamax.co</string> |
| 166 | + </array> |
| 167 | + <key>RunAtLoad</key> |
| 168 | + <true/> |
| 169 | + <key>KeepAlive</key> |
| 170 | + <true/> |
| 171 | + <key>StandardOutPath</key> |
| 172 | + <string>/Users/YOUR_USERNAME/.qamax-agent/logs/agent.log</string> |
| 173 | + <key>StandardErrorPath</key> |
| 174 | + <string>/Users/YOUR_USERNAME/.qamax-agent/logs/agent.error.log</string> |
| 175 | +</dict> |
| 176 | +</plist> |
| 177 | +``` |
| 178 | + |
| 179 | +Load the service: |
| 180 | +```bash |
| 181 | +launchctl load ~/Library/LaunchAgents/com.qamax.agent.plist |
| 182 | +``` |
| 183 | + |
| 184 | +### Linux (systemd) |
| 185 | + |
| 186 | +Create `/etc/systemd/system/qamax-agent.service`: |
| 187 | + |
| 188 | +```ini |
| 189 | +[Unit] |
| 190 | +Description=QualityMax Local Agent |
| 191 | +After=network.target |
| 192 | + |
| 193 | +[Service] |
| 194 | +Type=simple |
| 195 | +User=YOUR_USERNAME |
| 196 | +ExecStart=/home/YOUR_USERNAME/.qamax-agent/qamax-agent run --cloud-url https://app.qamax.co |
| 197 | +Restart=always |
| 198 | +RestartSec=10 |
| 199 | + |
| 200 | +[Install] |
| 201 | +WantedBy=multi-user.target |
| 202 | +``` |
| 203 | + |
| 204 | +Enable and start: |
| 205 | +```bash |
| 206 | +sudo systemctl enable qamax-agent |
| 207 | +sudo systemctl start qamax-agent |
| 208 | +``` |
| 209 | + |
| 210 | +## Troubleshooting |
| 211 | + |
| 212 | +### Agent fails to register |
| 213 | + |
| 214 | +- Check internet connection |
| 215 | +- Verify cloud URL is correct |
| 216 | +- Verify registration secret matches server configuration |
| 217 | +- Review logs for detailed error messages |
| 218 | + |
| 219 | +### Login fails |
| 220 | + |
| 221 | +- Ensure port 9876 is available (or use `--port` to specify another) |
| 222 | +- Check that the QualityMax app URL is correct |
| 223 | +- Try `qamax-agent login --api-url https://app.qamax.co` |
| 224 | + |
| 225 | +### Capture fails |
| 226 | + |
| 227 | +- Ensure Google Chrome is installed |
| 228 | +- Ensure you are logged in (`qamax-agent login`) |
| 229 | +- Check that the project ID is valid (`qamax-agent projects`) |
| 230 | + |
| 231 | +### No test assignments received |
| 232 | + |
| 233 | +- Verify agent is online in QualityMax dashboard (`qamax-agent status`) |
| 234 | +- Ensure tests are assigned to agents in the UI |
| 235 | +- Check polling interval (default: 5 seconds) |
| 236 | + |
| 237 | +### Tests fail to execute |
| 238 | + |
| 239 | +- Ensure Node.js and npm are installed |
| 240 | +- Verify Playwright is available: `npx playwright --version` |
| 241 | +- Check browser availability |
| 242 | + |
| 243 | +## Security |
| 244 | + |
| 245 | +- All communication uses HTTPS/TLS |
| 246 | +- Config file permissions are restricted to 0600 (owner read/write only) |
| 247 | +- Config directory permissions are 0700 |
| 248 | +- API key and OAuth token are stored locally only |
| 249 | +- Artifacts (screenshots, videos) are base64 encoded during transmission |
0 commit comments