WangHan
2024-09-12 d5855a4926926698b740bc6c7ba489de47adb68b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package tech.powerjob.client.test;
 
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import tech.powerjob.common.response.JobInfoDTO;
import tech.powerjob.common.response.ResultDTO;
import tech.powerjob.common.utils.CommonUtils;
 
/**
 * 测试容灾能力
 *
 * @author tjq
 * @since 2024/8/11
 */
@Slf4j
public class TestClusterHA extends ClientInitializer {
 
    @Test
    void testHa() {
        // 人工让 server 启停
        for (int i = 0; i < 1000000; i++) {
 
            CommonUtils.easySleep(100);
 
            ResultDTO<JobInfoDTO> jobInfoDTOResultDTO = powerJobClient.fetchJob(1L);
 
            log.info("[TestClusterHA] response: {}", JSONObject.toJSONString(jobInfoDTOResultDTO));
 
            if (!jobInfoDTOResultDTO.isSuccess()) {
                throw new RuntimeException("request failed!");
            }
        }
    }
}