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

Document that port cannot be set in parallel tests #731

Merged
merged 4 commits into from
Nov 14, 2024

Conversation

danile42
Copy link
Contributor

Hi,

as noted in #726, overriding the port does not (always) work with ZIO or Weaver. The reason seems to be that both execute tests in parallel by default.

I documented this in the README and added two specific tests for ZIO.

For Weaver, setting the suite to sequential did not work/help. I tried it as documented here: https://disneystreaming.github.io/weaver-test/docs/parallelism

(BTW, #726 was not my first contribution as mentioned in the release notes for 0.15.1. #526 was my first :) )

Best,
Daniel

@danile42
Copy link
Contributor Author

Oh, of course this only applies to "inline" style tests. I'll change that later today.

@jbwheatley
Copy link
Owner

found the fix for weaver:

when we create the server resource in weaver.InlineRequestResponsePactForging, turns out that createServer creates a connection before server.start is called, so we need to suspend it:

Resource.eval(F.delay(createServer)).flatMap { server =>
      Resource.make[F, BaseMockServer] {
        {
          for {
            _ <- validatePactVersion(mockProviderConfig.getPactVersion).liftTo[F]
            _ <- F.delay(server.start())
            _ <- F.delay(server.waitForServer())
          } yield server
        }.onError { case _: Throwable => F.delay(server.stop()) }
      } { s =>
        F.delay(s.stop())
      }
    }

instead of

val server = createServer
Resource.make[F, BaseMockServer] {
  {
        for {
          _ <- validatePactVersion(mockProviderConfig.getPactVersion).liftTo[F]
          _ <- F.delay(server.start())
          _ <- F.delay(server.waitForServer())
        } yield server
      }.onError { case _: Throwable => F.delay(server.stop()) }
    } { s =>
      F.delay(s.stop())
}

once i made that change i could run the weaver tests sequentially as you pointed out

daniel added 3 commits November 13, 2024 23:10
…, because they are only relevant there. Add sample test for Weaver, too.
…d by jbwheatley), to allow multiple sequential instances using the same port.
@danile42
Copy link
Contributor Author

@jbwheatley: I incorporated your Weaver fix, added tests and fixed the documentation.

@jbwheatley jbwheatley merged commit cbcdc0a into jbwheatley:main Nov 14, 2024
6 checks passed
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

Successfully merging this pull request may close these issues.

2 participants