refactor(接口测试): 发送执行任务,响应超时不重试

--bug=1048936 --user=陈建星 [测试计划]github#34183多资源池节点执行测试计划会导致报告显示步骤重复多次及测试执行时间翻倍 https://www.tapd.cn/55049933/s/1615683
This commit is contained in:
AgAngle 2024-11-22 17:55:06 +08:00 committed by Craftsman
parent fa3caa483f
commit ef258a4be2
1 changed files with 13 additions and 0 deletions

View File

@ -59,11 +59,13 @@ import org.springframework.http.MediaType;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.ResourceAccessException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.SocketTimeoutException;
import java.util.*; import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -298,6 +300,11 @@ public class ApiExecuteService {
} }
break; break;
} catch (Exception e) { } catch (Exception e) {
if (e instanceof ResourceAccessException resourceAccessException
&& resourceAccessException.getCause() instanceof SocketTimeoutException) {
// 响应超时则视为成功避免任务重复发送
break;
}
lastException = e; lastException = e;
LogUtils.error(e); LogUtils.error(e);
// 记录异常节点重试 // 记录异常节点重试
@ -417,6 +424,12 @@ public class ApiExecuteService {
} }
break; break;
} catch (Exception e) { } catch (Exception e) {
if (e instanceof ResourceAccessException resourceAccessException
&& resourceAccessException.getCause() instanceof SocketTimeoutException) {
// 响应超时则视为成功避免任务重复发送
success = true;
break;
}
invalidNodeSet.add(testResourceNode); invalidNodeSet.add(testResourceNode);
LogUtils.error("发送批量任务到 {} 节点执行失败", endpoint); LogUtils.error("发送批量任务到 {} 节点执行失败", endpoint);
LogUtils.error(e); LogUtils.error(e);