Skip to content

Commit a3dd419

Browse files
authored
[integration-tests] extend versioned_health_incompat with a param add (#93)
This is to exercise drift's other asymmetric-path case.
1 parent 9c0749a commit a3dd419

3 files changed

Lines changed: 87 additions & 9 deletions

File tree

crates/integration-tests/src/fixtures.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,9 @@ pub mod versioned_health_incompat {
11081108
) -> Result<HttpResponseOk<HealthStatusV1>, HttpError>;
11091109

11101110
/// Get detailed health status (v2+).
1111+
///
1112+
/// Adds a required query parameter `verbose` relative to the
1113+
/// blessed shape. See `DetailedFilter` below.
11111114
#[endpoint {
11121115
method = GET,
11131116
path = "/health/detailed",
@@ -1116,6 +1119,7 @@ pub mod versioned_health_incompat {
11161119
}]
11171120
async fn detailed_health_check(
11181121
rqctx: RequestContext<Self::Context>,
1122+
query: Query<DetailedFilter>,
11191123
) -> Result<HttpResponseOk<DetailedHealthStatus>, HttpError>;
11201124

11211125
/// Get service metrics (v3+).
@@ -1157,6 +1161,15 @@ pub mod versioned_health_incompat {
11571161
pub use super::versioned_health::{
11581162
DependencyStatus, DetailedHealthStatus, HealthStatusV1, ServiceMetrics,
11591163
};
1164+
1165+
/// Required query parameter added to `detailed_health_check`. This is
1166+
/// drift's second asymmetric-path case (operation on the missing side,
1167+
/// parameter on the present side) — see comments on the test that
1168+
/// exercises this fixture.
1169+
#[derive(Debug, Deserialize, JsonSchema)]
1170+
pub struct DetailedFilter {
1171+
pub verbose: bool,
1172+
}
11601173
}
11611174

11621175
/// Versioned health API with 4 versions (adds v4 to the base API). Used to test

crates/integration-tests/tests/integration/versioned.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,8 +1016,10 @@ fn test_incompatible_blessed_api_change() -> Result<()> {
10161016
.unwrap()
10171017
);
10181018

1019-
// Now introduce incompatible changes. This adds a new endpoint, which
1020-
// (while forward-compatible) we treat as a breaking change.
1019+
// Now introduce incompatible changes. The incompat fixture adds a new
1020+
// endpoint to v3.0.0 and adds a new required query parameter to
1021+
// `detailed_health_check` (which is in v2.0.0+), so both v2.0.0 and
1022+
// v3.0.0 are reported as broken.
10211023
let incompatible_apis = versioned_health_incompat_apis()?;
10221024

10231025
// This check should return Failures.
@@ -1026,11 +1028,18 @@ fn test_incompatible_blessed_api_change() -> Result<()> {
10261028
assert_eq!(result, CheckResult::Failures);
10271029
assert_eq!(
10281030
summaries,
1029-
[ProblemSummary::new(
1030-
"versioned-health",
1031-
"3.0.0",
1032-
ProblemKind::BlessedVersionBroken,
1033-
)],
1031+
[
1032+
ProblemSummary::new(
1033+
"versioned-health",
1034+
"2.0.0",
1035+
ProblemKind::BlessedVersionBroken,
1036+
),
1037+
ProblemSummary::new(
1038+
"versioned-health",
1039+
"3.0.0",
1040+
ProblemKind::BlessedVersionBroken,
1041+
),
1042+
],
10341043
);
10351044

10361045
Ok(())

crates/integration-tests/tests/output/integration/blessed_version_broken.txt

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,36 @@
55
-------
66
Checking 3 OpenAPI documents...
77
Fresh versioned-health (versioned v1.0.0 (blessed)): Versioned Health API
8-
Fresh versioned-health (versioned v2.0.0 (blessed)): Versioned Health API
8+
Failure versioned-health (versioned v2.0.0 (blessed)): Versioned Health API
9+
error: OpenAPI document generated from the current code is not
10+
compatible with the blessed document (from upstream)
11+
- at .paths."/health/detailed".get: backward-incompatible
12+
change: A new, required parameter 'verbose' was added
13+
--- a/blessed
14+
+++ b/generated
15+
@@ -1,11 +1,22 @@
16+
{
17+
"get": {
18+
+ "description": "Adds a required query parameter `verbose` relative to the blessed shape. See `DetailedFilter` below.",
19+
"operationId": "detailed_health_check",
20+
+ "parameters": [
21+
+ {
22+
+ "in": "query",
23+
+ "name": "verbose",
24+
+ "required": true,
25+
+ "schema": {
26+
+ "type": "boolean"
27+
+ }
28+
+ }
29+
+ ],
30+
"responses": {
31+
"200": {
32+
"content": {
33+
"application/json": {
34+
"schema": {
35+
"$ref": "#/components/schemas/DetailedHealthStatus"
36+
}
37+
}
938
Failure versioned-health (versioned v3.0.0 (blessed)): Versioned Health API
1039
error: OpenAPI document generated from the current code is not
1140
compatible with the blessed document (from upstream)
@@ -39,7 +68,34 @@
3968
+ "summary": "Get system info (v3+): new endpoint added to existing version."
4069
+ }
4170
+}
71+
- at .paths."/health/detailed".get: backward-incompatible
72+
change: A new, required parameter 'verbose' was added
73+
--- a/blessed
74+
+++ b/generated
75+
@@ -1,11 +1,22 @@
76+
{
77+
"get": {
78+
+ "description": "Adds a required query parameter `verbose` relative to the blessed shape. See `DetailedFilter` below.",
79+
"operationId": "detailed_health_check",
80+
+ "parameters": [
81+
+ {
82+
+ "in": "query",
83+
+ "name": "verbose",
84+
+ "required": true,
85+
+ "schema": {
86+
+ "type": "boolean"
87+
+ }
88+
+ }
89+
+ ],
90+
"responses": {
91+
"200": {
92+
"content": {
93+
"application/json": {
94+
"schema": {
95+
"$ref": "#/components/schemas/DetailedHealthStatus"
96+
}
97+
}
4298
Fresh versioned-health "latest" symlink
4399
-------
44-
Failure 3 documents checked: 3 fresh, 0 stale, 1 failed, 0 other problems
100+
Failure 3 documents checked: 2 fresh, 0 stale, 2 failed, 0 other problems
45101
(fix failures, then run test-openapi-manager generate to update)

0 commit comments

Comments
 (0)