mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-26 09:26:22 +00:00
checking in testing fixtures. docker still not working
This commit is contained in:
parent
1ddbdee60c
commit
9e61220132
@ -26,4 +26,5 @@ typed-ast==1.4.1
|
||||
typing-extensions==3.7.4.2
|
||||
wcwidth==0.1.9
|
||||
zipp==3.1.0
|
||||
pytest-docker
|
||||
|
||||
|
||||
0
metadata-ingestion/tests/__init__.py
Normal file
0
metadata-ingestion/tests/__init__.py
Normal file
0
metadata-ingestion/tests/integration/__init__.py
Normal file
0
metadata-ingestion/tests/integration/__init__.py
Normal file
5
metadata-ingestion/tests/integration/conftest.py
Normal file
5
metadata-ingestion/tests/integration/conftest.py
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
pytest_plugins = [
|
||||
"tests.integration.fixtures.sql_server"
|
||||
]
|
||||
|
||||
12
metadata-ingestion/tests/integration/docker-compose.yml
Normal file
12
metadata-ingestion/tests/integration/docker-compose.yml
Normal file
@ -0,0 +1,12 @@
|
||||
version: '2'
|
||||
services:
|
||||
testsqlserver:
|
||||
image: "mcr.microsoft.com/mssql/server:latest"
|
||||
container_name: "testsqlserver"
|
||||
environment:
|
||||
ACCEPT_EULA: "Y"
|
||||
SA_PASSWORD: "test!Password"
|
||||
ports:
|
||||
- 1433:1433
|
||||
volumes:
|
||||
- ./sql_server/setup:/setup
|
||||
21
metadata-ingestion/tests/integration/fixtures/sql_server.py
Normal file
21
metadata-ingestion/tests/integration/fixtures/sql_server.py
Normal file
@ -0,0 +1,21 @@
|
||||
import os
|
||||
import pytest
|
||||
|
||||
def is_responsive(container: str):
|
||||
ready_string="SQL Server is now ready for client connections."
|
||||
ret = os.system(f"docker logs {container} | grep -q \"{ready_string}\"")
|
||||
return ret == 0
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def docker_compose_file(pytestconfig):
|
||||
return os.path.join(str(pytestconfig.rootdir), "tests/integration/", "docker-compose.yml")
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def sql_server(docker_ip, docker_services):
|
||||
port = docker_services.port_for("testsqlserver", 1433)
|
||||
docker_services.wait_until_responsive(
|
||||
timeout=30.0, pause=0.1, check=lambda: is_responsive("testsqlserver"))
|
||||
return port
|
||||
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
import os
|
||||
import pytest
|
||||
import subprocess
|
||||
|
||||
|
||||
import time
|
||||
def test_ingest(sql_server):
|
||||
assert sql_server == 1433
|
||||
docker="docker"
|
||||
command = f"{docker} exec testsqlserver /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'test!Password' -d master -i /setup/setup.sql"
|
||||
ret = subprocess.run(command, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
assert ret.returncode == 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user