1

I've got a pact-jvm-server instance in Docker and when ever I call the /create method it creates a stub server and returns the correct responses. But now when I try to delete the stub server on the selected port with /complete call and port in body of the POST request it always returns 400 even though it deletes the stub service on provided port.

Any help would be appreciated.

Docker logs:

b51ce9 starting unfiltered app at 0.0.0.0 on port 8080
08:26:44.847 [main] DEBUG i.n.u.i.l.InternalLoggerFactory - Using SLF4J as                 the default logging framework
08:26:44.853 [main] DEBUG i.n.c.MultithreadEventLoopGroup - -
Dio.netty.eventLoopThreads: 408:26:44.860 [main] DEBUG i.n.util.internal.PlatformDependent0 - 
java.nio.Buffer.address: available
08:26:44.860 [main] DEBUG i.n.util.internal.PlatformDependent0 sun.misc.Unsafe.theUnsafe: available
08:26:44.861 [main] DEBUG i.n.util.internal.PlatformDependent0 -         sun.misc.Unsafe.copyMemory: available
08:26:44.861 [main] DEBUG i.n.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: true
08:26:44.913 [main] DEBUG i.n.util.internal.PlatformDependent - UID: 0
08:26:44.914 [main] DEBUG i.n.util.internal.PlatformDependent - Java version: 8
08:26:44.914 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noUnsafe: false
08:26:44.914 [main] DEBUG i.n.util.internal.PlatformDependent - sun.misc.Unsafe: available
08:26:44.914 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noJavassist: false
08:26:44.916 [main] DEBUG i.n.util.internal.PlatformDependent - Javassist: unavailable
08:26:44.916 [main] DEBUG i.n.util.internal.PlatformDependent - You don't have Javassist in your class path or you don't have enough permission to load dynamically generated classes.  Please check the configuration for better performance.
08:26:44.916 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.tmpdir: /tmp (java.io.tmpdir)
08:26:44.917 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
08:26:44.917 [main] DEBUG i.n.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
08:26:44.938 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
08:26:44.938 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
08:26:44.984 [main] DEBUG i.n.util.internal.ThreadLocalRandom - -Dio.netty.initialSeedUniquifier: 0x1f1143a58dddfa74 (took 20 ms)
08:26:45.006 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: unpooled
08:26:45.006 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 65536
08:26:45.009 [main] DEBUG io.netty.util.NetUtil - Loopback interface: lo (lo, 127.0.0.1)
08:26:45.009 [main] DEBUG io.netty.util.NetUtil - /proc/sys/net/core/somaxconn: 128
08:26:46.383 [nioEventLoopGroup-3-1] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetectionLevel: simple
08:26:46.405 [nioEventLoopGroup-3-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxCapacity.default: 262144
08:26:46.409 [nioEventLoopGroup-3-1] DEBUG io.netty.util.internal.Cleaner0 - java.nio.ByteBuffer.cleaner(): available
08:27:08.830 [nioEventLoopGroup-3-2] DEBUG au.com.dius.pact.server.Create$ - path=/create
08:27:08.830 [nioEventLoopGroup-3-2] DEBUG au.com.dius.pact.server.Create$ - query={state=[HarryPotter]}
08:27:08.871 [nioEventLoopGroup-3-2] DEBUG au.com.dius.pact.server.Create$ - au.com.dius.pact.model.OptionalBody(PRESENT, {
"provider": {
    "name": "microservices-simple-catalogue"
},
"consumer": {
    "name": "microservices-simple-orders"
},
"interactions": [
    {
        "description": "catalogue test interaction",
        "request": {
            "method": "GET",
            "path": "/books/1"
        },
        "response": {
            "status": 200,
            "headers": {
                "Content-Type": "application/json"
            },
            "body": {
                "bookOrders": [

                ],
                "author": "J.K. Rowling",
                "description": "Books about a wizard",
                "id": 1,
                "title": "Harry Potter"
            },
            "matchingRules": {
                "body": {
                    "$.bookOrders": {
                        "matchers": [
                            {
                                "match": "type",
                                "min": 0
                            }
                        ],
                        "combine": "AND"
                    }
                }
            }
        },
        "providerStates": [
            {
                "name": "test state for returning Harry Potter book"
            }
        ]
    }
],
"metadata": {
    "pact-specification": {
        "version": "3.0.0"
    },
    "pact-jvm": {
        "version": "3.5.1"
    }
 }
})

If I call it over the curl:

$ curl -v -d '{"port":20004}' localhost:8080/complete
* timeout on name lookup is not supported
*   Trying ::1...
* TCP_NODELAY set
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to localhost (::1) port 8080 (#0)
> POST /complete HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Length: 14
> Content-Type: application/x-www-form-urlencoded
>
} [14 bytes data]
* upload completely sent off: 14 out of 14 bytes
< HTTP/1.1 400 Bad Request
< Content-Type: application/json
< Connection: keep-alive
< Content-Length: 613
<
{ [613 bytes data]
* Curl_http_done: called premature == 0
100   627  100   613  100    14  40866    933 --:--:-- --:--:-- --:--:--  598k{"error": "Pact verification failed for the following reasons:

The following requests were not received:
Interaction: catalogue test interaction
    in state None
request:
    method: GET
    path: /books/1
    query: null
    headers: null
    matchers: null
    body: au.com.dius.pact.model.OptionalBody(MISSING, null)

response:
    status: 200
    headers: [Content-Type:application/json]
    matchers: [body:[$.bookOrders:[combine:AND, matchers:[[match:type, min:0]]]]]
    body: au.com.dius.pact.model.OptionalBody(PRESENT, {"author":"J.K. Rowling","bookOrders":[],"description":"Books about a wizard","id":1,"title":"Harry Potter"})"}
* Connection #0 to host localhost left intact
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
cotnic
  • 158
  • 2
  • 11
  • 1
    Check your containers logs `docker logs ` and update the question with logs from the container which show 400 error code and exceptions – Tarun Lalwani Jul 31 '17 at 08:12
  • thanks for the heads up. I've added the docker logs. There is no 400 error code. The complete is not even logged as it seems – cotnic Jul 31 '17 at 08:33
  • Get inside the container using `docker exec bash` and see if you can locate a log file which has the details – Tarun Lalwani Jul 31 '17 at 08:43
  • I've tried to get inside but it's blank and dosen't let me insert any bash command. Tried to delete the container and start again, but it's the same – cotnic Jul 31 '17 at 08:45
  • My bad it should be `docker exec -it bash` – Tarun Lalwani Jul 31 '17 at 09:04
  • Yes, that is working. Thanks, but I didn't find any log files that would point to pact-jvm-server. Not in /home/pact-jvm-server and not even in /var/logs. Any other path they could be? – cotnic Jul 31 '17 at 09:44
  • Post all the commands that you have used and use curl -v to execute them and post those details – Tarun Lalwani Jul 31 '17 at 09:49
  • I should post all the commands I ran for searching for log files or the commands I ran for creating pact stub servers? – cotnic Jul 31 '17 at 09:51
  • Commands for create and delete. And use curl to execute them and update your docker logs if something changes. Looking at your docker logs the create commands are logged and so should be the complete or delete ones – Tarun Lalwani Jul 31 '17 at 09:54
  • I'm trying with cURL from powershell but it returns an error: curl -v -d '{"port":20006}' http://localhost:8080/complete Invoke-WebRequest : A positional parameter cannot be found that accepts argument 'http://localhost:8080/complete'. At line:1 char:1 + curl -v -d '{"port":20006}' http://localhost:8080/complete + ~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand – cotnic Jul 31 '17 at 10:02
  • If you have Git Bash then try the command in that – Tarun Lalwani Jul 31 '17 at 10:13
  • If I execute it over curl it goes through. Added the log to my question. – cotnic Jul 31 '17 at 10:30
  • See that it does give an error The following requests were not received: Interaction: catalogue test interaction in state None – Tarun Lalwani Jul 31 '17 at 11:01
  • 1
    Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/150591/discussion-between-tarun-lalwani-and-cotnic). – Tarun Lalwani Jul 31 '17 at 11:02

0 Answers0