Skip to content

Commit

Permalink
[IT]Adjust integration tests for cluster,code,smoke modules in the co…
Browse files Browse the repository at this point in the history
…re module to comply with checkstyle. (#12350)
  • Loading branch information
stone-98 authored Jul 18, 2024
1 parent 8664a1a commit c717538
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@
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:[email protected]">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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,22 @@
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:[email protected]">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;

Expand All @@ -70,7 +75,8 @@ void before() throws Exception {
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());
Expand All @@ -90,19 +96,19 @@ void after() throws Exception {
}

@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);
Expand All @@ -113,11 +119,11 @@ void test_b_lookup_standalone() throws Exception {
}
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");
Expand All @@ -128,7 +134,7 @@ void test_c_lookup_address_server() throws Exception {
}
MemberLookup lookup = LookupFactory.getLookUp();
System.out.println(lookup);
assertTrue(lookup instanceof AddressServerMemberLookup);
assertInstanceOf(AddressServerMemberLookup.class, lookup);
try {
func(lookup);
} catch (NacosException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@
*
* @author <a href="mailto:[email protected]">liaochuntao</a>
*/
// todo fix
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
@TestMethodOrder(MethodName.class)
// todo fix
class ServerMemberManager_ITCase {
class ServerMemberManagerCoreITCase {

private ServerMemberManager memberManager;

Expand Down Expand Up @@ -148,7 +149,8 @@ void testMemberHealthCheck() throws Exception {
@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;
Expand Down Expand Up @@ -186,7 +188,7 @@ public Class<? extends Event> subscribeType() {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
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() {
Expand Down

0 comments on commit c717538

Please sign in to comment.