Skip to content

Commit 5e4c3fa

Browse files
authored
Add query-compatible protocol tests (#3896)
* Protocol test project updates * Generator updates. New protocol test C2J files and updates to tt files * Add generated protocol tests and generate protocol test services * Generated service changes and updates to solution files * Fix type on devconfig
1 parent f157259 commit 5e4c3fa

File tree

255 files changed

+4857
-398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+4857
-398
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"core": {
3+
"updateMinimum": true,
4+
"type": "patch",
5+
"changeLogMessages": [
6+
"Add new protocol tests. Update JSON response unmarshallers to return safely if the service returns an empty string as a response instead of an empty json body"
7+
]
8+
}
9+
}

generator/ProtocolTestsGenerator/settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pluginManagement {
1212
dependencyResolutionManagement {
1313
versionCatalogs {
1414
create("codegen") {
15-
version("smithy", "1.54.0")
15+
version("smithy", "1.60.3")
1616
library("protocol-tests", "software.amazon.smithy", "smithy-aws-protocol-tests").versionRef("smithy")
1717
library("codegen-core", "software.amazon.smithy", "smithy-codegen-core").versionRef("smithy")
1818
library("protocol-tests-traits", "software.amazon.smithy", "smithy-protocol-test-traits").versionRef("smithy")

generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/HttpProtocolTestGenerator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ private void generateErrorResponseTests(OperationShape operation, OperationIndex
9494
for (StructureShape error : index.getErrors(operation, service)) {
9595
error.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> {
9696
for (HttpResponseTestCase httpResponseTestCase : trait.getTestCasesFor(AppliesTo.CLIENT)) {
97-
generateErrorResponseTest(operation, error, httpResponseTestCase);
97+
if (!ProtocolTestCustomizations.TestsToSkip.contains(httpResponseTestCase.getId())){
98+
generateErrorResponseTest(operation, error, httpResponseTestCase);
99+
}
98100
}
99101
});
100102
}

generator/ProtocolTestsGenerator/smithy-dotnet-codegen/src/main/java/software/amazon/smithy/dotnet/codegen/customizations/ProtocolTestCustomizations.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ private ProtocolTestCustomizations() {
9696
// to use exceptions and control flow.
9797
"QueryEmptyInputAndEmptyOutput",
9898
"QueryNoInputAndNoOutput",
99-
"QueryNoInputAndOutput"
99+
"QueryNoInputAndOutput",
100+
// this test is skipped because in the C2J Ruby added a hook which adds the "code" json key which can NEVER exist in a
101+
// non-query protocol. this causes our code generation to check on this code instead of what is modeled and our protocol
102+
// test passes. As this can never happen in a real service, we can skip this to avoid unnecessary customizations in the generator
103+
// for a scenario that will never happen.
104+
"QueryCompatibleAwsJson10CustomCodeError"
100105
);
101106
public static final List<String> VNextTests = Arrays.asList(
102107
//These are the tests that are failing in v4 after updating to 1.54.0 and artifacts 1.0.3004.0. Each one needs to be investigated.

generator/ProtocolTestsGenerator/smithy-dotnet-protocol-test/smithy-build.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@
127127
"packageVersion": "0.0.1"
128128
}
129129
}
130+
},
131+
"QueryCompatibleJSONRPC10": {
132+
"transforms": [
133+
{
134+
"name": "includeServices",
135+
"args": {
136+
"services": [
137+
"aws.protocoltests.json10#QueryCompatibleJsonRpc10"
138+
]
139+
}
140+
}
141+
],
142+
"plugins": {
143+
"dotnet-protocol-test-codegen": {
144+
"service": "aws.protocoltests.json10#QueryCompatibleJsonRpc10",
145+
"packageVersion": "0.0.1"
146+
}
147+
}
130148
}
131149
}
132150
}

generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCResponseUnmarshaller.cs

Lines changed: 31 additions & 30 deletions
Large diffs are not rendered by default.

