Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
push:
branches:
- main
- fix/srw

permissions:
id-token: write # This is required for requesting the JWT
Expand Down
2 changes: 1 addition & 1 deletion aws_advanced_python_wrapper/pep249_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DbApiMethod(Enum):
CURSOR_NEXT = (30, "Cursor.__next__", False)
CURSOR_LASTROWID = (31, "Cursor.lastrowid", False)

# AWS Advaced Python Wrapper Methods for
# AWS Advanced Python Wrapper Methods for the execution pipelines.
CONNECT = (32, "connect", True)
FORCE_CONNECT = (33, "force_connect", True)
INIT_HOST_PROVIDER = (34, "init_host_provider", True)
Expand Down
4 changes: 3 additions & 1 deletion aws_advanced_python_wrapper/read_write_splitting_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def __init__(
self._is_writer_conn_from_internal_pool: bool = False
self._in_read_write_split: bool = False

ReadWriteSplittingConnectionManager._SUBSCRIBED_METHODS.update(self._plugin_service.network_bound_methods)

@property
def subscribed_methods(self) -> Set[str]:
return self._SUBSCRIBED_METHODS
Expand Down Expand Up @@ -450,7 +452,7 @@ def host_list_provider_service(self) -> Optional[HostListProviderService]:
...

@host_list_provider_service.setter
def host_list_provider_service(self, new_value: int) -> None:
def host_list_provider_service(self, new_value: HostListProviderService) -> None:
"""The setter for the 'host_list_provider_service' attribute."""
...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ UnknownDialect.AbortConnection=[UnknownDialect] abort_connection was called, but
Wrapper.ConnectMethod=[Wrapper] Target driver should be a target driver's connect() method/function.
Wrapper.RequiredTargetDriver=[Wrapper] Target driver is required.
Wrapper.UnsupportedAttribute=[Wrapper] Target driver does not have the attribute: '{}'
Wrapper.Properties=[Wrapper] "Connection Properties: "
Wrapper.Properties=[Wrapper] "Connection Properties: {}"

WriterFailoverHandler.AlreadyWriter=[WriterFailoverHandler] Current reader connection is actually a new writer connection.
WriterFailoverHandler.CurrentTopologyNone=[WriterFailoverHandler] Current topology cannot be None.
Expand Down
7 changes: 4 additions & 3 deletions aws_advanced_python_wrapper/utils/telemetry/xray_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def set_success(self, success: bool):

def set_attribute(self, key: str, value: AttributeValue):
if self._trace_entity is not None:
self._trace_entity.put_annotation(key, value)
# XRay only supports str, bool, int, float - not sequences
if isinstance(value, (str, bool, int, float)):
self._trace_entity.put_annotation(key, value)

def set_exception(self, exception: Exception):
if self._trace_entity is not None and exception is not None:
Expand Down Expand Up @@ -90,8 +92,7 @@ def _clone_and_close_context(context: XRayTelemetryContext, trace_level: Telemet

clone._trace_entity.start_time = context._trace_entity.start_time

for key in context._trace_entity.annotations.items():
value = context._trace_entity.annotations[key]
for key, value in context._trace_entity.annotations.items():
if key != TelemetryConst.TRACE_NAME_ANNOTATION and value is not None:
clone.set_attribute(key, value)

Expand Down
2 changes: 1 addition & 1 deletion docs/examples/PGXRayTelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
print("-- running application")
logging.basicConfig(level=logging.DEBUG)

xray_recorder.configure(sampler=LocalSampler({"version": 1, "default": {"fixed_target": 1, "rate": 1.0}}))
xray_recorder.configure(sampler=LocalSampler({"version": 1, "default": {"fixed_target": 1, "rate": 1.0}, "rules": []}))
global_sdk_config.set_sdk_enabled(True)

with xray_recorder.in_segment("python_xray_telemetry_app") as segment:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/container/utils/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _create() -> TestEnvironment:
xray_recorder.configure(daemon_address=xray_daemon_endpoint,
context_missing="IGNORE_ERROR",
sampler=LocalSampler(
{"version": 1, "default": {"fixed_target": 1, "rate": 1.0}}))
{"version": 1, "default": {"fixed_target": 1, "rate": 1.0}, "rules": []}))
global_sdk_config.set_sdk_enabled(True)

if TestEnvironmentFeatures.TELEMETRY_METRICS_ENABLED in env.get_features():
Expand Down
44 changes: 21 additions & 23 deletions tests/integration/host/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,30 @@ repositories {
}

