Skip to content

Commit

Permalink
feat(verification): publish verification results to broker
Browse files Browse the repository at this point in the history
- Upgrade to latest verifier (v1.0.1)
- Add new flags to verifier to allow results to be published
  to a Pact Broker
  • Loading branch information
mefellows committed May 9, 2017
1 parent f7c3add commit ee36bff
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 26 deletions.
2 changes: 2 additions & 0 deletions daemon/verification_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
53 changes: 30 additions & 23 deletions dsl/pact_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions dsl/pact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
16 changes: 16 additions & 0 deletions types/verify_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit ee36bff

Please sign in to comment.