-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for ServerAdminAction & GrpcUtilsTest
- Loading branch information
1 parent
c2201b3
commit d4f9430
Showing
4 changed files
with
169 additions
and
8 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
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
20 changes: 20 additions & 0 deletions
20
internal/venice-common/src/test/java/com/linkedin/venice/meta/ServerAdminActionTest.java
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.linkedin.venice.meta; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.expectThrows; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
|
||
public class ServerAdminActionTest { | ||
@Test | ||
public void testFromValue() { | ||
// Test all valid values | ||
assertEquals(ServerAdminAction.fromValue(0), ServerAdminAction.DUMP_INGESTION_STATE); | ||
assertEquals(ServerAdminAction.fromValue(1), ServerAdminAction.DUMP_SERVER_CONFIGS); | ||
|
||
// Test invalid values | ||
expectThrows(IllegalArgumentException.class, () -> ServerAdminAction.fromValue(-1)); | ||
expectThrows(IllegalArgumentException.class, () -> ServerAdminAction.fromValue(2)); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
internal/venice-common/src/test/java/com/linkedin/venice/utils/NettyUtilsTest.java
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.linkedin.venice.utils; | ||
|
||
import static com.linkedin.venice.HttpConstants.VENICE_RETRY; | ||
import static org.testng.Assert.assertFalse; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
import io.netty.handler.codec.http.DefaultHttpRequest; | ||
import io.netty.handler.codec.http.HttpMethod; | ||
import io.netty.handler.codec.http.HttpRequest; | ||
import io.netty.handler.codec.http.HttpVersion; | ||
import org.testng.annotations.Test; | ||
|
||
|
||
public class NettyUtilsTest { | ||
@Test | ||
public void testContainRetryHeader() { | ||
// 1. Header is present | ||
HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/test"); | ||
httpRequest.headers().set(VENICE_RETRY, "1"); | ||
assertTrue(NettyUtils.containRetryHeader(httpRequest), "Request should contain the retry header"); | ||
|
||
// 2. Header is present with value "true" | ||
httpRequest.headers().clear(); | ||
httpRequest.headers().set(VENICE_RETRY, "true"); | ||
assertTrue(NettyUtils.containRetryHeader(httpRequest), "Request should contain the retry header"); | ||
|
||
// 3. Header is not present | ||
httpRequest.headers().clear(); | ||
assertFalse(NettyUtils.containRetryHeader(httpRequest), "Request should not contain the retry header"); | ||
} | ||
} |