[
https://issues.apache.org/jira/browse/GOBBLIN-2110?focusedWorklogId=926219&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-926219
]
ASF GitHub Bot logged work on GOBBLIN-2110:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 16/Jul/24 19:48
Start Date: 16/Jul/24 19:48
Worklog Time Spent: 10m
Work Description: arjun4084346 commented on code in PR #4001:
URL: https://github.com/apache/gobblin/pull/4001#discussion_r1679987978
##########
gobblin-utility/src/test/java/org/apache/gobblin/util/retry/RetryerFactoryTest.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.gobblin.util.retry;
+
+import java.util.Arrays;
+
+import org.mockito.Mockito;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.typesafe.config.Config;
+
+/**
+ * Unit tests for the {@link org.apache.gobblin.util.retry.RetryerFactory}
class.
+ */
+public class RetryerFactoryTest {
+ private static final String EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY =
"EXCEPTION_LIST_FOR_RETRY";
+
+ @Test
+ public void testGetRetryPredicateFromConfigOrDefault_withEmptyConfig() {
+ Config config = Mockito.mock(Config.class);
+
Mockito.when(config.hasPath(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY)).thenReturn(false);
+ Predicate<Throwable> result =
RetryerFactory.getRetryPredicateFromConfigOrDefault(config);
+
+ Assert.assertEquals(RetryerFactory.RETRY_EXCEPTION_PREDICATE_DEFAULT,
result);
+ }
+
+ @Test
+ public void testGetRetryPredicateFromConfigOrDefault_withValidException() {
+ Config config = Mockito.mock(Config.class);
+
Mockito.when(config.hasPath(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY)).thenReturn(true);
+ Mockito.when(config.getStringList(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY))
+ .thenReturn(Arrays.asList("java.lang.RuntimeException"));
+
+ Predicate<Throwable> result =
RetryerFactory.getRetryPredicateFromConfigOrDefault(config);
+
+ Assert.assertTrue(result.test(new RuntimeException()));
+ Assert.assertFalse(result.test(new Exception()));
+ }
+
+ @Test
+ public void testGetRetryPredicateFromConfigOrDefault_withInvalidException() {
+ Config config = Mockito.mock(Config.class);
+
Mockito.when(config.hasPath(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY)).thenReturn(true);
+ Mockito.when(config.getStringList(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY))
+ .thenReturn(Arrays.asList("non.existent.Exception"));
+
+ Predicate<Throwable> result =
RetryerFactory.getRetryPredicateFromConfigOrDefault(config);
+
+ Assert.assertEquals(RetryerFactory.RETRY_EXCEPTION_PREDICATE_DEFAULT,
result);
+ }
+
+ @Test
+ public void testGetRetryPredicateFromConfigOrDefault_withMixedExceptions() {
+ Config config = Mockito.mock(Config.class);
+
Mockito.when(config.hasPath(EXCEPTION_LIST_FOR_RETRY_CONFIG_KEY)).thenReturn(true);
Review Comment:
you can create Config like `ConfigBuilder configBuilder =
ConfigBuilder.create()
.addPrimitive(ConfigurationKeys.FLOW_GROUP_KEY,
flowConfig.getId().getFlowGroup())
.addPrimitive(ConfigurationKeys.FLOW_NAME_KEY,
flowConfig.getId().getFlowName());`
or like `Config config =
ConfigFactory.empty().withValue(GobblinClusterConfigurationKeys.GOBBLIN_CLUSTER_SYSTEM_PROPERTY_PREFIX
+ ".prop2",
ConfigValueFactory.fromAnyRef("val2"))`
Issue Time Tracking
-------------------
Worklog Id: (was: 926219)
Time Spent: 1h 50m (was: 1h 40m)
> Make retry_exception_predicate configurable in RetryerFactory
> -------------------------------------------------------------
>
> Key: GOBBLIN-2110
> URL: https://issues.apache.org/jira/browse/GOBBLIN-2110
> Project: Apache Gobblin
> Issue Type: Bug
> Reporter: Aditya Pratap Singh
> Priority: Minor
> Time Spent: 1h 50m
> Remaining Estimate: 0h
>
> Make retry_exception_predicate configurable in RetryerFactory
--
This message was sent by Atlassian Jira
(v8.20.10#820010)