micronaut-projects / micronaut-projects/micronaut-http-benchmarks

Upstream declarative Hyperfoil response-body validation

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Goal

Add stock, declarative Hyperfoil YAML support for validating complete HTTP response bodies so endpoint smoke benchmarks do not require a project-specific `Processor` extension.

The required matching modes are:

- Exact body equality.
- Full regular-expression match.
- Structural JSON equality.

## Motivation

Hyperfoil already provides the required processing infrastructure:

- `httpRequest.handler.status` for status validation.
- `httpRequest.handler.body` processors with fragmented-buffer lifecycle support.
- Request invalidation and `stopOnInvalid`.
- Streaming JSON parsing.

However, the existing `SearchValidator` only counts substring occurrences. It cannot express complete-body equality, `Matcher.matches()` semantics, or structural JSON equality.

The benchmark suite currently models these modes as `EQUAL`, `REGEX`, and `JSON`. A stock Hyperfoil equivalent would let Nix generate self-contained smoke YAML with no extension JAR or ServiceLoader registration.

## Proposed upstream work

Introduce a built-in declarative body validator, for example:

```yaml
httpRequest:
GET: /endpoint
handler:
body:
check:
equalTo: '{"result":1}'
```

Alternative strategies under the same `check` builder:

```yaml
check:
regex: '^prefix-.*-suffix$'
```

```yaml
check:
json: '{"result":1}'
```

The builder should require exactly one strategy.

Expected semantics:

- `equalTo`: complete body and length equality, with no ignored prefix/suffix.
- `regex`: full-body `Matcher.matches()`, not substring `find()`.
- `json`: structural equality; ignore insignificant whitespace and object-key order, preserve array order, and document numeric comparison semantics.
- All modes must work when the HTTP body is delivered in multiple fragments.
- Mismatches must mark the request invalid and integrate with `stopOnInvalid` and strict CLI failure reporting.

## Upstream deliverables

- Built-in processor and YAML builder.
- Generated JSON schema support.
- Reference documentation and examples.
- Tests for fragmented bodies and each matching mode.
- Tests for extra/missing bytes, regex substring-only mismatch, malformed JSON, object-key order, array order, and invalidation behavior.

## Repository integration

After an upstream release includes the validator:

- Update the pinned Hyperfoil version.
- Generate stock `handler.body.check` YAML from the existing Nix `responseMatchingMode` data.
- Remove the custom smoke response-validator class and extension packaging.
- Continue using Hyperfoil status validation for readiness checks and allow configured non-2xx benchmark responses where intended.

## Acceptance criteria

- Nix-generated smoke YAML represents all current `EQUAL`, `REGEX`, and `JSON` modes using stock Hyperfoil features.
- Mismatched responses reliably invalidate the smoke run.
- Fragmented responses produce the same result as contiguous responses.
- `micronaut-http-benchmarks` no longer packages a custom response processor or ServiceLoader metadata.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the existing SearchValidator and the HTTP handler.body processor lifecycle, then trace the Nix responseMatchingMode data and custom smoke response-validator packaging. Define the built-in check builder, schema, documentation, examples, and fragmented-body tests around equal, regex, and JSON modes. Done means stock Hyperfoil features cover all modes and the custom processor and ServiceLoader metadata can be removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, yaml
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.