You've already forked FrameTour-BE
test~
This commit is contained in:
@ -0,0 +1,52 @@
|
||||
package com.ycwl.basic.facebody.adapter;
|
||||
|
||||
import com.ycwl.basic.facebody.entity.AliFaceBodyConfig;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class AliFaceBodyAdapterTest {
|
||||
private AliFaceBodyAdapter getAdapter() {
|
||||
AliFaceBodyAdapter adapter = new AliFaceBodyAdapter();
|
||||
AliFaceBodyConfig config = new AliFaceBodyConfig();
|
||||
config.setAccessKeyId("LTAI5tMwrmxVcUEKoH5QzLHx");
|
||||
config.setAccessKeySecret("ZCIP8aKx1jwX1wkeYIPQEDZ8fPtN1c");
|
||||
config.setRegion("cn-shanghai");
|
||||
adapter.setConfig(config);
|
||||
return adapter;
|
||||
};
|
||||
@Test
|
||||
public void test() {
|
||||
// String dbName = "3940097994925412352";
|
||||
String dbName = "3975985126059413504";
|
||||
AliFaceBodyAdapter adapter = getAdapter();
|
||||
while (true) {
|
||||
AtomicInteger count = new AtomicInteger(0);
|
||||
List<String> strings = adapter.listFace(dbName, "", 0, 200);
|
||||
if (strings == null || strings.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for (String s : strings) {
|
||||
if (StringUtils.contains(s, "_")) {
|
||||
count.incrementAndGet();
|
||||
System.out.println(s);
|
||||
adapter.deleteFace(dbName, s);
|
||||
}
|
||||
}
|
||||
if (count.get() == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteDb() {
|
||||
AliFaceBodyAdapter adapter = getAdapter();
|
||||
adapter.deleteFaceDb("userFace3972138108618674176");
|
||||
}
|
||||
}
|
@ -1,19 +1,37 @@
|
||||
package com.ycwl.basic.facebody.adapter;
|
||||
|
||||
import com.ycwl.basic.facebody.entity.AddFaceResp;
|
||||
import com.ycwl.basic.facebody.entity.BceFaceBodyConfig;
|
||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
import com.ycwl.basic.model.pc.faceSample.req.FaceSampleReqQuery;
|
||||
import com.ycwl.basic.model.pc.faceSample.resp.FaceSampleRespVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
public class BceFaceBodyAdapterTest {
|
||||
@Autowired
|
||||
private FaceSampleMapper faceSampleMapper;
|
||||
|
||||
private BceFaceBodyAdapter getAdapter() {
|
||||
BceFaceBodyAdapter adapter = new BceFaceBodyAdapter();
|
||||
BceFaceBodyConfig config = new BceFaceBodyConfig();
|
||||
config.setAppId("118363478");
|
||||
config.setApiKey("3rXrDdU4cHZqLS8ICFSYZKse");
|
||||
config.setSecretKey("zgGFehERZKYXEiRQpqWs9AYchLxzXzYa");
|
||||
config.setAppId("118363836");
|
||||
config.setApiKey("J2IRPrGFQWNeMtYFr6bgr6XO");
|
||||
config.setSecretKey("Gp6dx0ngG1VZN8Ono3y4kCgKo6nhURK8");
|
||||
config.setAddQps(9.9f);
|
||||
config.setSearchQps(9.9f);
|
||||
adapter.setConfig(config);
|
||||
return adapter;
|
||||
}
|
||||
@ -46,4 +64,27 @@ public class BceFaceBodyAdapterTest {
|
||||
List<String> listFace = adapter.listFace("test", null, 0, 10);
|
||||
assertTrue(listFace.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMigrateToBCE() {
|
||||
BceFaceBodyAdapter adapter = getAdapter();
|
||||
long scenicId = 3972138108618674176L;
|
||||
adapter.assureFaceDb(String.valueOf(scenicId));
|
||||
FaceSampleReqQuery query = new FaceSampleReqQuery();
|
||||
query.setScenicId(scenicId);
|
||||
List<FaceSampleRespVO> list = faceSampleMapper.list(query);
|
||||
list.parallelStream().forEach(faceSampleRespVO -> {
|
||||
AddFaceResp addFaceResp = adapter.addFace(String.valueOf(scenicId), faceSampleRespVO.getId().toString(), faceSampleRespVO.getFaceUrl(), faceSampleRespVO.getId().toString());
|
||||
if (addFaceResp == null) {
|
||||
addFaceResp = adapter.addFace(String.valueOf(scenicId), faceSampleRespVO.getId().toString(), faceSampleRespVO.getFaceUrl(), faceSampleRespVO.getId().toString());
|
||||
if (addFaceResp == null) {
|
||||
log.error("当前景区{},人脸样本ID{},迁移失败", scenicId, faceSampleRespVO.getId());
|
||||
} else {
|
||||
log.info("当前景区{},人脸样本ID{},迁移1成功", scenicId, faceSampleRespVO.getId());
|
||||
}
|
||||
} else {
|
||||
log.info("当前景区{},人脸样本ID{},迁移成功", scenicId, faceSampleRespVO.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -34,6 +34,13 @@ public class FaceCleanerTest {
|
||||
private FaceSampleMapper faceSampleMapper;
|
||||
@Autowired
|
||||
private ScenicMapper scenicMapper;
|
||||
@Autowired
|
||||
private FaceCleaner faceCleaner;
|
||||
|
||||
@Test
|
||||
public void testC() {
|
||||
faceCleaner.cleanSourceOss();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
@ -41,33 +48,7 @@ public class FaceCleanerTest {
|
||||
List<ScenicRespVO> scenicList = scenicMapper.list(scenicQuery);
|
||||
scenicList.forEach(scenic -> {
|
||||
log.info("当前景区{},开始删除人脸样本", scenic.getName());
|
||||
taskFaceService.batchDeleteExpiredFace(scenic.getId());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testC() {
|
||||
List<List<Integer>> list = Arrays.asList(Arrays.asList(1,2,3), Arrays.asList(4,5,6), Arrays.asList(7,8,9), Arrays.asList(10,11,12));
|
||||
ThreadPoolExecutor executor = new ThreadPoolExecutor(8, 16, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(16));
|
||||
list.parallelStream().forEach(integers -> {
|
||||
executor.execute(() -> {
|
||||
integers.forEach(integer -> {
|
||||
executor.execute(() -> {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
log.info("{}", integer);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
executor.shutdown();
|
||||
executor.awaitTermination(1, TimeUnit.MINUTES);
|
||||
} catch (InterruptedException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
22
src/test/java/com/ycwl/basic/utils/VideoReUploaderTest.java
Normal file
22
src/test/java/com/ycwl/basic/utils/VideoReUploaderTest.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.ycwl.basic.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@Slf4j
|
||||
@SpringBootTest
|
||||
@RunWith(SpringRunner.class)
|
||||
public class VideoReUploaderTest {
|
||||
@Autowired
|
||||
private VideoReUploader videoReUploader;
|
||||
|
||||
@Test
|
||||
public void testReUpload() throws InterruptedException {
|
||||
videoReUploader.addTask(3975968518398152704L);
|
||||
Thread.sleep(1_000_000L);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user