Skip to content

Commit

Permalink
chore: update issue reproduction code [ci-skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jan 21, 2021
1 parent 1920031 commit 68bd9ea
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 18 deletions.
6 changes: 3 additions & 3 deletions ISSUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ You can use it to easily reproduce issues.

To use it:

* Run the Pact Broker using the latest development code:
* Run the Pact Broker using a specific Pact Broker Docker image by setting the required tag for the pact-broker service in the docker-compose-issue-repro-with-pact-broker-docker-image.yml file.

```
docker-compose -f docker-compose-issue-repro.yml up --build pact-broker
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml up --build pact-broker
```

* Run the reproduction script.

```
docker-compose -f docker-compose-issue-repro.yml up repro-issue
docker-compose -f docker-compose-issue-repro-with-pact-broker-docker-image.yml up repro-issue
```

You can modify `script/reproduce-issue.rb` and then re-run it with the change applied.
33 changes: 33 additions & 0 deletions docker-compose-issue-repro-with-pact-broker-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "3"

services:
postgres:
image: postgres
healthcheck:
test: psql postgres --command "select 1" -U postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres

pact-broker:
image: pactfoundation/pact-broker:2.73.0.0
ports:
- "9292:9292"
depends_on:
- postgres
environment:
PACT_BROKER_PORT: '9292'
PACT_BROKER_DATABASE_URL: "postgres://postgres:password@postgres/postgres"
PACT_BROKER_LOG_LEVEL: INFO
PACT_BROKER_SQL_LOG_LEVEL: DEBUG

repro-issue:
build: .
depends_on:
- pact-broker
command: dockerize -wait http://pact-broker:9292 -timeout 30s /home/script/reproduce-issue.rb
environment:
- PACT_BROKER_BASE_URL=http://pact-broker:9292
volumes:
- $PWD:/home
2 changes: 1 addition & 1 deletion lib/pact_broker/test/http_test_data_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class HttpTestDataBuilder

attr_reader :client, :last_consumer_name, :last_provider_name, :last_consumer_version_number, :last_provider_version_number

def initialize(pact_broker_base_url, auth)
def initialize(pact_broker_base_url, auth = {})
@client = Faraday.new(url: pact_broker_base_url) do |faraday|
faraday.request :json
faraday.response :json, :content_type => /\bjson$/
Expand Down
31 changes: 17 additions & 14 deletions script/reproduce-issue.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
#!/usr/bin/env ruby

$LOAD_PATH << "#{Dir.pwd}/lib"

begin

$LOAD_PATH << "#{Dir.pwd}/lib"
require 'pact_broker/test/http_test_data_builder'
base_url = ENV['PACT_BROKER_BASE_URL'] || 'http://localhost:9292'

td = PactBroker::Test::HttpTestDataBuilder.new(base_url, { })
td.delete_integration(consumer: "MyConsumer", provider: "MyProvider")
.create_pacticipant("MyConsumer")
.create_pacticipant("MyProvider")
.publish_pact(consumer: "MyConsumer", consumer_version: "1", provider: "MyProvider", content_id: "111", tag: "main")
.publish_pact(consumer: "MyConsumer", consumer_version: "2", provider: "MyProvider", content_id: "222", tag: "main")
.publish_pact(consumer: "MyConsumer", consumer_version: "3", provider: "MyProvider", content_id: "111", tag: "feat/a")
td = PactBroker::Test::HttpTestDataBuilder.new(base_url)
td.delete_integration(consumer: "foo-consumer", provider: "bar-provider")
.publish_pact(consumer: "foo-consumer", consumer_version: "1", provider: "bar-provider", content_id: "111", tag: "main")
.get_pacts_for_verification(
enable_pending: true,
provider_version_tag: "main",
consumer_version_selectors: [{ tag: "main" }, { tag: "feat/a", latest: true }])
.verify_pact(success: true, provider_version_tag: "main", provider_version: "2" )

include_wip_pacts_since: "2020-01-01",
consumer_version_selectors: [{ tag: "main", latest: true }])
.verify_pact(
index: 0,
provider_version_tag: "main",
provider_version: "1",
success: true
)
.can_i_deploy(pacticipant: "bar-provider", version: "1", to: "prod")
.deploy_to_prod(pacticipant: "bar-provider", version: "1")
.can_i_deploy(pacticipant: "foo-consumer", version: "1", to: "prod")
.deploy_to_prod(pacticipant: "foo-consumer", version: "1")

rescue StandardError => e
puts "#{e.class} #{e.message}"
puts e.backtrace
exit 1
end

0 comments on commit 68bd9ea

Please sign in to comment.