Skip to content
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

chore(ci): pin mariadb container to 10.7 image tag (backport #3913) #4395

Merged
merged 2 commits into from
Oct 27, 2022
Merged
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
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
ports:
- "127.0.0.1:5432:5432"
mariadb:
image: mariadb
image: mariadb:10.7
environment:
- MYSQL_ROOT_PASSWORD=example
- MYSQL_DATABASE=test
Expand Down
38 changes: 26 additions & 12 deletions tests/contrib/mariadb/test_mariadb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import Tuple

import mariadb
import pytest
Expand All @@ -15,6 +16,17 @@
from tests.utils import snapshot


MARIADB_VERSION = mariadb.__version_info__ # type: Tuple[int, int, int, str, int]
SNAPSHOT_VARIANTS = {
"pre_1_1": MARIADB_VERSION < (1, 1, 0),
"post_1_1": MARIADB_VERSION
>= (
1,
1,
),
}


@pytest.fixture
def tracer():
tracer = DummyTracer()
Expand Down Expand Up @@ -73,6 +85,7 @@ def test_query_executemany(connection, tracer):
dummy_key VARCHAR(32) PRIMARY KEY,
dummy_value TEXT NOT NULL)"""
)
cursor.execute("DELETE FROM dummy")
tracer.enabled = True

stmt = "INSERT INTO dummy (dummy_key, dummy_value) VALUES (%s, %s)"
Expand Down Expand Up @@ -133,7 +146,7 @@ def test_analytics_default(connection, tracer):
"""