dependencies {
testImplementation("org.checkerframework:checker-qual:3.26.0")
testImplementation("org.junit.platform:junit-platform-commons:1.9.0")
testImplementation("org.junit.platform:junit-platform-engine:1.9.0")
testImplementation("org.junit.platform:junit-platform-launcher:1.9.0")
testImplementation("org.junit.platform:junit-platform-suite-engine:1.9.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.1")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.1")
testImplementation("org.checkerframework:checker-qual:3.49.0")
testImplementation("org.junit.platform:junit-platform-commons:1.11.4")
testImplementation("org.junit.platform:junit-platform-engine:1.11.4")
testImplementation("org.junit.platform:junit-platform-launcher:1.11.4")
testImplementation("org.junit.platform:junit-platform-suite-engine:1.11.4")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.4")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.4")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")

testImplementation("org.apache.commons:commons-dbcp2:2.9.0")
testImplementation("org.postgresql:postgresql:42.5.0")
testImplementation("mysql:mysql-connector-java:8.0.31")
testImplementation("org.springframework.boot:spring-boot-starter-jdbc:2.7.4")
testImplementation("org.mockito:mockito-inline:4.8.0")
testImplementation("software.amazon.awssdk:rds:2.20.49")
testImplementation("software.amazon.awssdk:ec2:2.20.61")
testImplementation("software.amazon.awssdk:secretsmanager:2.20.49")
testImplementation("org.apache.commons:commons-dbcp2:2.12.0")
testImplementation("org.postgresql:postgresql:42.7.5")
testImplementation("com.mysql:mysql-connector-j:9.1.0")
testImplementation("software.amazon.awssdk:rds:2.30.10")
testImplementation("software.amazon.awssdk:ec2:2.30.10")
testImplementation("software.amazon.awssdk:secretsmanager:2.30.10")
// Note: all org.testcontainers dependencies should have the same version
testImplementation("org.testcontainers:testcontainers:1.21.2")
testImplementation("org.testcontainers:mysql:1.21.2")
testImplementation("org.testcontainers:postgresql:1.21.2")
testImplementation("org.testcontainers:junit-jupiter:1.21.2")
testImplementation("org.testcontainers:toxiproxy:1.21.2")
testImplementation("org.apache.poi:poi-ooxml:5.2.2")
testImplementation("org.slf4j:slf4j-simple:2.0.3")
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.14.2")
testImplementation("org.testcontainers:testcontainers:2.0.3")
testImplementation("org.testcontainers:testcontainers-mysql:2.0.3")
testImplementation("org.testcontainers:testcontainers-postgresql:2.0.3")
testImplementation("org.testcontainers:testcontainers-toxiproxy:2.0.3")
testImplementation("org.testcontainers:testcontainers-junit-jupiter:2.0.3")
testImplementation("org.apache.poi:poi-ooxml:5.3.0")
testImplementation("org.slf4j:slf4j-simple:2.0.16")
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.18.2")
}

tasks.test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Logger;
import org.testcontainers.shaded.org.apache.commons.lang3.NotImplementedException;

public class DriverHelper {

Expand All @@ -33,7 +32,7 @@ public static String getDriverProtocol(DatabaseEngine databaseEngine) {
case PG:
return "jdbc:postgresql://";
default:
throw new NotImplementedException(databaseEngine.toString());
throw new UnsupportedOperationException(databaseEngine.toString());
}
}

Expand All @@ -44,7 +43,7 @@ public static String getDriverClassname(DatabaseEngine databaseEngine) {
case PG:
return getDriverClassname(TestDriver.PG);
default:
throw new NotImplementedException(databaseEngine.toString());
throw new UnsupportedOperationException(databaseEngine.toString());
}
}

Expand All @@ -55,7 +54,7 @@ public static String getDriverClassname(TestDriver testDriver) {
case PG:
return "org.postgresql.Driver";
default:
throw new NotImplementedException(testDriver.toString());
throw new UnsupportedOperationException(testDriver.toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.ToxiproxyContainer;
import org.testcontainers.shaded.org.apache.commons.lang3.NotImplementedException;
import software.amazon.awssdk.services.rds.model.BlueGreenDeployment;
import software.amazon.awssdk.services.rds.model.DBCluster;
import software.amazon.awssdk.services.rds.model.DBInstance;
Expand Down Expand Up @@ -149,7 +148,7 @@ public static TestEnvironment build(TestEnvironmentRequest request) throws IOExc
break;

default:
throw new NotImplementedException(request.getDatabaseEngineDeployment().toString());
throw new UnsupportedOperationException(request.getDatabaseEngineDeployment().toString());
}

if (request.getFeatures().contains(TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED)) {
Expand Down Expand Up @@ -272,7 +271,7 @@ private static TestEnvironment createAuroraOrMultiAzEnvironment(TestEnvironmentR
configureIamAccess(env);
break;
default:
throw new NotImplementedException(request.getDatabaseEngineDeployment().toString());
throw new UnsupportedOperationException(request.getDatabaseEngineDeployment().toString());
}

return env;
Expand Down Expand Up @@ -404,7 +403,7 @@ private static void createDatabaseContainers(TestEnvironment env) {
}
break;
default:
throw new NotImplementedException(env.info.getRequest().getDatabaseInstances().toString());
throw new UnsupportedOperationException(env.info.getRequest().getDatabaseInstances().toString());
}

switch (env.info.getRequest().getDatabaseEngine()) {
Expand Down Expand Up @@ -453,7 +452,7 @@ private static void createDatabaseContainers(TestEnvironment env) {
break;

default:
throw new NotImplementedException(env.info.getRequest().getDatabaseEngine().toString());
throw new UnsupportedOperationException(env.info.getRequest().getDatabaseEngine().toString());
}
}

Expand Down Expand Up @@ -489,7 +488,7 @@ private static void createDbCluster(TestEnvironment env) {
createDbCluster(env, env.numOfInstances);
break;
default:
throw new NotImplementedException(env.info.getRequest().getDatabaseEngine().toString());
throw new UnsupportedOperationException(env.info.getRequest().getDatabaseEngine().toString());
}
}

