Skip to content

Commit

Permalink
Fix docker networking
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPansino committed Jun 23, 2023
1 parent cbf41f3 commit abe65c6
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 81 deletions.
173 changes: 102 additions & 71 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

steps:
Expand Down Expand Up @@ -162,6 +164,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

steps:
Expand Down Expand Up @@ -205,6 +209,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

services:
Expand Down Expand Up @@ -263,6 +269,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

services:
Expand Down Expand Up @@ -324,6 +332,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

services:
Expand Down Expand Up @@ -380,6 +390,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

services:
Expand Down Expand Up @@ -438,6 +450,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

services:
Expand Down Expand Up @@ -494,6 +508,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

services:
Expand Down Expand Up @@ -540,77 +556,84 @@ jobs:
retention-days: 1

# kafka:
# env:
# TOTAL_GROUPS: 4

# strategy:
# fail-fast: false
# matrix:
# group-number: [1, 2, 3, 4]

# runs-on: ubuntu-20.04
# timeout-minutes: 30

# services:
# zookeeper:
# image: bitnami/zookeeper:3.7
# env:
# ALLOW_ANONYMOUS_LOGIN: yes

# ports:
# - 2181:2181

# kafka:
# image: bitnami/kafka:3.2
# ports:
# - 8080:8080
# - 8081:8081
# env:
# ALLOW_PLAINTEXT_LISTENER: yes
# KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
# KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true
# KAFKA_CFG_LISTENERS: L1://:8080,L2://:8081
# KAFKA_CFG_ADVERTISED_LISTENERS: L1://127.0.0.1:8080,L2://kafka:8081,
# KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: L1:PLAINTEXT,L2:PLAINTEXT
# KAFKA_CFG_INTER_BROKER_LISTENER_NAME: L2

# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0

# # Special case packages
# - name: Install librdkafka-dev
# run: |
# # Use lsb-release to find the codename of Ubuntu to use to install the correct library name
# sudo apt-get update
# sudo ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
# sudo apt-get install -y wget gnupg2 software-properties-common
# sudo wget -qO - https://packages.confluent.io/deb/7.2/archive.key | sudo apt-key add -
# sudo add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"
# sudo apt-get update
# sudo apt-get install -y librdkafka-dev/$(lsb_release -c | cut -f 2)

# - name: Get Environments
# id: get-envs
# run: |
# echo "envs=$(tox -l | grep '^${{ github.job }}\-' | ./.github/workflows/get-envs.py)" >> $GITHUB_OUTPUT
# env:
# GROUP_NUMBER: ${{ matrix.group-number }}

# - name: Test
# run: |
# tox -vv -e ${{ steps.get-envs.outputs.envs }}
# env:
# TOX_PARALLEL_NO_SPINNER: 1
# PY_COLORS: 0

# - name: Upload Coverage Artifacts
# uses: actions/upload-artifact@v3
# with:
# name: coverage-${{ github.job }}-${{ strategy.job-index }}
# path: ./**/.coverage.*
# retention-days: 1
# env:
# TOTAL_GROUPS: 4

# strategy:
# fail-fast: false
# matrix:
# group-number: [1, 2, 3, 4]

# runs-on: ubuntu-20.04
# container:
# image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
# options: >-
# --add-host=host.docker.internal:host-gateway
# timeout-minutes: 30

# services:
# zookeeper:
# image: bitnami/zookeeper:3.7
# env:
# ALLOW_ANONYMOUS_LOGIN: yes

# ports:
# - 2181:2181

# kafka:
# image: bitnami/kafka:3.2
# ports:
# - 8080:8080
# - 8081:8081
# env:
# ALLOW_PLAINTEXT_LISTENER: yes
# KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
# KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE: true
# KAFKA_CFG_LISTENERS: L1://:8080,L2://:8081
# KAFKA_CFG_ADVERTISED_LISTENERS: L1://127.0.0.1:8080,L2://kafka:8081,
# KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: L1:PLAINTEXT,L2:PLAINTEXT
# KAFKA_CFG_INTER_BROKER_LISTENER_NAME: L2

# steps:
# - uses: actions/checkout@v3

# - name: Fetch git tags
# run: |
# git config --global --add safe.directory "$GITHUB_WORKSPACE"
# git fetch --tags origin

# # Special case packages
# - name: Install librdkafka-dev
# run: |
# # Use lsb-release to find the codename of Ubuntu to use to install the correct library name
# sudo apt-get update
# sudo ln -fs /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
# sudo apt-get install -y wget gnupg2 software-properties-common
# sudo wget -qO - https://packages.confluent.io/deb/7.2/archive.key | sudo apt-key add -
# sudo add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"
# sudo apt-get update
# sudo apt-get install -y librdkafka-dev/$(lsb_release -c | cut -f 2)

