dannycranmer commented on a change in pull request #18553:
URL: https://github.com/apache/flink/pull/18553#discussion_r800814706
##########
File path:
flink-connectors/flink-connector-aws-kinesis-firehose/src/test/java/org/apache/flink/connector/firehose/sink/KinesisFirehoseSinkITCase.java
##########
@@ -126,6 +123,70 @@ public void test() throws Exception {
objects,
BUCKET_NAME,
response -> new
String(response.asByteArrayUnsafe())))
- .containsAll(expectedElements);
+ .containsAll(getSampleDataGenerated());
+ }
+
+ @Test
+ public void firehoseSinkFailsWhenAccessKeyIdIsNotProvided() {
+ Properties properties = getConfig(mockFirehoseContainer.getEndpoint());
+ properties.setProperty(
+ AWS_CREDENTIALS_PROVIDER,
AWSConfigConstants.CredentialProvider.BASIC.toString());
+
properties.remove(AWSConfigConstants.accessKeyId(AWS_CREDENTIALS_PROVIDER));
+
firehoseSinkFailsWithAppropriateMessageWhenInitialConditionsAreMisconfigured(
+ properties, "Please set values for AWS Access Key ID");
+ }
+
+ @Test
+ public void firehoseSinkFailsWhenRegionIsNotProvided() {
+ Properties properties = getConfig(mockFirehoseContainer.getEndpoint());
+ properties.remove(AWS_REGION);
+
firehoseSinkFailsWithAppropriateMessageWhenInitialConditionsAreMisconfigured(
+ properties, "region must not be null.");
+ }
+
+ @Test
+ public void firehoseSinkFailsWhenUnableToConnectToRemoteService() {
+ Properties properties = getConfig(mockFirehoseContainer.getEndpoint());
+ properties.remove(TRUST_ALL_CERTIFICATES);
+
firehoseSinkFailsWithAppropriateMessageWhenInitialConditionsAreMisconfigured(
+ properties,
+ "Encountered non-recoverable exception relating to
mis-configured client");
+ }
+
+ private void
firehoseSinkFailsWithAppropriateMessageWhenInitialConditionsAreMisconfigured(
+ Properties properties, String errorMessage) {
+ KinesisFirehoseSink<String> kdsSink =
+ KinesisFirehoseSink.<String>builder()
+ .setSerializationSchema(new SimpleStringSchema())
+ .setDeliveryStreamName("non-existent-stream")
+ .setMaxBatchSize(1)
+ .setFirehoseClientProperties(properties)
+ .build();
+
+ getSampleDataGenerator().sinkTo(kdsSink);
+
+ Assertions.assertThatExceptionOfType(JobExecutionException.class)
+ .isThrownBy(() -> env.execute("Integration Test"))
+ .havingCause()
+ .havingCause()
+ .withMessageContaining(errorMessage);
+ }
+
+ private DataStream<String> getSampleDataGenerator() {
+ ObjectMapper mapper = new ObjectMapper();
+
+ return env.fromSequence(1, NUMBER_OF_ELEMENTS)
+ .map(Object::toString)
+ .returns(String.class)
+ .map(data -> mapper.writeValueAsString(ImmutableMap.of("data",
data)));
+ }
+
+ private List<String> getSampleDataGenerated() throws
JsonProcessingException {
+ List<String> expectedElements = new ArrayList<>();
+ for (int i = 1; i < NUMBER_OF_ELEMENTS; i++) {
Review comment:
This will add `NUMBER_OF_ELEMENTS - 1` to the list, is that expected?
##########
File path:
flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/util/RetryableExceptionClassifier.java
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.base.sink.util;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.util.ExceptionUtils;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.Predicate;
+
+/** Util class acting as a classifier for exception to suppress. */
Review comment:
nit: I would like to see a better comment here, this is not technically
a util class.
##########
File path:
flink-connectors/flink-connector-aws-base/src/main/java/org/apache/flink/connector/aws/util/AWSCredentialExceptionWrappers.java
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.aws.util;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.connector.base.sink.util.RetryableExceptionClassifier;
+
+import software.amazon.awssdk.core.exception.SdkClientException;
+import software.amazon.awssdk.services.sts.model.StsException;
+
+/** Class containing Exception Wrappers for AWS credenetial failures. */
+@Internal
+public class AWSCredentialExceptionWrappers {
Review comment:
Should this be `AWSCredentialRetryableExceptionClassifier` ?
##########
File path:
flink-connectors/flink-connector-base/src/main/java/org/apache/flink/connector/base/sink/writer/AsyncSinkThrowableWrappers.java
##########
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.connector.base.sink.writer;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.connector.base.sink.util.RetryableExceptionClassifier;
+import org.apache.flink.util.FlinkException;
+
+/** Common retry strategies needed to fail fast on common errors. */
Review comment:
nit?
> Common retry strategies needed to fail fast on common errors
"Common retry strategies used to classify common errors"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]