Expand Down Expand Up @@ -852,7 +851,7 @@ private static String getDbEngine(TestEnvironmentRequest request) {
case RDS_MULTI_AZ_INSTANCE:
return getRdsEngine(request);
default:
throw new NotImplementedException(request.getDatabaseEngineDeployment().toString());
throw new UnsupportedOperationException(request.getDatabaseEngineDeployment().toString());
}
}

Expand All @@ -863,7 +862,7 @@ private static String getAuroraDbEngine(TestEnvironmentRequest request) {
case PG:
return "aurora-postgresql";
default:
throw new NotImplementedException(request.getDatabaseEngine().toString());
throw new UnsupportedOperationException(request.getDatabaseEngine().toString());
}
}

Expand All @@ -874,7 +873,7 @@ private static String getRdsEngine(TestEnvironmentRequest request) {
case PG:
return "postgres";
default:
throw new NotImplementedException(request.getDatabaseEngine().toString());
throw new UnsupportedOperationException(request.getDatabaseEngine().toString());
}
}

Expand All @@ -889,7 +888,7 @@ private static String getDbEngineVersion(String engineName, TestEnvironment env)
systemPropertyVersion = config.pgVersion;
break;
default:
throw new NotImplementedException(request.getDatabaseEngine().toString());
throw new UnsupportedOperationException(request.getDatabaseEngine().toString());
}
return findEngineVersion(env, engineName, systemPropertyVersion);
}
Expand Down Expand Up @@ -919,7 +918,7 @@ private static int getPort(TestEnvironmentRequest request) {
case PG:
return 5432;
default:
throw new NotImplementedException(request.getDatabaseEngine().toString());
throw new UnsupportedOperationException(request.getDatabaseEngine().toString());
}
}

Expand Down Expand Up @@ -1148,7 +1147,7 @@ private static String getContainerBaseImageName(TestEnvironmentRequest request)
case PYTHON_3_13:
return "python:3.13";
default:
throw new NotImplementedException(request.getTargetPythonVersion().toString());
throw new UnsupportedOperationException(request.getTargetPythonVersion().toString());
}
}

Expand Down Expand Up @@ -1315,7 +1314,7 @@ public void close() throws Exception {
// do nothing
break;
default:
throw new NotImplementedException(this.info.getRequest().getDatabaseEngineDeployment().toString());
throw new UnsupportedOperationException(this.info.getRequest().getDatabaseEngineDeployment().toString());
}
}

Expand Down Expand Up @@ -1490,7 +1489,7 @@ private static void preCreateEnvironment(int currentEnvIndex) {
configureIamAccess(env);
break;
default:
throw new NotImplementedException(env.info.getRequest().getDatabaseEngineDeployment().toString());
throw new UnsupportedOperationException(env.info.getRequest().getDatabaseEngineDeployment().toString());
}
return env;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.testcontainers.shaded.org.apache.commons.lang3.NotImplementedException;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.AwsSessionCredentials;
Expand Down Expand Up @@ -897,7 +896,7 @@ public String getDbInstanceClass(TestEnvironmentRequest request) {
case RDS_MULTI_AZ_CLUSTER:
return "db.m5d.large";
default:
throw new NotImplementedException(request.getDatabaseEngineDeployment().toString());
throw new UnsupportedOperationException(request.getDatabaseEngineDeployment().toString());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@

public class ContainerHelper {

private static final String MYSQL_CONTAINER_IMAGE_NAME = "mysql:8.0.36";
private static final String MYSQL_CONTAINER_IMAGE_NAME = "mysql:latest";
private static final String POSTGRES_CONTAINER_IMAGE_NAME = "postgres:latest";
private static final DockerImageName TOXIPROXY_IMAGE =
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.11.0");
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.12.0");

private static final int PROXY_CONTROL_PORT = 8474;
private static final int PROXY_PORT = 8666;
Expand Down
Loading