Skip to content

Commit

Permalink
chore: update examples to work with podman on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Sep 7, 2023
1 parent ed5f86c commit ff8e81c
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ pact-broker publish /path/to/pacts/consumer-provider.json --consumer-app-version
### Python API

```python
broker = Broker(broker_base_url="http://localhost")
broker = Broker(broker_base_url="http://localhost:9292")
broker.publish("TestConsumer",
"2.0.1",
branch='consumer-branch',
Expand Down
13 changes: 8 additions & 5 deletions examples/broker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ services:
# As well as changing the image, the destination port will need to be changed
# from 9292 below, and in the nginx.conf proxy_pass section
image: pactfoundation/pact-broker:latest-multi
# PODMAN:- Error response from daemon: rootlessport cannot expose privileged port 80, you can add 'net.ipv4.ip_unprivileged_port_start=80' to /etc/sysctl.conf (currently 1024), or choose a larger port number (>= 1024): listen tcp 0.0.0.0:80: bind: permission denied
ports:
- "80:9292"
- "9292:9292"
depends_on:
- postgres
links:
- postgres
# PODMAN:- Error response from daemon: bad parameter: link is not supported
# links:
# - postgres
environment:
PACT_BROKER_DATABASE_USERNAME: postgres
PACT_BROKER_DATABASE_PASSWORD: password
Expand All @@ -47,8 +49,9 @@ services:
# terminate with SSL
nginx:
image: nginx:alpine
links:
- broker_app:broker
# PODMAN:- Error response from daemon: bad parameter: link is not supported
# links:
# - broker_app:broker
volumes:
- ./ssl/nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./ssl:/etc/nginx/ssl
Expand Down
5 changes: 3 additions & 2 deletions examples/common/sharedfixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def publish_existing_pact(broker):

target_platform = platform.platform().lower()

if 'macos' in target_platform or 'windows' in target_platform:
envs["PACT_BROKER_BASE_URL"] = "http://host.docker.internal:80"
# PODMAN:- Can't bind to port <1024
# if 'macos' in target_platform or 'windows' in target_platform:
# envs["PACT_BROKER_BASE_URL"] = "http://host.docker.internal:80"

client = docker.from_env()

Expand Down
3 changes: 2 additions & 1 deletion examples/consumer/run_pytest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -o pipefail

pytest tests --run-broker True --publish-pact 1
# PODMAN:- Log verbosely when failing tests to work out whats going on!
pytest tests --run-broker True --publish-pact 1 -rP
3 changes: 2 additions & 1 deletion examples/consumer/tests/consumer/test_user_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
# If publishing the Pact(s), they will be submitted to the Pact Broker here.
# For the purposes of this example, the broker is started up as a fixture defined
# in conftest.py. For normal usage this would be self-hosted or using PactFlow.
PACT_BROKER_URL = "http://localhost"
# PODMAN:- Can't bind to port <1024
PACT_BROKER_URL = "http://localhost:9292"
PACT_BROKER_USERNAME = "pactbroker"
PACT_BROKER_PASSWORD = "pactbroker"

Expand Down
2 changes: 1 addition & 1 deletion examples/fastapi_provider/tests/provider/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# For the purposes of this example, the broker is started up as a fixture defined
# in conftest.py. For normal usage this would be self-hosted or using PactFlow.
PACT_BROKER_URL = "http://localhost"
PACT_BROKER_URL = "http://localhost:9292"
PACT_BROKER_USERNAME = "pactbroker"
PACT_BROKER_PASSWORD = "pactbroker"

Expand Down
2 changes: 1 addition & 1 deletion examples/flask_provider/tests/provider/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# For the purposes of this example, the broker is started up as a fixture defined
# in conftest.py. For normal usage this would be self-hosted or using PactFlow.
PACT_BROKER_URL = "http://localhost"
PACT_BROKER_URL = "http://localhost:9292"
PACT_BROKER_USERNAME = "pactbroker"
PACT_BROKER_PASSWORD = "pactbroker"

Expand Down
2 changes: 1 addition & 1 deletion examples/message/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ import pytest
from pact import MessageProvider


PACT_BROKER_URL = "http://localhost"
PACT_BROKER_URL = "http://localhost:9292"
PACT_BROKER_USERNAME = "pactbroker"
PACT_BROKER_PASSWORD = "pactbroker"
PACT_DIR = "pacts"
Expand Down
2 changes: 1 addition & 1 deletion examples/message/tests/consumer/test_message_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

PACT_BROKER_URL = "http://localhost"
PACT_BROKER_URL = "http://localhost:9292"
PACT_BROKER_USERNAME = "pactbroker"
PACT_BROKER_PASSWORD = "pactbroker"
PACT_DIR = "pacts"
Expand Down
2 changes: 1 addition & 1 deletion examples/message/tests/provider/test_message_provider.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from pact import MessageProvider

PACT_BROKER_URL = "http://localhost"
PACT_BROKER_URL = "http://localhost:9292"
PACT_BROKER_USERNAME = "pactbroker"
PACT_BROKER_PASSWORD = "pactbroker"
PACT_DIR = "pacts"
Expand Down
16 changes: 8 additions & 8 deletions tests/test_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_publish_without_broker_url(self):

def test_publish_fails(self):
self.mock_Popen.return_value.returncode = 1
broker = Broker(broker_base_url="http://localhost",
broker = Broker(broker_base_url="http://localhost:9292",
broker_username="username",
broker_password="password",
broker_token="token")
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_publish_with_broker_url_environment_variable(self):
del os.environ["PACT_BROKER_BASE_URL"]

def test_basic_authenticated_publish(self):
broker = Broker(broker_base_url="http://localhost",
broker = Broker(broker_base_url="http://localhost:9292",
broker_username="username",
broker_password="password")

Expand All @@ -89,7 +89,7 @@ def test_basic_authenticated_publish(self):
'./TestConsumer-TestProvider.json'])

def test_token_authenticated_publish(self):
broker = Broker(broker_base_url="http://localhost",
broker = Broker(broker_base_url="http://localhost:9292",
broker_username="username",
broker_password="password",
broker_token="token")
Expand All @@ -108,7 +108,7 @@ def test_token_authenticated_publish(self):
'./TestConsumer-TestProvider.json'])

def test_git_tagged_publish(self):
broker = Broker(broker_base_url="http://localhost")
broker = Broker(broker_base_url="http://localhost:9292")

broker.publish("TestConsumer",
"2.0.1",
Expand All @@ -123,7 +123,7 @@ def test_git_tagged_publish(self):
'--tag-with-git-branch'])

def test_manual_tagged_publish(self):
broker = Broker(broker_base_url="http://localhost")
broker = Broker(broker_base_url="http://localhost:9292")

broker.publish("TestConsumer",
"2.0.1",
Expand All @@ -139,7 +139,7 @@ def test_manual_tagged_publish(self):
'-t', 'tag2'])

def test_branch_publish(self):
broker = Broker(broker_base_url="http://localhost")
broker = Broker(broker_base_url="http://localhost:9292")

broker.publish("TestConsumer",
"2.0.1",
Expand All @@ -154,7 +154,7 @@ def test_branch_publish(self):
'--branch=consumer-branch'])

def test_build_url_publish(self):
broker = Broker(broker_base_url="http://localhost")
broker = Broker(broker_base_url="http://localhost:9292")

broker.publish("TestConsumer",
"2.0.1",
Expand All @@ -169,7 +169,7 @@ def test_build_url_publish(self):
'--build-url=http://ci'])

def test_auto_detect_version_properties_publish(self):
broker = Broker(broker_base_url="http://localhost")
broker = Broker(broker_base_url="http://localhost:9292")

broker.publish("TestConsumer",
"2.0.1",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_message_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def setUp(self):
self.options = {
'broker_username': "test",
'broker_password': "test",
'broker_url': "http://localhost",
'broker_url': "http://localhost:9292",
'publish_version': '3',
'publish_verification_results': False
}
Expand Down Expand Up @@ -65,7 +65,7 @@ def test_verify_with_broker(self, mock_verify_pacts):
assert mock_verify_pacts.call_count == 1
mock_verify_pacts.assert_called_with(False, None, broker_username="test",
broker_password="test",
broker_url="http://localhost",
broker_url="http://localhost:9292",
publish_version='3',
publish_verification_results=False)

Expand Down

0 comments on commit ff8e81c

Please sign in to comment.