Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contract test compare_model assertion error when integer property is defined as integer literal in input file #1063

Open
AgustinBettati opened this issue Mar 11, 2024 · 0 comments

Comments

@AgustinBettati
Copy link

Command being run

cfn test --function-name TestEntrypoint --verbose

Version

cfn 0.2.35

Resource type schema

{
  ...
  "definitions": {
    "ApiSearchDeploymentSpec": {
      "type": "object",
      "properties": {
        "InstanceSize": {
          "type": "string"
        },
        "NodeCount": {
          "type": "integer"
        }
      },
      "required": [
        "InstanceSize",
        "NodeCount"
      ],
      "additionalProperties": false
    }
  },
  "properties": { 
    "Specs": {
      "insertionOrder": false,
      "type": "array",
      "items": {
        "$ref": "#/definitions/ApiSearchDeploymentSpec",
        "type": "object"
      },
    }
  },
  ...
}

Contract test input file

{
  ...
  "Specs": [
    {
      "InstanceSize": "S30_HIGHCPU_NVME",
      "NodeCount": 3
    }
  ]
}

Unexpected error output

/opt/homebrew/Cellar/cloudformation-cli/0.2.35_1/libexec/lib/python3.12/site-packages/rpdk/core/contract/resource_client.py:498: in compare_model
raise AssertionError(assertion_error_message) from exception
E   AssertionError: All properties specified in the request MUST be present in the model returned, and they MUST match exactly, with the exception of properties defined as writeOnlyProperties in the resource schema
E    Request Model : {'Profile': 'default', 'ProjectId': '65251446ae5f3f6ec7968b13', 'ClusterName': 'Cluster0', 'Specs': [{'InstanceSize': 'S30_HIGHCPU_NVME', 'NodeCount': 3}]}
E    Returned Model : {'Profile': 'default', 'ClusterName': 'Cluster0', 'ProjectId': '65251446ae5f3f6ec7968b13', 'Specs': [{'InstanceSize': 'S30_HIGHCPU_NVME', 'NodeCount': '3'}]}
E   , inputs: {"Profile": "default", "ProjectId": "65251446ae5f3f6ec7968b13", "ClusterName": "Cluster0", "Specs": [{"InstanceSize": "S30_HIGHCPU_NVME", "NodeCount": 3}]}, outputs: {"Profile": "default", "ClusterName": "Cluster0", "ProjectId": "65251446ae5f3f6ec7968b13", "Specs": [{"InstanceSize": "S30_HIGHCPU_NVME", "NodeCount": "3"}]}

As a workaround, if the input file defines the integer property as a string the compare logic does not fail and contract tests are successful:

{
  ...
  "Specs": [
    {
      "InstanceSize": "S30_HIGHCPU_NVME",
      "NodeCount": "3"
    }
  ]
}
@AgustinBettati AgustinBettati changed the title contract test compare_model assertion error when integer type property is defined as integer literal in input file Contract test compare_model assertion error when integer property is defined as integer literal in input file Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant