-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IT]Adjust integration tests for cluster,code,smoke modules in the co…
…re module to comply with checkstyle. (#12350)
- Loading branch information
Showing
5 changed files
with
36 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
@@ -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()); | ||
|
@@ -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); | ||
|
@@ -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"); | ||
|
@@ -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) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
@@ -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; | ||
|
@@ -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()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters