Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix broken mssql integration tests
We were giving mssql server 10 seconds to start before creating the test
database. It now takes Github CI more than 10 seconds to start the mssql
server. Instead of increasing the leeway with guesses, this commit moves
the creation of test database from docker compose to the python test suite.
This allows the docker image to come up first and then create the DB
inside the test suite with proper retry mechanism that is already in
place.
  • Loading branch information
owais committed Oct 12, 2021
commit b4a11ca70cf3df0eae544b2cf4f329d800fe3979
24 changes: 19 additions & 5 deletions tests/opentelemetry-docker-tests/tests/check_availability.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,27 @@ def check_redis_connection():
connection.hgetall("*")


@retryable
def check_mssql_connection():
def new_mssql_connection() -> pyodbc.Connection:
connection = pyodbc.connect(
f"DRIVER={{ODBC Driver 17 for SQL Server}};SERVER={MSSQL_HOST},"
f"{MSSQL_PORT};DATABASE={MSSQL_DB_NAME};UID={MSSQL_USER};"
f"PWD={MSSQL_PASSWORD}"
f"{MSSQL_PORT};DATABASE=master;UID={MSSQL_USER};"
f"PWD={MSSQL_PASSWORD}",
autocommit=True,
)
connection.close()
return connection


@retryable
def check_mssql_connection():
conn = new_mssql_connection()
conn.close()


def setup_mssql_db():
conn = new_mssql_connection()
cur = conn.cursor()
cur.execute(f"CREATE DATABASE [{MSSQL_DB_NAME}]")
conn.close()


def check_docker_services_availability():
Expand All @@ -127,6 +140,7 @@ def check_docker_services_availability():
check_postgres_connection()
check_redis_connection()
check_mssql_connection()
setup_mssql_db()


check_docker_services_availability()
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ services:
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "yourStrong(!)Password"
command: /bin/sh -c "sleep 10s && /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P yourStrong\(!\)Password -d master -Q 'CREATE DATABASE [opentelemetry-tests]' & /opt/mssql/bin/sqlservr"
command: /opt/mssql/bin/sqlservr