I `start` the main mock server. After that, I `cre...
# general
r
I
start
the main mock server. After that, I
create
a new mock server from a pact file. The debug output of the main server shows this:
Copy code
13:29:03 [DEBUG] (18) pact_mock_server_cli::server: Starting mock server with id 49c8834c-661f-4b65-94ce-03d9384bb330
13:29:03 [DEBUG] (18) pact_mock_server::mock_server: Started mock server on 0.0.0.0:51714
13:29:03 [DEBUG] (18) pact_mock_server_cli::server: mock server started on port 51714
13:29:03 [DEBUG] (18) pact_mock_server_cli::server: Result of starting mock server: Ok(true)
13:29:03 [DEBUG] (4) pact_mock_server_cli::server: Result of thread: Ok(true)
When I run
./pact_mock_server_cli list
after that, the
list
call hangs. This is the only debug info shown on the main server:
Copy code
13:29:30 [DEBUG] (11) hyper::proto::h1::io: parsed 3 headers
13:29:30 [DEBUG] (11) hyper::proto::h1::conn: incoming body is empty
13:29:30 [DEBUG] (11) pact_mock_server_cli::server: main_resource -> resource_exists
13:29:30 [DEBUG] (11) pact_mock_server_cli::server: main_resource -> render_response
Am I doing something wrong? Any known issues with this?
t
I don’t know - in most use cases, you don’t need to interact directly with the mock server like this. What are you trying to do?
I agree with your steps, though - the docs suggest that what you’re doing is right.
r
@Timothy Jones see the other thread on what I’m trying to do.
t
Interesting!
I assume it doesn’t work without the
list
command? What happens if you just start the server, and then try to use it?
Have you tried not doing
start
?
Ah, wait, that won’t help, according to the docs.
r
The
list
command was already to debug the fact that my created mock server wasn’t responding at all.
t
Yeah, I thought that might be the case.
If your pact file is spec V2 or lower (or can be generated as such), you could try the Ruby mock server
Otherwise you might have to wait for a rust core maintainer to come online (probably best to open an issue here)
The team is in Australia, so they’re probably asleep now
r
Thanks for the suggestion, but I’m going to stop investigating this way for now. I already have to debug our customer problem. Not going to debug the pact tooling on top of that. No offence.
😕 1
😅 1
t
That’s very reasonable.
The Ruby CLI has been around for a long time, so it’s likely to work for you - but it doesn’t support the more recent Pact spec versions.
thankyou 1
Are you able to share the pact file? I’d be happy to make the issue from there.
understand if this is not possible, of course
y
If I read this correctly you are using the pact tooling, in your tool for your customer. I think it is completely reasonable that you raise debug steps for us to follow up. We don't expect you to debug it, but if you are asking for help here, and we are openly providing it, it would be kind to share a repro back
That way volunteers help is going back into helping the community if that makes sense 🙂
r
This is a small handwritten pact file, which I want to return the
body
when a
GET
is done on the given `path`:
Copy code
{
  "provider": {
    "name": "PulumiService"
  },
  "consumer": {
    "name": "PulumiCLI"
  },
  "interactions": [
    {
      "description": "History request",
      "request": {
        "method": "GET",
        "path": "/api/stacks/redacted_customer_name/redacted_project_name/dev/updates?output-type=service&pageSize=1&page=28",
        "headers": {
          "Content-Type": "application/json"
        },
        "body": {},
        "matchingRules": {}
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json; charset=UTF-8"
        },
        "body": {
          "updates": [
            {
              "info": {
                "kind": "import",
                "startTime": 1669315256,
                "message": "",
                "environment": {},
                "config": {},
                "result": "succeeded",
                "endTime": 1669315256,
                "version": 139,
                "resourceChanges": {
                  "create": 0,
                  "delete": 0,
                  "same": 58,
                  "update": 0
                }
              },
              "updateID": "3b1f14e2-bc4e-4b5a-8875-2a56c5fd0217",
              "version": 139,
              "latestVersion": 139,
              "requestedBy": {
                "name": "",
                "githubLogin": "redacted-user",
                "avatarUrl": "<https://avatars.githubusercontent.com>"
              }
            }
          ],
          "itemsPerPage": 10,
          "total": 139
        },
        "matchingRules": {}
      }
    }
  ],
  "metadata": {
    "pact-specification": {
      "version": "3.0.0"
    },
    "pact-jvm": {
      "version": "3.5.6"
    }
  }
}
I only redacted some customer and user info.
t
Awesome, thanks. It being hand-written is a good bit of info - I don’t know if much validation is done, as it expects the Pacts to be generated by Pact.
r
@Yousaf Nabi (pactflow.io) fair point. I’m only under time pressure to follow up on this Pact based setup. Need to find another way to get to the bottom of my customer issue first.
t
Although at a glance it looks ok
I appreciate that you’re a few layers deep, and not excited to debug the tool you’re using to debug a different thing. Thanks for the pact file!
y
No rush @Ringo 💛 in your own time, we are here all the time 😅 Hope you get a happy customer in the end
I appreciate that you’re a few layers deep, and not excited to debug the tool you’re using to debug a different thing. Thanks for the pact file!
Can totally appreciate those frustrations budd. that is my everyday life - yak shaving party yak 🪒
r
FYI: I’m mocking our Pulumi Service REST API here: https://www.pulumi.com/docs/reference/service-rest-api/
y
Oh very cool, your companies name came up recently in conversation, I can't remember with whom, as something to checkout. I'm definitely interested in helping you get to the bottom of it eventually and learning a bit more about Pulumi on my journey. Your docs look fabulous
r
I know. Matt contacted me recently.
y
Ah I see you are using Pact-JVM. AFAIK, the pact-jvm doesn't use the Rust reference implementation and has its own core. (or this pact was created with pact-jvm)?
t
I don’t think your Pact file is the problem - I experience the same issue with a different pact file written by Pact-JS
You aren’t using any V3 features, though - so you could just change the spec version and use the ruby standalone
You would want the
pact-stub-service
binary
Ah, your hand written pact file isn’t right - the query string should be separate to the
path
Copy code
{
  "provider": {
    "name": "PulumiService"
  },
  "consumer": {
    "name": "PulumiCLI"
  },
  "interactions": [
    {
      "description": "History request",
      "request": {
        "method": "GET",
        "path": "/api/stacks/redacted_customer_name/redacted_project_name/dev/updates",
        "query": "output-type=service&pageSize=1&page=28",
        "headers": {
          "Content-Type": "application/json"
        }
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json; charset=UTF-8"
        },
        "body": {
          "updates": [
            {
              "info": {
                "kind": "import",
                "startTime": 1669315256,
                "message": "",
                "environment": {},
                "config": {},
                "result": "succeeded",
                "endTime": 1669315256,
                "version": 139,
                "resourceChanges": {
                  "create": 0,
                  "delete": 0,
                  "same": 58,
                  "update": 0
                }
              },
              "updateID": "3b1f14e2-bc4e-4b5a-8875-2a56c5fd0217",
              "version": 139,
              "latestVersion": 139,
              "requestedBy": {
                "name": "",
                "githubLogin": "redacted-user",
                "avatarUrl": "<https://avatars.githubusercontent.com>"
              }
            }
          ],
          "itemsPerPage": 10,
          "total": 139
        }
      }
    }
  ],
  "metadata": {
    "pact-specification": {
      "version": "2.0.0"
    },
    "hand-written": {
      "version": "na"
    }
  }
}
@Ringo Here is a working pact file
Copy code
pact-stub-service example.json
Then
Copy code
export PORT= <whatever was in the output of pact-stub-service>
curl -H "Content-Type: application/json" "<http://localhost>:${PORT}/api/stacks/redacted_customer_name/redacted_project_name/dev/updates?output-type=service&pageSize=1&page=28"
Side point - I don’t think a GET request should have a Content-Type, but since that’s in the linked docs, I left it as is. I did remove the empty body from the Pact, as that wasn’t in the docs.
Anyway, there’s a solution if you want to use pact tooling for this 🙌
r
@Timothy Jones sorry I was silent until now, but I had a few customer calls. Will see if I can get it working. Thanks for your help already! 🙏
👍 1