@@ -56,6 +56,7 @@ void Test::run() {
56
56
testFluxParserMissingDatatype ();
57
57
testFluxParserErrorInRow ();
58
58
testBasicFunction ();
59
+ testFlushing ();
59
60
testInit ();
60
61
testRepeatedInit ();
61
62
testV1 ();
@@ -2076,6 +2077,46 @@ void Test::testBuckets() {
2076
2077
TEST_END ();
2077
2078
}
2078
2079
2080
+ void Test::testFlushing () {
2081
+ TEST_INIT (" testFlushing" );
2082
+ InfluxDBClient client (Test::apiUrl, Test::orgName, Test::bucketName, Test::token);
2083
+ TEST_ASSERT (waitServer (Test::managementUrl, true ));
2084
+ TEST_ASSERT (client.validateConnection ());
2085
+ TEST_ASSERT (!client.isBufferFull ());
2086
+ TEST_ASSERT (client.isBufferEmpty ());
2087
+ client.setWriteOptions (WriteOptions ().batchSize (10 ).bufferSize (30 ).flushInterval (2 ));
2088
+
2089
+ for (int i = 0 ; i < 5 ; i++) {
2090
+ Point *p = createPoint (" test1" );
2091
+ p->addField (" index" , i);
2092
+ TEST_ASSERT (client.writePoint (*p));
2093
+ delete p;
2094
+ }
2095
+ TEST_ASSERT (!client.isBufferFull ());
2096
+ TEST_ASSERT (!client.isBufferEmpty ());
2097
+ client.checkBuffer ();
2098
+ TEST_ASSERT (!client.isBufferFull ());
2099
+ TEST_ASSERT (!client.isBufferEmpty ());
2100
+ String query = " select" ;
2101
+ FluxQueryResult q = client.query (query);
2102
+ int count = countLines (q);
2103
+ TEST_ASSERTM (q.getError ()==" " , q.getError ());
2104
+ TEST_ASSERTM ( count == 0 , String (count) + " vs 0" ); // 5 points
2105
+
2106
+ delay (2100 );
2107
+ client.checkBuffer ();
2108
+ TEST_ASSERT (!client.isBufferFull ());
2109
+ TEST_ASSERT (client.isBufferEmpty ());
2110
+
2111
+ q = client.query (query);
2112
+ count = countLines (q);
2113
+ TEST_ASSERTM (q.getError ()==" " , q.getError ());
2114
+ TEST_ASSERTM ( count == 5 , String (count) + " vs 0" ); // 5 points
2115
+
2116
+ TEST_END ();
2117
+ deleteAll (Test::apiUrl);
2118
+ }
2119
+
2079
2120
void Test::setServerUrl (InfluxDBClient &client, String serverUrl) {
2080
2121
client._connInfo .serverUrl = serverUrl;
2081
2122
client._service ->_apiURL = serverUrl + " /api/v2/" ;
0 commit comments