k11-integration-qa-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- k11_integration_qa_mcp-0.1.0/.gitignore +10 -0
- k11_integration_qa_mcp-0.1.0/LICENSE +21 -0
- k11_integration_qa_mcp-0.1.0/PKG-INFO +176 -0
- k11_integration_qa_mcp-0.1.0/README.md +152 -0
- k11_integration_qa_mcp-0.1.0/pyproject.toml +42 -0
- k11_integration_qa_mcp-0.1.0/src/k11_integration_qa/__init__.py +3 -0
- k11_integration_qa_mcp-0.1.0/src/k11_integration_qa/__main__.py +3 -0
- k11_integration_qa_mcp-0.1.0/src/k11_integration_qa/brokers.py +215 -0
- k11_integration_qa_mcp-0.1.0/src/k11_integration_qa/cli.py +101 -0
- k11_integration_qa_mcp-0.1.0/src/k11_integration_qa/config.py +94 -0
- k11_integration_qa_mcp-0.1.0/src/k11_integration_qa/flows.py +436 -0
- k11_integration_qa_mcp-0.1.0/src/k11_integration_qa/report.py +139 -0
- k11_integration_qa_mcp-0.1.0/src/k11_integration_qa/run.py +58 -0
- k11_integration_qa_mcp-0.1.0/src/k11_integration_qa/server.py +155 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 K11 Software Solutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: k11-integration-qa-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server and CI tool for integration testing of event-driven and batch systems: flows that combine API calls, Kafka messages (publish, expect, dead-letter queues, AsyncAPI schemas), batch jobs and database checks, with evidence for release decisions.
|
|
5
|
+
Project-URL: Homepage, https://github.com/K11-Software-Solutions/k11techlab-integration-qa-mcp
|
|
6
|
+
Project-URL: Issues, https://github.com/K11-Software-Solutions/k11techlab-integration-qa-mcp/issues
|
|
7
|
+
Author: K11 Software Solutions
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: asyncapi,batch-jobs,claude,database-testing,event-driven,integration-testing,kafka,mcp,middleware,qa
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Software Development :: Testing
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Requires-Dist: k11-api-functional-qa-mcp<0.2,>=0.1.1
|
|
17
|
+
Requires-Dist: mcp<2,>=1.20
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest-timeout>=2; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
21
|
+
Provides-Extra: kafka
|
|
22
|
+
Requires-Dist: kafka-python>=2.0.2; extra == 'kafka'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# k11 Integration QA: MCP server and CI tool
|
|
26
|
+
|
|
27
|
+
<!-- mcp-name: io.github.K11-Software-Solutions/integration-qa -->
|
|
28
|
+
|
|
29
|
+
[](https://pypi.org/project/k11-integration-qa-mcp/)
|
|
30
|
+
[](https://github.com/K11-Software-Solutions/k11techlab-integration-qa-mcp/actions/workflows/ci.yml)
|
|
31
|
+
[](LICENSE)
|
|
32
|
+
|
|
33
|
+
**The API returned 201. Did the consumer actually reserve the stock?**
|
|
34
|
+
|
|
35
|
+
In event-driven and batch systems the bugs live *between* the parts: the event is published with the wrong quantity,
|
|
36
|
+
a consumer drops a message it can't read instead of dead-lettering it, a nightly job double-counts when it's retried.
|
|
37
|
+
Unit tests and API tests each pass. k11 Integration QA tests the whole chain in one flow: the API call, the Kafka
|
|
38
|
+
message, the consumer's effect in the database, the dead-letter queue and the batch job, with evidence for the release decision.
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
name: An order reserves stock through the inventory consumer
|
|
42
|
+
fixtures: [sku] # a fresh SKU in the test database, deleted afterwards
|
|
43
|
+
steps:
|
|
44
|
+
- listen: { broker: main, topic: orders.events, as: events } # subscribe BEFORE acting
|
|
45
|
+
- call: POST /orders
|
|
46
|
+
body: { sku: "${fixture.sku.sku}", qty: 3 }
|
|
47
|
+
expect: { status: 201 }
|
|
48
|
+
save: { orderId: "$.id" }
|
|
49
|
+
- name: OrderCreated is published and matches the AsyncAPI contract
|
|
50
|
+
expect_message:
|
|
51
|
+
from: events
|
|
52
|
+
match: { "$.type": OrderCreated, "$.orderId": "${orderId}" }
|
|
53
|
+
schema: OrderCreated
|
|
54
|
+
within: 10s
|
|
55
|
+
- name: the inventory consumer reserves all 3
|
|
56
|
+
expect_message: { from: events, match: { "$.type": StockReserved, "$.orderId": "${orderId}", "$.qty": 3 }, within: 10s }
|
|
57
|
+
- name: the reservation is in the database
|
|
58
|
+
wait_until:
|
|
59
|
+
db: SELECT reserved FROM inventory WHERE sku = :sku
|
|
60
|
+
params: { sku: "${fixture.sku.sku}" }
|
|
61
|
+
expect: { row: { reserved: 3 } }
|
|
62
|
+
within: 10s
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## See it work
|
|
66
|
+
|
|
67
|
+
The included demo, K11 Shop, has an order API, two consumers, a dead-letter queue and a batch job, each with a bug you
|
|
68
|
+
can switch on. With all three bugs on:
|
|
69
|
+
|
|
70
|
+
```text
|
|
71
|
+
4 of 4 flow(s) did not pass: 0 passed, 4 failed (2 published, 6 message checks, 2 job runs)
|
|
72
|
+
- An order reserves stock through the inventory consumer — the inventory consumer reserves all 3:
|
|
73
|
+
0 of 1 matching message(s) within 10s (2 message(s) on orders.events); closest: $.qty: expected 3, got 1
|
|
74
|
+
- Cancelling an order releases its stock — the stock is released: reserved 0: expected 0, got -1; not met after 41 check(s)
|
|
75
|
+
- An unreadable command goes to the dead-letter queue — it is dead-lettered with the reason:
|
|
76
|
+
0 of 1 matching message(s) within 10s (0 message(s) on orders.dlq)
|
|
77
|
+
- The sku_totals batch job is safe to run twice — the total is still 2: qty 2: expected 2, got 4
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
When nothing matches, the report shows the **closest message** and how it differed, so "the event never came" and
|
|
81
|
+
"the event came with the wrong quantity" are different findings. With the bugs off, all four flows pass. CI runs the
|
|
82
|
+
same flows against a real Apache Kafka broker.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pip install "k11-integration-qa-mcp[kafka]"
|
|
86
|
+
python demo/shop/shop.py --bugs consumer # in-process broker; add --kafka localhost:9092 for Kafka
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Step types
|
|
90
|
+
|
|
91
|
+
Everything from [k11 API Functional QA](https://github.com/K11-Software-Solutions/k11techlab-api-functional-qa-mcp)
|
|
92
|
+
(`call`, `db`, fixtures, cleanup, auth profiles, `${ENV:…}` secrets, matchers like `{ gt: 0 }`), plus:
|
|
93
|
+
|
|
94
|
+
| Step | What it does |
|
|
95
|
+
|---|---|
|
|
96
|
+
| `listen` | Subscribe to a topic from *now on*, before the action that should produce the event |
|
|
97
|
+
| `publish` | Send a message (JSON or text, key, headers): commands, or a poison message for the DLQ |
|
|
98
|
+
| `expect_message` | A matching message arrives within the time limit; match on JSON paths, `key`, `header:Name`, `value`; `count`, `save`, AsyncAPI `schema` |
|
|
99
|
+
| `expect_no_message` | Nothing matching arrives (no `OrderFailed`, no duplicate) for the given time |
|
|
100
|
+
| `run_job` | Run a batch job: a command (a list, no shell) or an HTTP trigger with polling (`until`, `fail_if`) |
|
|
101
|
+
| `wait_until` | Poll a `SELECT` or `GET` until the expectation holds: eventual consistency without sleeps |
|
|
102
|
+
|
|
103
|
+
## Configure
|
|
104
|
+
|
|
105
|
+
`.qa-mcp/integration.yaml` (environments, auth, databases and fixtures come from `.qa-mcp/api-test.yaml`, shared with API Functional QA):
|
|
106
|
+
|
|
107
|
+
```yaml
|
|
108
|
+
brokers:
|
|
109
|
+
main: { type: kafka, bootstrap: "${ENV:KAFKA_BOOTSTRAP}" } # extra keys go to kafka-python (security_protocol, sasl_*…)
|
|
110
|
+
jobs:
|
|
111
|
+
sku_totals:
|
|
112
|
+
command: [python, jobs/sku_totals.py]
|
|
113
|
+
env: { SHOP_DB: shop.db }
|
|
114
|
+
timeout: 60s
|
|
115
|
+
reindex:
|
|
116
|
+
http: { call: POST /admin/jobs/reindex, save: { jobId: "$.id" } }
|
|
117
|
+
poll: { call: "GET /admin/jobs/${jobId}", until: { "$.status": done }, fail_if: { "$.status": failed } }
|
|
118
|
+
asyncapi: asyncapi.yaml
|
|
119
|
+
protected_topics: ["prod.*", "*.prod.*", "*production*"]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Safety
|
|
123
|
+
|
|
124
|
+
- **Publishing and jobs change data**, so they follow API Functional QA's write rules: local hosts, test-named environments or `allow_writes: true`; production-like names are refused.
|
|
125
|
+
- **Protected topics** (production-named by default) are never published to, on any environment.
|
|
126
|
+
- **Jobs run without a shell** (the command is a list), inside the project, with a time limit.
|
|
127
|
+
- **Every wait has a time limit;** listeners are closed and cleanup always runs.
|
|
128
|
+
- **Read-only listening:** listeners use no consumer group, so they never take messages from your real consumers or move their offsets.
|
|
129
|
+
- Secrets come from `${ENV:NAME}` and are masked in reports.
|
|
130
|
+
|
|
131
|
+
## Tools (MCP)
|
|
132
|
+
|
|
133
|
+
| Tool | What it does |
|
|
134
|
+
|---|---|
|
|
135
|
+
| `integration_config` | Brokers, jobs, AsyncAPI contract, protected topics, environments (and whether publishing and jobs may run there), flows |
|
|
136
|
+
| `run_integration_tests` | Runs flows (all, by path or by tag); writes `.qa-mcp/integration-report/` (Markdown, JSON, JUnit) |
|
|
137
|
+
| `validate_flow` | Checks a flow file's structure without running it |
|
|
138
|
+
| `watch_topic` | Listens to a topic for a few seconds and shows the messages, to learn their shape |
|
|
139
|
+
| `get_report` | The last report, or one flow's steps with full evidence (messages, queries, job output) |
|
|
140
|
+
| `init_integration_config` | Writes a starter `.qa-mcp/integration.yaml` and an example flow |
|
|
141
|
+
|
|
142
|
+
Command: **`/integration-check`**.
|
|
143
|
+
|
|
144
|
+
## Install and CI
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pip install "k11-integration-qa-mcp[kafka]"
|
|
148
|
+
k11-integration-qa-mcp init # .qa-mcp/integration.yaml + tests/integration/example.yaml
|
|
149
|
+
k11-integration-qa-mcp run --env ci # exit 1 when a flow fails (--fail-on never to only report)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Claude Code:
|
|
153
|
+
|
|
154
|
+
```text
|
|
155
|
+
/plugin install integration-qa --marketplace K11-Software-Solutions/k11techlab-integration-qa-mcp
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
On Claude Code before 2.1.275: `/plugin marketplace add K11-Software-Solutions/k11techlab-integration-qa-mcp`, then `/plugin install integration-qa@k11-integration-qa`.
|
|
159
|
+
|
|
160
|
+
[`docs/integration-tests.yml`](docs/integration-tests.yml) starts Kafka and runs the flows on every pull request.
|
|
161
|
+
`integration-report.json` is read by the [k11 Release Gate](https://github.com/K11-Software-Solutions/k11techlab-release-gate-mcp) as integration evidence.
|
|
162
|
+
|
|
163
|
+
## Part of the K11 QA suite
|
|
164
|
+
|
|
165
|
+
[Playwright QA](https://github.com/K11-Software-Solutions/k11techlab-playwright-qa-mcp) · [Selenium QA](https://github.com/K11-Software-Solutions/k11techlab-selenium-qa-mcp) · [Appium QA](https://github.com/K11-Software-Solutions/k11techlab-appium-qa-mcp) · [API Contract QA](https://github.com/K11-Software-Solutions/k11techlab-api-contract-qa-mcp) · [API Functional QA](https://github.com/K11-Software-Solutions/k11techlab-api-functional-qa-mcp) · [API Security QA](https://github.com/K11-Software-Solutions/k11techlab-api-security-qa-mcp) · **Integration QA** · [Performance QA](https://github.com/K11-Software-Solutions/k11techlab-performance-qa-mcp) · [LLM Assure](https://github.com/K11-Software-Solutions/k11techlab-llm-assurance-toolkit) · [Release Gate](https://github.com/K11-Software-Solutions/k11techlab-release-gate-mcp) · [Release Readiness Agent](https://github.com/K11-Software-Solutions/k11techlab-release-readiness-agent)
|
|
166
|
+
|
|
167
|
+
## Roadmap
|
|
168
|
+
|
|
169
|
+
- RabbitMQ, Amazon SQS/SNS and Google Pub/Sub brokers
|
|
170
|
+
- Schema Registry (Avro, Protobuf) payloads
|
|
171
|
+
- Ordering and exactly-once checks (per-key order, duplicate detection)
|
|
172
|
+
- Generating flows from an AsyncAPI document
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
Built by [K11 Software Solutions](https://k11softwaresolutions.com). MIT licensed.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# k11 Integration QA: MCP server and CI tool
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: io.github.K11-Software-Solutions/integration-qa -->
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/k11-integration-qa-mcp/)
|
|
6
|
+
[](https://github.com/K11-Software-Solutions/k11techlab-integration-qa-mcp/actions/workflows/ci.yml)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
|
|
9
|
+
**The API returned 201. Did the consumer actually reserve the stock?**
|
|
10
|
+
|
|
11
|
+
In event-driven and batch systems the bugs live *between* the parts: the event is published with the wrong quantity,
|
|
12
|
+
a consumer drops a message it can't read instead of dead-lettering it, a nightly job double-counts when it's retried.
|
|
13
|
+
Unit tests and API tests each pass. k11 Integration QA tests the whole chain in one flow: the API call, the Kafka
|
|
14
|
+
message, the consumer's effect in the database, the dead-letter queue and the batch job, with evidence for the release decision.
|
|
15
|
+
|
|
16
|
+
```yaml
|
|
17
|
+
name: An order reserves stock through the inventory consumer
|
|
18
|
+
fixtures: [sku] # a fresh SKU in the test database, deleted afterwards
|
|
19
|
+
steps:
|
|
20
|
+
- listen: { broker: main, topic: orders.events, as: events } # subscribe BEFORE acting
|
|
21
|
+
- call: POST /orders
|
|
22
|
+
body: { sku: "${fixture.sku.sku}", qty: 3 }
|
|
23
|
+
expect: { status: 201 }
|
|
24
|
+
save: { orderId: "$.id" }
|
|
25
|
+
- name: OrderCreated is published and matches the AsyncAPI contract
|
|
26
|
+
expect_message:
|
|
27
|
+
from: events
|
|
28
|
+
match: { "$.type": OrderCreated, "$.orderId": "${orderId}" }
|
|
29
|
+
schema: OrderCreated
|
|
30
|
+
within: 10s
|
|
31
|
+
- name: the inventory consumer reserves all 3
|
|
32
|
+
expect_message: { from: events, match: { "$.type": StockReserved, "$.orderId": "${orderId}", "$.qty": 3 }, within: 10s }
|
|
33
|
+
- name: the reservation is in the database
|
|
34
|
+
wait_until:
|
|
35
|
+
db: SELECT reserved FROM inventory WHERE sku = :sku
|
|
36
|
+
params: { sku: "${fixture.sku.sku}" }
|
|
37
|
+
expect: { row: { reserved: 3 } }
|
|
38
|
+
within: 10s
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## See it work
|
|
42
|
+
|
|
43
|
+
The included demo, K11 Shop, has an order API, two consumers, a dead-letter queue and a batch job, each with a bug you
|
|
44
|
+
can switch on. With all three bugs on:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
4 of 4 flow(s) did not pass: 0 passed, 4 failed (2 published, 6 message checks, 2 job runs)
|
|
48
|
+
- An order reserves stock through the inventory consumer — the inventory consumer reserves all 3:
|
|
49
|
+
0 of 1 matching message(s) within 10s (2 message(s) on orders.events); closest: $.qty: expected 3, got 1
|
|
50
|
+
- Cancelling an order releases its stock — the stock is released: reserved 0: expected 0, got -1; not met after 41 check(s)
|
|
51
|
+
- An unreadable command goes to the dead-letter queue — it is dead-lettered with the reason:
|
|
52
|
+
0 of 1 matching message(s) within 10s (0 message(s) on orders.dlq)
|
|
53
|
+
- The sku_totals batch job is safe to run twice — the total is still 2: qty 2: expected 2, got 4
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
When nothing matches, the report shows the **closest message** and how it differed, so "the event never came" and
|
|
57
|
+
"the event came with the wrong quantity" are different findings. With the bugs off, all four flows pass. CI runs the
|
|
58
|
+
same flows against a real Apache Kafka broker.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install "k11-integration-qa-mcp[kafka]"
|
|
62
|
+
python demo/shop/shop.py --bugs consumer # in-process broker; add --kafka localhost:9092 for Kafka
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Step types
|
|
66
|
+
|
|
67
|
+
Everything from [k11 API Functional QA](https://github.com/K11-Software-Solutions/k11techlab-api-functional-qa-mcp)
|
|
68
|
+
(`call`, `db`, fixtures, cleanup, auth profiles, `${ENV:…}` secrets, matchers like `{ gt: 0 }`), plus:
|
|
69
|
+
|
|
70
|
+
| Step | What it does |
|
|
71
|
+
|---|---|
|
|
72
|
+
| `listen` | Subscribe to a topic from *now on*, before the action that should produce the event |
|
|
73
|
+
| `publish` | Send a message (JSON or text, key, headers): commands, or a poison message for the DLQ |
|
|
74
|
+
| `expect_message` | A matching message arrives within the time limit; match on JSON paths, `key`, `header:Name`, `value`; `count`, `save`, AsyncAPI `schema` |
|
|
75
|
+
| `expect_no_message` | Nothing matching arrives (no `OrderFailed`, no duplicate) for the given time |
|
|
76
|
+
| `run_job` | Run a batch job: a command (a list, no shell) or an HTTP trigger with polling (`until`, `fail_if`) |
|
|
77
|
+
| `wait_until` | Poll a `SELECT` or `GET` until the expectation holds: eventual consistency without sleeps |
|
|
78
|
+
|
|
79
|
+
## Configure
|
|
80
|
+
|
|
81
|
+
`.qa-mcp/integration.yaml` (environments, auth, databases and fixtures come from `.qa-mcp/api-test.yaml`, shared with API Functional QA):
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
brokers:
|
|
85
|
+
main: { type: kafka, bootstrap: "${ENV:KAFKA_BOOTSTRAP}" } # extra keys go to kafka-python (security_protocol, sasl_*…)
|
|
86
|
+
jobs:
|
|
87
|
+
sku_totals:
|
|
88
|
+
command: [python, jobs/sku_totals.py]
|
|
89
|
+
env: { SHOP_DB: shop.db }
|
|
90
|
+
timeout: 60s
|
|
91
|
+
reindex:
|
|
92
|
+
http: { call: POST /admin/jobs/reindex, save: { jobId: "$.id" } }
|
|
93
|
+
poll: { call: "GET /admin/jobs/${jobId}", until: { "$.status": done }, fail_if: { "$.status": failed } }
|
|
94
|
+
asyncapi: asyncapi.yaml
|
|
95
|
+
protected_topics: ["prod.*", "*.prod.*", "*production*"]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Safety
|
|
99
|
+
|
|
100
|
+
- **Publishing and jobs change data**, so they follow API Functional QA's write rules: local hosts, test-named environments or `allow_writes: true`; production-like names are refused.
|
|
101
|
+
- **Protected topics** (production-named by default) are never published to, on any environment.
|
|
102
|
+
- **Jobs run without a shell** (the command is a list), inside the project, with a time limit.
|
|
103
|
+
- **Every wait has a time limit;** listeners are closed and cleanup always runs.
|
|
104
|
+
- **Read-only listening:** listeners use no consumer group, so they never take messages from your real consumers or move their offsets.
|
|
105
|
+
- Secrets come from `${ENV:NAME}` and are masked in reports.
|
|
106
|
+
|
|
107
|
+
## Tools (MCP)
|
|
108
|
+
|
|
109
|
+
| Tool | What it does |
|
|
110
|
+
|---|---|
|
|
111
|
+
| `integration_config` | Brokers, jobs, AsyncAPI contract, protected topics, environments (and whether publishing and jobs may run there), flows |
|
|
112
|
+
| `run_integration_tests` | Runs flows (all, by path or by tag); writes `.qa-mcp/integration-report/` (Markdown, JSON, JUnit) |
|
|
113
|
+
| `validate_flow` | Checks a flow file's structure without running it |
|
|
114
|
+
| `watch_topic` | Listens to a topic for a few seconds and shows the messages, to learn their shape |
|
|
115
|
+
| `get_report` | The last report, or one flow's steps with full evidence (messages, queries, job output) |
|
|
116
|
+
| `init_integration_config` | Writes a starter `.qa-mcp/integration.yaml` and an example flow |
|
|
117
|
+
|
|
118
|
+
Command: **`/integration-check`**.
|
|
119
|
+
|
|
120
|
+
## Install and CI
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
pip install "k11-integration-qa-mcp[kafka]"
|
|
124
|
+
k11-integration-qa-mcp init # .qa-mcp/integration.yaml + tests/integration/example.yaml
|
|
125
|
+
k11-integration-qa-mcp run --env ci # exit 1 when a flow fails (--fail-on never to only report)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Claude Code:
|
|
129
|
+
|
|
130
|
+
```text
|
|
131
|
+
/plugin install integration-qa --marketplace K11-Software-Solutions/k11techlab-integration-qa-mcp
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
On Claude Code before 2.1.275: `/plugin marketplace add K11-Software-Solutions/k11techlab-integration-qa-mcp`, then `/plugin install integration-qa@k11-integration-qa`.
|
|
135
|
+
|
|
136
|
+
[`docs/integration-tests.yml`](docs/integration-tests.yml) starts Kafka and runs the flows on every pull request.
|
|
137
|
+
`integration-report.json` is read by the [k11 Release Gate](https://github.com/K11-Software-Solutions/k11techlab-release-gate-mcp) as integration evidence.
|
|
138
|
+
|
|
139
|
+
## Part of the K11 QA suite
|
|
140
|
+
|
|
141
|
+
[Playwright QA](https://github.com/K11-Software-Solutions/k11techlab-playwright-qa-mcp) · [Selenium QA](https://github.com/K11-Software-Solutions/k11techlab-selenium-qa-mcp) · [Appium QA](https://github.com/K11-Software-Solutions/k11techlab-appium-qa-mcp) · [API Contract QA](https://github.com/K11-Software-Solutions/k11techlab-api-contract-qa-mcp) · [API Functional QA](https://github.com/K11-Software-Solutions/k11techlab-api-functional-qa-mcp) · [API Security QA](https://github.com/K11-Software-Solutions/k11techlab-api-security-qa-mcp) · **Integration QA** · [Performance QA](https://github.com/K11-Software-Solutions/k11techlab-performance-qa-mcp) · [LLM Assure](https://github.com/K11-Software-Solutions/k11techlab-llm-assurance-toolkit) · [Release Gate](https://github.com/K11-Software-Solutions/k11techlab-release-gate-mcp) · [Release Readiness Agent](https://github.com/K11-Software-Solutions/k11techlab-release-readiness-agent)
|
|
142
|
+
|
|
143
|
+
## Roadmap
|
|
144
|
+
|
|
145
|
+
- RabbitMQ, Amazon SQS/SNS and Google Pub/Sub brokers
|
|
146
|
+
- Schema Registry (Avro, Protobuf) payloads
|
|
147
|
+
- Ordering and exactly-once checks (per-key order, duplicate detection)
|
|
148
|
+
- Generating flows from an AsyncAPI document
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
Built by [K11 Software Solutions](https://k11softwaresolutions.com). MIT licensed.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.25"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "k11-integration-qa-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "MCP server and CI tool for integration testing of event-driven and batch systems: flows that combine API calls, Kafka messages (publish, expect, dead-letter queues, AsyncAPI schemas), batch jobs and database checks, with evidence for release decisions."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "K11 Software Solutions" }]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
keywords = ["mcp", "integration-testing", "kafka", "event-driven", "asyncapi", "batch-jobs", "middleware", "database-testing", "qa", "claude"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Topic :: Software Development :: Testing",
|
|
20
|
+
]
|
|
21
|
+
dependencies = ["k11-api-functional-qa-mcp>=0.1.1,<0.2", "mcp>=1.20,<2"]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
kafka = ["kafka-python>=2.0.2"]
|
|
25
|
+
dev = ["pytest>=8", "pytest-timeout>=2"]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/K11-Software-Solutions/k11techlab-integration-qa-mcp"
|
|
29
|
+
Issues = "https://github.com/K11-Software-Solutions/k11techlab-integration-qa-mcp/issues"
|
|
30
|
+
|
|
31
|
+
[project.scripts]
|
|
32
|
+
k11-integration-qa-mcp = "k11_integration_qa.cli:main"
|
|
33
|
+
|
|
34
|
+
[tool.hatch.build.targets.wheel]
|
|
35
|
+
packages = ["src/k11_integration_qa"]
|
|
36
|
+
|
|
37
|
+
[tool.hatch.build.targets.sdist]
|
|
38
|
+
include = ["src", "README.md", "LICENSE"]
|
|
39
|
+
|
|
40
|
+
[tool.pytest.ini_options]
|
|
41
|
+
testpaths = ["tests"]
|
|
42
|
+
timeout = 300
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"""Message brokers behind one small interface: publish, and listen from "now on".
|
|
2
|
+
|
|
3
|
+
A listener starts at the topic's current end, so a test only sees messages produced after it
|
|
4
|
+
subscribed: start listening before the action that should produce the event. Messages are kept
|
|
5
|
+
(not consumed) so several expectations can look at the same stream.
|
|
6
|
+
|
|
7
|
+
memory in-process broker (tests and demos; the service under test must run in the same process)
|
|
8
|
+
kafka Apache Kafka via kafka-python (pip install "k11-integration-qa-mcp[kafka]")
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
import threading
|
|
15
|
+
import time
|
|
16
|
+
from dataclasses import dataclass, field
|
|
17
|
+
from typing import Any
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass
|
|
21
|
+
class Message:
|
|
22
|
+
topic: str
|
|
23
|
+
value: Any
|
|
24
|
+
key: str | None = None
|
|
25
|
+
headers: dict[str, str] = field(default_factory=dict)
|
|
26
|
+
partition: int | None = None
|
|
27
|
+
offset: int | None = None
|
|
28
|
+
timestamp: float = field(default_factory=time.time)
|
|
29
|
+
raw: str = ""
|
|
30
|
+
|
|
31
|
+
def as_dict(self) -> dict:
|
|
32
|
+
return {"topic": self.topic, "key": self.key, "value": self.value, "headers": self.headers,
|
|
33
|
+
"partition": self.partition, "offset": self.offset}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def decode(data: bytes | str | None) -> tuple[Any, str]:
|
|
37
|
+
if data is None:
|
|
38
|
+
return None, ""
|
|
39
|
+
text = data.decode("utf-8", errors="replace") if isinstance(data, bytes) else str(data)
|
|
40
|
+
try:
|
|
41
|
+
return json.loads(text), text
|
|
42
|
+
except ValueError:
|
|
43
|
+
return text, text
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def encode(value: Any) -> bytes:
|
|
47
|
+
if isinstance(value, bytes):
|
|
48
|
+
return value
|
|
49
|
+
if isinstance(value, str):
|
|
50
|
+
return value.encode("utf-8")
|
|
51
|
+
return json.dumps(value).encode("utf-8")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Listener:
|
|
55
|
+
def __init__(self, topic: str):
|
|
56
|
+
self.topic = topic
|
|
57
|
+
self.messages: list[Message] = []
|
|
58
|
+
self.lock = threading.Lock()
|
|
59
|
+
self.error: str | None = None
|
|
60
|
+
|
|
61
|
+
def add(self, m: Message) -> None:
|
|
62
|
+
with self.lock:
|
|
63
|
+
self.messages.append(m)
|
|
64
|
+
|
|
65
|
+
def snapshot(self) -> list[Message]:
|
|
66
|
+
with self.lock:
|
|
67
|
+
return list(self.messages)
|
|
68
|
+
|
|
69
|
+
def close(self) -> None: # overridden by backends that hold resources
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# ---- in-memory ----------------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
class MemoryBroker:
|
|
76
|
+
"""A process-wide broker: everything in this process that uses the same name shares topics."""
|
|
77
|
+
|
|
78
|
+
_registry: dict[str, "MemoryBroker"] = {}
|
|
79
|
+
_reg_lock = threading.Lock()
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def named(cls, name: str) -> "MemoryBroker":
|
|
83
|
+
with cls._reg_lock:
|
|
84
|
+
if name not in cls._registry:
|
|
85
|
+
cls._registry[name] = cls()
|
|
86
|
+
return cls._registry[name]
|
|
87
|
+
|
|
88
|
+
@classmethod
|
|
89
|
+
def reset(cls) -> None:
|
|
90
|
+
with cls._reg_lock:
|
|
91
|
+
cls._registry.clear()
|
|
92
|
+
|
|
93
|
+
def __init__(self):
|
|
94
|
+
self.lock = threading.Lock()
|
|
95
|
+
self.topics: dict[str, list[Message]] = {}
|
|
96
|
+
self.listeners: dict[str, list[Listener]] = {}
|
|
97
|
+
self.subscribers: dict[str, list] = {} # topic -> callbacks (services under test)
|
|
98
|
+
|
|
99
|
+
def publish(self, topic: str, value: Any, key: str | None = None, headers: dict | None = None) -> Message:
|
|
100
|
+
parsed, raw = decode(encode(value))
|
|
101
|
+
with self.lock:
|
|
102
|
+
log = self.topics.setdefault(topic, [])
|
|
103
|
+
m = Message(topic, parsed, key, dict(headers or {}), 0, len(log), raw=raw)
|
|
104
|
+
log.append(m)
|
|
105
|
+
listeners = list(self.listeners.get(topic, []))
|
|
106
|
+
subs = list(self.subscribers.get(topic, []))
|
|
107
|
+
for lst in listeners:
|
|
108
|
+
lst.add(m)
|
|
109
|
+
for cb in subs:
|
|
110
|
+
threading.Thread(target=cb, args=(m,), daemon=True).start()
|
|
111
|
+
return m
|
|
112
|
+
|
|
113
|
+
def listen(self, topic: str) -> Listener:
|
|
114
|
+
lst = Listener(topic)
|
|
115
|
+
with self.lock:
|
|
116
|
+
self.listeners.setdefault(topic, []).append(lst)
|
|
117
|
+
return lst
|
|
118
|
+
|
|
119
|
+
def subscribe(self, topic: str, callback) -> None:
|
|
120
|
+
"""For services under test: callback(message) for every new message."""
|
|
121
|
+
with self.lock:
|
|
122
|
+
self.subscribers.setdefault(topic, []).append(callback)
|
|
123
|
+
|
|
124
|
+
def close(self) -> None:
|
|
125
|
+
pass
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# ---- Kafka --------------------------------------------------------------------------------------
|
|
129
|
+
|
|
130
|
+
class KafkaListener(Listener):
|
|
131
|
+
def __init__(self, topic: str, bootstrap: str, extra: dict):
|
|
132
|
+
super().__init__(topic)
|
|
133
|
+
from kafka import KafkaConsumer, TopicPartition
|
|
134
|
+
|
|
135
|
+
self._stop = threading.Event()
|
|
136
|
+
self.consumer = KafkaConsumer(bootstrap_servers=bootstrap, enable_auto_commit=False, group_id=None,
|
|
137
|
+
consumer_timeout_ms=200, **extra)
|
|
138
|
+
parts = None
|
|
139
|
+
deadline = time.time() + 10
|
|
140
|
+
while not parts and time.time() < deadline:
|
|
141
|
+
parts = self.consumer.partitions_for_topic(topic)
|
|
142
|
+
if not parts:
|
|
143
|
+
time.sleep(0.2)
|
|
144
|
+
if not parts:
|
|
145
|
+
self.consumer.close()
|
|
146
|
+
raise ValueError(f"Kafka topic '{topic}' not found")
|
|
147
|
+
tps = [TopicPartition(topic, p) for p in sorted(parts)]
|
|
148
|
+
self.consumer.assign(tps)
|
|
149
|
+
self.consumer.seek_to_end(*tps)
|
|
150
|
+
for tp in tps:
|
|
151
|
+
self.consumer.position(tp) # resolve "end" now, so only later messages are seen
|
|
152
|
+
self.thread = threading.Thread(target=self._run, daemon=True)
|
|
153
|
+
self.thread.start()
|
|
154
|
+
|
|
155
|
+
def _run(self) -> None:
|
|
156
|
+
try:
|
|
157
|
+
while not self._stop.is_set():
|
|
158
|
+
batch = self.consumer.poll(timeout_ms=200)
|
|
159
|
+
for _tp, records in batch.items():
|
|
160
|
+
for r in records:
|
|
161
|
+
value, raw = decode(r.value)
|
|
162
|
+
key = r.key.decode("utf-8", errors="replace") if isinstance(r.key, bytes) else r.key
|
|
163
|
+
hdrs = {k: (v.decode("utf-8", errors="replace") if isinstance(v, bytes) else str(v)) for k, v in (r.headers or [])}
|
|
164
|
+
self.add(Message(r.topic, value, key, hdrs, r.partition, r.offset, (r.timestamp or 0) / 1000, raw))
|
|
165
|
+
except Exception as e: # noqa: BLE001 - surfaced in results
|
|
166
|
+
self.error = f"{type(e).__name__}: {e}"
|
|
167
|
+
|
|
168
|
+
def close(self) -> None:
|
|
169
|
+
self._stop.set()
|
|
170
|
+
self.thread.join(timeout=3)
|
|
171
|
+
try:
|
|
172
|
+
self.consumer.close()
|
|
173
|
+
except Exception: # noqa: BLE001
|
|
174
|
+
pass
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class KafkaBroker:
|
|
178
|
+
def __init__(self, bootstrap: str, extra: dict | None = None):
|
|
179
|
+
try:
|
|
180
|
+
from kafka import KafkaProducer
|
|
181
|
+
except ImportError:
|
|
182
|
+
raise ValueError('Kafka needs kafka-python: pip install "k11-integration-qa-mcp[kafka]"') from None
|
|
183
|
+
self.bootstrap, self.extra = bootstrap, dict(extra or {})
|
|
184
|
+
self.producer = KafkaProducer(bootstrap_servers=bootstrap, **self.extra)
|
|
185
|
+
self.listeners: list[KafkaListener] = []
|
|
186
|
+
|
|
187
|
+
def publish(self, topic: str, value: Any, key: str | None = None, headers: dict | None = None) -> Message:
|
|
188
|
+
fut = self.producer.send(topic, value=encode(value), key=key.encode() if key else None,
|
|
189
|
+
headers=[(k, str(v).encode()) for k, v in (headers or {}).items()])
|
|
190
|
+
md = fut.get(timeout=15)
|
|
191
|
+
parsed, raw = decode(encode(value))
|
|
192
|
+
return Message(topic, parsed, key, dict(headers or {}), md.partition, md.offset, raw=raw)
|
|
193
|
+
|
|
194
|
+
def listen(self, topic: str) -> Listener:
|
|
195
|
+
lst = KafkaListener(topic, self.bootstrap, {k: v for k, v in self.extra.items() if k.startswith(("security", "sasl", "ssl"))})
|
|
196
|
+
self.listeners.append(lst)
|
|
197
|
+
return lst
|
|
198
|
+
|
|
199
|
+
def close(self) -> None:
|
|
200
|
+
for lst in self.listeners:
|
|
201
|
+
lst.close()
|
|
202
|
+
try:
|
|
203
|
+
self.producer.close(timeout=3)
|
|
204
|
+
except Exception: # noqa: BLE001
|
|
205
|
+
pass
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def open_broker(name: str, spec: dict):
|
|
209
|
+
from .config import sub_env
|
|
210
|
+
|
|
211
|
+
spec = sub_env(spec)
|
|
212
|
+
if spec["type"] == "memory":
|
|
213
|
+
return MemoryBroker.named(spec.get("name", name))
|
|
214
|
+
extra = {k: v for k, v in spec.items() if k not in ("type", "bootstrap", "name")}
|
|
215
|
+
return KafkaBroker(spec["bootstrap"], extra)
|