diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index d9a41805..d15aca9b 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -5,6 +5,7 @@ on: push: branches: - main + - fix/srw permissions: id-token: write # This is required for requesting the JWT diff --git a/aws_advanced_python_wrapper/pep249_methods.py b/aws_advanced_python_wrapper/pep249_methods.py index 8d3f6487..0406c1d4 100644 --- a/aws_advanced_python_wrapper/pep249_methods.py +++ b/aws_advanced_python_wrapper/pep249_methods.py @@ -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) diff --git a/aws_advanced_python_wrapper/read_write_splitting_plugin.py b/aws_advanced_python_wrapper/read_write_splitting_plugin.py index 94e7c9b0..3d1624b2 100644 --- a/aws_advanced_python_wrapper/read_write_splitting_plugin.py +++ b/aws_advanced_python_wrapper/read_write_splitting_plugin.py @@ -49,6 +49,18 @@ class ReadWriteSplittingConnectionManager(Plugin): DbApiMethod.CONNECT.method_name, DbApiMethod.NOTIFY_CONNECTION_CHANGED.method_name, DbApiMethod.CONNECTION_SET_READ_ONLY.method_name, + + DbApiMethod.CONNECTION_COMMIT.method_name, + DbApiMethod.CONNECTION_AUTOCOMMIT.method_name, + DbApiMethod.CONNECTION_AUTOCOMMIT_SETTER.method_name, + DbApiMethod.CONNECTION_IS_READ_ONLY.method_name, + DbApiMethod.CONNECTION_SET_READ_ONLY.method_name, + DbApiMethod.CONNECTION_ROLLBACK.method_name, + + DbApiMethod.CURSOR_EXECUTE.method_name, + DbApiMethod.CURSOR_FETCHONE.method_name, + DbApiMethod.CURSOR_FETCHMANY.method_name, + DbApiMethod.CURSOR_FETCHALL.method_name } _POOL_PROVIDER_CLASS_NAME = "aws_advanced_python_wrapper.sql_alchemy_connection_provider.SqlAlchemyPooledConnectionProvider" @@ -450,7 +462,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.""" ... diff --git a/aws_advanced_python_wrapper/resources/aws_advanced_python_wrapper_messages.properties b/aws_advanced_python_wrapper/resources/aws_advanced_python_wrapper_messages.properties index 8a0dd562..6d03cef3 100644 --- a/aws_advanced_python_wrapper/resources/aws_advanced_python_wrapper_messages.properties +++ b/aws_advanced_python_wrapper/resources/aws_advanced_python_wrapper_messages.properties @@ -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. diff --git a/aws_advanced_python_wrapper/utils/telemetry/xray_telemetry.py b/aws_advanced_python_wrapper/utils/telemetry/xray_telemetry.py index 5ec1ac4c..728798ad 100644 --- a/aws_advanced_python_wrapper/utils/telemetry/xray_telemetry.py +++ b/aws_advanced_python_wrapper/utils/telemetry/xray_telemetry.py @@ -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: @@ -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) diff --git a/docs/examples/PGXRayTelemetry.py b/docs/examples/PGXRayTelemetry.py index 56f6365a..55aded07 100644 --- a/docs/examples/PGXRayTelemetry.py +++ b/docs/examples/PGXRayTelemetry.py @@ -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: diff --git a/tests/integration/container/utils/test_environment.py b/tests/integration/container/utils/test_environment.py index e547dba2..0b303207 100644 --- a/tests/integration/container/utils/test_environment.py +++ b/tests/integration/container/utils/test_environment.py @@ -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(): diff --git a/tests/integration/host/build.gradle.kts b/tests/integration/host/build.gradle.kts index 7a3bc19c..c98afa21 100644 --- a/tests/integration/host/build.gradle.kts +++ b/tests/integration/host/build.gradle.kts @@ -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 { diff --git a/tests/integration/host/src/test/java/integration/DriverHelper.java b/tests/integration/host/src/test/java/integration/DriverHelper.java index b4c4f679..65ed4acf 100644 --- a/tests/integration/host/src/test/java/integration/DriverHelper.java +++ b/tests/integration/host/src/test/java/integration/DriverHelper.java @@ -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 { @@ -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()); } } @@ -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()); } } @@ -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()); } } diff --git a/tests/integration/host/src/test/java/integration/host/TestEnvironment.java b/tests/integration/host/src/test/java/integration/host/TestEnvironment.java index 2eb36682..7179c1ec 100644 --- a/tests/integration/host/src/test/java/integration/host/TestEnvironment.java +++ b/tests/integration/host/src/test/java/integration/host/TestEnvironment.java @@ -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; @@ -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)) { @@ -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; @@ -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()) { @@ -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()); } } @@ -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()); } } @@ -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()); } } @@ -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()); } } @@ -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()); } } @@ -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); } @@ -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()); } } @@ -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()); } } @@ -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()); } } @@ -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; diff --git a/tests/integration/host/src/test/java/integration/util/AuroraTestUtility.java b/tests/integration/host/src/test/java/integration/util/AuroraTestUtility.java index a04d44a9..1b8684ed 100644 --- a/tests/integration/host/src/test/java/integration/util/AuroraTestUtility.java +++ b/tests/integration/host/src/test/java/integration/util/AuroraTestUtility.java @@ -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; @@ -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()); } } diff --git a/tests/integration/host/src/test/java/integration/util/ContainerHelper.java b/tests/integration/host/src/test/java/integration/util/ContainerHelper.java index 5895ebe7..ef725437 100644 --- a/tests/integration/host/src/test/java/integration/util/ContainerHelper.java +++ b/tests/integration/host/src/test/java/integration/util/ContainerHelper.java @@ -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;