Skip to content

Importing multiple simulation files initializes only the last sequence #839

Description

@denisrosca

Description of the bug

Importing multiple simulation files initializes only the sequences from the last imported file.
Note: I'm using docker for this

Steps to reproduce the issue

  1. Define two simulation files:
    1.json
{
  "data": {
    "pairs": [
      {
        "request": {
          "method": [
            {
              "matcher": "exact",
              "value": "GET"
            }
          ],
          "path": [
            {
              "matcher": "exact",
              "value": "/1"
            }
          ],
          "requiresState": {
            "sequence:first": "1"
          }
        },
        "response": {
          "status": 200,
          "body": "Hello World 1!",
          "transitionsState": {
            "sequence:first": "2"
          }
        }
      }
    ]
  }
}

and 2.json:

{
  "data": {
    "pairs": [
      {
        "request": {
          "method": [
            {
              "matcher": "exact",
              "value": "GET"
            }
          ],
          "path": [
            {
              "matcher": "exact",
              "value": "/2"
            }
          ],
          "requiresState": {
            "sequence:second": "1"
          }
        },
        "response": {
          "status": 200,
          "body": "Hello World 2!",
          "transitionsState": {
            "sequence:second": "2"
          }
        }
      }
    ]
  }
}
  1. Import them both: -webserver -import 1.json -import 2.json
  2. Make a request to GET /1

Observed result

Hoverfly error messages seen (If none, say none)

api_mocks_1       | WARN[2019-05-13T11:31:30Z] Failed to find matching request from simulation  destination="localhost:8500" error="No match found" method=GET path=/1 query="map[]"
api_mocks_1       | ERRO[2019-05-13T11:31:30Z] There was an error when matching              error="Could not find a match for request, create or record a valid matcher first!\n\nThe following request was made, but was not matched by Hoverfly:\n\n{\n    \"Path\": \"/1\",\n    \"Method\": \"GET\",\n    \"Destination\": \"localhost:8500\",\n    \"Scheme\": \"http\",\n    \"Query\": {},\n    \"Body\": \"\",\n    \"Headers\": {\n        \"Accept\": [\n            \"*/*\"\n        ],\n        \"Accept-Encoding\": [\n            \"gzip, deflate\"\n        ],\n        \"Accept-Language\": [\n            \"en-US,en;q=0.5\"\n        ],\n        \"Connection\": [\n            \"keep-alive\"\n        ],\n        \"User-Agent\": [\n            \"Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0\"\n        ]\n    }\n}\n\nWhilst Hoverfly has the following state:\n\n{\n    \"sequence:second\": \"1\"\n}\n\nThe matcher which came closest was:\n\n{\n    \"path\": [\n        {\n            \"matcher\": \"exact\",\n            \"value\": \"/1\"\n        }\n    ],\n    \"method\": [\n        {\n            \"matcher\": \"exact\",\n            \"value\": \"GET\"\n        }\n    ],\n    \"requiresState\": {\n        \"sequence:first\": \"1\"\n    }\n}\n\nBut it did not match on the following fields:\n\n[state]\n\nWhich if hit would have given the following response:\n\n{\n    \"status\": 200,\n    \"body\": \"Hello World 1!\",\n    \"encodedBody\": false,\n    \"templated\": false,\n    \"transitionsState\": {\n        \"sequence:first\": \"2\"\n    }\n}" mode=simulate

Expected result

Request matches and returns correct result.

Additional relevant information

  1. Hoverfly version:
↳ ./hoverctl version

+----------+--------------+
| hoverctl | master-3141  |
| hoverfly | v1.0.0-rc.2  |
+----------+--------------+
  1. Anything that might help us to diagnose the problem
↳ ./hoverctl state get-all
State of Hoverfly:
"sequence:second"="1"

P.S. Note that I'm using the latest docker image available on docker hub and I was expecting the hoverfly version to be 1.0.0 instead of 1.0.0-rc2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions