-
Notifications
You must be signed in to change notification settings - Fork 5
Design: Fix 9 milestone issues (docs, tests, query limits) #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d0ad46e
2431ad9
324063a
41c7e1a
b878619
07c514a
85b5b40
f9cf64a
d885cd8
a640134
b1f0512
f6c3e04
a72bf4b
4b74cc5
7b98aaa
49f0d96
1f093ea
14d4f71
a2c5937
c77d106
dcdfb26
4e968f2
70b321b
492ae7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(npm:*)", | ||
| "Bash(yarn:*)", | ||
| "Bash(npx:*)", | ||
| "Bash(node:*)", | ||
| "Bash(curl:*)", | ||
| "Bash(gh:*)", | ||
| "Bash(jq:*)", | ||
| "Bash(mkdir:*)", | ||
| "Bash(docker:*)", | ||
| "Bash(docker compose:*)", | ||
| "Edit", | ||
| "Read", | ||
| "Write", | ||
| "Grep", | ||
| "Glob", | ||
| "LS" | ||
| ], | ||
| "deny": [ | ||
| "Read(./.env)", | ||
| "Read(./.env.*)", | ||
| "Read(./secrets/**)" | ||
| ], | ||
| "ask": [ | ||
| "Bash(git push:*)" | ||
| ] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,195 @@ | ||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||
| name: run-tests | ||||||||||||||||||||||||||||
| description: Run API tests against InfluxDB 3 Core. Handles service initialization, database setup, and test execution. | ||||||||||||||||||||||||||||
| author: InfluxData | ||||||||||||||||||||||||||||
| version: "1.0" | ||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Run Tests Skill | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## Purpose | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| This skill guides running the IoT API test suite against a local InfluxDB 3 Core instance. It covers service setup, database creation, and test execution. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## Quick Reference | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| | Task | Command | | ||||||||||||||||||||||||||||
| |------|---------| | ||||||||||||||||||||||||||||
| | Start InfluxDB 3 | `docker compose up -d influxdb3-core` | | ||||||||||||||||||||||||||||
| | Check status | `curl -i http://localhost:8181/health` | | ||||||||||||||||||||||||||||
| | Run tests | `yarn test` | | ||||||||||||||||||||||||||||
| | View logs | `docker logs influxdb3-core` | | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## Complete Setup Workflow | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 1. Initialize InfluxDB 3 Core | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| # Create required directories | ||||||||||||||||||||||||||||
| mkdir -p test/.influxdb3/core/data test/.influxdb3/core/plugins | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Generate admin token (first time only) | ||||||||||||||||||||||||||||
| openssl rand -hex 32 > test/.influxdb3/core/.token | ||||||||||||||||||||||||||||
| chmod 600 test/.influxdb3/core/.token | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Start the container | ||||||||||||||||||||||||||||
| docker compose up -d influxdb3-core | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Wait for healthy status | ||||||||||||||||||||||||||||
| docker compose ps | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 2. Create Databases | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| # Get the token | ||||||||||||||||||||||||||||
| TOKEN=$(cat test/.influxdb3/core/.token) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Create main database | ||||||||||||||||||||||||||||
| curl -X POST "http://localhost:8181/api/v3/configure/database" \ | ||||||||||||||||||||||||||||
| -H "Authorization: Bearer $TOKEN" \ | ||||||||||||||||||||||||||||
| -H "Content-Type: application/json" \ | ||||||||||||||||||||||||||||
| -d '{"db": "iot_center"}' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Create auth database | ||||||||||||||||||||||||||||
| curl -X POST "http://localhost:8181/api/v3/configure/database" \ | ||||||||||||||||||||||||||||
| -H "Authorization: Bearer $TOKEN" \ | ||||||||||||||||||||||||||||
| -H "Content-Type: application/json" \ | ||||||||||||||||||||||||||||
| -d '{"db": "iot_center_auth"}' | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Verify databases exist | ||||||||||||||||||||||||||||
| curl "http://localhost:8181/api/v3/configure/database?format=json" \ | ||||||||||||||||||||||||||||
| -H "Authorization: Bearer $TOKEN" | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 3. Configure Environment | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Create `.env.local` if it doesn't exist: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| cat > .env.local << EOF | ||||||||||||||||||||||||||||
| INFLUX_HOST=http://localhost:8181 | ||||||||||||||||||||||||||||
| INFLUX_TOKEN=$(cat test/.influxdb3/core/.token) | ||||||||||||||||||||||||||||
| INFLUX_DATABASE=iot_center | ||||||||||||||||||||||||||||
| INFLUX_DATABASE_AUTH=iot_center_auth | ||||||||||||||||||||||||||||
| EOF | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 4. Run Tests | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| # Install dependencies (if needed) | ||||||||||||||||||||||||||||
| yarn | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Run the test suite | ||||||||||||||||||||||||||||
| yarn test | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Run with verbose output | ||||||||||||||||||||||||||||
| yarn test --verbose | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Run specific test file | ||||||||||||||||||||||||||||
| yarn test __tests__/api.test.js | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## Troubleshooting | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Container Won't Start | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Symptom:** Container exits immediately | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Check:** | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| # View logs | ||||||||||||||||||||||||||||
| docker logs influxdb3-core | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Verify directories exist | ||||||||||||||||||||||||||||
| ls -la test/.influxdb3/core/ | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Verify token file exists | ||||||||||||||||||||||||||||
| cat test/.influxdb3/core/.token | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Common fixes:** | ||||||||||||||||||||||||||||
| - Create missing directories: `mkdir -p test/.influxdb3/core/data test/.influxdb3/core/plugins` | ||||||||||||||||||||||||||||
| - Generate token: `openssl rand -hex 32 > test/.influxdb3/core/.token` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 401 Unauthorized | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Symptom:** API calls return 401 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Check:** | ||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||
| # Verify token matches | ||||||||||||||||||||||||||||
| echo "Token in file: $(cat test/.influxdb3/core/.token)" | ||||||||||||||||||||||||||||
| echo "Token in .env.local: $(grep INFLUX_TOKEN .env.local)" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| # Test with token directly | ||||||||||||||||||||||||||||
| curl -i http://localhost:8181/api/v3/configure/database \ | ||||||||||||||||||||||||||||
| -H "Authorization: Bearer $(cat test/.influxdb3/core/.token)" | ||||||||||||||||||||||||||||
|
Comment on lines
+122
to
+128
|
||||||||||||||||||||||||||||
| # Verify token matches | |
| echo "Token in file: $(cat test/.influxdb3/core/.token)" | |
| echo "Token in .env.local: $(grep INFLUX_TOKEN .env.local)" | |
| # Test with token directly | |
| curl -i http://localhost:8181/api/v3/configure/database \ | |
| -H "Authorization: Bearer $(cat test/.influxdb3/core/.token)" | |
| # Verify INFLUX_TOKEN environment variable is set | |
| echo "INFLUX_TOKEN: ${INFLUX_TOKEN:-'(not set)'}" | |
| # Test with token directly from environment | |
| curl -i http://localhost:8181/api/v3/configure/database \ | |
| -H "Authorization: Bearer ${INFLUX_TOKEN:?INFLUX_TOKEN is not set}" |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The database name iot_center_auth is used throughout this file (lines 58, 74, 145, 188), but this is incorrect per issue #34. The project's default in .env.development and throughout the codebase is iot_center_devices for the auth database (INFLUX_DATABASE_AUTH).
According to the design document, all references to iot_center_auth should be changed to iot_center_devices to match the project defaults and prevent "database not found" errors.
| | `INFLUX_DATABASE_AUTH` | `iot_center_auth` | Device auth database | | |
| | `INFLUX_DATABASE_AUTH` | `iot_center_devices` | Device auth database | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,12 @@ | ||
| # Development environment non-secret defaults | ||
| # InfluxDB 3 Core configuration | ||
|
|
||
| INFLUX_URL=http://localhost:8086 | ||
| INFLUX_BUCKET=iot_center | ||
| INFLUX_BUCKET_AUTH=iot_center_devices | ||
| # InfluxDB 3 server URL (default port is 8181) | ||
| INFLUX_HOST=http://localhost:8181 | ||
|
|
||
| # Database names (equivalent to v2 buckets) | ||
| INFLUX_DATABASE=iot_center | ||
| INFLUX_DATABASE_AUTH=iot_center_devices | ||
|
|
||
| # Token should be set in .env.local (not committed to git) | ||
| # INFLUX_TOKEN=your_admin_token_here |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # AI Instructions Navigation Guide | ||
|
|
||
| This repository has multiple instruction files for different AI tools and use cases. | ||
|
|
||
| ## Quick Navigation | ||
|
|
||
| | If you are... | Start here | | ||
| |---------------|------------| | ||
| | **GitHub Copilot** | [../AGENTS.md](../AGENTS.md) | | ||
| | **Claude, ChatGPT, Gemini** | [../AGENTS.md](../AGENTS.md) | | ||
| | **Claude with MCP** | [../CLAUDE.md](../CLAUDE.md) | | ||
|
|
||
| ## File Organization | ||
|
|
||
| ``` | ||
| iot-api-js/ | ||
| ├── docs/ # Detailed documentation | ||
| │ ├── architecture.md # System design, project structure | ||
| │ ├── development.md # Setup, testing, debugging | ||
| │ ├── api-reference.md # API endpoints | ||
| │ ├── code-patterns.md # InfluxDB client usage | ||
| │ └── contributing.md # Style guidelines | ||
| ├── .claude/ | ||
| │ ├── settings.json # Claude permissions | ||
| │ └── skills/run-tests/SKILL.md # Test execution workflow | ||
| ├── .github/ | ||
| │ └── INSTRUCTIONS.md # THIS FILE | ||
| ├── AGENTS.md # AI assistant quick reference | ||
| ├── CLAUDE.md # Claude with MCP quick reference | ||
| └── README.md # User-facing documentation | ||
| ``` | ||
|
|
||
| ## Documentation | ||
|
|
||
| | Topic | Location | | ||
| |-------|----------| | ||
| | System architecture | [../docs/architecture.md](../docs/architecture.md) | | ||
| | Development setup | [../docs/development.md](../docs/development.md) | | ||
| | API endpoints | [../docs/api-reference.md](../docs/api-reference.md) | | ||
| | Code patterns | [../docs/code-patterns.md](../docs/code-patterns.md) | | ||
| | Contributing | [../docs/contributing.md](../docs/contributing.md) | | ||
|
|
||
| ## Getting Started | ||
|
|
||
| 1. **New to the repository?** Start with [../README.md](../README.md) | ||
| 2. **Using AI assistants?** Read [../AGENTS.md](../AGENTS.md) then explore [../docs/](../docs/) | ||
| 3. **Using Claude with MCP?** Check [../CLAUDE.md](../CLAUDE.md) and [../.claude/](../.claude/) |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||||||||||
| # IoT API JS - AI Assistant Guide | ||||||||||||||
|
|
||||||||||||||
| Sample application for InfluxData tutorials demonstrating REST APIs with InfluxDB 3 Core. | ||||||||||||||
|
|
||||||||||||||
| **Target audience:** Developers learning to build IoT applications with InfluxDB 3. | ||||||||||||||
|
|
||||||||||||||
| ## Quick Reference | ||||||||||||||
|
|
||||||||||||||
| | Task | Command | | ||||||||||||||
| |------|---------| | ||||||||||||||
| | Install | `yarn` | | ||||||||||||||
| | Dev server | `yarn dev -p 5200` | | ||||||||||||||
| | Run tests | `yarn test` | | ||||||||||||||
| | Start InfluxDB | `docker compose up -d influxdb3-core` | | ||||||||||||||
|
|
||||||||||||||
| ## Key Files | ||||||||||||||
|
|
||||||||||||||
| | File | Purpose | | ||||||||||||||
| |------|---------| | ||||||||||||||
| | `lib/influxdb.js` | InfluxDB client factory and helpers | | ||||||||||||||
| | `pages/api/devices/create.js` | Device registration endpoint | | ||||||||||||||
| | `pages/api/devices/_devices.js` | Shared device query logic | | ||||||||||||||
| | `pages/api/devices/[[...deviceParams]].js` | Device CRUD operations | | ||||||||||||||
| | `__tests__/api.test.js` | API integration tests | | ||||||||||||||
|
Comment on lines
+23
to
+24
|
||||||||||||||
| | `pages/api/devices/[[...deviceParams]].js` | Device CRUD operations | | |
| | `pages/api/measurements/index.js` | Telemetry query endpoint | | |
| | `__tests__/api.test.js` | API integration tests | | |
| | `pages/api/devices/[[...deviceParams]].js` | Device GET and measurement queries | | |
| | `pages/api/measurements/index.js` | Shared telemetry query helper | | |
| | `__tests__/api.test.js` | API unit tests (mocked) | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # IoT API JS - Claude Instructions | ||
|
|
||
| Next.js REST API demonstrating InfluxDB 3 Core integration for IoT device data. | ||
|
|
||
| ## Quick Reference | ||
|
|
||
| | Task | Command | | ||
| |------|---------| | ||
| | Install | `yarn` | | ||
| | Dev server | `yarn dev -p 5200` | | ||
| | Run tests | `yarn test` | | ||
| | Start InfluxDB | `docker compose up -d influxdb3-core` | | ||
|
|
||
| ## Key Files | ||
|
|
||
| | File | Purpose | | ||
| |------|---------| | ||
| | `lib/influxdb.js` | Client factory and query/write helpers | | ||
| | `pages/api/devices/create.js` | Device registration | | ||
| | `pages/api/devices/_devices.js` | Shared device queries | | ||
| | `pages/api/devices/[[...deviceParams]].js` | Device CRUD + measurements | | ||
|
|
||
| ## Documentation | ||
|
|
||
| | Topic | Location | | ||
| |-------|----------| | ||
| | System architecture | [docs/architecture.md](docs/architecture.md) | | ||
| | Development setup | [docs/development.md](docs/development.md) | | ||
| | API endpoints | [docs/api-reference.md](docs/api-reference.md) | | ||
| | Code patterns | [docs/code-patterns.md](docs/code-patterns.md) | | ||
| | Contributing | [docs/contributing.md](docs/contributing.md) | | ||
| | Testing workflow | [.claude/skills/run-tests/SKILL.md](.claude/skills/run-tests/SKILL.md) | | ||
|
|
||
| ## Other Resources | ||
|
|
||
| - [AGENTS.md](AGENTS.md) - Guide for general AI assistants | ||
| - [.github/INSTRUCTIONS.md](.github/INSTRUCTIONS.md) - Navigation guide | ||
| - [.claude/](.claude/) - Claude Code settings and skills |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The skill description and purpose incorrectly state that tests run "against InfluxDB 3 Core" and require a database instance, which contradicts issue #33 that this PR claims to resolve.
The test suite uses mocks (see tests/api.test.js lines 13-30) and runs without any database connection. According to the design document, the skill should be updated to describe the mocked/unit test workflow, with database setup moved to an optional section for manual testing.