Katerina Foniok
10/02/2023, 12:47 PMpending pact
feature for synchronization. The good thing is it doesn't fail the suite, but it seems the tests are run twice - is that expected? It also seems that the verifyRequest.AfterEach
is ignored somehow as the second run reports that resources already exist. Maybe I have something bad in my configuration, could you help me find a culprit please? Adding screens and log to the thread.Katerina Foniok
10/02/2023, 12:48 PM...
The pact at <https://pact-broker-hac-pact-broker.apps.hac-devsandbox.5unc.p1.openshiftapps.com/pacts/provider/HAS/consumer/HACdev/pact-version/8f7d677e2bd85f9e523914e612b3082c558c6b17> is being verified because the pact content belongs to the consumer version matching the following criterion:
* all consumer versions tagged 'PR808' (37dc07b)
This pact is in pending state for this version of HAS because a successful verification result for a version of HAS from branch 'main' has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at <https://docs.pact.io/go/pending>
Verifying a pact between HACdev and HAS
Get app with its components. (1s 53ms loading, 2s 846ms verification)
Given Application exists
And Application has components
returns a response which
has status code 200 (OK)
includes headers
"Content-Type" with value "application/json" (OK)
has a matching body (OK)
CDQ was created (1s 53ms loading, 6ms verification)
Given CDQ exists
returns a response which
has status code 201 (OK)
includes headers
"Content-Type" with value "application/json" (OK)
has a matching body (FAILED)
Create an application. (1s 53ms loading, 6ms verification)
Given No app with the name app-to-create in the default namespace exists.
returns a response which
has status code 201 (OK)
includes headers
"Content-Type" with value "application/json" (OK)
has a matching body (OK)
This pact is still in pending state for any version of HAS from branch 'main' as the successful verification results have not yet been published.
The pact at <https://pact-broker-hac-pact-broker.apps.hac-devsandbox.5unc.p1.openshiftapps.com/pacts/provider/HAS/consumer/HACdev/pact-version/015fa7731662a83578a37f235f4f4b43b8c2fe5b> is being verified because the pact content belongs to the consumer version matching the following criterion:
* all consumer versions tagged 'PR808' (e28530f)
This pact is in pending state for this version of HAS because a successful verification result for a version of HAS from branch 'main' has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at <https://docs.pact.io/go/pending>
Verifying a pact between HACdev and HAS
Get app with its components. (1s 53ms loading, 7ms verification)
Given Application exists
And Application has components
Request Failed - One or more of the setup state change handlers has failed
CDQ was created (1s 53ms loading, 5ms verification)
Given CDQ exists
returns a response which
has status code 201 (FAILED)
includes headers
"Content-Type" with value "application/json" (OK)
has a matching body (FAILED)
Create an application. (1s 53ms loading, 6ms verification)
Given No app with the name app-to-create in the default namespace exists.
returns a response which
has status code 201 (FAILED)
includes headers
"Content-Type" with value "application/json" (OK)
has a matching body (FAILED)
This pact is still in pending state for any version of HAS from branch 'main' as the successful verification results have not yet been published.
Pending Failures:
1) Verifying a pact between HACdev and HAS Given CDQ exists - CDQ was created
1.1) has a matching body
$ -> Actual map is missing the following keys: status
2) Verifying a pact between HACdev and HAS Given Application exists And Application has components - Get app with its components. - One or more of the setup state change handlers has failed
3) Verifying a pact between HACdev and HAS Given CDQ exists - CDQ was created
3.1) has a matching body
$.status -> Type mismatch: Expected Map {"conditions":[{"lastTransitionTime":"2022-06-01T19:46:56Z","message":"ComponentDetectionQuery is processing","reason":"Success","type":"Processing"}]} but received String "Failure"
$ -> Actual map is missing the following keys: spec
$.apiVersion -> Expected '<http://appstudio.redhat.com/v1alpha1|appstudio.redhat.com/v1alpha1>' (String) but received 'v1' (String)
$.kind -> Expected 'ComponentDetectionQuery' (String) but received 'Status' (String)
$.metadata -> Actual map is missing the following keys: creationTimestamp, generation, name, namespace
3.2) has status code 201
expected 201 but was 409
4) Verifying a pact between HACdev and HAS Given No app with the name app-to-create in the default namespace exists. - Create an application.
4.1) has a matching body
$ -> Actual map is missing the following keys: spec
$.apiVersion -> Expected '<http://appstudio.redhat.com/v1alpha1|appstudio.redhat.com/v1alpha1>' (String) but received 'v1' (String)
$.kind -> Expected 'Application' (String) but received 'Status' (String)
$.metadata -> Actual map is missing the following keys: creationTimestamp, generation, managedFields, name, namespace, resourceVersion, uid
4.2) has status code 201
expected 201 but was 409
There were 4 non-fatal pact failures on pending pacts or interactions (see <http://docs.pact.io/pending|docs.pact.io/pending> for more information)
...
Matt (pactflow.io / pact-js / pact-go)
Katerina Foniok
10/02/2023, 12:48 PMMatt (pactflow.io / pact-js / pact-go)
Katerina Foniok
10/02/2023, 12:49 PMMatt (pactflow.io / pact-js / pact-go)
The pact at <https://pact-broker-hac-pact-broker.apps.hac-devsandbox.5unc.p1.openshiftapps.com/pacts/provider/HAS/consumer/HACdev/pact-version/8f7d677e2bd85f9e523914e612b3082c558c6b17> is being verified because the pact content belongs to the consumer version matching the following criterion:
* all consumer versions tagged 'PR808' (37dc07b)
Second one:
This pact is still in pending state for any version of HAS from branch 'main' as the successful verification results have not yet been published.
The pact at <https://pact-broker-hac-pact-broker.apps.hac-devsandbox.5unc.p1.openshiftapps.com/pacts/provider/HAS/consumer/HACdev/pact-version/015fa7731662a83578a37f235f4f4b43b8c2fe5b> is being verified because the pact content belongs to the consumer version matching the following criterion:
* all consumer versions tagged 'PR808' (e28530f)
Matt (pactflow.io / pact-js / pact-go)
But it still seems that after method is ignored, right?It shouldn’t, so it could be a bug
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
is ignored somehow as the second run reports that resources already exist.are you able to elaborate on this point further?
Katerina Foniok
10/02/2023, 1:07 PMGet app with its components.
and Create an application.
are not touched and should succeed. The second run fails though, saying that resources (those applications) already exists:
2023-10-02T10:35:57.119775Z DEBUG ThreadId(01) verify_interaction{interaction="Create an application."}: pact_verifier::provider_client: body:
{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"<http://applications.appstudio.redhat.com|applications.appstudio.redhat.com> \"app-to-create\" already exists","reason":"AlreadyExists","details":{"name":"app-to-create","group":"<http://appstudio.redhat.com|appstudio.redhat.com>","kind":"applications"},"code":409}
That indicates that the app was not removed, but should be during the verifyRequest.AfterEach
.
To verify the method was called, I've put debug text to the After Each method and it appreared 2 times in the middle of logs, seems like some asynchronous behaviour to me. Not sure if it is bug or my issue. I can try to move that logic to teardown suite.Katerina Foniok
10/02/2023, 1:08 PMKaterina Foniok
10/02/2023, 1:10 PMMatt (pactflow.io / pact-js / pact-go)
Is it intended though that AfterEach is not executed when the test fails?It’s a good question. Ideally it should still run I think