-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f87984b
commit ff1ef2e
Showing
3 changed files
with
36 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
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
31 changes: 31 additions & 0 deletions
31
app/src/test/java/org/astraea/performance/TrackerTest.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 org.astraea.performance; | ||
|
||
import java.util.List; | ||
import org.astraea.concurrent.ThreadPool; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TrackerTest { | ||
@Test | ||
public void testTerminate() throws InterruptedException { | ||
var producerData = List.of(new Metrics()); | ||
var consumerData = List.of(new Metrics()); | ||
List<Metrics> empty = List.of(); | ||
int records = 1; | ||
|
||
try (Tracker tracker = new Tracker(producerData, consumerData, records)) { | ||
Assertions.assertEquals(ThreadPool.Executor.State.RUNNING, tracker.execute()); | ||
producerData.get(0).put(1, 1); | ||
consumerData.get(0).put(1, 1); | ||
Assertions.assertEquals(ThreadPool.Executor.State.DONE, tracker.execute()); | ||
} | ||
|
||
// Zero consumer | ||
producerData = List.of(new Metrics()); | ||
try (Tracker tracker = new Tracker(producerData, empty, records)) { | ||
Assertions.assertEquals(ThreadPool.Executor.State.RUNNING, tracker.execute()); | ||
producerData.get(0).put(1, 1); | ||
Assertions.assertEquals(ThreadPool.Executor.State.DONE, tracker.execute()); | ||
} | ||
} | ||
} |