generator/ServiceClientGeneratorLib/Generators/Marshallers/JsonRPCResponseUnmarshaller.tt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
9191
{
9292
#>
9393
StreamingUtf8JsonReader reader = new StreamingUtf8JsonReader(context.Stream);
94+
if (reader.Reader.IsFinalBlock) return response;
9495
var unmarshaller = <#= payload.DetermineTypeUnmarshallerInstantiate() #>;
9596
response.<#=payload.PropertyName#> = unmarshaller.Unmarshall(context, ref reader);
9697
<#

generator/TestServiceModels/json10-tests-client/json-rpc-10-2020-07-14.normal.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@
114114
"input":{"shape":"PutWithContentEncodingInput"},
115115
"requestcompression":{"encodings":["gzip"]}
116116
},
117+
"QueryIncompatibleOperation":{
118+
"name":"QueryIncompatibleOperation",
119+
"http":{
120+
"method":"POST",
121+
"requestUri":"/"
122+
},
123+
"idempotent":true
124+
},
117125
"SimpleScalarProperties":{
118126
"name":"SimpleScalarProperties",
119127
"http":{
@@ -153,22 +161,19 @@
153161
},
154162
"ContentTypeParametersOutput":{
155163
"type":"structure",
156-
"members":{
157-
}
164+
"members":{}
158165
},
159166
"Double":{
160167
"type":"double",
161168
"box":true
162169
},
163170
"EmptyInputAndEmptyOutputInput":{
164171
"type":"structure",
165-
"members":{
166-
}
172+
"members":{}
167173
},
168174
"EmptyInputAndEmptyOutputOutput":{
169175
"type":"structure",
170-
"members":{
171-
}
176+
"members":{}
172177
},
173178
"EndpointWithHostLabelOperationInput":{
174179
"type":"structure",
@@ -196,8 +201,7 @@
196201
},
197202
"FooError":{
198203
"type":"structure",
199-
"members":{
200-
},
204+
"members":{},
201205
"documentation":"<p>This error has test cases that test some of the dark corners of Amazon service framework history. It should only be implemented by clients.</p>",
202206
"exception":true,
203207
"fault":true
@@ -267,8 +271,7 @@
267271
},
268272
"NoInputAndOutputOutput":{
269273
"type":"structure",
270-
"members":{
271-
}
274+
"members":{}
272275
},
273276
"PutWithContentEncodingInput":{
274277
"type":"structure",

generator/TestServiceModels/json11-tests-client/json-protocol-2018-01-01.normal.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@
211211
},
212212
"ContentTypeParametersOutput":{
213213
"type":"structure",
214-
"members":{
215-
}
214+
"members":{}
216215
},
217216
"DateTime":{
218217
"type":"timestamp",
@@ -226,8 +225,7 @@
226225
},
227226
"Document":{
228227
"type":"structure",
229-
"members":{
230-
},
228+
"members":{},
231229
"document":true
232230
},
233231
"Double":{
@@ -236,8 +234,7 @@
236234
},
237235
"EmptyStruct":{
238236
"type":"structure",
239-
"members":{
240-
}
237+
"members":{}
241238
},
242239
"ErrorWithMembers":{
243240
"type":"structure",
@@ -257,8 +254,7 @@
257254
},
258255
"ErrorWithoutMembers":{
259256
"type":"structure",
260-
"members":{
261-
},
257+
"members":{},
262258
"exception":true,
263259
"fault":true
264260
},
@@ -291,8 +287,7 @@
291287
},
292288
"FooError":{
293289
"type":"structure",
294-
"members":{
295-
},
290+
"members":{},
296291
"documentation":"<p>This error has test cases that test some of the dark corners of Amazon service framework history. It should only be implemented by clients.</p>",
297292
"exception":true,
298293
"fault":true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"active": true,
3+
"test-service": true,
4+
"synopsis": "query-compatible test service"
5+
}

0 commit comments

Comments
 (0)