Merge pull request #2995 from alibaba/perf_config_notify

[#ISSUE 2994] Perf config notify
This commit is contained in:
TsingLiang 2020-06-10 10:06:37 +08:00 committed by GitHub
commit 510ffb5599
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 189 additions and 136 deletions

View File

@ -29,6 +29,7 @@ before_install:
script:
- mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true
- mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
- mvn clean install -Pcit-test
- mvn clean package -Pit-test
after_success:
- mvn clean package -Pit-test

View File

@ -179,6 +179,13 @@ public final class CollectionUtils {
}
}
public static <T> boolean contains(Collection<T> coll, T target) {
if (isEmpty(coll)) {
return false;
}
return coll.contains(target);
}
/**
* Null-safe check if the specified collection is empty.
* <p>

View File

@ -21,7 +21,6 @@ import com.alibaba.nacos.common.utils.MapUtils;
import com.alibaba.nacos.config.server.auth.ConfigResourceParser;
import com.alibaba.nacos.config.server.constant.Constants;
import com.alibaba.nacos.config.server.controller.parameters.SameNamespaceCloneConfigBean;
import com.alibaba.nacos.config.server.filter.ToLeader;
import com.alibaba.nacos.config.server.model.ConfigAdvanceInfo;
import com.alibaba.nacos.config.server.model.ConfigAllInfo;
import com.alibaba.nacos.config.server.model.ConfigInfo;
@ -34,6 +33,7 @@ import com.alibaba.nacos.config.server.result.ResultBuilder;
import com.alibaba.nacos.config.server.result.code.ResultCodeEnum;
import com.alibaba.nacos.config.server.service.AggrWhitelist;
import com.alibaba.nacos.config.server.model.event.ConfigDataChangeEvent;
import com.alibaba.nacos.config.server.service.ConfigChangePublisher;
import com.alibaba.nacos.config.server.service.ConfigSubService;
import com.alibaba.nacos.config.server.service.repository.PersistService;
import com.alibaba.nacos.config.server.service.trace.ConfigTraceService;
@ -42,7 +42,6 @@ import com.alibaba.nacos.config.server.utils.ParamUtils;
import com.alibaba.nacos.config.server.utils.RequestUtil;
import com.alibaba.nacos.config.server.utils.TimeUtils;
import com.alibaba.nacos.config.server.utils.ZipUtils;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher;
import com.alibaba.nacos.core.auth.ActionTypes;
import com.alibaba.nacos.core.auth.Secured;
import com.alibaba.nacos.core.utils.InetUtils;
@ -113,17 +112,16 @@ public class ConfigController {
}
/**
* 增加或更新非聚合数据
* Adds or updates non-aggregated data.
*
* @throws NacosException
*/
@PostMapping
@ToLeader
@Secured(action = ActionTypes.WRITE, parser = ConfigResourceParser.class)
public Boolean publishConfig(HttpServletRequest request, HttpServletResponse response,
@RequestParam("dataId") String dataId, @RequestParam("group") String group,
@RequestParam(value = "dataId") String dataId, @RequestParam(value = "group") String group,
@RequestParam(value = "tenant", required = false, defaultValue = StringUtils.EMPTY) String tenant,
@RequestParam("content") String content,
@RequestParam(value = "content") String content,
@RequestParam(value = "tag", required = false) String tag,
@RequestParam(value = "appName", required = false) String appName,
@RequestParam(value = "src_user", required = false) String srcUser,
@ -165,16 +163,19 @@ public class ConfigController {
if (StringUtils.isBlank(tag)) {
persistService.insertOrUpdate(srcIp, srcUser, configInfo, time,
configAdvanceInfo, true);
ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent(false, dataId, group, tenant, time.getTime()));
}
else {
persistService
.insertOrUpdateTag(configInfo, tag, srcIp, srcUser, time, true);
ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent(false, dataId, group, tenant, tag, time.getTime()));
}
}
else {
// beta publish
persistService
.insertOrUpdateBeta(configInfo, betaIps, srcIp, srcUser, time, true);
ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent(true, dataId, group, tenant, time.getTime()));
}
ConfigTraceService.logPersistenceEvent(dataId, group, tenant, requestIpApp, time.getTime(),
InetUtils.getSelfIp(), ConfigTraceService.PERSISTENCE_EVENT_PUB, content);
@ -182,7 +183,7 @@ public class ConfigController {
}
/**
* 取数据
* get configure board infomation fail
*
* @throws ServletException
* @throws IOException
@ -207,7 +208,7 @@ public class ConfigController {
}
/**
* 取数据
* Get the specific configuration information that the console USES
*
* @throws NacosException
*/
@ -226,12 +227,11 @@ public class ConfigController {
}
/**
* 同步删除某个dataId下面所有的聚合前数据
* Synchronously delete all pre-aggregation data under a dataId
*
* @throws NacosException
*/
@DeleteMapping
@ToLeader
@Secured(action = ActionTypes.WRITE, parser = ConfigResourceParser.class)
public Boolean deleteConfig(HttpServletRequest request, HttpServletResponse response,
@RequestParam("dataId") String dataId, //
@ -255,6 +255,7 @@ public class ConfigController {
ConfigTraceService
.logPersistenceEvent(dataId, group, tenant, null, time.getTime(),
clientIp, ConfigTraceService.PERSISTENCE_EVENT_REMOVE, null);
ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent(false, dataId, group, tenant, tag, time.getTime()));
return true;
}
@ -266,7 +267,6 @@ public class ConfigController {
* @Param [request, response, dataId, group, tenant, tag]
*/
@DeleteMapping(params = "delType=ids")
@ToLeader
@Secured(action = ActionTypes.WRITE, parser = ConfigResourceParser.class)
public RestResult<Boolean> deleteConfigs(HttpServletRequest request,
HttpServletResponse response, @RequestParam(value = "ids") List<Long> ids) {
@ -276,6 +276,8 @@ public class ConfigController {
.removeConfigInfoByIds(ids, clientIp, null);
if (!CollectionUtils.isEmpty(configInfoList)) {
for (ConfigInfo configInfo : configInfoList) {
ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(), time.getTime()));
ConfigTraceService.logPersistenceEvent(configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(), null,
time.getTime(), clientIp,
@ -299,7 +301,7 @@ public class ConfigController {
}
/**
* 比较MD5
* The client listens for configuration changes
*/
@PostMapping("/listener")
@Secured(action = ActionTypes.READ, parser = ConfigResourceParser.class)
@ -326,7 +328,7 @@ public class ConfigController {
}
/**
* 订阅改配置的客户端信息
* Subscribe to configured client information
*/
@GetMapping("/listener")
@Secured(action = ActionTypes.READ, parser = ConfigResourceParser.class)
@ -348,7 +350,7 @@ public class ConfigController {
}
/**
* 查询配置信息返回JSON格式
* Query the configuration information and return it in JSON format.
*/
@GetMapping(params = "search=accurate")
@Secured(action = ActionTypes.READ, parser = ConfigResourceParser.class)
@ -379,7 +381,8 @@ public class ConfigController {
}
/**
* 模糊查询配置信息不允许只根据内容模糊查询即dataId和group都为NULL但content不是NULL这种情况下返回所有配置
* Fuzzy query configuration information. Fuzzy queries based only on content are not allowed, that is,
* both dataId and group are NULL, but content is not NULL. In this case, all configurations are returned.
*/
@GetMapping(params = "search=blur")
@Secured(action = ActionTypes.READ, parser = ConfigResourceParser.class)
@ -410,7 +413,6 @@ public class ConfigController {
}
@DeleteMapping(params = "beta=true")
@ToLeader
@Secured(action = ActionTypes.WRITE, parser = ConfigResourceParser.class)
public RestResult<Boolean> stopBeta(@RequestParam(value = "dataId") String dataId,
@RequestParam(value = "group") String group,
@ -426,6 +428,7 @@ public class ConfigController {
rr.setMessage("remove beta data error");
return rr;
}
ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent(true, dataId, group, tenant, System.currentTimeMillis()));
rr.setCode(200);
rr.setData(true);
rr.setMessage("stop beta ok");
@ -504,7 +507,6 @@ public class ConfigController {
}
@PostMapping(params = "import=true")
@ToLeader
@Secured(action = ActionTypes.WRITE, parser = ConfigResourceParser.class)
public RestResult<Map<String, Object>> importAndPublishConfig(
HttpServletRequest request,
@ -593,7 +595,7 @@ public class ConfigController {
.batchInsertOrUpdate(configInfoList, srcUser, srcIp, null, time, false,
policy);
for (ConfigInfo configInfo : configInfoList) {
EventDispatcher.fireEvent(
ConfigChangePublisher.notifyConfigChange(
new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(),
time.getTime()));
@ -607,7 +609,6 @@ public class ConfigController {
}
@PostMapping(params = "clone=true")
@ToLeader
@Secured(action = ActionTypes.WRITE, parser = ConfigResourceParser.class)
public RestResult<Map<String, Object>> cloneConfig(HttpServletRequest request,
@RequestParam(value = "src_user", required = false) String srcUser,
@ -681,7 +682,7 @@ public class ConfigController {
.batchInsertOrUpdate(configInfoList4Clone, srcUser, srcIp, null, time,
false, policy);
for (ConfigInfo configInfo : configInfoList4Clone) {
EventDispatcher.fireEvent(
ConfigChangePublisher.notifyConfigChange(
new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(),
time.getTime()));
@ -691,7 +692,7 @@ public class ConfigController {
InetUtils.getSelfIp(), ConfigTraceService.PERSISTENCE_EVENT_PUB,
configInfo.getContent());
}
return ResultBuilder.buildSuccessResult("克隆成功", saveResult);
return ResultBuilder.buildSuccessResult("Clone Completed Successfully", saveResult);
}
private String processTenant(String tenant) {

View File

@ -14,14 +14,23 @@
* limitations under the License.
*/
package com.alibaba.nacos.config.server.filter;
package com.alibaba.nacos.config.server.service;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import com.alibaba.nacos.config.server.model.event.ConfigDataChangeEvent;
import com.alibaba.nacos.config.server.utils.PropertyUtil;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher;
import com.alibaba.nacos.core.utils.ApplicationUtils;
/**
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface ToLeader {
public class ConfigChangePublisher {
public static void notifyConfigChange(ConfigDataChangeEvent event) {
if (PropertyUtil.isEmbeddedStorage() && !ApplicationUtils.getStandaloneMode()) {
return;
}
EventDispatcher.fireEvent(event);
}
}

View File

@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.config.server.service;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.ExceptionUtil;
import com.alibaba.nacos.config.server.model.SampleResult;
import com.alibaba.nacos.config.server.model.event.LocalDataChangeEvent;
import com.alibaba.nacos.config.server.monitor.MetricsMonitor;
@ -308,7 +310,7 @@ public class LongPollingService extends AbstractEventListener {
ClientLongPolling clientSub = iter.next();
if (clientSub.clientMd5Map.containsKey(groupKey)) {
// 如果beta发布且不在beta列表直接跳过
if (isBeta && !betaIps.contains(clientSub.ip)) {
if (isBeta && !CollectionUtils.contains(betaIps, clientSub.ip)) {
continue;
}
@ -329,14 +331,10 @@ public class LongPollingService extends AbstractEventListener {
}
}
} catch (Throwable t) {
LogUtil.defaultLog.error("data change error:" + t.getMessage(), t.getCause());
LogUtil.defaultLog.error("data change error: {}", ExceptionUtil.getStackTrace(t));
}
}
DataChangeTask(String groupKey) {
this(groupKey, false, null);
}
DataChangeTask(String groupKey, boolean isBeta, List<String> betaIps) {
this(groupKey, isBeta, betaIps, null);
}
@ -475,6 +473,14 @@ public class LongPollingService extends AbstractEventListener {
final long timeoutTime;
Future<?> asyncTimeoutFuture;
@Override
public String toString() {
return "ClientLongPolling{" + "clientMd5Map=" + clientMd5Map + ", createTime="
+ createTime + ", ip='" + ip + '\'' + ", appName='" + appName + '\''
+ ", tag='" + tag + '\'' + ", probeRequestSize=" + probeRequestSize
+ ", timeoutTime=" + timeoutTime + '}';
}
}
void generateResponse(HttpServletRequest request, HttpServletResponse response, List<String> changedGroups) {

View File

@ -38,15 +38,12 @@ import com.alibaba.nacos.config.server.model.Page;
import com.alibaba.nacos.config.server.model.SameConfigPolicy;
import com.alibaba.nacos.config.server.model.SubInfo;
import com.alibaba.nacos.config.server.model.TenantInfo;
import com.alibaba.nacos.config.server.model.event.ConfigDataChangeEvent;
import com.alibaba.nacos.config.server.service.datasource.DataSourceService;
import com.alibaba.nacos.config.server.service.datasource.DynamicDataSource;
import com.alibaba.nacos.config.server.service.sql.EmbeddedStorageContextUtils;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.config.server.utils.ParamUtils;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher;
import com.alibaba.nacos.core.distributed.id.IdGeneratorManager;
import com.alibaba.nacos.core.utils.ApplicationUtils;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
@ -386,12 +383,6 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
else {
updateConfigInfo4Beta(configInfo, betaIps, srcIp, null, time, notify);
}
if (ApplicationUtils.getStandaloneMode()) {
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(true, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(),
time.getTime()));
}
}
public void insertOrUpdateTag(final ConfigInfo configInfo, final String tag,
@ -404,12 +395,6 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
else {
updateConfigInfo4Tag(configInfo, tag, srcIp, null, time, notify);
}
if (ApplicationUtils.getStandaloneMode()) {
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(), tag,
time.getTime()));
}
}
public void updateMd5(String dataId, String group, String tenant, String md5,
@ -448,12 +433,6 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
else {
updateConfigInfo(configInfo, srcIp, srcUser, time, configAdvanceInfo, notify);
}
if (ApplicationUtils.getStandaloneMode()) {
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(),
time.getTime()));
}
}
public void insertOrUpdateSub(SubInfo subInfo) {

View File

@ -38,13 +38,10 @@ import com.alibaba.nacos.config.server.model.Page;
import com.alibaba.nacos.config.server.model.SameConfigPolicy;
import com.alibaba.nacos.config.server.model.SubInfo;
import com.alibaba.nacos.config.server.model.TenantInfo;
import com.alibaba.nacos.config.server.model.event.ConfigDataChangeEvent;
import com.alibaba.nacos.config.server.service.datasource.DataSourceService;
import com.alibaba.nacos.config.server.service.datasource.DynamicDataSource;
import com.alibaba.nacos.config.server.service.trace.ConfigTraceService;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.config.server.utils.ParamUtils;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
@ -184,12 +181,6 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
addConfigTagsRelation(configId, configTags, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant());
insertConfigHistoryAtomic(0, configInfo, srcIp, srcUser, time, "I");
if (notify) {
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(),
time.getTime()));
}
}
catch (CannotGetJdbcConnectionException e) {
LogUtil.fatalLog.error("[db-error] " + e.toString(), e);
@ -349,10 +340,6 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
updateConfigInfo4Beta(configInfo, betaIps, srcIp, null, time,
notify);
}
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(true, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(),
time.getTime()));
}
public void insertOrUpdateTag(final ConfigInfo configInfo,
@ -364,10 +351,6 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
catch (DataIntegrityViolationException ive) { // 唯一性约束冲突
updateConfigInfo4Tag(configInfo, tag, srcIp, null, time, notify);
}
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(), tag,
time.getTime()));
}
/**
@ -406,10 +389,6 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
updateConfigInfo(configInfo, srcIp, srcUser, time, configAdvanceInfo,
notify);
}
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(),
time.getTime()));
}
/**
@ -452,9 +431,6 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
return Boolean.TRUE;
}
});
EventDispatcher.fireEvent(new ConfigDataChangeEvent(false, dataId, group, tenant,
System.currentTimeMillis()));
}
/**
@ -496,20 +472,6 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
}
}
});
if (!CollectionUtils.isEmpty(result)) {
long currentTime = System.currentTimeMillis();
for (ConfigInfo configInfo : result) {
ConfigTraceService.logPersistenceEvent(configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(), null, currentTime,
srcIp, ConfigTraceService.PERSISTENCE_EVENT_REMOVE, null);
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(),
currentTime));
}
}
return result;
}
@ -519,27 +481,21 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
public void removeConfigInfo4Beta(final String dataId, final String group,
final String tenant) {
final String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant;
tjt.execute(new TransactionCallback<Boolean>() {
@Override
public Boolean doInTransaction(TransactionStatus status) {
try {
ConfigInfo configInfo = findConfigInfo4Beta(dataId, group, tenant);
if (configInfo != null) {
jt.update(
"DELETE FROM config_info_beta WHERE data_id=? AND group_id=? AND tenant_id=?",
dataId, group, tenantTmp);
}
tjt.execute(status -> {
try {
ConfigInfo configInfo = findConfigInfo4Beta(dataId, group, tenant);
if (configInfo != null) {
jt.update(
"DELETE FROM config_info_beta WHERE data_id=? AND group_id=? AND tenant_id=?",
dataId, group, tenantTmp);
}
catch (CannotGetJdbcConnectionException e) {
LogUtil.fatalLog.error("[db-error] " + e.toString(), e);
throw e;
}
return Boolean.TRUE;
}
catch (CannotGetJdbcConnectionException e) {
LogUtil.fatalLog.error("[db-error] " + e.toString(), e);
throw e;
}
return Boolean.TRUE;
});
EventDispatcher.fireEvent(new ConfigDataChangeEvent(true, dataId, group, tenant,
System.currentTimeMillis()));
}
// ----------------------- config_aggr_info insert update delete
@ -2688,9 +2644,6 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
LogUtil.fatalLog.error("[db-error] " + e.toString(), e);
throw e;
}
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(false, dataId, group, tenant, tag,
System.currentTimeMillis()));
}
/**

View File

@ -0,0 +1,69 @@
package com.alibaba.nacos.config.server.service;
import com.alibaba.nacos.config.server.model.event.ConfigDataChangeEvent;
import com.alibaba.nacos.config.server.utils.PropertyUtil;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher;
import com.alibaba.nacos.core.utils.ApplicationUtils;
import org.junit.Assert;
import org.junit.Test;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
public class ConfigChangePublisherTest {
@Test
public void testConfigChangeNotify() {
AtomicReference<ConfigDataChangeEvent> reference = new AtomicReference<>();
EventDispatcher.addEventListener(new EventDispatcher.AbstractEventListener() {
@Override
public List<Class<? extends EventDispatcher.Event>> interest() {
return Collections.singletonList(ConfigDataChangeEvent.class);
}
@Override
public void onEvent(EventDispatcher.Event event) {
reference.set((ConfigDataChangeEvent) event);
}
});
// nacos is standalone mode and use embedded storage
ApplicationUtils.setIsStandalone(true);
PropertyUtil.setEmbeddedStorage(true);
ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent("chuntaojun", "chuntaojun", System.currentTimeMillis()));
Assert.assertNotNull(reference.get());
reference.set(null);
// nacos is standalone mode and use external storage
ApplicationUtils.setIsStandalone(true);
PropertyUtil.setEmbeddedStorage(false);
ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent("chuntaojun", "chuntaojun", System.currentTimeMillis()));
Assert.assertNotNull(reference.get());
reference.set(null);
// nacos is cluster mode and use embedded storage
ApplicationUtils.setIsStandalone(false);
PropertyUtil.setEmbeddedStorage(true);
ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent("chuntaojun", "chuntaojun", System.currentTimeMillis()));
Assert.assertNull(reference.get());
reference.set(null);
// nacos is cluster mode and use external storage
ApplicationUtils.setIsStandalone(false);
PropertyUtil.setEmbeddedStorage(false);
ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent("chuntaojun", "chuntaojun", System.currentTimeMillis()));
Assert.assertNotNull(reference.get());
reference.set(null);
}
}

28
pom.xml
View File

@ -460,6 +460,34 @@
</build>
</profile>
<profile>
<!-- Run integration tests for configuration modules separately -->
<id>cit-test</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<argLine>@{failsafeArgLine}</argLine>
<argLine>-Dnacos.standalone=true</argLine>
<includes>
<include>**/*CITCase.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- Run integration tests for all modules separately -->
<id>it-test</id>
<build>
<plugins>

View File

@ -50,9 +50,9 @@ import java.util.concurrent.atomic.AtomicInteger;
* @author xiaochun.xxc
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Nacos.class, properties = {"server.servlet.context-path=/nacos"},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ConfigAPI_ITCase {
@SpringBootTest(classes = Nacos.class, properties = {"server.servlet.context-path=/nacos", "server.port=7001"},
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class ConfigAPI_CITCase {
public static final long TIME_OUT = 5000;
static ConfigService iconfig = null;
@ -378,7 +378,7 @@ public class ConfigAPI_ITCase {
* @author xiaochun.xxc
* @since 3.6.8
*/
@Test(timeout = 5 * TIME_OUT)
@Test(timeout = Constants.CONFIG_LONG_POLL_TIMEOUT << 2)
public void nacos_addListener_3() throws InterruptedException, NacosException {
final AtomicInteger count = new AtomicInteger(0);
final String dataId = "nacos_addListener_3";
@ -386,7 +386,6 @@ public class ConfigAPI_ITCase {
final String content = "test-abc";
final String newContent = "nacos_addListener_3";
boolean result = iconfig.publishConfig(dataId, group, content);
Thread.sleep(TIME_OUT);
Assert.assertTrue(result);
Listener ml = new AbstractListener() {
@ -399,9 +398,6 @@ public class ConfigAPI_ITCase {
iconfig.addListener(dataId, group, ml);
result = iconfig.publishConfig(dataId, group, newContent);
Assert.assertTrue(result);
while (count.get() == 0) {
Thread.sleep(2000);
}
// Get enough sleep to ensure that the monitor is triggered only once
// during the two long training sessions
ThreadUtils.sleep(Constants.CONFIG_LONG_POLL_TIMEOUT << 1);

View File

@ -19,6 +19,7 @@ package com.alibaba.nacos.test.config;
import com.alibaba.nacos.Nacos;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.common.utils.JacksonUtils;
import com.alibaba.nacos.common.utils.ThreadUtils;
import com.alibaba.nacos.test.base.Params;
import org.junit.Assert;
import org.junit.Before;
@ -41,9 +42,9 @@ import org.springframework.web.util.UriComponentsBuilder;
* @date 2019-07-03
**/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Nacos.class, properties = {"server.servlet.context-path=/nacos"},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ConfigBeta_ITCase {
@SpringBootTest(classes = Nacos.class, properties = {"server.servlet.context-path=/nacos", "server.port=7002"},
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class ConfigBeta_CITCase {
@LocalServerPort
private int port;
@ -178,6 +179,8 @@ public class ConfigBeta_ITCase {
Assert.assertTrue(response.getStatusCode().is2xxSuccessful());
Assert.assertEquals("true", response.getBody());
ThreadUtils.sleep(10_000L);
ResponseEntity<String> response1 = request(CONFIG_CONTROLLER_PATH + "/configs?beta=false",
Params.newParams()
.appendParam("dataId", dataId)

View File

@ -41,9 +41,9 @@ import java.util.*;
* @date 2019/5/23 15:26
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Nacos.class, properties = {"server.servlet.context-path=/nacos"},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ConfigExportAndImportAPI_ITCase {
@SpringBootTest(classes = Nacos.class, properties = {"server.servlet.context-path=/nacos", "server.port=7003"},
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class ConfigExportAndImportAPI_CITCase {
private static final long TIME_OUT = 2000;
private static final String CONFIG_CONTROLLER_PATH = "/v1/cs/configs";
@ -121,7 +121,7 @@ public class ConfigExportAndImportAPI_ITCase {
}
}
@Test(timeout = 3*TIME_OUT)
@Test()
public void testExportByIds(){
String getDataUrl = "?search=accurate&dataId=&group=&appName=&config_tags=&pageNo=1&pageSize=10&tenant=&namespaceId=";
String queryResult = httpClient.get(SERVER_ADDR + CONFIG_CONTROLLER_PATH + getDataUrl, null);
@ -129,8 +129,9 @@ public class ConfigExportAndImportAPI_ITCase {
JsonNode resultConfigs = resultObj.get("pageItems");
JsonNode config1 = resultConfigs.get(0);
JsonNode config2 = resultConfigs.get(1);
String exportByIdsUrl = "?export=true&tenant=&group=&appName=&ids=" + config1.get("id").longValue()
+ "," + config2.get("id").longValue();
String id1 = config1.get("id").asText();
String id2 = config2.get("id").asText();
String exportByIdsUrl = "?export=true&tenant=&group=&appName=&ids=" + id1 + "," + id2;
System.out.println(exportByIdsUrl);
byte[] zipData = httpClient.download(SERVER_ADDR + CONFIG_CONTROLLER_PATH + exportByIdsUrl, null);
ZipUtils.UnZipResult unZiped = ZipUtils.unzip(zipData);

View File

@ -37,9 +37,9 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Nacos.class, properties = {"server.servlet.context-path=/nacos"},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ConfigLongPollReturnChanges_ITCase {
@SpringBootTest(classes = Nacos.class, properties = {"server.servlet.context-path=/nacos", "server.port=7005"},
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class ConfigLongPollReturnChanges_CITCase {
@LocalServerPort
private int port;

View File

@ -39,9 +39,9 @@ import java.util.concurrent.TimeUnit;
* @date 2019-06-07 22:24
**/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Nacos.class, properties = {"server.servlet.context-path=/nacos"},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ConfigLongPoll_ITCase {
@SpringBootTest(classes = Nacos.class, properties = {"server.servlet.context-path=/nacos", "server.port=7004"},
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class ConfigLongPoll_CITCase {
@LocalServerPort
private int port;

View File

@ -29,7 +29,7 @@ import java.util.concurrent.Executors;
/**
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
public class EmbeddedStorageContextUtils_ITCase {
public class EmbeddedStorageContextUtils_CITCase {
@Test
public void test_multi_thread_sql_contexts() throws Exception {