Skip to content

Commit da57463

Browse files
authored
Add integration tests for Python 3.8 (#370)
1 parent c583a02 commit da57463

File tree

5 files changed

+170
-4
lines changed

5 files changed

+170
-4
lines changed

.github/workflows/integration_tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010
build-integration-tests:
1111
name: Run Integration Tests
1212
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: [ "3.8", "3.11" ]
1317

1418
steps:
1519
- name: 'Clone repository'
@@ -54,7 +58,7 @@ jobs:
5458
5559
- name: 'Run Integration Tests'
5660
run: |
57-
./gradlew --no-parallel --no-daemon test-all-environments --info
61+
./gradlew --no-parallel --no-daemon test-python-${{ matrix.python-version }} --info
5862
env:
5963
RDS_CLUSTER_DOMAIN: ${{ secrets.DB_CONN_SUFFIX }}
6064
AURORA_DB_REGION: ${{ secrets.AWS_DEFAULT_REGION }}

aws_advanced_python_wrapper/utils/mysql_exception_handler.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ def is_network_exception(self, error: Optional[Exception] = None, sql_state: Opt
4040
if isinstance(error, QueryTimeoutError):
4141
return True
4242

43-
if sql_state is None and isinstance(error, InterfaceError):
44-
sql_state = error.sqlstate
43+
if isinstance(error, InterfaceError):
44+
if error.errno in self._NETWORK_ERRORS:
45+
return True
46+
47+
if sql_state is None and error.sqlstate is not None:
48+
sql_state = error.sqlstate
4549

4650
if sql_state is not None and (sql_state.startswith("08") or sql_state.startswith("HY")):
4751
# Connection exceptions may also be returned as a generic error

tests/integration/host/build.gradle.kts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ tasks.withType<Test> {
6262
systemProperty("java.util.logging.config.file", "${project.buildDir}/resources/test/logging-test.properties")
6363
}
6464

65-
tasks.register<Test>("test-all-environments") {
65+
tasks.register<Test>("test-python-3.11") {
6666
group = "verification"
6767
filter.includeTestsMatching("integration.host.TestRunner.runTests")
6868
doFirst {
@@ -71,6 +71,15 @@ tasks.register<Test>("test-all-environments") {
7171
}
7272
}
7373

74+
tasks.register<Test>("test-python-3.8") {
75+
group = "verification"
76+
filter.includeTestsMatching("integration.host.TestRunner.runTests")
77+
doFirst {
78+
systemProperty("exclude-performance", "true")
79+
systemProperty("exclude-python-311", "true")
80+
}
81+
}
82+
7483
tasks.register<Test>("test-docker") {
7584
group = "verification"
7685
filter.includeTestsMatching("integration.host.TestRunner.runTests")

tests/integration/host/src/test/java/integration/host/TestEnvironmentProvider.java

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,92 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
210210
}
211211

212212
if (!excludeAurora) {
213+
if (!excludeMysqlEngine && !excludePython38) {
214+
if (numInstances == null || numInstances == 5) {
215+
resultContextList.add(
216+
getEnvironment(
217+
new TestEnvironmentRequest(
218+
DatabaseEngine.MYSQL,
219+
DatabaseInstances.MULTI_INSTANCE,
220+
5,
221+
DatabaseEngineDeployment.AURORA,
222+
TargetPythonVersion.PYTHON_3_8,
223+
TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
224+
excludeFailover ? null : TestEnvironmentFeatures.FAILOVER_SUPPORTED,
225+
TestEnvironmentFeatures.AWS_CREDENTIALS_ENABLED,
226+
excludeIam ? null : TestEnvironmentFeatures.IAM,
227+
excludeSecretsManager ? null : TestEnvironmentFeatures.SECRETS_MANAGER,
228+
excludePerformance ? null : TestEnvironmentFeatures.PERFORMANCE,
229+
excludeMysqlDriver ? TestEnvironmentFeatures.SKIP_MYSQL_DRIVER_TESTS : null,
230+
excludePgDriver ? TestEnvironmentFeatures.SKIP_PG_DRIVER_TESTS : null,
231+
testAutoscalingOnly ? TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY : null)));
232+
}
233+
234+
if (numInstances == null || numInstances == 2) {
235+
// Tests for IAM, SECRETS_MANAGER and PERFORMANCE are covered by
236+
// cluster configuration above, so it's safe to skip these tests for configurations below.
237+
// The main goal of the following cluster configurations is to check failover.
238+
resultContextList.add(
239+
getEnvironment(
240+
new TestEnvironmentRequest(
241+
DatabaseEngine.MYSQL,
242+
DatabaseInstances.MULTI_INSTANCE,
243+
2,
244+
DatabaseEngineDeployment.AURORA,
245+
TargetPythonVersion.PYTHON_3_8,
246+
TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
247+
excludeFailover ? null : TestEnvironmentFeatures.FAILOVER_SUPPORTED,
248+
TestEnvironmentFeatures.AWS_CREDENTIALS_ENABLED,
249+
excludeMysqlDriver ? TestEnvironmentFeatures.SKIP_MYSQL_DRIVER_TESTS : null,
250+
excludePgDriver ? TestEnvironmentFeatures.SKIP_PG_DRIVER_TESTS : null,
251+
testAutoscalingOnly ? TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY : null)));
252+
}
253+
}
254+
255+
if (!excludePgEngine && !excludePython38) {
256+
if (numInstances == null || numInstances == 5) {
257+
resultContextList.add(
258+
getEnvironment(
259+
new TestEnvironmentRequest(
260+
DatabaseEngine.PG,
261+
DatabaseInstances.MULTI_INSTANCE,
262+
5,
263+
DatabaseEngineDeployment.AURORA,
264+
TargetPythonVersion.PYTHON_3_8,
265+
TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
266+
TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED,
267+
excludeFailover ? null : TestEnvironmentFeatures.FAILOVER_SUPPORTED,
268+
TestEnvironmentFeatures.AWS_CREDENTIALS_ENABLED,
269+
excludeIam ? null : TestEnvironmentFeatures.IAM,
270+
excludeSecretsManager ? null : TestEnvironmentFeatures.SECRETS_MANAGER,
271+
excludePerformance ? null : TestEnvironmentFeatures.PERFORMANCE,
272+
excludeMysqlDriver ? TestEnvironmentFeatures.SKIP_MYSQL_DRIVER_TESTS : null,
273+
excludePgDriver ? TestEnvironmentFeatures.SKIP_PG_DRIVER_TESTS : null,
274+
testAutoscalingOnly ? TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY : null)));
275+
}
276+
277+
if (numInstances == null || numInstances == 2) {
278+
// Tests for IAM, SECRETS_MANAGER and PERFORMANCE are covered by
279+
// cluster configuration above, so it's safe to skip these tests for configurations below.
280+
// The main goal of the following cluster configurations is to check failover.
281+
resultContextList.add(
282+
getEnvironment(
283+
new TestEnvironmentRequest(
284+
DatabaseEngine.PG,
285+
DatabaseInstances.MULTI_INSTANCE,
286+
2,
287+
DatabaseEngineDeployment.AURORA,
288+
TargetPythonVersion.PYTHON_3_8,
289+
TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
290+
TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED,
291+
excludeFailover ? null : TestEnvironmentFeatures.FAILOVER_SUPPORTED,
292+
TestEnvironmentFeatures.AWS_CREDENTIALS_ENABLED,
293+
excludeMysqlDriver ? TestEnvironmentFeatures.SKIP_MYSQL_DRIVER_TESTS : null,
294+
excludePgDriver ? TestEnvironmentFeatures.SKIP_PG_DRIVER_TESTS : null,
295+
testAutoscalingOnly ? TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY : null)));
296+
}
297+
}
298+
213299
if (!excludeMysqlEngine && !excludePython311) {
214300
if (numInstances == null || numInstances == 5) {
215301
resultContextList.add(
@@ -251,6 +337,7 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
251337
testAutoscalingOnly ? TestEnvironmentFeatures.RUN_AUTOSCALING_TESTS_ONLY : null)));
252338
}
253339
}
340+
254341
if (!excludePgEngine && !excludePython311) {
255342
if (numInstances == null || numInstances == 5) {
256343
resultContextList.add(
@@ -297,6 +384,67 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
297384
}
298385

299386
if (!excludeMultiAz) {
387+
if (!excludeMysqlEngine && !excludePython38) {
388+
if (numInstances != null && numInstances != 3) {
389+
LOGGER.warning(numInstances + " instances were requested, but multi-az tests are only supported with" +
390+
" 3 instances. The multi-az tests will be run with 3 instances, and NUM_INSTANCES will be ignored.");
391+
}
392+
393+
if (!excludeFailover) {
394+
LOGGER.warning("Tests requiring database failover are not supported for multi-az clusters. It may take 1hr+" +
395+
" for the original writer to become available again after multi-az failover. Tests requiring database " +
396+
" failover will be skipped for multi-az test runs.");
397+
}
398+
399+
resultContextList.add(
400+
getEnvironment(
401+
new TestEnvironmentRequest(
402+
DatabaseEngine.MYSQL,
403+
DatabaseInstances.MULTI_INSTANCE,
404+
3,
405+
DatabaseEngineDeployment.MULTI_AZ,
406+
TargetPythonVersion.PYTHON_3_8,
407+
TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
408+
// Tests requiring database failover are not supported. It may take 1hr+ for the original writer to
409+
// become available after multi-az failover.
410+
TestEnvironmentFeatures.AWS_CREDENTIALS_ENABLED,
411+
excludeSecretsManager ? null : TestEnvironmentFeatures.SECRETS_MANAGER,
412+
excludePerformance ? null : TestEnvironmentFeatures.PERFORMANCE,
413+
excludeMysqlDriver ? TestEnvironmentFeatures.SKIP_MYSQL_DRIVER_TESTS : null,
414+
excludePgDriver ? TestEnvironmentFeatures.SKIP_PG_DRIVER_TESTS : null)));
415+
}
416+
417+
if (!excludePgEngine && !excludePython38) {
418+
if (numInstances != null && numInstances != 3) {
419+
LOGGER.warning(numInstances + " instances were requested, but multi-az tests are only supported with" +
420+
" 3 instances. The multi-az tests will be run with 3 instances, and NUM_INSTANCES will be ignored.");
421+
}
422+
423+
if (!excludeFailover) {
424+
LOGGER.warning("Tests requiring database failover are not supported for multi-az clusters. It may take 1hr+" +
425+
" for the original writer to become available again after multi-az failover. Tests requiring database " +
426+
" failover will be skipped for multi-az test runs.");
427+
}
428+
429+
resultContextList.add(
430+
getEnvironment(
431+
new TestEnvironmentRequest(
432+
DatabaseEngine.PG,
433+
DatabaseInstances.MULTI_INSTANCE,
434+
3,
435+
DatabaseEngineDeployment.MULTI_AZ,
436+
TargetPythonVersion.PYTHON_3_8,
437+
TestEnvironmentFeatures.NETWORK_OUTAGES_ENABLED,
438+
TestEnvironmentFeatures.ABORT_CONNECTION_SUPPORTED,
439+
// Tests requiring database failover are not supported. It may take 1hr+ for the original writer to
440+
// become available after multi-az failover.
441+
TestEnvironmentFeatures.AWS_CREDENTIALS_ENABLED,
442+
excludeSecretsManager ? null : TestEnvironmentFeatures.SECRETS_MANAGER,
443+
excludePerformance ? null : TestEnvironmentFeatures.PERFORMANCE,
444+
excludeMysqlDriver ? TestEnvironmentFeatures.SKIP_MYSQL_DRIVER_TESTS : null,
445+
excludePgDriver ? TestEnvironmentFeatures.SKIP_PG_DRIVER_TESTS : null)));
446+
}
447+
300448
if (!excludeMysqlEngine && !excludePython311) {
301449
if (numInstances != null && numInstances != 3) {
302450
LOGGER.warning(numInstances + " instances were requested, but multi-az tests are only supported with" +
@@ -326,6 +474,7 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
326474
excludeMysqlDriver ? TestEnvironmentFeatures.SKIP_MYSQL_DRIVER_TESTS : null,
327475
excludePgDriver ? TestEnvironmentFeatures.SKIP_PG_DRIVER_TESTS : null)));
328476
}
477+
329478
if (!excludePgEngine && !excludePython311) {
330479
if (numInstances != null && numInstances != 3) {
331480
LOGGER.warning(numInstances + " instances were requested, but multi-az tests are only supported with" +

0 commit comments

Comments
 (0)