[IT]Adjust integration tests for cluster,code,smoke modules in the core module to comply with checkstyle. (#12350)

This commit is contained in:
阿魁 2024-07-18 11:12:14 +08:00 committed by GitHub
parent 8664a1aec6
commit c717538bd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 36 additions and 19 deletions

View File

@ -24,12 +24,16 @@ import org.springframework.core.env.StandardEnvironment;
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>
*/
class SnowFlowerIdGenerator_ITCase {
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
class SnowFlowerIdGeneratorCoreITCase {
@Test
void test_idGenerator() {
void testIdGenerator() {
EnvUtil.setEnvironment(new StandardEnvironment());
SnowFlowerIdGenerator generator1 = new SnowFlowerIdGenerator();
SnowFlowerIdGenerator generator2 = new SnowFlowerIdGenerator();

View File

@ -43,17 +43,22 @@ import java.util.Arrays;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
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>
*/
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
@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;
@ -70,7 +75,8 @@ class MemberLookup_ITCase {
File file = Paths.get(path, "conf", name).toFile();
DiskUtils.touch(file);
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 {
memberManager = new ServerMemberManager(new MockServletContext());
@ -90,19 +96,19 @@ class MemberLookup_ITCase {
}
@Test
void test_a_lookup_file_config() throws Exception {
void testLookupFileConfig() throws Exception {
try {
LookupFactory.createLookUp(memberManager);
} catch (Throwable ignore) {
}
MemberLookup lookup = LookupFactory.getLookUp();
System.out.println(lookup);
assertTrue(lookup instanceof FileConfigMemberLookup);
assertInstanceOf(FileConfigMemberLookup.class, lookup);
func(lookup);
}
@Test
void test_b_lookup_standalone() throws Exception {
void testLookupStandalone() throws Exception {
EnvUtil.setIsStandalone(true);
try {
LookupFactory.createLookUp(memberManager);
@ -113,11 +119,11 @@ class MemberLookup_ITCase {
}
MemberLookup lookup = LookupFactory.getLookUp();
System.out.println(lookup);
assertTrue(lookup instanceof StandaloneMemberLookup);
assertInstanceOf(StandaloneMemberLookup.class, lookup);
}
@Test
void test_c_lookup_address_server() throws Exception {
void testLookupAddressServer() throws Exception {
EnvUtil.setIsStandalone(false);
System.out.println(EnvUtil.getClusterConfFilePath());
DiskUtils.deleteFile(Paths.get(path, "conf").toString(), "cluster.conf");
@ -128,7 +134,7 @@ class MemberLookup_ITCase {
}
MemberLookup lookup = LookupFactory.getLookUp();
System.out.println(lookup);
assertTrue(lookup instanceof AddressServerMemberLookup);
assertInstanceOf(AddressServerMemberLookup.class, lookup);
try {
func(lookup);
} catch (NacosException e) {

View File

@ -57,9 +57,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/
// todo fix
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
@TestMethodOrder(MethodName.class)
// todo fix
class ServerMemberManager_ITCase {
class ServerMemberManagerCoreITCase {
private ServerMemberManager memberManager;
@ -148,7 +149,8 @@ class ServerMemberManager_ITCase {
@Override
public void onEvent(MembersChangeEvent 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) {
first.countDown();
return;
@ -186,7 +188,7 @@ class ServerMemberManager_ITCase {
member.setState(NodeState.DOWN);
assertTrue(memberManager.update(member));
second.await();//fix blocking
second.await(); //fix blocking
copy = new HashSet<>(firstMemberList);
copy.removeAll(healthMembers.get());
assertEquals(3, copy.size());

View File

@ -31,10 +31,14 @@ import java.util.Map;
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
* @since 1.3.2
*/
class ControllerMethodsCache_ITCase {
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
class ControllerMethodsCacheCoreITCase {
private ControllerMethodsCache methodsCache;

View File

@ -21,9 +21,10 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
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
void setUp() {