-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for round-robin host rotation.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.typesense.api; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.typesense.resources.Node; | ||
|
||
import java.time.Duration; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class APICallTest { | ||
|
||
private ApiCall apiCall; | ||
|
||
@BeforeEach | ||
void setUp() throws Exception { | ||
List<Node> nodes = new ArrayList<>(); | ||
nodes.add(new Node("http","localhost","8108")); | ||
nodes.add(new Node("http","localhost","7108")); | ||
nodes.add(new Node("http","localhost","6108")); | ||
apiCall = new ApiCall(new Configuration(nodes, Duration.ofSeconds(3),"xyz")); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() throws Exception { | ||
|
||
} | ||
|
||
@Test | ||
void testRoundRobin() throws Exception { | ||
assertEquals("7108", apiCall.getNode().port); | ||
assertEquals("6108", apiCall.getNode().port); | ||
assertEquals("8108", apiCall.getNode().port); | ||
|
||
assertEquals("7108", apiCall.getNode().port); | ||
assertEquals("6108", apiCall.getNode().port); | ||
assertEquals("8108", apiCall.getNode().port); | ||
} | ||
} |