Skip to content

POC For docker compose #46570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ci/docker/pandas-db-test.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python

RUN apt-get update

RUN python -m pip install --upgrade pip
RUN python -m pip install \
cython \
hypothesis \
numpy \
pymysql \
psycopg2 \
pytest \
pytest-asyncio \
python-dateutil \
pytz \
sqlalchemy

WORKDIR /pandas

6 changes: 6 additions & 0 deletions ci/scripts/run-db-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

python setup.py build_ext --inplace -j4
python -m pytest pandas/tests/io/test_sql.py
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
testing:
build:
context: .
dockerfile: ci/docker/pandas-db-test.dockerfile
volumes:
- .:/pandas
command: /pandas/ci/scripts/run-db-tests.sh

postgres-db:
image: postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: pandas

mysql-db:
image: mysql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: pandas
10 changes: 5 additions & 5 deletions pandas/tests/io/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def mysql_pymysql_engine(iris_path, types_data):
sqlalchemy = pytest.importorskip("sqlalchemy")
pymysql = pytest.importorskip("pymysql")
engine = sqlalchemy.create_engine(
"mysql+pymysql://root@localhost:3306/pandas",
"mysql+pymysql://root@mysql-db:3306/pandas",
connect_args={"client_flag": pymysql.constants.CLIENT.MULTI_STATEMENTS},
)
insp = sqlalchemy.inspect(engine)
Expand Down Expand Up @@ -409,7 +409,7 @@ def postgresql_psycopg2_engine(iris_path, types_data):
sqlalchemy = pytest.importorskip("sqlalchemy")
pytest.importorskip("psycopg2")
engine = sqlalchemy.create_engine(
"postgresql+psycopg2://postgres:postgres@localhost:5432/pandas"
"postgresql+psycopg2://postgres:postgres@postgres-db:5432/pandas"
)
insp = sqlalchemy.inspect(engine)
if not insp.has_table("iris"):
Expand Down Expand Up @@ -1528,7 +1528,7 @@ def test_sql_open_close(self, test_frame3):

@pytest.mark.skipif(SQLALCHEMY_INSTALLED, reason="SQLAlchemy is installed")
def test_con_string_import_error(self):
conn = "mysql://root@localhost/pandas"
conn = "mysql://root@mysql-db/pandas"
msg = "Using URI string without sqlalchemy installed"
with pytest.raises(ImportError, match=msg):
sql.read_sql("SELECT * FROM iris", conn)
Expand Down Expand Up @@ -2382,7 +2382,7 @@ class _TestMySQLAlchemy:
@classmethod
def connect(cls):
return sqlalchemy.create_engine(
f"mysql+{cls.driver}://root@localhost:{cls.port}/pandas",
f"mysql+{cls.driver}://root@mysql-db:{cls.port}/pandas",
connect_args=cls.connect_args,
)

Expand All @@ -2408,7 +2408,7 @@ class _TestPostgreSQLAlchemy:
@classmethod
def connect(cls):
return sqlalchemy.create_engine(
f"postgresql+{cls.driver}://postgres:postgres@localhost:{cls.port}/pandas"
f"postgresql+{cls.driver}://postgres:postgres@postgres-db:{cls.port}/pandas"
)

@classmethod
Expand Down