Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
thpierce authored Jun 14, 2024
2 parents b99fcaa + bbd0e8d commit e863eee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ target
examples/**/build/

# Performance test results
**/performance-tests/results/
**/performance-tests/results/

11 changes: 9 additions & 2 deletions contract-tests/images/applications/psycopg2/psycopg2_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
from typing_extensions import override

_PORT: int = 8080
_SUCCESS: str = "success"
_DROP_TABLE: str = "drop_table"
_ERROR: str = "error"
_FAULT: str = "fault"
_CREATE_DATABASE: str = "create_database"

_DB_HOST = os.getenv("DB_HOST")
_DB_USER = os.getenv("DB_USER")
Expand All @@ -26,11 +27,17 @@ class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
status_code: int = 200
conn = psycopg2.connect(dbname=_DB_NAME, user=_DB_USER, password=_DB_PASS, host=_DB_HOST)
if self.in_path(_SUCCESS):
conn.autocommit = True # CREATE DATABASE cannot run in a transaction block
if self.in_path(_DROP_TABLE):
cur = conn.cursor()
cur.execute("DROP TABLE IF EXISTS test_table")
cur.close()
status_code = 200
elif self.in_path(_CREATE_DATABASE):
cur = conn.cursor()
cur.execute("CREATE DATABASE test_database")
cur.close()
status_code = 200
elif self.in_path(_FAULT):
cur = conn.cursor()
try:
Expand Down
8 changes: 6 additions & 2 deletions contract-tests/tests/test/amazon/psycopg2/psycopg2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ def get_application_extra_environment_variables(self) -> Dict[str, str]:
def get_application_image_name(self) -> str:
return "aws-application-signals-tests-psycopg2-app"

def test_success(self) -> None:
def test_drop_table_succeeds(self) -> None:
self.mock_collector_client.clear_signals()
self.do_test_requests("success", "GET", 200, 0, 0, sql_command="DROP TABLE")
self.do_test_requests("drop_table", "GET", 200, 0, 0, sql_command="DROP TABLE")

def test_create_database_succeeds(self) -> None:
self.mock_collector_client.clear_signals()
self.do_test_requests("create_database", "GET", 200, 0, 0, sql_command="CREATE DATABASE")

def test_fault(self) -> None:
self.mock_collector_client.clear_signals()
Expand Down

0 comments on commit e863eee

Please sign in to comment.