|
| 1 | +--- |
| 2 | +name: influxdb3-test-setup |
| 3 | +description: Set up InfluxDB 3 Core and Enterprise instances for running documentation code block tests. Handles service initialization, worktree-specific databases, and test environment configuration. |
| 4 | +author: InfluxData |
| 5 | +version: "1.0" |
| 6 | +--- |
| 7 | + |
| 8 | +# InfluxDB 3 Test Setup Skill |
| 9 | + |
| 10 | +## Purpose |
| 11 | + |
| 12 | +This skill guides agents through setting up InfluxDB 3 Core and Enterprise instances for testing documentation code blocks. It covers service initialization, creating worktree-specific databases for test isolation, and configuring the test environment. |
| 13 | + |
| 14 | +## Architecture Overview |
| 15 | + |
| 16 | +``` |
| 17 | +~/influxdata-docs/.influxdb3/ # Shared across all worktrees |
| 18 | +├── enterprise/ |
| 19 | +│ ├── .env # License email (INFLUXDB3_ENTERPRISE_LICENSE_EMAIL) |
| 20 | +│ └── data/ # Enterprise data (persists license) |
| 21 | +└── plugins/ # Shared plugins |
| 22 | +
|
| 23 | +<worktree>/test/.influxdb3/ # Per-worktree (gitignored) |
| 24 | +├── core/ |
| 25 | +│ ├── .token # Core auth token |
| 26 | +│ ├── data/ # Core data |
| 27 | +│ └── plugins/ # Custom plugins |
| 28 | +└── .env.test # Test credentials |
| 29 | +``` |
| 30 | + |
| 31 | +**Key Design Decisions:** |
| 32 | + |
| 33 | +- **Core**: Per-worktree instance (port 8282) - data isolated to worktree |
| 34 | +- **Enterprise**: Shared instance (port 8181) - license persists across worktrees |
| 35 | +- **Databases**: Create worktree-named databases for test isolation on shared Enterprise |
| 36 | + |
| 37 | +## Quick Reference |
| 38 | + |
| 39 | +| Task | Command | |
| 40 | +| ----------------------- | ---------------------------------------------------------------------- | |
| 41 | +| Initialize Core | `./test/scripts/init-influxdb3.sh core` | |
| 42 | +| Initialize Enterprise | `./test/scripts/init-influxdb3.sh enterprise` | |
| 43 | +| Initialize both | `./test/scripts/init-influxdb3.sh all` | |
| 44 | +| Check Core status | `curl -i http://localhost:8282/ping` | |
| 45 | +| Check Enterprise status | `curl -i http://localhost:8181/ping -H "Authorization: Bearer $TOKEN"` | |
| 46 | +| Run code block tests | `yarn test:codeblocks:v2` | |
| 47 | + |
| 48 | +## Setup Workflows |
| 49 | + |
| 50 | +### Workflow 1: Core Only (Per-Worktree) |
| 51 | + |
| 52 | +Use when testing Core-specific documentation or when you need complete isolation. |
| 53 | + |
| 54 | +```bash |
| 55 | +# 1. Initialize Core |
| 56 | +./test/scripts/init-influxdb3.sh core |
| 57 | + |
| 58 | +# 2. Verify it's running |
| 59 | +curl -i http://localhost:8282/ping |
| 60 | + |
| 61 | +# 3. Get your token (JSON format) |
| 62 | +jq -r .token test/.influxdb3/core/.token |
| 63 | + |
| 64 | +# 4. Create a database for testing |
| 65 | +curl -X POST "http://localhost:8282/api/v3/configure/database" \ |
| 66 | + -H "Authorization: Bearer $(jq -r .token test/.influxdb3/core/.token)" \ |
| 67 | + -H "Content-Type: application/json" \ |
| 68 | + -d '{"db": "test_db"}' |
| 69 | +``` |
| 70 | + |
| 71 | +### Workflow 2: Enterprise (Shared Instance) |
| 72 | + |
| 73 | +Use when testing Enterprise-specific documentation. Creates worktree-named database for isolation. |
| 74 | + |
| 75 | +```bash |
| 76 | +# 1. First-time only: Create .env file with license email |
| 77 | +mkdir -p ~/influxdata-docs/.influxdb3/enterprise |
| 78 | + |
| 79 | + ~/influxdata-docs/.influxdb3/enterprise/.env |
| 80 | + |
| 81 | +# 2. Initialize Enterprise (generates admin token and starts service) |
| 82 | +./test/scripts/init-influxdb3.sh enterprise |
| 83 | + |
| 84 | +# 3. Get admin token from the generated file |
| 85 | +ADMIN_TOKEN=$(jq -r .token ~/influxdata-docs/.influxdb3/enterprise/admin-token.json) |
| 86 | + |
| 87 | +# 4. Verify it's running |
| 88 | +curl -i http://localhost:8181/ping \ |
| 89 | + -H "Authorization: Bearer $ADMIN_TOKEN" |
| 90 | + |
| 91 | +# 5. Create worktree-named database for test isolation |
| 92 | +WORKTREE_NAME=$(basename "$(pwd)" | tr '-' '_') |
| 93 | +curl -X POST "http://localhost:8181/api/v3/configure/database" \ |
| 94 | + -H "Authorization: Bearer $ADMIN_TOKEN" \ |
| 95 | + -H "Content-Type: application/json" \ |
| 96 | + -d "{\"db\": \"${WORKTREE_NAME}_db\"}" |
| 97 | +``` |
| 98 | + |
| 99 | +### Workflow 3: Both Services |
| 100 | + |
| 101 | +Use when testing documentation that covers both Core and Enterprise. |
| 102 | + |
| 103 | +```bash |
| 104 | +# Initialize both |
| 105 | +./test/scripts/init-influxdb3.sh all |
| 106 | + |
| 107 | +# Verify both are running |
| 108 | +curl -i http://localhost:8282/ping # Core (no auth by default) |
| 109 | +curl -i http://localhost:8181/ping -H "Authorization: Bearer $TOKEN" # Enterprise |
| 110 | +``` |
| 111 | + |
| 112 | +## Creating Worktree-Specific Databases |
| 113 | + |
| 114 | +When using the shared Enterprise instance, create databases named after the worktree to isolate test data: |
| 115 | + |
| 116 | +```bash |
| 117 | +# Get worktree name (converts hyphens to underscores for valid DB names) |
| 118 | +WORKTREE_NAME=$(basename "$(pwd)" | tr '-' '_') |
| 119 | +echo "Database name: ${WORKTREE_NAME}_db" |
| 120 | + |
| 121 | +# Create database |
| 122 | +curl -X POST "http://localhost:8181/api/v3/configure/database" \ |
| 123 | + -H "Authorization: Bearer $ADMIN_TOKEN" \ |
| 124 | + -H "Content-Type: application/json" \ |
| 125 | + -d "{\"db\": \"${WORKTREE_NAME}_db\"}" |
| 126 | + |
| 127 | +# List databases to verify |
| 128 | +curl "http://localhost:8181/api/v3/configure/database" \ |
| 129 | + -H "Authorization: Bearer $ADMIN_TOKEN" |
| 130 | +``` |
| 131 | + |
| 132 | +**Naming Convention:** |
| 133 | + |
| 134 | +- Worktree: `docs-v2-influxdb3-version-detection-headers` |
| 135 | +- Database: `docs_v2_influxdb3_version_detection_headers_db` |
| 136 | + |
| 137 | +## Test Environment Configuration |
| 138 | + |
| 139 | +### Configure .env.test for Code Block Tests |
| 140 | + |
| 141 | +Create `content/<product>/.env.test` with test credentials: |
| 142 | + |
| 143 | +```bash |
| 144 | +# For Enterprise testing |
| 145 | +ADMIN_TOKEN=$(jq -r .token ~/influxdata-docs/.influxdb3/enterprise/admin-token.json) |
| 146 | +cat > content/influxdb3/enterprise/.env.test << EOF |
| 147 | +INFLUX_HOST=http://localhost:8181 |
| 148 | +INFLUX_TOKEN=$ADMIN_TOKEN |
| 149 | +INFLUX_DATABASE=YOUR_WORKTREE_DB |
| 150 | +EOF |
| 151 | + |
| 152 | +# For Core testing |
| 153 | +cat > content/influxdb3/core/.env.test << EOF |
| 154 | +INFLUX_HOST=http://localhost:8282 |
| 155 | +INFLUX_TOKEN=$(jq -r .token test/.influxdb3/core/.token) |
| 156 | +INFLUX_DATABASE=test_db |
| 157 | +EOF |
| 158 | +``` |
| 159 | + |
| 160 | +### Run Code Block Tests |
| 161 | + |
| 162 | +```bash |
| 163 | +# Test specific product |
| 164 | +yarn test:codeblocks:v2 |
| 165 | + |
| 166 | +# Or run pytest directly |
| 167 | +docker compose run --rm v2-pytest |
| 168 | +``` |
| 169 | + |
| 170 | +## Troubleshooting |
| 171 | + |
| 172 | +### Enterprise Won't Start |
| 173 | + |
| 174 | +**Symptom:** Container exits immediately |
| 175 | + |
| 176 | +**Check:** |
| 177 | + |
| 178 | +```bash |
| 179 | +# View container logs |
| 180 | +docker logs influxdb3-enterprise |
| 181 | + |
| 182 | +# Common issues: |
| 183 | +# 1. Missing .env file |
| 184 | +ls -la ~/influxdata-docs/.influxdb3/enterprise/.env |
| 185 | + |
| 186 | +# 2. Wrong env var name (must be INFLUXDB3_ENTERPRISE_LICENSE_EMAIL) |
| 187 | +cat ~/influxdata-docs/.influxdb3/enterprise/.env |
| 188 | + |
| 189 | +# 3. Missing admin-token.json (run init script to generate) |
| 190 | +ls -la ~/influxdata-docs/.influxdb3/enterprise/admin-token.json |
| 191 | +``` |
| 192 | + |
| 193 | +### Core Token Not Working |
| 194 | + |
| 195 | +**Symptom:** 401 Unauthorized |
| 196 | + |
| 197 | +**Check:** |
| 198 | + |
| 199 | +```bash |
| 200 | +# Verify token file exists and is valid JSON |
| 201 | +cat test/.influxdb3/core/.token |
| 202 | +jq . test/.influxdb3/core/.token # Should parse without errors |
| 203 | + |
| 204 | +# Verify token is accessible in container (as secret) |
| 205 | +docker exec influxdb3-core cat /run/secrets/influxdb3-core-token |
| 206 | +``` |
| 207 | + |
| 208 | +### Port Already in Use |
| 209 | + |
| 210 | +**Symptom:** "port is already allocated" |
| 211 | + |
| 212 | +**Fix:** |
| 213 | + |
| 214 | +```bash |
| 215 | +# Find what's using the port |
| 216 | +lsof -i :8181 # Enterprise |
| 217 | +lsof -i :8282 # Core |
| 218 | + |
| 219 | +# Stop existing containers |
| 220 | +docker compose down influxdb3-enterprise influxdb3-core |
| 221 | +``` |
| 222 | + |
| 223 | +### Getting the Admin Token |
| 224 | + |
| 225 | +The init script generates and saves admin tokens to JSON files for both Core and Enterprise: |
| 226 | + |
| 227 | +```bash |
| 228 | +# Core token |
| 229 | +cat test/.influxdb3/core/.token |
| 230 | +jq -r .token test/.influxdb3/core/.token |
| 231 | + |
| 232 | +# Enterprise token |
| 233 | +cat ~/influxdata-docs/.influxdb3/enterprise/admin-token.json |
| 234 | +jq -r .token ~/influxdata-docs/.influxdb3/enterprise/admin-token.json |
| 235 | + |
| 236 | +# Export for use in commands |
| 237 | +export INFLUXDB3_CORE_TOKEN=$(jq -r .token test/.influxdb3/core/.token) |
| 238 | +export INFLUXDB3_ENTERPRISE_TOKEN=$(jq -r .token ~/influxdata-docs/.influxdb3/enterprise/admin-token.json) |
| 239 | + |
| 240 | +# Use in API calls |
| 241 | +curl -i http://localhost:8282/ping -H "Authorization: Bearer $INFLUXDB3_CORE_TOKEN" |
| 242 | +curl -i http://localhost:8181/ping -H "Authorization: Bearer $INFLUXDB3_ENTERPRISE_TOKEN" |
| 243 | +``` |
| 244 | + |
| 245 | +**Token File Format** (both Core and Enterprise): |
| 246 | +```json |
| 247 | +{ |
| 248 | + "token": "64-character-hexadecimal-token", |
| 249 | + "description": "Admin token for InfluxDB 3 Core/Enterprise" |
| 250 | +} |
| 251 | +``` |
| 252 | + |
| 253 | +## Service Comparison |
| 254 | + |
| 255 | +| Aspect | Core | Enterprise | |
| 256 | +| ------------- | ---------------- | -------------------------------- | |
| 257 | +| Port | 8282 | 8181 | |
| 258 | +| Data location | Per-worktree | Shared | |
| 259 | +| Auth default | Optional | Required | |
| 260 | +| License | None | Trial/Paid | |
| 261 | +| Use case | Isolated testing | Shared testing with worktree DBs | |
| 262 | + |
| 263 | +## Related Files |
| 264 | + |
| 265 | +- **Init script**: `test/scripts/init-influxdb3.sh` |
| 266 | +- **Docker Compose**: `compose.yaml` (services: influxdb3-core, influxdb3-enterprise) |
| 267 | +- **Test config**: `content/<product>/.env.test` |
| 268 | + |
| 269 | +## Related Skills |
| 270 | + |
| 271 | +- **cypress-e2e-testing** - For running E2E tests on documentation UI |
| 272 | +- **docs-cli-workflow** - For creating/editing documentation content |
0 commit comments