@snapshot(async_mode=False)
@snapshot(async_mode=False, variants=SNAPSHOT_VARIANTS)
def test_user_specified_dd_service_snapshot(run_python_code_in_subprocess):
"""
When a user specifies a service for the app
Expand All @@ -148,7 +161,7 @@ def test_user_specified_dd_service_snapshot(run_python_code_in_subprocess):
assert status == 0, err


@snapshot(async_mode=False)
@snapshot(async_mode=False, variants=SNAPSHOT_VARIANTS)
def test_user_specified_dd_mariadb_service_snapshot(run_python_code_in_subprocess):
"""
When a user specifies a service for the app
Expand All @@ -164,7 +177,7 @@ def test_user_specified_dd_mariadb_service_snapshot(run_python_code_in_subproces
assert status == 0, err


@snapshot(include_tracer=True)
@snapshot(include_tracer=True, variants=SNAPSHOT_VARIANTS)
def test_simple_query_snapshot(tracer):
with get_connection(tracer) as connection:
cursor = connection.cursor()
Expand All @@ -173,15 +186,15 @@ def test_simple_query_snapshot(tracer):
assert len(rows) == 1


@snapshot(include_tracer=True, ignores=["meta.error.stack"])
@snapshot(include_tracer=True, variants=SNAPSHOT_VARIANTS, ignores=["meta.error.stack"])
def test_simple_malformed_query_snapshot(tracer):
with get_connection(tracer) as connection:
cursor = connection.cursor()
with pytest.raises(mariadb.ProgrammingError):
cursor.execute("SELEC 1")


@snapshot(include_tracer=True)
@snapshot(include_tracer=True, variants=SNAPSHOT_VARIANTS)
def test_simple_query_fetchall_snapshot(tracer):
with override_config("mariadb", dict(trace_fetch_methods=True)):
with get_connection(tracer) as connection:
Expand All @@ -191,7 +204,7 @@ def test_simple_query_fetchall_snapshot(tracer):
assert len(rows) == 1


@snapshot(include_tracer=True)
@snapshot(include_tracer=True, variants=SNAPSHOT_VARIANTS)
def test_query_with_several_rows_snapshot(tracer):
with get_connection(tracer) as connection:
cursor = connection.cursor()
Expand All @@ -201,7 +214,7 @@ def test_query_with_several_rows_snapshot(tracer):
assert len(rows) == 3


@snapshot(include_tracer=True)
@snapshot(include_tracer=True, variants=SNAPSHOT_VARIANTS)
def test_query_with_several_rows_fetchall_snapshot(tracer):
with override_config("mariadb", dict(trace_fetch_methods=True)):
with get_connection(tracer) as connection:
Expand All @@ -212,7 +225,7 @@ def test_query_with_several_rows_fetchall_snapshot(tracer):
assert len(rows) == 3


@snapshot(include_tracer=True)
@snapshot(include_tracer=True, variants=SNAPSHOT_VARIANTS)
def test_query_many_fetchall_snapshot(tracer):
with override_config("mariadb", dict(trace_fetch_methods=True)):
with get_connection(tracer) as connection:
Expand All @@ -227,6 +240,7 @@ def test_query_many_fetchall_snapshot(tracer):
dummy_key VARCHAR(32) PRIMARY KEY,
dummy_value TEXT NOT NULL)"""
)
cursor.execute("DELETE FROM dummy")
tracer.enabled = True

stmt = "INSERT INTO dummy (dummy_key, dummy_value) VALUES (%s, %s)"
Expand All @@ -241,13 +255,13 @@ def test_query_many_fetchall_snapshot(tracer):
assert len(rows) == 2


@snapshot(include_tracer=True)
@snapshot(include_tracer=True, variants=SNAPSHOT_VARIANTS)
def test_commit_snapshot(tracer):
with get_connection(tracer) as connection:
connection.commit()


@snapshot(include_tracer=True)
@snapshot(include_tracer=True, variants=SNAPSHOT_VARIANTS)
def test_query_proc_snapshot(tracer):
with get_connection(tracer) as connection:
# create a procedure
Expand All @@ -268,7 +282,7 @@ def test_query_proc_snapshot(tracer):
cursor.callproc(proc, data)


@snapshot(include_tracer=True)
@snapshot(include_tracer=True, variants=SNAPSHOT_VARIANTS)
def test_analytics_with_rate_snapshot(tracer):
with override_config("mariadb", dict(analytics_enabled=True, analytics_sample_rate=0.5)):
with get_connection(tracer) as connection:
Expand All @@ -278,7 +292,7 @@ def test_analytics_with_rate_snapshot(tracer):
assert len(rows) == 1


@snapshot(include_tracer=True)
@snapshot(include_tracer=True, variants=SNAPSHOT_VARIANTS)
def test_analytics_without_rate_snapshot(tracer):
with override_config("mariadb", dict(analytics_enabled=True)):
with get_connection(tracer) as connection:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[[
{
"name": "mariadb.query",
"service": "mariadb",
"resource": "SELECT 1",
"trace_id": 0,
"span_id": 1,
"parent_id": 0,
"type": "sql",
"meta": {
"db.name": "test",
"db.user": "test",
"out.host": "127.0.0.1",
"runtime-id": "778c778962a54eeea3ae401d2417ef86"
},
"metrics": {
"_dd.agent_psr": 1.0,
"_dd.measured": 1,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_dd1.sr.eausr": 0.5,
"_sampling_priority_v1": 1,
"db.rowcount": 1,
"out.port": 3306,
"sql.rows": 1,
"system.pid": 9677
},
"duration": 1412500,
"start": 1656521264659140100
}]]
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"db.name": "test",
"db.user": "test",
"out.host": "127.0.0.1",
"runtime-id": "afb83c6e2adf41f9a723786fdb1b223b"
"runtime-id": "93f76aae38d74161926ccd64013f5d01"
},
"metrics": {
"_dd.agent_psr": 1.0,
Expand All @@ -23,8 +23,8 @@
"db.rowcount": 0,
"out.port": 3306,
"sql.rows": 0,
"system.pid": 5857
"system.pid": 9600
},
"duration": 1238000,
"start": 1633039295271632000
"duration": 650000,
"start": 1656521180778211000
}]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[[
{
"name": "mariadb.query",
"service": "mariadb",
"resource": "SELECT 1",
"trace_id": 0,
"span_id": 1,
"parent_id": 0,
"type": "sql",
"meta": {
"db.name": "test",
"db.user": "test",
"out.host": "127.0.0.1",
"runtime-id": "778c778962a54eeea3ae401d2417ef86"
},
"metrics": {
"_dd.agent_psr": 1.0,
"_dd.measured": 1,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_dd1.sr.eausr": 1.0,
"_sampling_priority_v1": 1,
"db.rowcount": 1,
"out.port": 3306,
"sql.rows": 1,
"system.pid": 9677
},
"duration": 580200,
"start": 1656521264692636300
}]]
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"db.name": "test",
"db.user": "test",
"out.host": "127.0.0.1",
"runtime-id": "afb83c6e2adf41f9a723786fdb1b223b"
"runtime-id": "93f76aae38d74161926ccd64013f5d01"
},
"metrics": {
"_dd.agent_psr": 1.0,
Expand All @@ -23,8 +23,8 @@
"db.rowcount": 0,
"out.port": 3306,
"sql.rows": 0,
"system.pid": 5857
"system.pid": 9600
},
"duration": 976000,
"start": 1633039295305654000
"duration": 616000,
"start": 1656521180800547000
}]]
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
"db.name": "test",
"db.user": "test",
"out.host": "127.0.0.1",
"runtime-id": "afb83c6e2adf41f9a723786fdb1b223b"
"runtime-id": "778c778962a54eeea3ae401d2417ef86"
},
"metrics": {
"_dd.agent_psr": 1.0,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_sampling_priority_v1": 1,
"out.port": 3306,
"system.pid": 5857
"system.pid": 9677
},
"duration": 784000,
"start": 1633039295184325000
"duration": 420500,
"start": 1656521264458364000
}]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[[
{
"name": "mariadb.connection.commit",
"service": "mariadb",
"resource": "mariadb.connection.commit",
"trace_id": 0,
"span_id": 1,
"parent_id": 0,
"meta": {
"db.name": "test",
"db.user": "test",
"out.host": "127.0.0.1",
"runtime-id": "93f76aae38d74161926ccd64013f5d01"
},
"metrics": {
"_dd.agent_psr": 1.0,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_sampling_priority_v1": 1,
"out.port": 3306,
"system.pid": 9600
},
"duration": 395000,
"start": 1656521180729828000
}]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[[
{
"name": "mariadb.query",
"service": "mariadb",
"resource": "INSERT INTO dummy (dummy_key, dummy_value) VALUES (%s, %s)",
"trace_id": 0,
"span_id": 1,
"parent_id": 0,
"type": "sql",
"meta": {
"db.name": "test",
"db.user": "test",
"out.host": "127.0.0.1",
"runtime-id": "778c778962a54eeea3ae401d2417ef86",
"sql.executemany": "true"
},
"metrics": {
"_dd.agent_psr": 1.0,
"_dd.measured": 1,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_sampling_priority_v1": 1,
"db.rowcount": 2,
"out.port": 3306,
"sql.rows": 2,
"system.pid": 9677
},
"duration": 1468400,
"start": 1656521264429166700
}],
[
{
"name": "mariadb.query",
"service": "mariadb",
"resource": "SELECT dummy_key, dummy_value FROM dummy ORDER BY dummy_key",
"trace_id": 1,
"span_id": 1,
"parent_id": 0,
"type": "sql",
"meta": {
"db.name": "test",
"db.user": "test",
"out.host": "127.0.0.1",
"runtime-id": "778c778962a54eeea3ae401d2417ef86"
},
"metrics": {
"_dd.agent_psr": 1.0,
"_dd.measured": 1,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_sampling_priority_v1": 1,
"db.rowcount": 2,
"out.port": 3306,
"sql.rows": 2,
"system.pid": 9677
},
"duration": 698300,
"start": 1656521264432090500
}],
[
{
"name": "mariadb.query.fetchall",
"service": "mariadb",
"resource": "SELECT dummy_key, dummy_value FROM dummy ORDER BY dummy_key",
"trace_id": 2,
"span_id": 1,
"parent_id": 0,
"type": "sql",
"meta": {
"db.name": "test",
"db.user": "test",
"out.host": "127.0.0.1",
"runtime-id": "778c778962a54eeea3ae401d2417ef86"
},
"metrics": {
"_dd.agent_psr": 1.0,
"_dd.top_level": 1,
"_dd.tracer_kr": 1.0,
"_sampling_priority_v1": 1,
"db.rowcount": 2,
"out.port": 3306,
"sql.rows": 2,
"system.pid": 9677
},
"duration": 94000,
"start": 1656521264433020400
}]]
Loading