Skip to content

Commit 51b46f6

Browse files
authored
Merge pull request #9 from isc-tdyar/033-devtester-skills
feat: Integrate iris-devtester agentic skills for automated testing
2 parents 7a2b446 + cf39d95 commit 51b46f6

18 files changed

+1338
-120
lines changed

AGENTS.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# iris-pgwire-gh Development Guidelines
2+
3+
Auto-generated from all feature plans. Last updated: 2026-01-02
4+
5+
## Active Technologies
6+
7+
- Python 3.11+ + `iris-devtester`, `intersystems-irispython`, `psycopg[binary]` (033-devtester-skills)
8+
9+
## Project Structure
10+
11+
```text
12+
src/
13+
tests/
14+
```
15+
16+
## Commands
17+
18+
cd src [ONLY COMMANDS FOR ACTIVE TECHNOLOGIES][ONLY COMMANDS FOR ACTIVE TECHNOLOGIES] pytest [ONLY COMMANDS FOR ACTIVE TECHNOLOGIES][ONLY COMMANDS FOR ACTIVE TECHNOLOGIES] ruff check .
19+
20+
## Code Style
21+
22+
Python 3.11+: Follow standard conventions
23+
24+
## Recent Changes
25+
26+
- 033-devtester-skills: Added Python 3.11+ + `iris-devtester`, `intersystems-irispython`, `psycopg[binary]`
27+
28+
<!-- MANUAL ADDITIONS START -->
29+
<!-- MANUAL ADDITIONS END -->

docs/testing.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ This framework follows the project's constitutional principles:
4444
- **Principle III**: Protocol Fidelity (real PostgreSQL clients)
4545
- **Principle V**: Diagnostic Excellence (comprehensive failure capture)
4646

47+
### Automated Infrastructure with iris-devtester
48+
49+
The framework now integrates with `iris-devtester` to provide automated container management and troubleshooting.
50+
51+
**Automated Containers**: `iris_container` fixture automatically starts an IRIS instance if one is not running.
52+
**Auto-Remediation**: `iris_connection` automatically handles "Password change required" and enables CallIn services.
53+
**Test Fixtures**: `iris_fixture` allows loading and exporting reproducible test data sets via `.DAT` files.
54+
**Agentic Diagnostics**: Failures trigger the `/troubleshooting` skill logic to provide remediation hints in `test_failures.jsonl`.
55+
4756
---
4857

4958
## Quick Start
@@ -254,6 +263,46 @@ def test_pgwire_query(pgwire_client):
254263

255264
**Cleanup**: Connection closed after test
256265

266+
### `iris_connection` (Function-Scoped)
267+
268+
**Purpose**: Provides a DBAPI connection to IRIS with auto-remediation
269+
270+
**Returns**: `irispython.Connection` (or equivalent DBAPI connection)
271+
272+
**Features**:
273+
- Auto-retries on transient connection failures
274+
- Automatically handles "ChangePassword" requirement
275+
- Enables CallIn service if disabled
276+
277+
**Example**:
278+
```python
279+
def test_with_remediation(iris_connection):
280+
with iris_connection.cursor() as cur:
281+
cur.execute("SELECT 1")
282+
assert cur.fetchone()[0] == 1
283+
```
284+
285+
---
286+
287+
### `iris_fixture` (Function-Scoped)
288+
289+
**Purpose**: Load and export IRIS test data sets (.DAT files)
290+
291+
**Returns**: Fixture helper object
292+
293+
**Methods**:
294+
- `load(dat_file)`: Loads a .DAT file into IRIS
295+
- `export(table_name, output_file)`: Exports a table to a .DAT file
296+
297+
**Example**:
298+
```python
299+
def test_vector_search(iris_fixture, iris_connection):
300+
iris_fixture.load("healthcare_data.dat")
301+
with iris_connection.cursor() as cur:
302+
cur.execute("SELECT COUNT(*) FROM Patients")
303+
assert cur.fetchone()[0] > 0
304+
```
305+
257306
---
258307

