From ee36bff719132ba6fd838176e6566c8cdd3a1abc Mon Sep 17 00:00:00 2001 From: Matt Fellows Date: Tue, 9 May 2017 15:02:05 +1000 Subject: [PATCH] feat(verification): publish verification results to broker - Upgrade to latest verifier (v1.0.1) - Add new flags to verifier to allow results to be published to a Pact Broker --- daemon/verification_service.go | 2 ++ dsl/pact_integration_test.go | 53 +++++++++++++++++++--------------- dsl/pact_test.go | 6 ++-- scripts/package.sh | 2 +- types/verify_request.go | 16 ++++++++++ 5 files changed, 53 insertions(+), 26 deletions(-) diff --git a/daemon/verification_service.go b/daemon/verification_service.go index d7fc2e42f..a9a04ab03 100644 --- a/daemon/verification_service.go +++ b/daemon/verification_service.go @@ -22,6 +22,8 @@ type VerificationService struct { // --provider-states-setup-url // --broker-username // --broker-password +// --publish_verification_results +// --provider_app_version func (m *VerificationService) NewService(args []string) (int, Service) { log.Printf("[DEBUG] starting verification service with args: %v\n", args) diff --git a/dsl/pact_integration_test.go b/dsl/pact_integration_test.go index e13031d31..b314b27e0 100644 --- a/dsl/pact_integration_test.go +++ b/dsl/pact_integration_test.go @@ -131,10 +131,11 @@ func TestPact_Integration(t *testing.T) { PactDir: pactDir, } err = providerPact.VerifyProvider(types.VerifyRequest{ - ProviderBaseURL: fmt.Sprintf("http://localhost:%d", providerPort), - PactURLs: []string{fmt.Sprintf("%s/billy-bobby.json", pactDir)}, - ProviderStatesURL: fmt.Sprintf("http://localhost:%d/states", providerPort), - ProviderStatesSetupURL: fmt.Sprintf("http://localhost:%d/setup", providerPort), + ProviderBaseURL: fmt.Sprintf("http://localhost:%d", providerPort), + PactURLs: []string{fmt.Sprintf("%s/billy-bobby.json", pactDir)}, + ProviderStatesURL: fmt.Sprintf("http://localhost:%d/states", providerPort), + ProviderStatesSetupURL: fmt.Sprintf("http://localhost:%d/setup", providerPort), + PublishVerificationResults: false, // No HAL links in local pacts }) if err != nil { @@ -143,12 +144,14 @@ func TestPact_Integration(t *testing.T) { // Verify the Provider - Specific Published Pacts err = providerPact.VerifyProvider(types.VerifyRequest{ - ProviderBaseURL: fmt.Sprintf("http://localhost:%d", providerPort), - PactURLs: []string{fmt.Sprintf("%s/pacts/provider/bobby/consumer/billy/latest/sit4", brokerHost)}, - ProviderStatesURL: fmt.Sprintf("http://localhost:%d/states", providerPort), - ProviderStatesSetupURL: fmt.Sprintf("http://localhost:%d/setup", providerPort), - BrokerUsername: os.Getenv("PACT_BROKER_USERNAME"), - BrokerPassword: os.Getenv("PACT_BROKER_PASSWORD"), + ProviderBaseURL: fmt.Sprintf("http://localhost:%d", providerPort), + PactURLs: []string{fmt.Sprintf("%s/pacts/provider/bobby/consumer/billy/latest/sit4", brokerHost)}, + ProviderStatesURL: fmt.Sprintf("http://localhost:%d/states", providerPort), + ProviderStatesSetupURL: fmt.Sprintf("http://localhost:%d/setup", providerPort), + BrokerUsername: os.Getenv("PACT_BROKER_USERNAME"), + BrokerPassword: os.Getenv("PACT_BROKER_PASSWORD"), + PublishVerificationResults: true, + ProviderVersion: "1.0.0", }) if err != nil { @@ -157,12 +160,14 @@ func TestPact_Integration(t *testing.T) { // Verify the Provider - Latest Published Pacts for any known consumers err = providerPact.VerifyProvider(types.VerifyRequest{ - ProviderBaseURL: fmt.Sprintf("http://localhost:%d", providerPort), - BrokerURL: brokerHost, - ProviderStatesURL: fmt.Sprintf("http://localhost:%d/states", providerPort), - ProviderStatesSetupURL: fmt.Sprintf("http://localhost:%d/setup", providerPort), - BrokerUsername: os.Getenv("PACT_BROKER_USERNAME"), - BrokerPassword: os.Getenv("PACT_BROKER_PASSWORD"), + ProviderBaseURL: fmt.Sprintf("http://localhost:%d", providerPort), + BrokerURL: brokerHost, + ProviderStatesURL: fmt.Sprintf("http://localhost:%d/states", providerPort), + ProviderStatesSetupURL: fmt.Sprintf("http://localhost:%d/setup", providerPort), + BrokerUsername: os.Getenv("PACT_BROKER_USERNAME"), + BrokerPassword: os.Getenv("PACT_BROKER_PASSWORD"), + PublishVerificationResults: true, + ProviderVersion: "1.0.0", }) if err != nil { @@ -171,13 +176,15 @@ func TestPact_Integration(t *testing.T) { // Verify the Provider - Tag-based Published Pacts for any known consumers err = providerPact.VerifyProvider(types.VerifyRequest{ - ProviderBaseURL: fmt.Sprintf("http://localhost:%d", providerPort), - BrokerURL: brokerHost, - Tags: []string{"latest", "sit4"}, - ProviderStatesURL: fmt.Sprintf("http://localhost:%d/states", providerPort), - ProviderStatesSetupURL: fmt.Sprintf("http://localhost:%d/setup", providerPort), - BrokerUsername: os.Getenv("PACT_BROKER_USERNAME"), - BrokerPassword: os.Getenv("PACT_BROKER_PASSWORD"), + ProviderBaseURL: fmt.Sprintf("http://localhost:%d", providerPort), + BrokerURL: brokerHost, + Tags: []string{"latest", "sit4"}, + ProviderStatesURL: fmt.Sprintf("http://localhost:%d/states", providerPort), + ProviderStatesSetupURL: fmt.Sprintf("http://localhost:%d/setup", providerPort), + BrokerUsername: os.Getenv("PACT_BROKER_USERNAME"), + BrokerPassword: os.Getenv("PACT_BROKER_PASSWORD"), + PublishVerificationResults: true, + ProviderVersion: "1.0.0", }) if err != nil { diff --git a/dsl/pact_test.go b/dsl/pact_test.go index 9749355e8..356155152 100644 --- a/dsl/pact_test.go +++ b/dsl/pact_test.go @@ -239,8 +239,10 @@ func TestPact_VerifyProviderBroker(t *testing.T) { pact := &Pact{Port: port, LogLevel: "DEBUG", pactClient: &PactClient{Port: port}, Provider: "bobby"} err := pact.VerifyProvider(types.VerifyRequest{ - ProviderBaseURL: "http://www.foo.com", - BrokerURL: fmt.Sprintf("http://localhost:%d", brokerPort), + ProviderBaseURL: "http://www.foo.com", + BrokerURL: fmt.Sprintf("http://localhost:%d", brokerPort), + PublishVerificationResults: true, + ProviderVersion: "1.0.0", }) if err != nil { diff --git a/scripts/package.sh b/scripts/package.sh index 0e3263c48..362d67f09 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -3,7 +3,7 @@ set -e export PACT_MOCK_SERVICE_VERSION=2.0.0 # Seg faults... -export PACT_PROVIDER_VERIFIER_VERSION=0.0.15 +export PACT_PROVIDER_VERIFIER_VERSION=1.0.1 # Create the OS specific versions of the mock service and verifier echo "==> Building Ruby Binaries..." diff --git a/types/verify_request.go b/types/verify_request.go index 714dd4b28..3a1a82246 100644 --- a/types/verify_request.go +++ b/types/verify_request.go @@ -31,6 +31,12 @@ type VerifyRequest struct { // Password when authenticating to a Pact Broker. BrokerPassword string + // PublishVerificationResults to the Pact Broker. + PublishVerificationResults bool + + // ProviderVersion is the semantical version of the Provider API. + ProviderVersion string + // Verbose increases verbosity of output Verbose bool @@ -78,6 +84,16 @@ func (v *VerifyRequest) Validate() error { v.Args = append(v.Args, v.BrokerPassword) } + if v.ProviderVersion != "" { + v.Args = append(v.Args, "--provider_app_version") + v.Args = append(v.Args, v.ProviderVersion) + } + + if v.PublishVerificationResults { + v.Args = append(v.Args, "--publish_verification_results") + v.Args = append(v.Args, "true") + } + if v.Verbose { v.Args = append(v.Args, "--verbose") v.Args = append(v.Args, fmt.Sprintf("%v", v.Verbose))