(improvement)(headless) Fix Windows and CentOS CI failed (#1169)

Co-authored-by: lxwcodemonkey
This commit is contained in:
LXW
2024-06-21 14:03:47 +08:00
committed by GitHub
parent 1c7b09285f
commit d9de4aabdd
7 changed files with 59 additions and 56 deletions

View File

@@ -7,14 +7,13 @@ import com.tencent.supersonic.headless.server.persistence.mapper.TagCustomMapper
import com.tencent.supersonic.headless.server.persistence.mapper.TagMapper;
import com.tencent.supersonic.headless.server.persistence.repository.TagRepository;
import com.tencent.supersonic.headless.server.pojo.TagFilter;
import java.util.List;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Objects;
@Slf4j
@Repository
public class TagRepositoryImpl implements TagRepository {

View File

@@ -39,14 +39,15 @@ import com.tencent.supersonic.headless.server.service.QueryService;
import com.tencent.supersonic.headless.server.utils.QueryReqConverter;
import com.tencent.supersonic.headless.server.utils.QueryUtils;
import com.tencent.supersonic.headless.server.utils.StatUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service
@Slf4j
@@ -95,6 +96,7 @@ public class QueryServiceImpl implements QueryService {
//2.query from cache
QueryCache queryCache = ComponentFactory.getQueryCache();
String cacheKey = queryCache.getCacheKey(queryReq);
log.info("cacheKey:{}", cacheKey);
Object query = queryCache.query(queryReq, cacheKey);
if (Objects.nonNull(query)) {
SemanticQueryResp queryResp = (SemanticQueryResp) query;

View File

@@ -18,6 +18,11 @@ import com.tencent.supersonic.headless.server.service.ModelService;
import com.tencent.supersonic.headless.server.service.QueryService;
import com.tencent.supersonic.headless.server.service.TagMetaService;
import com.tencent.supersonic.headless.server.service.TagQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@@ -26,10 +31,6 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@Service
@Slf4j

View File

@@ -1,8 +1,5 @@
package com.tencent.supersonic.headless.server.service;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import com.google.common.collect.Lists;
import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.common.pojo.DataFormat;
@@ -25,12 +22,16 @@ import com.tencent.supersonic.headless.server.service.impl.DataSetServiceImpl;
import com.tencent.supersonic.headless.server.service.impl.MetricServiceImpl;
import com.tencent.supersonic.headless.server.utils.AliasGenerateHelper;
import com.tencent.supersonic.headless.server.utils.MetricConverter;
import java.util.HashMap;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.context.ApplicationEventPublisher;
import java.util.HashMap;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
public class MetricServiceImplTest {
@Test

View File

@@ -1,10 +1,5 @@
package com.tencent.supersonic.headless;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.common.pojo.Aggregator;
import com.tencent.supersonic.common.pojo.Filter;
@@ -15,26 +10,36 @@ import com.tencent.supersonic.common.pojo.enums.QueryType;
import com.tencent.supersonic.common.pojo.exception.InvalidPermissionException;
import com.tencent.supersonic.headless.api.pojo.request.QueryStructReq;
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
import com.tencent.supersonic.headless.core.cache.QueryCache;
import com.tencent.supersonic.headless.core.utils.ComponentFactory;
import com.tencent.supersonic.util.DataUtils;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
@Slf4j
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class QueryByStructTest extends BaseTest {
@Test
@Order(1)
public void testCacheQuery() throws Exception {
@Order(0)
public void testCacheQuery() {
QueryStructReq queryStructReq1 = buildQueryStructReq(Arrays.asList("department"));
QueryStructReq queryStructReq2 = buildQueryStructReq(Arrays.asList("department"));
queryService.queryByReq(queryStructReq1, User.getFakeUser());
SemanticQueryResp result2 = queryService.queryByReq(queryStructReq2, User.getFakeUser());
assertTrue(result2.isUseCache());
QueryCache queryCache = ComponentFactory.getQueryCache();
String cacheKey1 = queryCache.getCacheKey(queryStructReq1);
String cacheKey2 = queryCache.getCacheKey(queryStructReq2);
Assertions.assertEquals(cacheKey1, cacheKey2);
}
@Test

View File

@@ -1,24 +0,0 @@
package com.tencent.supersonic.headless;
import static org.junit.Assert.assertTrue;
import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.headless.api.pojo.request.ItemValueReq;
import com.tencent.supersonic.headless.api.pojo.response.ItemValueResp;
import com.tencent.supersonic.headless.server.service.TagQueryService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class QueryTagValueTest extends BaseTest {
@Autowired
protected TagQueryService tagQueryService;
@Test
public void testQueryTagValue() throws Exception {
ItemValueReq itemValueReq = new ItemValueReq();
itemValueReq.setId(1L);
ItemValueResp itemValueResp = tagQueryService.queryTagValue(itemValueReq, User.getFakeUser());
assertTrue(itemValueResp != null);
}
}

View File

@@ -3,26 +3,35 @@ package com.tencent.supersonic.headless;
import com.github.pagehelper.PageInfo;
import com.tencent.supersonic.auth.api.authentication.pojo.User;
import com.tencent.supersonic.headless.api.pojo.enums.TagDefineType;
import com.tencent.supersonic.headless.api.pojo.request.ItemValueReq;
import com.tencent.supersonic.headless.api.pojo.request.TagDeleteReq;
import com.tencent.supersonic.headless.api.pojo.request.TagFilterPageReq;
import com.tencent.supersonic.headless.api.pojo.request.TagReq;
import com.tencent.supersonic.headless.api.pojo.response.ItemValueResp;
import com.tencent.supersonic.headless.api.pojo.response.TagResp;
import com.tencent.supersonic.headless.server.pojo.TagFilter;
import com.tencent.supersonic.headless.server.service.TagMetaService;
import com.tencent.supersonic.headless.server.service.TagQueryService;
import org.junit.Assert;
import org.junit.Before;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class TagTest extends BaseTest {
@Autowired
private TagMetaService tagMetaService;
@Autowired
private TagQueryService tagQueryService;
private User user = User.getFakeUser();
public TagReq newTagReq() {
@@ -46,7 +55,6 @@ public class TagTest extends BaseTest {
return tagReq;
}
@Before
public void setUp() {
TagDeleteReq tagDeleteReq = new TagDeleteReq();
tagDeleteReq.setTagDefineType(TagDefineType.DIMENSION);
@@ -56,6 +64,7 @@ public class TagTest extends BaseTest {
tagMetaService.deleteBatch(tagDeleteReqList, user);
}
@Order(1)
@Test
public void testCreateTag() {
setUp();
@@ -78,6 +87,7 @@ public class TagTest extends BaseTest {
Assert.assertEquals(0, tags1.size());
}
@Order(2)
@Test
public void testTagMarket() {
setUp();
@@ -100,4 +110,13 @@ public class TagTest extends BaseTest {
tagMetaService.deleteBatch(tagDeleteReqList, user);
}
@Test
@Order(0)
public void testQueryTagValue() throws Exception {
ItemValueReq itemValueReq = new ItemValueReq();
itemValueReq.setId(1L);
ItemValueResp itemValueResp = tagQueryService.queryTagValue(itemValueReq, user);
Assertions.assertNotNull(itemValueResp);
}
}