|
|
|
@ -29,7 +29,6 @@ import org.apache.dolphinscheduler.common.enums.WarningType;
|
|
|
|
|
import org.apache.dolphinscheduler.common.utils.DateUtils; |
|
|
|
|
import org.apache.dolphinscheduler.dao.BaseDaoTest; |
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.Command; |
|
|
|
|
import org.apache.dolphinscheduler.dao.mapper.CommandMapper; |
|
|
|
|
import org.apache.dolphinscheduler.dao.repository.CommandDao; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.RandomUtils; |
|
|
|
@ -39,34 +38,28 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.RepeatedTest; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.test.annotation.DirtiesContext; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
|
|
|
|
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD) |
|
|
|
|
class CommandDaoImplTest extends BaseDaoTest { |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private CommandDao commandDao; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private CommandMapper commandMapper; |
|
|
|
|
|
|
|
|
|
@RepeatedTest(value = 100) |
|
|
|
|
@RepeatedTest(value = 10) |
|
|
|
|
void fetchCommandByIdSlot() { |
|
|
|
|
// clear all commands
|
|
|
|
|
commandMapper.delete(new QueryWrapper<Command>().ge("id", -1)); |
|
|
|
|
|
|
|
|
|
int totalSlot = RandomUtils.nextInt(1, 10); |
|
|
|
|
int currentSlotIndex = RandomUtils.nextInt(0, totalSlot); |
|
|
|
|
int fetchSize = RandomUtils.nextInt(10, 100); |
|
|
|
|
int idStep = RandomUtils.nextInt(1, 5); |
|
|
|
|
int commandSize = RandomUtils.nextInt(currentSlotIndex, 1000); |
|
|
|
|
// Generate commandSize commands
|
|
|
|
|
int id = 0; |
|
|
|
|
int id = 1; |
|
|
|
|
for (int j = 0; j < commandSize; j++) { |
|
|
|
|
id += idStep; |
|
|
|
|
Command command = generateCommand(CommandType.START_PROCESS, 0); |
|
|
|
|
command.setId(id); |
|
|
|
|
commandDao.insert(command); |
|
|
|
|
id += idStep; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<Command> commands = commandDao.queryCommandByIdSlot(currentSlotIndex, totalSlot, idStep, fetchSize); |
|
|
|
|