259308
## Timeout Configuration

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ test = [
7878
# [binary] includes C extension + libpq, no system dependencies needed
7979
"psycopg[binary]>=3.1.0",
8080
"docker>=6.0.0",
81+
"iris-devtester>=0.1.0",
8182
# Runtime dependencies needed when importing iris_pgwire modules in tests
8283
"sqlparse>=0.4.0",
8384
# Kerberos test realm isolation (constitutional TDD requirement - feature 024)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Specification Quality Checklist: IRIS DevTester Agentic Skills Integration
2+
3+
**Purpose**: Validate specification completeness and quality before proceeding to planning
4+
**Created**: 2025-01-02
5+
**Feature**: [spec.md](../spec.md)
6+
7+
## Content Quality
8+
9+
- [x] No implementation details (languages, frameworks, APIs)
10+
- [x] Focused on user value and business needs
11+
- [x] Written for non-technical stakeholders
12+
- [x] All mandatory sections completed
13+
14+
## Requirement Completeness
15+
16+
- [x] No [NEEDS CLARIFICATION] markers remain
17+
- [x] Requirements are testable and unambiguous
18+
- [x] Success criteria are measurable
19+
- [x] Success criteria are technology-agnostic (no implementation details)
20+
- [x] All acceptance scenarios are defined
21+
- [x] Edge cases are identified
22+
- [x] Scope is clearly bounded
23+
- [x] Dependencies and assumptions identified
24+
25+
## Feature Readiness
26+
27+
- [x] All functional requirements have clear acceptance criteria
28+
- [x] User scenarios cover primary flows
29+
- [x] Feature meets measurable outcomes defined in Success Criteria
30+
- [x] No implementation details leak into specification
31+
32+
## Notes
33+
34+
- Spec is ready for `/speckit.plan` phase
35+
- All clarifications resolved with reasonable defaults
36+
- 14 functional requirements defined covering:
37+
- Dependency management (2 requirements)
38+
- Container management (3 requirements)
39+
- Connection management (3 requirements)
40+
- Test data management (2 requirements)
41+
- Troubleshooting (2 requirements)
42+
- New functionality testing (2 requirements)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Contract: IRIS DevTester Pytest Fixtures
2+
3+
## Purpose
4+
This contract defines the public interface for the `pytest` fixtures provided by the `iris-devtester` integration.
5+
6+
## Fixtures
7+
8+
### 1. `iris_container`
9+
High-level fixture that ensures a healthy IRIS instance is available.
10+
11+
- **Scope**: Session or Module
12+
- **Returns**: `iris_devtester.IRISContainer` object
13+
- **Responsibilities**:
14+
- Pull image if missing.
15+
- Start container.
16+
- Wait for port 1972 to be ready.
17+
- Disable password expiry.
18+
- Enable CallIn service.
19+
- Cleanup on teardown.
20+
21+
### 2. `iris_connection`
22+
Provides a DBAPI connection with auto-remediation.
23+
24+
- **Scope**: Function
25+
- **Depends on**: `iris_container`
26+
- **Returns**: `iris.dbapi.Connection`
27+
- **Responsibilities**:
28+
- Auto-retry on transient failures.
29+
- Handle "ChangePassword" requirement.
30+
- Switch to requested namespace.
31+
32+
### 3. `iris_fixture`
33+
Helper to load specific test data sets.
34+
35+
- **Scope**: Function
36+
- **Usage**:
37+
```python
38+
def test_vectors(iris_fixture):
39+
iris_fixture.load("vectors_1024d.dat")
40+
# ...
41+
```
42+
- **Responsibilities**:
43+
- Load `.DAT` files via `FixtureCreator`.
44+
- Validate schema before loading.
45+
- Teardown (optional) - drop tables if requested.
46+
47+
## Hooks
48+
49+
### `pytest_runtest_makereport` (Failure Hook)
50+
- On `call.failed`, triggers the `/troubleshooting` skill logic.
51+
- Captures:
52+
- IRIS connection status.
53+
- Container health.
54+
- Last few IRIS system log entries.
55+
- Outputs to: `test_failures.jsonl`
56+
57+
## Configuration
58+
Controlled via `pytest` CLI or `pyproject.toml`:
59+
- `--iris-image`: Specify custom IRIS image.
60+
- `--iris-namespace`: Default namespace for connections.
61+
- `--iris-persist`: If True, don't stop container on teardown (for debugging).

specs/033-devtester-skills/plan.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Implementation Plan: IRIS DevTester Agentic Skills Integration
2+
3+
**Branch**: `033-devtester-skills` | **Date**: 2025-01-02 | **Spec**: specs/033-devtester-skills/spec.md
4+
**Input**: Feature specification from `/specs/033-devtester-skills/spec.md`
5+
6+
## Summary
7+
8+
Integrate `iris-devtester`'s agentic skills (slash commands) into the `iris-pgwire` testing workflow to automate container management, connection handling, and test data fixtures. This will replace manual `docker-compose` management with automated container lifecycle handling within `pytest` and provide auto-remediation for common IRIS/Docker issues.
9+
10+
## Technical Context
11+
12+
**Language/Version**: Python 3.11+
13+
**Primary Dependencies**: `iris-devtester`, `intersystems-irispython`, `psycopg[binary]`
14+
**Storage**: InterSystems IRIS (managed via Docker)
15+
**Testing**: `pytest`
16+
**Target Platform**: Docker-enabled environments
17+
**Project Type**: Python Library
18+
**Performance Goals**: Container startup/health check < 60s; troubleshooting < 5s
19+
**Constraints**: Must match constitutional principles; no manual container setup required for tests
20+
**Scale/Scope**: 14 Functional Requirements covering dependency, container, connection, data management, and troubleshooting
21+
22+
## Constitution Check
23+
24+
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
25+
26+
| Principle | Status | Justification |
27+
|-----------|--------|---------------|
28+
| I. Protocol Fidelity | ✅ PASS | Improves testing of PostgreSQL compatibility without changing protocol implementation. |
29+
| II. Test-First Development | ✅ PASS | Feature specifically enhances the testing infrastructure and reliability. |
30+
| III. Phased Implementation | ✅ PASS | Follows standard feature implementation lifecycle. |
31+
| IV. IRIS Integration | ✅ PASS | Leverages native IRIS integration patterns via `iris-devtester`. |
32+
| V. Production Readiness | ✅ PASS | Ensures test reliability and reduces setup time for new developers/CI. |
33+
34+
## Project Structure
35+
36+
### Documentation (this feature)
37+
38+
```text
39+
specs/033-devtester-skills/
40+
├── plan.md # This file
41+
├── research.md # Phase 0 output
42+
├── quickstart.md # Phase 1 output
43+
├── contracts/ # Phase 1 output
44+
└── tasks.md # Phase 2 output (generated by /speckit.tasks)
45+
```
46+
47+
### Source Code (repository root)
48+
49+
```text
50+
src/iris_pgwire/
51+
├── tests/
52+
│ ├── conftest.py # Update to use iris-devtester container management
53+
│ ├── test_devtester_integration.py # New tests for devtester skills
54+
55+
tests/
56+
├── unit/
57+
├── integration/
58+
├── conftest.py # Update to leverage new devtester skills
59+
```
60+
61+
**Structure Decision**: Single project structure (Option 1). We will update existing `conftest.py` files to use `iris-devtester` and add integration tests for the new skills.
62+
63+
## Complexity Tracking
64+
65+
> **No violations detected.**
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Quickstart: Automated Testing with iris-devtester
2+
3+
This guide shows how to leverage the new automated testing infrastructure in `iris-pgwire`.
4+
5+
## Prerequisites
6+
1. **Docker Desktop** running.
7+
2. **Local iris-devtester**: Clone and install in editable mode.
8+
```bash
9+
cd ..
10+
git clone https://github.com/intersystems-community/iris-devtester.git
11+
cd iris-devtester
12+
pip install -e .
13+
```
14+
15+
## Running Tests
16+
You no longer need to manually run `docker-compose up`. Simply run `pytest`:
17+
18+
```bash
19+
# Run all tests (automatically starts IRIS)
20+
pytest
21+
22+
# Run with specific IRIS image
23+
pytest --iris-image=intersystems/iris-community:2025.1.0
24+
25+
# Run only integration tests
26+
pytest tests/integration/ -v
27+
```
28+
29+
## Using the Agentic Skills (Slash Commands)
30+
If you are using **Claude Code**, you can invoke the skills directly:
31+
32+
- **`/container`**: Manage your test container.
33+
- **`/connection`**: Debug your database connection.
34+
- **`/fixture`**: Load test data.
35+
- **`/troubleshooting`**: Diagnose test failures.
36+
37+
## Writing a New Test
38+
The framework provides high-level fixtures:
39+
40+
```python
41+
def test_my_new_feature(iris_connection):
42+
# iris_connection is already connected and ready
43+
with iris_connection.cursor() as cursor:
44+
cursor.execute("SELECT 1")
45+
assert cursor.fetchone()[0] == 1
46+
47+
def test_with_data(iris_fixture, iris_connection):
48+
# Load specific data set
49+
iris_fixture.load("healthcare_data.dat")
50+
51+
with iris_connection.cursor() as cursor:
52+
cursor.execute("SELECT COUNT(*) FROM Patients")
53+
assert cursor.fetchone()[0] > 0
54+
```
55+
56+
## Troubleshooting Failures
57+
On failure, check `test_failures.jsonl` in the project root for detailed diagnostics and remediation steps.

0 commit comments

Comments
 (0)