Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #2847] Fix config IT #3120

Merged
merged 6 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@ private static void checkState() {
throw new IllegalStateException("WatchFileCenter already shutdown");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
import com.alibaba.nacos.common.utils.JacksonUtils;
import com.alibaba.nacos.common.utils.ThreadUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down Expand Up @@ -90,6 +92,12 @@ public void cleanup() throws Exception {
Assert.fail();
}
}

@BeforeClass
@AfterClass
public static void cleanClientCache() throws Exception {
ConfigCleanUtils.cleanClientCache();
}

/**
* @TCDescription : nacos_正常获取数据
Expand Down Expand Up @@ -383,10 +391,13 @@ public void nacos_addListener_3() throws InterruptedException, NacosException {
final AtomicInteger count = new AtomicInteger(0);
final String dataId = "nacos_addListener_3";
final String group = "nacos_addListener_3";
final String content = "test-abc";
final String newContent = "nacos_addListener_3";
final String content = "test-abc-" + System.currentTimeMillis();
final String newContent = "nacos_addListener_3-" + System.currentTimeMillis();
boolean result = iconfig.publishConfig(dataId, group, content);
Assert.assertTrue(result);

// Maximum assurance level notification has been performed
ThreadUtils.sleep(5000);

Listener ml = new AbstractListener() {
@Override
Expand All @@ -395,7 +406,8 @@ public void receiveConfigInfo(String configInfo) {
Assert.assertEquals(newContent, configInfo);
}
};
iconfig.addListener(dataId, group, ml);
String receive = iconfig.getConfigAndSignListener(dataId, group, 5000L, ml);
Assert.assertEquals(content, receive);
result = iconfig.publishConfig(dataId, group, newContent);
Assert.assertTrue(result);
// Get enough sleep to ensure that the monitor is triggered only once
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import com.alibaba.nacos.common.utils.JacksonUtils;
import com.alibaba.nacos.common.utils.ThreadUtils;
import com.alibaba.nacos.test.base.Params;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -61,6 +63,12 @@ public class ConfigBeta_CITCase {
String tenant = "dungu";
String content = "test";
String appName = "nacos";

@BeforeClass
@AfterClass
public static void cleanClientCache() throws Exception {
ConfigCleanUtils.cleanClientCache();
}

@Before
public void init() throws NacosException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.nacos.test.config;

import com.alibaba.nacos.client.config.impl.LocalConfigInfoProcessor;
import com.alibaba.nacos.core.utils.DiskUtils;

import java.io.IOException;

/**
* Cache files to clear tool classes.
*
* @author <a href="mailto:[email protected]">liaochuntao</a>
*/
public class ConfigCleanUtils {

public static void cleanClientCache() throws IOException {
DiskUtils.deleteDirThenMkdir(LocalConfigInfoProcessor.LOCAL_SNAPSHOT_PATH);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ public class ConfigExportAndImportAPI_CITCase {
private String SERVER_ADDR = null;

private HttpAgent agent = null;


@BeforeClass
@AfterClass
public static void cleanClientCache() throws Exception {
ConfigCleanUtils.cleanClientCache();
}

@Before
public void setUp() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.client.config.listener.impl.AbstractConfigChangeListener;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -46,6 +48,12 @@ public class ConfigLongPollReturnChanges_CITCase {
private int port;

private ConfigService configService;

@BeforeClass
@AfterClass
public static void cleanClientCache() throws Exception {
ConfigCleanUtils.cleanClientCache();
}

@Before
public void init() throws NacosException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import com.alibaba.nacos.api.config.listener.Listener;
import com.alibaba.nacos.api.exception.NacosException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
Expand All @@ -47,6 +49,12 @@ public class ConfigLongPoll_CITCase {
private int port;

private ConfigService configService;

@BeforeClass
@AfterClass
public static void cleanClientCache() throws Exception {
ConfigCleanUtils.cleanClientCache();
}

@Before
public void init() throws NacosException {
Expand Down