refactor(系统设置): 针对gitee测试用例偶发的无法连接问题增加重试处理

This commit is contained in:
song-tianyang 2024-01-09 11:22:19 +08:00 committed by 刘瑞斌
parent e516de1602
commit 35a95cb40e
1 changed files with 17 additions and 1 deletions

View File

@ -192,7 +192,23 @@ public class FileRepositoryControllerTest extends BaseTest {
createRequest.setUserName(giteeUserName);
createRequest.setToken(giteeToken);
createRequest.setName("GITEE存储库");
result = this.requestPostWithOkAndReturn(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest);
int tryCount = 0;
while (true) {
//github连接gitee有时会连不到这里重试10次
result = this.requestPost(FileManagementRequestUtils.URL_FILE_REPOSITORY_CREATE, createRequest).andReturn();
if (result.getResponse().getStatus() == 200) {
break;
} else {
tryCount++;
if (tryCount > 10) {
throw new Exception("无法创建gitee存储库");
} else {
Thread.sleep(1000);
}
}
}
returnStr = result.getResponse().getContentAsString();
rh = JSON.parseObject(returnStr, ResultHolder.class);
this.checkFileRepository(rh.getData().toString(), createRequest.getProjectId(), createRequest.getName(), createRequest.getPlatform(), createRequest.getUrl(), createRequest.getToken(), createRequest.getUserName());