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

sbt pactVerify fails with incomprehensive error #164

Open
atsviatkou opened this issue Aug 18, 2020 · 1 comment
Open

sbt pactVerify fails with incomprehensive error #164

atsviatkou opened this issue Aug 18, 2020 · 1 comment

Comments

@atsviatkou
Copy link

atsviatkou commented Aug 18, 2020

I have very simple pact file with health check endpoints

{
  "provider" : {
    "name" : "service-api"
  },
  "interactions" : [
    {
      "request" : {
        "method" : "GET",
        "path" : "/readiness"
      },
      "description" : "Fetching readiness response",
      "response" : {
        "status" : 200,
        "body" : {
          "result" : {
            "data" : [
              {
                "status" : "UP"
              }
            ],
            "total_count" : 1
          },
          "status" : 200
        }
      },
      "providerState" : "readiness"
    },
    {
      "request" : {
        "method" : "GET",
        "path" : "/liveness"
      },
      "description" : "Fetching liveness response",
      "response" : {
        "status" : 200,
        "body" : {
          "result" : {
            "data" : [
              {
                "status" : "UP"
              }
            ],
            "total_count" : 1
          },
          "status" : 200
        }
      },
      "providerState" : "liveness"
    }
  ],
  "consumer" : {
    "name" : "HealthCheckConsumer"
  },
  "metadata" : {
    "pactSpecification" : {
      "version" : "2.0.0"
    },
    "scala-pact" : {
      "version" : "2.3.17"
    }
  }
}

When I run command

sbt "pactVerify --host localhost --protocol http --port 9000 --source target/pacts"

I got error:

Verifying against 'localhost' on port '9000' with a timeout of second(s). -------------------- Attempting to run provider state: liveness Provider state run failed -------------------- Error executing unknown provider state function with key: liveness [error] com.itv.scalapactcore.verifier.ProviderStateFailure [error] at com.itv.scalapactcore.verifier.Verifier$.$anonfun$doRequest$1(Verifier.scala:183) [error] at scala.Function1.$anonfun$andThen$1(Function1.scala:57) [error] at com.itv.scalapactcore.verifier.Verifier$.$anonfun$verify$14(Verifier.scala:84) [error] at scala.collection.immutable.List.map(List.scala:286) [error] at com.itv.scalapactcore.verifier.Verifier$.$anonfun$verify$13(Verifier.scala:77) [error] at scala.collection.immutable.List.map(List.scala:286) [error] at com.itv.scalapactcore.verifier.Verifier$.$anonfun$verify$1(Verifier.scala:74) [error] at com.itv.scalapactcore.verifier.Verifier$.$anonfun$verify$1$adapted(Verifier.scala:24) [error] at com.itv.scalapact.plugin.shared.ScalaPactVerifyCommand$.doPactVerify(ScalaPactVerifyCommand.scala:46) [error] at com.itv.scalapact.plugin.ScalaPactPlugin$.$anonfun$pactCheckTask$3(ScalaPactPlugin.scala:180) [error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) [error] at sbt.std.Transform$$anon$3.$anonfun$apply$2(Transform.scala:46) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:67) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19) [error] at sbt.Execute.work(Execute.scala:290) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:281) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] (pactVerify) com.itv.scalapactcore.verifier.ProviderStateFailure [error] Total time: 0 s, completed Aug 18, 2020 6:07:24 PM

I get this error even if I start pactStubber

sbt "pactStubber --host localhost --port 9000 --source target/pacts"

and run verification against subbed services by command

sbt "pactVerify --host localhost --protocol http --port 9000 --source target/pacts"

The Pact files are the same for pactVerify and pactStubber

Environment

Java=Oracle jdk 8
Scala=2.12.7
sbt=1.3.10

build.sbt:
...
lazy val scalaPactVersion = "2.3.17"
// scalapact
"com.itv" %% "scalapact-circe-0-13" % scalaPactVersion % Test withSources (),
"com.itv" %% "scalapact-http4s-0-18" % scalaPactVersion % Test withSources (),
"com.itv" %% "scalapact-scalatest" % scalaPactVersion % Test withSources ()

plugins.sbt:
...
addSbtPlugin("com.itv" % "sbt-scalapact" % "2.3.17")

@solarmosaic-kflorence
Copy link
Contributor

@atsviatkou did you set up a provider state called liveness? See http://io.itv.com/scala-pact/advanced/provider-states.html

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

2 participants