From 611676d108b26ee378a2b0c128c855017d162772 Mon Sep 17 00:00:00 2001 From: Yi Hu Date: Tue, 21 May 2024 20:47:11 -0400 Subject: [PATCH] Fix DebeziumIO testWrongHost trying to connect real external address (#31365) --- .../DebeziumReadSchemaTransformTest.java | 33 ++++++++----------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/sdks/java/io/debezium/src/test/java/org/apache/beam/io/debezium/DebeziumReadSchemaTransformTest.java b/sdks/java/io/debezium/src/test/java/org/apache/beam/io/debezium/DebeziumReadSchemaTransformTest.java index db5797497724..c75621040913 100644 --- a/sdks/java/io/debezium/src/test/java/org/apache/beam/io/debezium/DebeziumReadSchemaTransformTest.java +++ b/sdks/java/io/debezium/src/test/java/org/apache/beam/io/debezium/DebeziumReadSchemaTransformTest.java @@ -188,26 +188,19 @@ public void testWrongPort() { } @Test - public void testWrongHost() throws Exception { + public void testWrongHost() { Pipeline readPipeline = Pipeline.create(); - Exception ex = - assertThrows( - Exception.class, - () -> { - PCollectionRowTuple.empty(readPipeline) - .apply( - makePtransform( - userName, - password, - database, - databaseContainer.getMappedPort(port), - "23.128.129.130")) - .get("output"); - }); - Throwable lowestCause = ex.getCause(); - while (lowestCause.getCause() != null) { - lowestCause = lowestCause.getCause(); - } - assertThat(lowestCause.getMessage(), Matchers.containsString("Connection refused")); + assertThrows( + Exception.class, + () -> + PCollectionRowTuple.empty(readPipeline) + .apply( + makePtransform( + userName, + password, + database, + databaseContainer.getMappedPort(port), + "169.254.254.254")) + .get("output")); } }