Skip to content

Commit

Permalink
Add test for round-robin host rotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
kishorenc committed Feb 19, 2024
1 parent f6a6b0f commit 3bf7c84
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/test/java/org/typesense/api/APICallTest.java
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);
}
}

0 comments on commit 3bf7c84

Please sign in to comment.