[IT]Adjust integration tests for cluster,code,smoke modules in the core module to comply with checkstyle. (#12350)
This commit is contained in:
parent
8664a1aec6
commit
c717538bd7
@ -24,12 +24,16 @@ import org.springframework.core.env.StandardEnvironment;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Integration test case for validating unique ID generation using SnowFlowerIdGenerator with distinct initializations
|
||||||
|
* and assertions for uniqueness.
|
||||||
|
*
|
||||||
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
|
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
|
||||||
*/
|
*/
|
||||||
class SnowFlowerIdGenerator_ITCase {
|
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
|
||||||
|
class SnowFlowerIdGeneratorCoreITCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test_idGenerator() {
|
void testIdGenerator() {
|
||||||
EnvUtil.setEnvironment(new StandardEnvironment());
|
EnvUtil.setEnvironment(new StandardEnvironment());
|
||||||
SnowFlowerIdGenerator generator1 = new SnowFlowerIdGenerator();
|
SnowFlowerIdGenerator generator1 = new SnowFlowerIdGenerator();
|
||||||
SnowFlowerIdGenerator generator2 = new SnowFlowerIdGenerator();
|
SnowFlowerIdGenerator generator2 = new SnowFlowerIdGenerator();
|
@ -43,17 +43,22 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Integration test case for Member Lookup functionality, validating different lookup strategies: file configuration,
|
||||||
|
* standalone mode, and address server lookup.
|
||||||
|
*
|
||||||
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
|
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
|
||||||
@TestMethodOrder(MethodName.class)
|
@TestMethodOrder(MethodName.class)
|
||||||
class MemberLookup_ITCase {
|
class MemberLookupCoreITCase {
|
||||||
|
|
||||||
static final String path = Paths.get(System.getProperty("user.home"), "/member_look").toString();
|
private final String path = Paths.get(System.getProperty("user.home"), "/member_look").toString();
|
||||||
|
|
||||||
static final String name = "cluster.conf";
|
private final String name = "cluster.conf";
|
||||||
|
|
||||||
ServerMemberManager memberManager;
|
ServerMemberManager memberManager;
|
||||||
|
|
||||||
@ -70,7 +75,8 @@ class MemberLookup_ITCase {
|
|||||||
File file = Paths.get(path, "conf", name).toFile();
|
File file = Paths.get(path, "conf", name).toFile();
|
||||||
DiskUtils.touch(file);
|
DiskUtils.touch(file);
|
||||||
String ip = InetUtils.getSelfIP();
|
String ip = InetUtils.getSelfIP();
|
||||||
DiskUtils.writeFile(file, (ip + ":8848," + ip + ":8847," + ip + ":8849").getBytes(StandardCharsets.UTF_8), false);
|
DiskUtils.writeFile(file, (ip + ":8848," + ip + ":8847," + ip + ":8849").getBytes(StandardCharsets.UTF_8),
|
||||||
|
false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
memberManager = new ServerMemberManager(new MockServletContext());
|
memberManager = new ServerMemberManager(new MockServletContext());
|
||||||
@ -90,19 +96,19 @@ class MemberLookup_ITCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test_a_lookup_file_config() throws Exception {
|
void testLookupFileConfig() throws Exception {
|
||||||
try {
|
try {
|
||||||
LookupFactory.createLookUp(memberManager);
|
LookupFactory.createLookUp(memberManager);
|
||||||
} catch (Throwable ignore) {
|
} catch (Throwable ignore) {
|
||||||
}
|
}
|
||||||
MemberLookup lookup = LookupFactory.getLookUp();
|
MemberLookup lookup = LookupFactory.getLookUp();
|
||||||
System.out.println(lookup);
|
System.out.println(lookup);
|
||||||
assertTrue(lookup instanceof FileConfigMemberLookup);
|
assertInstanceOf(FileConfigMemberLookup.class, lookup);
|
||||||
func(lookup);
|
func(lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test_b_lookup_standalone() throws Exception {
|
void testLookupStandalone() throws Exception {
|
||||||
EnvUtil.setIsStandalone(true);
|
EnvUtil.setIsStandalone(true);
|
||||||
try {
|
try {
|
||||||
LookupFactory.createLookUp(memberManager);
|
LookupFactory.createLookUp(memberManager);
|
||||||
@ -113,11 +119,11 @@ class MemberLookup_ITCase {
|
|||||||
}
|
}
|
||||||
MemberLookup lookup = LookupFactory.getLookUp();
|
MemberLookup lookup = LookupFactory.getLookUp();
|
||||||
System.out.println(lookup);
|
System.out.println(lookup);
|
||||||
assertTrue(lookup instanceof StandaloneMemberLookup);
|
assertInstanceOf(StandaloneMemberLookup.class, lookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test_c_lookup_address_server() throws Exception {
|
void testLookupAddressServer() throws Exception {
|
||||||
EnvUtil.setIsStandalone(false);
|
EnvUtil.setIsStandalone(false);
|
||||||
System.out.println(EnvUtil.getClusterConfFilePath());
|
System.out.println(EnvUtil.getClusterConfFilePath());
|
||||||
DiskUtils.deleteFile(Paths.get(path, "conf").toString(), "cluster.conf");
|
DiskUtils.deleteFile(Paths.get(path, "conf").toString(), "cluster.conf");
|
||||||
@ -128,7 +134,7 @@ class MemberLookup_ITCase {
|
|||||||
}
|
}
|
||||||
MemberLookup lookup = LookupFactory.getLookUp();
|
MemberLookup lookup = LookupFactory.getLookUp();
|
||||||
System.out.println(lookup);
|
System.out.println(lookup);
|
||||||
assertTrue(lookup instanceof AddressServerMemberLookup);
|
assertInstanceOf(AddressServerMemberLookup.class, lookup);
|
||||||
try {
|
try {
|
||||||
func(lookup);
|
func(lookup);
|
||||||
} catch (NacosException e) {
|
} catch (NacosException e) {
|
@ -57,9 +57,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||||||
*
|
*
|
||||||
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
|
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
|
||||||
*/
|
*/
|
||||||
|
// todo fix
|
||||||
|
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
|
||||||
@TestMethodOrder(MethodName.class)
|
@TestMethodOrder(MethodName.class)
|
||||||
// todo fix
|
class ServerMemberManagerCoreITCase {
|
||||||
class ServerMemberManager_ITCase {
|
|
||||||
|
|
||||||
private ServerMemberManager memberManager;
|
private ServerMemberManager memberManager;
|
||||||
|
|
||||||
@ -148,7 +149,8 @@ class ServerMemberManager_ITCase {
|
|||||||
@Override
|
@Override
|
||||||
public void onEvent(MembersChangeEvent event) {
|
public void onEvent(MembersChangeEvent event) {
|
||||||
System.out.println(event);
|
System.out.println(event);
|
||||||
healthMembers.set(MemberUtil.selectTargetMembers(event.getMembers(), member -> !NodeState.DOWN.equals(member.getState())));
|
healthMembers.set(MemberUtil.selectTargetMembers(event.getMembers(),
|
||||||
|
member -> !NodeState.DOWN.equals(member.getState())));
|
||||||
if (first.getCount() == 1) {
|
if (first.getCount() == 1) {
|
||||||
first.countDown();
|
first.countDown();
|
||||||
return;
|
return;
|
||||||
@ -186,7 +188,7 @@ class ServerMemberManager_ITCase {
|
|||||||
member.setState(NodeState.DOWN);
|
member.setState(NodeState.DOWN);
|
||||||
assertTrue(memberManager.update(member));
|
assertTrue(memberManager.update(member));
|
||||||
|
|
||||||
second.await();//fix blocking
|
second.await(); //fix blocking
|
||||||
copy = new HashSet<>(firstMemberList);
|
copy = new HashSet<>(firstMemberList);
|
||||||
copy.removeAll(healthMembers.get());
|
copy.removeAll(healthMembers.get());
|
||||||
assertEquals(3, copy.size());
|
assertEquals(3, copy.size());
|
@ -31,10 +31,14 @@ import java.util.Map;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Integration test case for validating ControllerMethodsCache functionality,ensuring correct method retrieval based on
|
||||||
|
* different request parameters.
|
||||||
|
*
|
||||||
* @author horizonzy
|
* @author horizonzy
|
||||||
* @since 1.3.2
|
* @since 1.3.2
|
||||||
*/
|
*/
|
||||||
class ControllerMethodsCache_ITCase {
|
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
|
||||||
|
class ControllerMethodsCacheCoreITCase {
|
||||||
|
|
||||||
private ControllerMethodsCache methodsCache;
|
private ControllerMethodsCache methodsCache;
|
||||||
|
|
@ -21,9 +21,10 @@ import org.junit.jupiter.api.AfterEach;
|
|||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class nacosSmoke_ITCase {
|
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
|
||||||
|
class NacosSmokeCoreITCase {
|
||||||
|
|
||||||
private static Logger logger = Logger.getLogger(nacosSmoke_ITCase.class);
|
private static Logger logger = Logger.getLogger(NacosSmokeCoreITCase.class);
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
Loading…
Reference in New Issue
Block a user