1
1
package alpakka .influxdb ;
2
2
3
- import org .apache .pekko .Done ;
4
3
import org .apache .pekko .actor .ActorSystem ;
5
- import org .junit .Ignore ;
6
4
import org .junit .jupiter .api .*;
7
5
import org .slf4j .Logger ;
8
6
import org .slf4j .LoggerFactory ;
13
11
import util .LogFileScanner ;
14
12
15
13
import java .io .IOException ;
16
- import java .util . List ;
14
+ import java .time . Duration ;
17
15
import java .util .concurrent .CompletableFuture ;
18
- import java .util .concurrent .CompletionStage ;
19
16
import java .util .concurrent .ExecutionException ;
20
- import java .util .concurrent .TimeUnit ;
21
- import java .util .stream .Collectors ;
22
17
import java .util .stream .IntStream ;
23
18
24
19
import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
@@ -46,8 +41,8 @@ public static void setupBeforeClass() throws IOException, InterruptedException {
46
41
// Doc: https://docs.influxdata.com/influxdb/v2.1/reference/release-notes/influxdb/
47
42
LOGGER .info ("InfluxDB container listening on port: {}. Running: {} " , influxDBContainer .getMappedPort (INFLUXDB_PORT ), influxDBContainer .isRunning ());
48
43
Container .ExecResult result = influxDBContainer .execInContainer ("influx" , "setup" , "-b" , "testbucket" , "-f" , "-o" , "testorg" , "-t" , "abcdefgh" , "-u" , "admin" , "-p" , "adminadmin" );
49
- LOGGER .info ("Result exit code: " + result .getExitCode ());
50
- LOGGER .info ("Result stdout: " + result .getStdout ());
44
+ LOGGER .info ("Result exit code: {}" , result .getExitCode ());
45
+ LOGGER .info ("Result stdout: {}" , result .getStdout ());
51
46
browserClient ();
52
47
}
53
48
@@ -67,12 +62,15 @@ public void setupBeforeTest(TestInfo testInfo) {
67
62
@ Order (1 )
68
63
void testWriteAndRead () {
69
64
int maxClients = 5 ;
70
- int nPoints = 1000 ;
65
+ int nPoints = 100 ;
71
66
72
- List <CompletionStage <Done >> futList = IntStream .rangeClosed (1 , maxClients ).boxed ().parallel ()
73
- .map (i -> influxDBWriter .writeTestPoints (nPoints , "sensor" + i ))
74
- .collect (Collectors .toList ());
75
- assertThat (CompletableFuture .allOf (futList .toArray (new CompletableFuture [futList .size ()]))).succeedsWithin (5 * maxClients , TimeUnit .SECONDS );
67
+ assertThat (
68
+ CompletableFuture .allOf (
69
+ IntStream .rangeClosed (1 , maxClients )
70
+ .mapToObj (i -> influxDBWriter .writeTestPoints (nPoints , "sensor" + i ))
71
+ .toArray (CompletableFuture []::new )
72
+ )
73
+ ).succeedsWithin (Duration .ofSeconds (10 * maxClients ));
76
74
77
75
assertThat (influxDBReader .getQuerySync ("testMem" ).length ()).isEqualTo (nPoints * maxClients );
78
76
assertThat (influxDBReader .fluxQueryCount ("testMem" )).isEqualTo (nPoints * maxClients );
@@ -81,13 +79,10 @@ void testWriteAndRead() {
81
79
82
80
@ Test
83
81
@ Order (2 )
84
- @ Ignore
85
82
void testWriteAndReadLineProtocol () throws ExecutionException , InterruptedException {
86
83
int nPoints = 10 ;
87
84
influxDBWriter .writeTestPointsFromLineProtocolSync ();
88
- // TODO Activate, when "com.influxdb" %% "influxdb-client-scala" is available for pekko
89
- //assertThat(influxDBReader.getQuerySync("testMemLP").length()).isEqualTo(nPoints);
90
- assert (true );
85
+ assertThat (influxDBReader .getQuerySync ("testMemLP" ).length ()).isEqualTo (nPoints );
91
86
}
92
87
93
88
@ Test
0 commit comments