Unverified Commit cf65f815 authored by Aaron Todd's avatar Aaron Todd Committed by GitHub
Browse files

make smithy-rs the source of truth for extra AWS model tests (#3686)

## Motivation and Context

There are extra service specific model tests in various
`aws/sdk/aws-models/[sdk-id]-tests.smithy` files. These are currently
manually duplicated to `aws-sdk-rust/aws-models`. This PR seeks to make
`smithy-rs` the single source of truth for these tests and remove the
need to copy them into `aws-sdk-rust` at all.

## Description

* move all `-tests.smithy` into a new sibling directory
`aws-models-extra` and _ALWAYS_ include these regardless of what the
path to `aws-models` is (e.g. even when overriding it and generating the
full SDK by setting `-Paws.sdk.models.path`
* move all `-tests.smithy` from `aws-sdk-rust/aws-models` into this
directory (previously only `s3`, `route53`, and `glacier` were in this
repo but there are also additional tests for `ebs`, `batch`, and `sqs`.
This makes `smithy-rs` the only source of truth for additional AWS SDK
model tests
    * see https://github.com/awslabs/aws-sdk-rust/pull/1161
* update the `s3` model to latest and revert
ttps://github.com/smithy-lang/smithy-rs/pull/3641

## Testing
Local + CI

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent a088b4b8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
This directory contains additional protocol tests for specific AWS service models. These models are ALWAYS
sourced alongside the real models by matching on the `sdkId` of the model. The convention is `{sdkId}-tests.smithy`.
+64 −0
Original line number Diff line number Diff line
$version: "1.0"

namespace com.amazonaws.batch
use smithy.test#httpResponseTests
apply DescribeComputeEnvironments @httpResponseTests([
    {
        id: "DeserializeDescribeCompute",
        documentation: "This test case validates a bug where unboxed primitives were incorrectly marked as required",
        body: """
            {
                "computeEnvironments":[{
                    "computeEnvironmentName":"test-batch-compute",
                    "computeEnvironmentArn":"arn",
                    "ecsClusterArn":"clusteran",
                    "tags":{"foo": "bar"},
                    "type":"MANAGED",
                    "state":"ENABLED",
                    "status":"VALID",
                    "statusReason":"ComputeEnvironment Healthy",
                    "computeResources":{
                        "type":"EC2",
                        "minvCpus":0,
                        "maxvCpus":256,
                        "desiredvCpus":0,
                        "instanceTypes":["optimal"],
                        "subnets":["subnet-c745b79c","subnet-d4e24fe8"],
                        "securityGroupIds":["sg-06a55e7b"],
                        "instanceRole":"instancerole",
                        "tags":{"Name":"batch-compute"},
                        "ec2Configuration":[{"imageType":"ECS_AL1"}]
                    },
                    "serviceRole":"arn:aws:iam::432762038596:role/service-role/AWSBatchServiceRole"
                }]
            }
        """,
        code: 200,
        protocol: "aws.protocols#restJson1",
        params: {
                "computeEnvironments":[{
                    "computeEnvironmentName":"test-batch-compute",
                    "computeEnvironmentArn":"arn",
                    "ecsClusterArn":"clusteran",
                    "tags":{"foo": "bar"},
                    "type":"MANAGED",
                    "state":"ENABLED",
                    "status":"VALID",
                    "statusReason":"ComputeEnvironment Healthy",
                    "computeResources":{
                        "type":"EC2",
                        "minvCpus":0,
                        "maxvCpus":256,
                        "desiredvCpus":0,
                        "instanceTypes":["optimal"],
                        "subnets":["subnet-c745b79c","subnet-d4e24fe8"],
                        "securityGroupIds":["sg-06a55e7b"],
                        "instanceRole":"instancerole",
                        "tags":{"Name":"batch-compute"},
                        "ec2Configuration":[{"imageType":"ECS_AL1"}]
                    },
                    "serviceRole":"arn:aws:iam::432762038596:role/service-role/AWSBatchServiceRole"
                }]
            }
    }
])
+51 −0
Original line number Diff line number Diff line
$version: "1.0"
namespace com.amazonaws.ebs

use smithy.test#httpResponseTests

apply ValidationException @httpResponseTests([
    {
        id: "LowercaseMessage",
        documentation: "This test case validates case insensitive parsing of `message`",
        params: {
            Message: "1 validation error detected"
        },
        bodyMediaType: "application/json",
        body: """
        {
          "message": "1 validation error detected"
        }
        """,
        protocol: "aws.protocols#restJson1",
        code: 400,
        headers:  {
            "x-amzn-requestid": "2af8f013-250a-4f6e-88ae-6dd7f6e12807",
            "x-amzn-errortype": "ValidationException:http://internal.amazon.com/coral/com.amazon.coral.validate/",
            "content-type": "application/json",
            "content-length": "77",
            "date": "Wed, 30 Jun 2021 23:42:27 GMT"
        },
    },

    {
        id: "UppercaseMessage",
        documentation: "This test case validates case insensitive parsing of `message`",
        params: {
            Message: "Invalid volume size: 99999999999",
            Reason: "INVALID_VOLUME_SIZE"
        },
        bodyMediaType: "application/json",
        body: """
        {"Message":"Invalid volume size: 99999999999","Reason":"INVALID_VOLUME_SIZE"}
        """,
        protocol: "aws.protocols#restJson1",
        code: 400,
        headers:  {
            "x-amzn-requestid": "2af8f013-250a-4f6e-88ae-6dd7f6e12807",
            "x-amzn-errortype": "ValidationException:http://internal.amazon.com/coral/com.amazon.zeppelindataservice/",
            "content-type": "application/json",
            "content-length": "77",
            "date": "Wed, 30 Jun 2021 23:42:27 GMT"
        },
    },
])
Loading