Nathan Farmer
10/27/2023, 3:15 PMNathan Farmer
10/27/2023, 3:16 PMAssertionError: An interaction with same description ("a request for a Data Context") and provider state ("the Data Context exists") but a different request headers has already been used. Please use a different description or provider state, or remove any random data in the interaction.
Nathan Farmer
10/27/2023, 3:20 PMpact_test: pact.Pact = pact.Consumer(
name=CONSUMER_NAME,
version=version,
tag_with_git_branch=True,
auto_detect_version_properties=True,
).has_pact_with(
pact.Provider(name=PROVIDER_NAME),
broker_base_url=pact_broker_base_url,
broker_token=broker_token,
host_name=PACT_MOCK_HOST,
port=PACT_MOCK_PORT,
pact_dir=str(PACT_DIR.resolve()),
publish_to_broker=publish_to_broker,
)
Nathan Farmer
10/27/2023, 3:26 PMYousaf Nabi (pactflow.io)
publish_to_broker
is set to true.
Also do you have more than one test, do those tests share the same given and when statements?
("a request for a Data Context") and provider state ("the Data Context exists"
Nathan Farmer
10/27/2023, 5:55 PMpublish_to_broker
is only set to true in CI, because our logic is setup in such a way that the flag only gets set to true if the user has a read/write token (which we only have in CI)
• We don't have more than one test that shares the same given. It seems like there is something either different in the request that I can't find, or there is something about how this all works that I don't understand.Yousaf Nabi (pactflow.io)
Nathan Farmer
10/27/2023, 6:10 PMBoris
10/30/2023, 12:30 AMNot sure why you need to the local version of the providerThis is probably the point that's being missed, afaict. Consumer tests don't need a provider, that's what Pact provides for you. (The provider needs to exist later in the workflow, for verification)
Matt (pactflow.io / pact-js / pact-go)
Nathan Farmer
10/30/2023, 2:41 PMNathan Farmer
10/30/2023, 2:48 PMpact.stop_service()
pattern in the docs after `yield`ing the pact). I think maybe the debugger is having some sort of undesirable side effects, but I'm not 100% sure if that is the cause.
So changes to the test were being run against the same mock service resulting in that error message. Running this fixes the issue:
ps aux|grep pact
kill -9 <pid> for each PID listed in the output of
Boris
10/31/2023, 2:02 AMpact.stop_service()
. . .Matt (pactflow.io / pact-js / pact-go)
pact.verify()
command is what clears interactions between tests, if that’s the problem.
But the stop_service()
command should stop the underlying mock. We’d need to understand why that’s not shutting the process down, because you should defnitely not have to kill
the process manually.Matt (pactflow.io / pact-js / pact-go)