# - name: Get Environments
# id: get-envs
# run: |
# echo "envs=$(tox -l | grep '^${{ github.job }}\-' | ./.github/workflows/get-envs.py)" >> $GITHUB_OUTPUT
# env:
# GROUP_NUMBER: ${{ matrix.group-number }}

# - name: Test
# run: |
# tox -vv -e ${{ steps.get-envs.outputs.envs }}
# env:
# TOX_PARALLEL_NO_SPINNER: 1
# PY_COLORS: 0

# - name: Upload Coverage Artifacts
# uses: actions/upload-artifact@v3
# with:
# name: coverage-${{ github.job }}-${{ strategy.job-index }}
# path: ./**/.coverage.*
# retention-days: 1

mongodb:
env:
Expand All @@ -624,6 +647,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

services:
Expand Down Expand Up @@ -680,6 +705,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

services:
Expand Down Expand Up @@ -738,6 +765,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

services:
Expand Down Expand Up @@ -797,6 +826,8 @@ jobs:
runs-on: ubuntu-20.04
container:
image: ghcr.io/${{ github.repository }}-ci:sha-89f5dd62bd2d9167e51962c305b9b57a1a7cdb75
options: >-
--add-host=host.docker.internal:host-gateway
timeout-minutes: 30

services:
Expand Down
20 changes: 10 additions & 10 deletions tests/testing_support/db_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def postgresql_settings():
2. Github Actions
"""

host = "postgres" if "GITHUB_ACTIONS" in os.environ else "localhost"
host = "host.docker.internal" if "GITHUB_ACTIONS" in os.environ else "localhost"
instances = 2
settings = [
{
Expand All @@ -56,8 +56,8 @@ def mysql_settings():
2. Github Actions
"""

host = "mysql" if "GITHUB_ACTIONS" in os.environ else "127.0.0.1"
instances = 2
host = "host.docker.internal" if "GITHUB_ACTIONS" in os.environ else "127.0.0.1"
instances = 1
settings = [
{
"user": "python_agent",
Expand All @@ -83,7 +83,7 @@ def redis_settings():
2. Github Actions
"""

host = "redis" if "GITHUB_ACTIONS" in os.environ else "localhost"
host = "host.docker.internal" if "GITHUB_ACTIONS" in os.environ else "localhost"
instances = 2
settings = [
{
Expand All @@ -106,7 +106,7 @@ def memcached_settings():
2. Github Actions
"""

host = "rabbitmq" if "GITHUB_ACTIONS" in os.environ else "127.0.0.1"
host = "host.docker.internal" if "GITHUB_ACTIONS" in os.environ else "127.0.0.1"
instances = 2
settings = [
{
Expand All @@ -130,7 +130,7 @@ def mongodb_settings():
2. Github Actions
"""

host = "rabbitmq" if "GITHUB_ACTIONS" in os.environ else "127.0.0.1"
host = "host.docker.internal" if "GITHUB_ACTIONS" in os.environ else "127.0.0.1"
instances = 2
settings = [
{"host": host, "port": 8080 + instance_num, "collection": "mongodb_collection_" + str(os.getpid())}
Expand All @@ -150,7 +150,7 @@ def elasticsearch_settings():
2. Github Actions
"""

host = "elasticsearch" if "GITHUB_ACTIONS" in os.environ else "localhost"
host = "host.docker.internal" if "GITHUB_ACTIONS" in os.environ else "localhost"
instances = 2
settings = [
{
Expand All @@ -174,7 +174,7 @@ def solr_settings():
2. Github Actions
"""

host = "solr" if "GITHUB_ACTIONS" in os.environ else "127.0.0.1"
host = "host.docker.internal" if "GITHUB_ACTIONS" in os.environ else "127.0.0.1"
instances = 2
settings = [
{
Expand All @@ -198,7 +198,7 @@ def rabbitmq_settings():
2. Github Actions
"""

host = "rabbitmq" if "GITHUB_ACTIONS" in os.environ else "localhost"
host = "host.docker.internal" if "GITHUB_ACTIONS" in os.environ else "localhost"
instances = 1
settings = [
{
Expand All @@ -221,7 +221,7 @@ def kafka_settings():
2. Github Actions
"""

host = "kafka" if "GITHUB_ACTIONS" in os.environ else "localhost"
host = "host.docker.internal" if "GITHUB_ACTIONS" in os.environ else "localhost"
instances = 2
settings = [
{
Expand Down

0 comments on commit abe65c6

Please sign in to comment.