pactflow / pact-protobuf-plugin

Pact plugin for Protobufs and gRPC
MIT License
16 stars 8 forks source link

gRPC mock server return (-1073741819) access violation error randomly on Windows #52

Open tienvx opened 4 months ago

tienvx commented 4 months ago

This error only happen on Windows, randomly, when testing consumer (a gRPC mock server is started and a request is made to that server):

Script phpunit --no-coverage handling the test event returned with error code -1073741819

According to this comment, the error code -1073741819 is an access violation.

Information:

{
  "consumer": {
    "name": "protobufSyncMessageConsumer"
  },
  "interactions": [
    {
      "description": "request for calculate shape area",
      "interactionMarkup": {
        "markup": "```protobuf\nmessage AreaResponse {\n    float value = 1;\n}\n```\n",
        "markupType": "COMMON_MARK"
      },
      "pending": false,
      "pluginConfiguration": {
        "protobuf": {
          "descriptorKey": "6b90c212dfe22dc3c119d1c3fe42b5e1",
          "service": "Calculator/calculate"
        }
      },
      "request": {
        "contents": {
          "content": "EgoNAABAQBUAAIBA",
          "contentType": "application/protobuf;message=ShapeMessage",
          "contentTypeHint": "BINARY",
          "encoded": "base64"
        },
        "matchingRules": {
          "body": {
            "$.rectangle.length": {
              "combine": "AND",
              "matchers": [
                {
                  "match": "number"
                }
              ]
            },
            "$.rectangle.width": {
              "combine": "AND",
              "matchers": [
                {
                  "match": "number"
                }
              ]
            }
          }
        },
        "metadata": {
          "contentType": "application/protobuf;message=ShapeMessage"
        }
      },
      "response": [
        {
          "contents": {
            "content": "DQAAQEE=",
            "contentType": "application/protobuf;message=AreaResponse",
            "contentTypeHint": "BINARY",
            "encoded": "base64"
          },
          "matchingRules": {
            "body": {
              "$.value": {
                "combine": "AND",
                "matchers": [
                  {
                    "match": "number"
                  }
                ]
              }
            }
          },
          "metadata": {
            "contentType": "application/protobuf;message=AreaResponse"
          }
        }
      ],
      "transport": "grpc",
      "type": "Synchronous/Messages"
    }
  ],
  "metadata": {
    "pactRust": {
      "ffi": "0.4.14",
      "mockserver": "1.2.5",
      "models": "1.1.17"
    },
    "pactSpecification": {
      "version": "4.0"
    },
    "plugins": [
      {
        "configuration": {
          "6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plugins;\n\noption php_generic_services = true;\n\nservice Calculator {\n    rpc calculate (ShapeMessage) returns (AreaResponse) {}\n}\n\nmessage ShapeMessage {\n  oneof shape {\n    Square square = 1;\n    Rectangle rectangle = 2;\n    Circle circle = 3;\n    Triangle triangle = 4;\n    Parallelogram parallelogram = 5;\n  }\n}\n\nmessage Square {\n  float edge_length = 1;\n}\n\nmessage Rectangle {\n  float length = 1;\n  float width = 2;\n}\n\nmessage Circle {\n  float radius = 1;\n}\n\nmessage Triangle {\n  float edge_a = 1;\n  float edge_b = 2;\n  float edge_c = 3;\n}\n\nmessage Parallelogram {\n  float base_length = 1;\n  float height = 2;\n}\n\nmessage AreaResponse {\n    float value = 1;\n}\n"
          }
        },
        "name": "protobuf",
        "version": "0.3.13"
      }
    ]
  },
  "provider": {
    "name": "protobufSyncMessageProvider"
  }
}
tienvx commented 4 months ago

Switch from powershell to bash and I can see an extra error line below:

Script phpunit --no-coverage handling the test event returned with error code -1073741819
D:\a\_temp\ad6416d5-3f24-46c4-b4ed-876eaa522037.sh: line 1:  1826 Segmentation fault      composer test
Error: Process completed with exit code 139.

The number 1826 is not fixed. It look like a random number

tienvx commented 3 months ago

I have a work around for this: Run tests in different jobs for Windows on Github Actions.

https://github.com/pact-foundation/pact-php/pull/497

rholshausen commented 2 months ago

Looks like there is some issue on Windows with the integration tests as well. They are taking over 5 mins each to run.

running 1 test
test repeated_enum_test has been running for over 60 seconds
test repeated_enum_test ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 610.03s

     Running tests\mock_server_tests.rs (target\debug\deps\mock_server_tests-cac5d069ab2d137b.exe)

running 2 tests
test mock_server_with_no_requests ... ok
test each_value_matcher has been running for over 60 seconds
test each_value_matcher ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 610.04s
tienvx commented 1 month ago

This error happen to csv plugin as well recently, quite frequently. If it's not related, I can create new ticket for it on pact-foundation/pact-plugins repo.