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

Provider verification > auto-downloading plugins feature doesn't work as expected #44

Closed
tienvx opened this issue Aug 6, 2023 · 5 comments · Fixed by pact-foundation/pact-reference#308

Comments

@tienvx
Copy link
Contributor

tienvx commented Aug 6, 2023

Run provider verification alone did trigger auto-downloading required plugin, but it didn't work as expected.

How to reproduce:

  1. git clone https://github.com/tienvx/pact-php-csv.git
  2. composer install
  3. rm example/consumer/tests/Contract/pacts/*.json
  4. PACT_LOGLEVEL=debug phpunit --testsuite="Example Consumer" (to generate pact files. csv plugin is downloaded to ~/.pact if not downloaded)
  5. rm -rf ~/.pact
  6. PACT_LOGLEVEL=debug phpunit --testsuite="Example Provider"
  7. Expected: csv plugin is downloaded to ~/.pact, test is passed
  8. Actual: csv plugin is not downloaded, test is not passed
Log
2023-08-06T16:00:04.902489Z  INFO ThreadId(01) pact_verifier: Pact file requires plugins, will load those now
2023-08-06T16:00:04.902498Z DEBUG ThreadId(01) pact_plugin_driver::plugin_manager: Loading plugin PluginDependency { name: "csv", version: Some("0.0"), dependency_type: Plugin }
2023-08-06T16:00:04.902508Z DEBUG ThreadId(01) pact_plugin_driver::plugin_manager: Did not find plugin, will attempt to start it
2023-08-06T16:00:04.902510Z DEBUG ThreadId(01) pact_plugin_driver::plugin_manager: Loading plugin manifest for plugin PluginDependency { name: "csv", version: Some("0.0"), dependency_type: Plugin }
2023-08-06T16:00:04.902515Z DEBUG ThreadId(01) pact_plugin_driver::plugin_manager: Looking for plugin in "/home/user/.pact/plugins"
2023-08-06T16:00:04.902536Z  WARN ThreadId(01) pact_plugin_driver::plugin_manager: Could not load plugin manifest from disk, will try auto install it: Plugin csv:0.0 was not found (in $HOME/.pact/plugins or $PACT_PLUGIN_DIR)
2023-08-06T16:00:04.902859Z  INFO ThreadId(01) pact_plugin_driver::repository: Fetching index from github
2023-08-06T16:00:04.902932Z DEBUG tokio-runtime-worker hyper::client::connect::dns: resolving host="raw.githubusercontent.com"
2023-08-06T16:00:04.903238Z DEBUG ThreadId(01) hyper::client::connect::http: connecting to [2606:50c0:8003::154]:443
2023-08-06T16:00:04.950168Z DEBUG ThreadId(01) hyper::client::connect::http: connected to [2606:50c0:8003::154]:443
2023-08-06T16:00:05.001068Z DEBUG ThreadId(01) h2::client: binding client connection
2023-08-06T16:00:05.001077Z DEBUG ThreadId(01) h2::client: client connection bound
2023-08-06T16:00:05.001089Z DEBUG ThreadId(01) h2::codec::framed_write: send frame=Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384 }
2023-08-06T16:00:05.001148Z DEBUG ThreadId(01) hyper::client::pool: pooling idle connection for ("https", raw.githubusercontent.com)
2023-08-06T16:00:05.001150Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 5177345 }
2023-08-06T16:00:05.001205Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) }
2023-08-06T16:00:05.088810Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x0), max_concurrent_streams: 100 }
2023-08-06T16:00:05.088823Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Settings { flags: (0x1: ACK) }
2023-08-06T16:00:05.088829Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=WindowUpdate { stream_id: StreamId(0), size_increment: 16711681 }
2023-08-06T16:00:05.088834Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Settings { flags: (0x1: ACK) }
2023-08-06T16:00:05.088838Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::proto::settings: received settings ACK; applying Settings { flags: (0x0), enable_push: 0, initial_window_size: 2097152, max_frame_size: 16384 }
2023-08-06T16:00:05.089577Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) }
2023-08-06T16:00:05.089588Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(1), flags: (0x1: END_STREAM) }
2023-08-06T16:00:05.089708Z DEBUG ThreadId(01) hyper::client::pool: reuse idle connection for ("https", raw.githubusercontent.com)
2023-08-06T16:00:05.089739Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(3), flags: (0x5: END_HEADERS | END_STREAM) }
2023-08-06T16:00:05.174052Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Headers { stream_id: StreamId(3), flags: (0x4: END_HEADERS) }
2023-08-06T16:00:05.174068Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_read: received frame=Data { stream_id: StreamId(3), flags: (0x1: END_STREAM) }
2023-08-06T16:00:05.174955Z DEBUG ThreadId(01) pact_plugin_driver::repository: Installing plugin csv/0.0 from index
2023-08-06T16:00:05.175018Z ERROR ThreadId(01) pact_ffi::verifier::handle: Verification execution failed: Plugin csv:0.0 was not found (in $HOME/.pact/plugins or $PACT_PLUGIN_DIR)
2023-08-06T16:00:05.175018Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::codec::framed_write: send frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) }
2023-08-06T16:00:05.175028Z DEBUG tokio-runtime-worker Connection{peer=Client}: h2::proto::connection: Connection::poll; connection error error=GoAway(b"", NO_ERROR, Library)
2023-08-06T16:00:05.175043Z DEBUG ThreadId(01) pact_ffi::verifier: pact_ffi::verifier::pactffi_verifier_shutdown FFI function invoked
Output of ls ~/.pact/plugins/
repository.index  repository.index.sha256
Pact file
{
"consumer": {
  "name": "csvConsumer"
},
"interactions": [
  {
    "description": "request for a report.csv",
    "interactionMarkup": {
      "markup": "# Data\n\n|Name|100|2000-01-01|\n",
      "markupType": "COMMON_MARK"
    },
    "pending": false,
    "pluginConfiguration": {
      "csv": {
        "csvHeaders": false
      }
    },
    "providerStates": [
      {
        "name": "report.csv file exist"
      }
    ],
    "request": {
      "headers": {
        "Accept": [
          "text/csv"
        ]
      },
      "method": "GET",
      "path": "/report.csv"
    },
    "response": {
      "body": {
        "content": "Name,100,2000-01-01\n",
        "contentType": "text/csv;charset=utf-8",
        "contentTypeHint": "DEFAULT",
        "encoded": false
      },
      "generators": {
        "body": {
          "column:3": {
            "format": "yyyy-MM-dd",
            "type": "DateTime"
          }
        }
      },
      "headers": {
        "content-type": [
          "text/csv"
        ]
      },
      "matchingRules": {
        "body": {
          "column:1": {
            "combine": "AND",
            "matchers": [
              {
                "match": "type"
              }
            ]
          },
          "column:2": {
            "combine": "AND",
            "matchers": [
              {
                "match": "number"
              }
            ]
          },
          "column:3": {
            "combine": "AND",
            "matchers": [
              {
                "format": "yyyy-MM-dd",
                "match": "datetime"
              }
            ]
          }
        }
      },
      "status": 200
    },
    "transport": "http",
    "type": "Synchronous/HTTP"
  }
],
"metadata": {
  "pactRust": {
    "ffi": "0.4.7",
    "mockserver": "1.2.3",
    "models": "1.1.9"
  },
  "pactSpecification": {
    "version": "4.0"
  },
  "plugins": [
    {
      "configuration": {},
      "name": "csv",
      "version": "0.0.3"
    }
  ]
},
"provider": {
  "name": "csvProvider"
}
}
  • FFI Library: 0.4.7
  • CSV Plugin: 0.0.3
  • Specification: 4.0
@tienvx
Copy link
Contributor Author

tienvx commented Aug 7, 2023

The problem is: the version 0.0 is invalid CSV plugin version. There is no such CSV plugin with that version listed in ~/.pact/plugins/repository.index

@YOU54F
Copy link
Member

YOU54F commented Aug 7, 2023

I can't see that version "0.0" in here https://github.com/pact-foundation/pact-plugins/blob/main/repository/repository.index

I wonder where the index is coming from, maybe the plugin driver needs updating in the ffi, if it provides the registry index?

can you check the shasum to see if it matches that in the repo?

@YOU54F
Copy link
Member

YOU54F commented Aug 7, 2023

So just ran steps 1 & 2 and it was installed to the bin dir inside the pact-php-csv repo

Screenshot 2023-08-07 at 16 56 53

I did already have a csv plugin in my ~/.pact/plugins dir

Screenshot 2023-08-07 at 16 57 40

will remove all that and try again

@tienvx
Copy link
Contributor Author

tienvx commented Aug 7, 2023

@YOU54F Yes, 0.0 is not in repository.index, but the problem is not related to that file, so shasum of that file is not related to this bug.

I found the root cause of the bug and created a pull request for it here pact-foundation/pact-reference#308

@YOU54F
Copy link
Member

YOU54F commented Aug 7, 2023

Ok I've been able to reproduce it, thanks for the steps.

Note on step 5, rm -rf ~/.pact causes the local index not to be found, and it then fetches the registry from github.

Screenshot 2023-08-07 at 17 03 14

doing both that and clearing out the just the existing csv plugin result in the same error you noted in your report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

2 participants