D you know why I get this 2 value error. Also this...
# protobufs
r
D you know why I get this 2 value error. Also this error is not consistent, one time it is password another user.
Copy code
2022/08/24 17:38:41 [DEBUG] initialising rust mock server interface
2022/08/24 17:38:41 [DEBUG] log_to_stdout res 0
2022/08/24 17:38:41 [DEBUG] waiting for port 8222 to become available
2022/08/24 17:38:41 [DEBUG] executing verifier FFI with args [--hostname localhost --port 8222 --user admin --password 3@Gqd4Z7MkcLqD --broker-url <https://pact.internal.apps-broker.io/> --provider-version dev --provider-name module-producer --loglevel info]
2022-08-24T15:38:41.195073Z TRACE ThreadId(01) mio::poll: registering event source with poller: token=Token(0), interests=READABLE | WRITABLE    
2022-08-24T15:38:41.195726Z ERROR ThreadId(01) pact_ffi::verifier::verifier: error verifying Pact: "error: The argument '--user <user>' requires 1 values, but 2 were provided\n\nUSAGE:\n    pact_verifier_cli --broker-url <broker-url> --dir <dir>... --file <file>... --hostname <hostname> --loglevel <loglevel> --password <password> --port <port> --provider-name <provider-name> --provider-version <provider-version> --scheme <scheme> --url <url>... --user <user>\n\nFor more information try --help" Error { message: "error: The argument '--user <user>' requires 1 values, but 2 were provided\n\nUSAGE:\n    pact_verifier_cli --broker-url <broker-url> --dir <dir>... --file <file>... --hostname <hostname> --loglevel <loglevel> --password <password> --port <port> --provider-name <provider-name> --provider-version <provider-version> --scheme <scheme> --url <url>... --user <user>\n\nFor more information try --help", kind: WrongNumberOfValues, info: Some(["user"]) }    
=== RUN   TestGrpcProvider/Provider_pact_verification
    plugin_verifier.go:56: an unknown error ocurred when verifying the provider (this indicates a defect in the framework
=== CONT  TestGrpcProvider
    provider_test.go:166: 
                Error Trace:    provider_test.go:166
                Error:          Received unexpected error:
                                an unknown error ocurred when verifying the provider (this indicates a defect in the framework
                Test:           TestGrpcProvider
--- FAIL: TestGrpcProvider (0.06s)
    --- FAIL: TestGrpcProvider/Provider_pact_verification (0.00s)
FAIL
FAIL    command-line-arguments  2.891s
FAIL
I think it has something to do with parsing the variables and calling ffi from library. I use Pact-go
m
Can you please check if you have any
PACT_BROKER_
variables in your shell? I think it might be that
I need to migrate the verifier code to use the newer handles interface, which would improve this (just created a quick tracking card for this)
r
Yes I have as you can see them in my output.
Copy code
➜  producer git:(ROSI-145) ✗ echo $PACT_BROKER_PASSWORD 
3GX6u4sa7MdsacLqD
message has been deleted
message has been deleted
m
OK thanks. If you set the environment variables, you don’t need to set them in code (and vice versa). That’s why it thinks it’s getting 2 values instead of one
r
message has been deleted
hmm maybe my program sees them but the pact_verifier_cli not?
I wrote the variables to .zshrc but the output is the same ;/
m
have you sourced them from your IDE?
e.g.
source ~/.zshrc
(or
reload!
)
r
I've restarted zsh. Now trying putting right in the code withoud envs.
I have it
For any1 concerned: SOLUTION:
Copy code
In ~/.zshrc or ~/.bashrc:
export PACT_BROKER_BASE_URL=<https://pact.internal.apps-apps.com/>
export PACT_BROKER_USERNAME=admin
export PACT_BROKER_PASSWORD=3GX6udsadsacLqD
In code
Copy code
err = verifier.VerifyProvider(t, provider.VerifyPluginRequest{
		ProviderAddress: "<http://localhost:8222>",
		Provider:        "module-producer",
		BrokerURL:       os.Getenv("PACT_BROKER_BASE_URL"),
		ProviderVersion: "dev",
	})
	assert.NoError(t, err)
Don't fill the username and password VerifyPluginRequest fields. They will be taken from enviroment vars.
🙏 1
Thanks @Matt (pactflow.io / pact-js / pact-go)
👍 1
m
I’m going to fix this Robert. The implementation under the hood essentially wraps the CLI verifier. There is a newer FFI set of methods that I can use in Pact Go which will improve this experience. I’ll aim to get this added in the next week or so
r
Ok no problem. I just wonder if I should put my solutinons in form of github issue so more people can find the answer? Plus for me it is a github activity 🙂.
🙌 1
m
haha you can raise it, and i’ll close it when I get the above issue done (and you’ll get the kudos!)
🙌 1