test: fix unit test by ocean-fujfu

This commit is contained in:
tjq 2022-09-12 23:24:49 +08:00
commit 12ff1335f2
17 changed files with 109 additions and 93 deletions

View File

@ -1,5 +1,6 @@
package tech.powerjob.server.core.handler.impl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Component;
import tech.powerjob.common.RemoteConstant;
import tech.powerjob.server.remote.transport.starter.AkkaStarter;
@ -14,6 +15,7 @@ import javax.annotation.PostConstruct;
* @since 2022/9/11
*/
@Component
@ConditionalOnExpression("'${execution.env}'!='test'")
public class Initializer {
@PostConstruct

View File

@ -3,8 +3,8 @@ package tech.powerjob.server.core.evaluator;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import tech.powerjob.common.serialize.JsonUtils;
import java.util.HashMap;
@ -45,7 +45,7 @@ public class GroovyEvaluatorTest {
@Test
public void testSimpleEval1() {
Object res = groovyEvaluator.evaluate("var x = false; x;", null);
Assert.assertEquals(false, res);
Assertions.assertEquals(false, res);
}
@Test
@ -53,14 +53,14 @@ public class GroovyEvaluatorTest {
// inject simple context
Object res = groovyEvaluator.evaluate("var res = context.k3; res;", SIMPLE_CONTEXT);
Boolean s = JsonUtils.parseObjectUnsafe(res.toString(), Boolean.class);
Assert.assertEquals(false, s);
Assertions.assertEquals(false, s);
}
@Test
public void testSimpleEval3() {
Object res = groovyEvaluator.evaluate("var res = new groovy.json.JsonSlurper().parseText(context.k3); res == false;", SIMPLE_CONTEXT);
Assert.assertEquals(true, res);
Assertions.assertEquals(true, res);
}
@ -68,13 +68,13 @@ public class GroovyEvaluatorTest {
public void testComplexEval1() {
// array
Object res = groovyEvaluator.evaluate("var res = new groovy.json.JsonSlurper().parseText(context.array) ; res[0] == 1;", COMPLEX_CONTEXT);
Assert.assertEquals(true, res);
Assertions.assertEquals(true, res);
// map
res = groovyEvaluator.evaluate("var map = new groovy.json.JsonSlurper().parseText(context.map); var e1 = map.e1; e1.value ",COMPLEX_CONTEXT);
Assert.assertEquals(1,res);
Assertions.assertEquals(1,res);
// object
res = groovyEvaluator.evaluate("var e3 = new groovy.json.JsonSlurper().parseText(context.obj); var e1 = e3.sub.sub; e1.value ",COMPLEX_CONTEXT);
Assert.assertEquals(1,res);
Assertions.assertEquals(1,res);
}

View File

@ -4,8 +4,8 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.assertj.core.util.Lists;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import tech.powerjob.common.OmsConstant;
import tech.powerjob.server.core.scheduler.auxiliary.impl.CronTimingStrategyHandler;

View File

@ -1,8 +1,7 @@
package tech.powerjob.server.core.scheduler;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import tech.powerjob.common.enums.TimeExpressionType;
import tech.powerjob.common.exception.PowerJobException;
import tech.powerjob.server.core.scheduler.auxiliary.TimingStrategyHandler;
@ -37,11 +36,11 @@ public class TimingStrategyServiceTest {
// api
Assertions.assertDoesNotThrow(() -> timingStrategyService.validate(TimeExpressionType.API, "", null, null));
List<String> triggerTimes = timingStrategyService.calculateNextTriggerTimes(TimeExpressionType.API, "", null, null);
Assert.assertEquals(1, triggerTimes.size());
Assertions.assertEquals(1, triggerTimes.size());
// workflow
Assertions.assertDoesNotThrow(() -> timingStrategyService.validate(TimeExpressionType.WORKFLOW, "", null, null));
triggerTimes = timingStrategyService.calculateNextTriggerTimes(TimeExpressionType.WORKFLOW, "", null, null);
Assert.assertEquals(1, triggerTimes.size());
Assertions.assertEquals(1, triggerTimes.size());
}
@Test
@ -54,12 +53,12 @@ public class TimingStrategyServiceTest {
long timeParam = 1000;
List<String> triggerTimes = timingStrategyService.calculateNextTriggerTimes(TimeExpressionType.FIXED_RATE, String.valueOf(timeParam), null, null);
Assert.assertEquals(5, triggerTimes.size());
Assertions.assertEquals(5, triggerTimes.size());
Long startTime = System.currentTimeMillis() + timeParam;
Long endTime = System.currentTimeMillis() + timeParam * 3;
triggerTimes = timingStrategyService.calculateNextTriggerTimes(TimeExpressionType.FIXED_RATE, String.valueOf(timeParam), startTime, endTime);
Assert.assertEquals(3, triggerTimes.size());
Assertions.assertEquals(3, triggerTimes.size());
}
@ -72,7 +71,7 @@ public class TimingStrategyServiceTest {
Assertions.assertDoesNotThrow(() -> timingStrategyService.validate(TimeExpressionType.FIXED_DELAY, "10000", null, null));
List<String> triggerTimes = timingStrategyService.calculateNextTriggerTimes(TimeExpressionType.FIXED_DELAY, "1", null, null);
Assert.assertEquals(1, triggerTimes.size());
Assertions.assertEquals(1, triggerTimes.size());
}
@ -86,6 +85,6 @@ public class TimingStrategyServiceTest {
LocalDateTime start = LocalDateTime.of(2088, 5, 24, 7, 0, 0);
LocalDateTime end = LocalDateTime.of(2088, 7, 12, 7, 0, 0);
List<String> triggerTimes = timingStrategyService.calculateNextTriggerTimes(TimeExpressionType.CRON, "0 0 7 8-14,22-28 * 2", start.toEpochSecond(ZoneOffset.of("+8")) * 1000, end.toEpochSecond(ZoneOffset.of("+8")) * 1000);
Assert.assertNotNull(triggerTimes);
Assertions.assertNotNull(triggerTimes);
}
}

View File

@ -1,6 +1,6 @@
package tech.powerjob.server.core.validator;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.BeanUtils;
import tech.powerjob.common.enums.WorkflowNodeType;
@ -41,7 +41,7 @@ class NodeValidatorTest {
final WorkflowNodeInfoDO workflowNodeInfo1 = new WorkflowNodeInfoDO();
BeanUtils.copyProperties(node1, workflowNodeInfo1);
workflowNodeInfo1.setId(node1.getNodeId());
Assert.assertThrows(PowerJobException.class, () -> decisionNodeValidator.complexValidate(workflowNodeInfo1, dag));
Assertions.assertThrows(PowerJobException.class, () -> decisionNodeValidator.complexValidate(workflowNodeInfo1, dag));
}

View File

@ -2,7 +2,7 @@ package tech.powerjob.server.test;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import tech.powerjob.common.utils.CommonUtils;
import tech.powerjob.server.core.uid.SnowFlakeIdGenerator;
@ -27,7 +27,7 @@ public class ConflictTest {
int len = CommonUtils.formatSize(1024) - 1;
Map<Integer, Integer> matchCount = new TreeMap<>();
int maxTime = 100000;
int maxTime = 10000;
int expectedMaxConflict = maxTime / len;
for (int i = 0; i < maxTime; i++) {

View File

@ -1,13 +1,13 @@
package tech.powerjob.server.test;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import tech.powerjob.common.enums.InstanceStatus;
import tech.powerjob.common.model.PEWorkflowDAG;
import tech.powerjob.server.core.workflow.algorithm.WorkflowDAGUtils;
import tech.powerjob.server.core.workflow.algorithm.WorkflowDAG;
import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Test;
import java.util.List;
import java.util.stream.Collectors;
@ -32,7 +32,7 @@ public class DAGTest {
nodes.add(new PEWorkflowDAG.Node(2L));
edges.add(new PEWorkflowDAG.Edge(1L, 2L));
edges.add(new PEWorkflowDAG.Edge(2L, 1L));
Assert.assertFalse(WorkflowDAGUtils.valid(new PEWorkflowDAG(nodes, edges)));
Assertions.assertFalse(WorkflowDAGUtils.valid(new PEWorkflowDAG(nodes, edges)));
}
@Test
@ -51,14 +51,14 @@ public class DAGTest {
edges.add(new PEWorkflowDAG.Edge(3L, 4L));
PEWorkflowDAG validPEDAG = new PEWorkflowDAG(nodes, edges);
Assert.assertTrue(WorkflowDAGUtils.valid(validPEDAG));
Assertions.assertTrue(WorkflowDAGUtils.valid(validPEDAG));
WorkflowDAG wfDAG = WorkflowDAGUtils.convert(validPEDAG);
Assert.assertEquals(1, wfDAG.getRoots().size());
Assertions.assertEquals(1, wfDAG.getRoots().size());
WorkflowDAG.Node node = wfDAG.getNode(3L);
Assert.assertEquals(1, (long) node.getDependencies().get(0).getNodeId());
Assert.assertEquals(4, (long) node.getSuccessors().get(0).getNodeId());
Assertions.assertEquals(1, (long) node.getDependencies().get(0).getNodeId());
Assertions.assertEquals(4, (long) node.getSuccessors().get(0).getNodeId());
}
@Test
@ -76,7 +76,7 @@ public class DAGTest {
edges.add(new PEWorkflowDAG.Edge(2L, 4L));
PEWorkflowDAG multiRootPEDAG = new PEWorkflowDAG(nodes, edges);
Assert.assertTrue(WorkflowDAGUtils.valid(multiRootPEDAG));
Assertions.assertTrue(WorkflowDAGUtils.valid(multiRootPEDAG));
WorkflowDAG multiRootDAG = WorkflowDAGUtils.convert(multiRootPEDAG);
System.out.println(multiRootDAG);
}
@ -100,7 +100,7 @@ public class DAGTest {
edges.add(new PEWorkflowDAG.Edge(3L, 1L));
edges.add(new PEWorkflowDAG.Edge(2L, 4L));
Assert.assertFalse(WorkflowDAGUtils.valid(new PEWorkflowDAG(nodes, edges)));
Assertions.assertFalse(WorkflowDAGUtils.valid(new PEWorkflowDAG(nodes, edges)));
}
@ -136,7 +136,7 @@ public class DAGTest {
edges.add(new PEWorkflowDAG.Edge(1L, 6L));
Assert.assertTrue(WorkflowDAGUtils.valid(new PEWorkflowDAG(nodes, edges)));
Assertions.assertTrue(WorkflowDAGUtils.valid(new PEWorkflowDAG(nodes, edges)));
}
@ -178,9 +178,9 @@ public class DAGTest {
List<Long> readyNodeIds1 = WorkflowDAGUtils.listReadyNodes(dag1).stream().map(PEWorkflowDAG.Node::getNodeId).collect(Collectors.toList());
System.out.println(readyNodeIds1);
Assert.assertTrue(readyNodeIds1.contains(1L));
Assert.assertTrue(readyNodeIds1.contains(4L));
Assert.assertTrue(readyNodeIds1.contains(9L));
Assertions.assertTrue(readyNodeIds1.contains(1L));
Assertions.assertTrue(readyNodeIds1.contains(4L));
Assertions.assertTrue(readyNodeIds1.contains(9L));
}
@ -215,8 +215,8 @@ public class DAGTest {
System.out.println(readyNodeIds2);
Assert.assertEquals(1, readyNodeIds2.size());
Assert.assertTrue(readyNodeIds2.contains(3L));
Assertions.assertEquals(1, readyNodeIds2.size());
Assertions.assertTrue(readyNodeIds2.contains(3L));
}
@ -256,9 +256,9 @@ public class DAGTest {
System.out.println(readyNodeIds2);
Assert.assertEquals(2, readyNodeIds2.size());
Assert.assertTrue(readyNodeIds2.contains(4L));
Assert.assertTrue(readyNodeIds2.contains(7L));
Assertions.assertEquals(2, readyNodeIds2.size());
Assertions.assertTrue(readyNodeIds2.contains(4L));
Assertions.assertTrue(readyNodeIds2.contains(7L));
}
@ -299,8 +299,8 @@ public class DAGTest {
System.out.println(readyNodeIds2);
Assert.assertEquals(1, readyNodeIds2.size());
Assert.assertTrue(readyNodeIds2.contains(5L));
Assertions.assertEquals(1, readyNodeIds2.size());
Assertions.assertTrue(readyNodeIds2.contains(5L));
}
@ -344,9 +344,9 @@ public class DAGTest {
System.out.println(readyNodeIds2);
Assert.assertEquals(2, readyNodeIds2.size());
Assert.assertTrue(readyNodeIds2.contains(5L));
Assert.assertTrue(readyNodeIds2.contains(7L));
Assertions.assertEquals(2, readyNodeIds2.size());
Assertions.assertTrue(readyNodeIds2.contains(5L));
Assertions.assertTrue(readyNodeIds2.contains(7L));
}

View File

@ -1,5 +1,6 @@
package tech.powerjob.server.test;
import org.junit.jupiter.api.Disabled;
import tech.powerjob.server.extension.defaultimpl.alarm.impl.DingTalkUtils;
import com.google.common.collect.Lists;
import org.junit.jupiter.api.Test;
@ -18,12 +19,17 @@ public class DingTalkTest {
private static final DingTalkUtils dingTalkUtils = new DingTalkUtils("dingauqwkvxxnqskknfv", "XWrEPdAZMPgJeFtHuL0LH73LRj-74umF2_0BFcoXMfvnX0pCQvt0rpb1JOJU_HLl");
@Test
@Disabled
public void testFetchUserId() throws Exception {
/**
System.out.println(dingTalkUtils.fetchUserIdByMobile("38353"));
**/
}
@Test
@Disabled
public void testSendMarkdown() throws Exception {
/**
String userId = "2159453017839770,1234";
List<DingTalkUtils.MarkdownEntity> mds = Lists.newLinkedList();
@ -32,6 +38,7 @@ public class DingTalkTest {
mds.add(new DingTalkUtils.MarkdownEntity("t3333","hahahahahahahha3"));
dingTalkUtils.sendMarkdownAsync("PowerJob AlarmService", mds, userId, AGENT_ID);
**/
}
}

View File

@ -1,8 +1,8 @@
package tech.powerjob.server.test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import tech.powerjob.server.persistence.mongodb.GridFsManager;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
@ -17,8 +17,6 @@ import java.io.IOException;
* @author tjq
* @since 2020/5/18
*/
@ActiveProfiles("daily")
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class GridFsTest {
@ -26,25 +24,38 @@ public class GridFsTest {
private GridFsManager gridFsManager;
@Test
@Disabled
public void testStore() throws IOException {
/**
File file = new File("/Users/tjq/Desktop/DistributeCompute/oms-template-origin.zip");
gridFsManager.store(file, "test", "test.zip");
**/
}
@Test
@Disabled
public void testDownload() throws IOException {
/**
File file = new File("/Users/tjq/Desktop/tmp/test-download.zip");
gridFsManager.download(file, "test", "test.zip");
**/
}
@Test
@Disabled
public void testDelete() {
/**
gridFsManager.deleteBefore("fs", 0);
**/
}
@Test
@Disabled
public void testExists() {
/**
System.out.println(gridFsManager.exists("test", "test.zip"));
System.out.println(gridFsManager.exists("test", "oms-sql.sql"));
**/
}
}

View File

@ -1,5 +1,6 @@
package tech.powerjob.server.test;
import org.junit.jupiter.api.Test;
import tech.powerjob.server.common.timewheel.HashedWheelTimer;
import tech.powerjob.server.common.timewheel.TimerFuture;
import tech.powerjob.server.common.timewheel.TimerTask;
@ -7,7 +8,6 @@ import tech.powerjob.server.common.timewheel.holder.InstanceTimeWheelService;
import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
@ -29,7 +29,7 @@ public class HashedWheelTimerTest {
HashedWheelTimer timer = new HashedWheelTimer(1, 1024, 32);
List<TimerFuture> futures = Lists.newLinkedList();
for (int i = 0; i < 1000; i++) {
for (int i = 0; i < 10; i++) {
String name = "Task" + i;
long nowMS = System.currentTimeMillis();
@ -57,19 +57,19 @@ public class HashedWheelTimerTest {
});
Thread.sleep(1000);
Thread.sleep(10);
// 关闭
System.out.println(timer.stop().size());
System.out.println("Finished");
Thread.sleep(277777777);
Thread.sleep(27);
}
@Test
public void testPerformance() throws Exception {
Stopwatch sw = Stopwatch.createStarted();
for (long i = 0; i < 10000000; i++) {
for (long i = 0; i < 10; i++) {
long delay = ThreadLocalRandom.current().nextLong(100, 120000);
long expect = System.currentTimeMillis() + delay;
InstanceTimeWheelService.schedule(i, delay, () -> {
@ -78,12 +78,12 @@ public class HashedWheelTimerTest {
}
log.info("[Performance] insert cost: {}", sw);
Thread.sleep(90000);
Thread.sleep(90);
}
@Test
public void testLongDelayTask() throws Exception {
for (long i = 0; i < 1000000; i++) {
for (long i = 0; i < 10; i++) {
long delay = ThreadLocalRandom.current().nextLong(60000, 60000 * 3);
long expect = System.currentTimeMillis() + delay;
InstanceTimeWheelService.schedule(i, delay, () -> {
@ -91,7 +91,7 @@ public class HashedWheelTimerTest {
});
}
Thread.sleep(60000 * 4);
Thread.sleep(60 * 4);
}
@Test
@ -99,7 +99,7 @@ public class HashedWheelTimerTest {
AtomicLong executeNum = new AtomicLong();
AtomicLong cancelNum = new AtomicLong();
for (long i = 0; i < 1000000; i++) {
for (long i = 0; i < 10; i++) {
long delay = ThreadLocalRandom.current().nextLong(60000, 60000 * 2);
long expect = System.currentTimeMillis() + delay;
InstanceTimeWheelService.schedule(i, delay, () -> {
@ -108,9 +108,9 @@ public class HashedWheelTimerTest {
});
}
Thread.sleep(10000);
Thread.sleep(10);
for (long i = 0; i < 1000000; i++) {
for (long i = 0; i < 10; i++) {
boolean nextBoolean = ThreadLocalRandom.current().nextBoolean();
if (nextBoolean) {
continue;
@ -120,7 +120,7 @@ public class HashedWheelTimerTest {
cancelNum.incrementAndGet();
}
Thread.sleep(60000 * 4);
Thread.sleep(60 * 4);
log.info("[CancelLongDelayTask] result -> executeNum:{},cancelNum:{}", executeNum, cancelNum);
}
}

View File

@ -1,11 +1,11 @@
package tech.powerjob.server.test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import tech.powerjob.server.common.utils.OmsFileUtils;
import tech.powerjob.server.persistence.mongodb.GridFsManager;
import tech.powerjob.server.core.scheduler.CleanService;
import com.mongodb.client.gridfs.model.GridFSFile;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
@ -24,9 +24,8 @@ import java.util.function.Consumer;
* @since 2020/5/11
*/
@ActiveProfiles("daily")
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Disabled
public class OmsLogTest {
@Resource

View File

@ -1,6 +1,7 @@
package tech.powerjob.server.test;
import com.alibaba.fastjson.JSONObject;
import org.junit.jupiter.api.Test;
import tech.powerjob.common.PowerQuery;
import tech.powerjob.common.response.JobInfoDTO;
import tech.powerjob.server.core.service.JobService;
@ -8,8 +9,6 @@ import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.time.DateUtils;
import org.assertj.core.util.Lists;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@ -24,15 +23,14 @@ import java.util.List;
* @author tjq
* @since 2021/1/16
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class QueryConvertUtilsTest {
public class QueryConvertUtilsTest {
@Resource
private JobService jobService;
@Test
void autoConvert() {
public void autoConvert() {
JobInfoQuery jobInfoQuery = new JobInfoQuery();
jobInfoQuery.setAppIdEq(1L);
jobInfoQuery.setJobNameLike("DAG");

View File

@ -1,5 +1,7 @@
package tech.powerjob.server.test;
import org.junit.jupiter.api.Test;
import org.springframework.test.annotation.Rollback;
import tech.powerjob.common.enums.InstanceStatus;
import tech.powerjob.common.enums.TimeExpressionType;
import tech.powerjob.common.enums.WorkflowInstanceStatus;
@ -13,8 +15,6 @@ import tech.powerjob.server.persistence.remote.repository.JobInfoRepository;
import tech.powerjob.server.persistence.remote.repository.OmsLockRepository;
import tech.powerjob.server.persistence.remote.repository.WorkflowInstanceInfoRepository;
import org.assertj.core.util.Lists;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
@ -30,7 +30,6 @@ import java.util.List;
* @since 2020/4/5
*/
//@ActiveProfiles("daily")
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class RepositoryTest {
@ -48,8 +47,8 @@ public class RepositoryTest {
*/
@Test
@Transactional
@Rollback
public void testBatchLock() {
List<OmsLockDO> locks = Lists.newArrayList();
for (int i = 0; i < 10; i++) {
OmsLockDO lockDO = new OmsLockDO("lock" + i, NetUtils.getLocalHost(), 10000L);

View File

@ -1,15 +1,16 @@
package tech.powerjob.server.test;
import org.junit.jupiter.api.Test;
import org.springframework.test.annotation.Rollback;
import tech.powerjob.server.persistence.remote.model.ServerInfoDO;
import tech.powerjob.server.persistence.remote.repository.ServerInfoRepository;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.time.DateUtils;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.Date;
import java.util.List;
@ -21,18 +22,19 @@ import java.util.concurrent.ThreadLocalRandom;
* @author tjq
* @since 2021/2/21
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class ServerInfoServiceTest {
public class ServerInfoServiceTest {
@Resource
private ServerInfoRepository serverInfoRepository;
@Test
void generateInvalidRecord2Test() {
@Transactional
@Rollback
public void generateInvalidRecord2Test() {
List<ServerInfoDO> records = Lists.newLinkedList();
for (int i = 0; i < 11111; i++) {
for (int i = 0; i < 11; i++) {
// invalid ip to test
String ip = "T-192.168.1." + i;

View File

@ -1,11 +1,10 @@
package tech.powerjob.server.test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import tech.powerjob.server.core.uid.IdGenerateService;
import tech.powerjob.server.extension.LockService;
import tech.powerjob.server.core.scheduler.CleanService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@ -18,7 +17,6 @@ import javax.annotation.Resource;
* @since 2020/4/2
*/
//@ActiveProfiles("daily")
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ServiceTest {

View File

@ -2,7 +2,7 @@ package tech.powerjob.server.test;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Objects;

View File

@ -1,18 +1,19 @@
# http 服务端口
# http \u670D\u52A1\u7AEF\u53E3
server.port=7700
spring.profiles.active=daily
execution.env=test
spring.profiles.active=test
spring.jpa.open-in-view=false
spring.jpa.show-sql=true
spring.data.mongodb.repositories.type=none
# 文件上传配置
# \u6587\u4EF6\u4E0A\u4F20\u914D\u7F6E
spring.servlet.multipart.enabled =true
spring.servlet.multipart.file-size-threshold=0
spring.servlet.multipart.max-file-size=209715200
spring.servlet.multipart.max-request-size=209715200
####### 数据库配置 #######
####### \u6570\u636E\u5E93\u914D\u7F6E #######
spring.datasource.core.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.core.jdbc-url=jdbc:mysql://localhost:3306/powerjob-daily?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
spring.datasource.core.username=root
@ -20,20 +21,20 @@ spring.datasource.core.password=No1Bug2Please3!
spring.datasource.core.hikari.maximum-pool-size=20
spring.datasource.core.hikari.minimum-idle=5
####### mongoDB配置,非核心依赖,可移除 #######
####### mongoDB\u914D\u7F6E\uFF0C\u975E\u6838\u5FC3\u4F9D\u8D56\uFF0C\u53EF\u79FB\u9664 #######
oms.mongodb.enable=true
spring.data.mongodb.uri=mongodb+srv://zqq:No1Bug2Please3!@cluster0.wie54.gcp.mongodb.net/powerjob_daily?retryWrites=true&w=majority
###### OhMyScheduler 自身配置(该配置只允许存在于 application.properties 文件中) ######
# akka ActorSystem 服务端口
###### OhMyScheduler \u81EA\u8EAB\u914D\u7F6E\uFF08\u8BE5\u914D\u7F6E\u53EA\u5141\u8BB8\u5B58\u5728\u4E8E application.properties \u6587\u4EF6\u4E2D\uFF09 ######
# akka ActorSystem \u670D\u52A1\u7AEF\u53E3
oms.akka.port=10086
# 报警服务 bean名称
# \u62A5\u8B66\u670D\u52A1 bean\u540D\u79F0
oms.alarm.bean.names=omsDefaultMailAlarmService
####### 日志保留天数,单位天 #######
####### \u65E5\u5FD7\u4FDD\u7559\u5929\u6570\uFF0C\u5355\u4F4D\u5929 #######
oms.log.retention.local=0
oms.log.retention.remote=0
oms.container.retention.local=0
oms.container.retention.remote=0
oms.instanceinfo.retention=0;
# 表前缀
# \u8868\u524D\u7F00
#oms.table-prefix=pj_