@@ -68,6 +68,7 @@ void Test::run() {
68
68
testTimestamp ();
69
69
testRetryOnFailedConnection ();
70
70
testRetryOnFailedConnectionWithFlush ();
71
+ testNonRetry ();
71
72
testBufferOverwriteBatchsize1 ();
72
73
testBufferOverwriteBatchsize5 ();
73
74
testServerTempDownBatchsize5 ();
@@ -566,7 +567,7 @@ void Test::testRepeatedInit() {
566
567
} while (0 );
567
568
uint32_t endRAM = ESP.getFreeHeap ();
568
569
long diff = endRAM-startRAM;
569
- TEST_ASSERTM (diff>-100 ,String (diff));
570
+ TEST_ASSERTM (diff>-300 ,String (diff));
570
571
TEST_END ();
571
572
}
572
573
@@ -2121,6 +2122,60 @@ void Test::testFlushing() {
2121
2122
deleteAll (Test::apiUrl);
2122
2123
}
2123
2124
2125
+ #define WS_DEBUG_RAM (text ) { Serial.printf_P (PSTR (text " : free_heap %d, max_alloc_heap %d, heap_fragmentation %d\n " ), ESP.getFreeHeap (), ESP.getMaxFreeBlockSize (), ESP.getHeapFragmentation ()); }
2126
+
2127
+
2128
+ void Test::testNonRetry () {
2129
+ TEST_INIT (" testNonRetry" );
2130
+ const char *lines[] = {
2131
+ " device_status,clientId=WS-E09806011111,Device=WS-ESP8266,Version=0.58-rc3,Location=Prague\\ ,CZ,WiFi=Bonitoo-ng free_heap=16568i,max_alloc_heap=11336i,heap_fragmentation=29i,uptime=28821.23,wifi_disconnects=0i" ,
2132
+ " service_status,clientId=WS-E09806011111,Device=WS-ESP8266,Version=0.58-rc3,Location=Prague\\ ,CZ,WiFi=Bonitoo-ng,service=location state=3i,before_mem_free=36232i,before_mem_max_free_block=17544i,before_mem_framentation=49i,after_mem_free=35792i,after_mem_max_free_block=17544i,after_mem_framentation=48i" ,
2133
+ " service_status,clientId=WS-E09806011111,Device=WS-ESP8266,Version=0.58-rc3,Location=Prague\\ ,CZ,WiFi=Bonitoo-ng,service=clock state=2i,before_mem_free=16704i,before_mem_max_free_block=11336i,before_mem_framentation=30i,after_mem_free=16704i,after_mem_max_free_block=11336i,after_mem_framentation=30i" ,
2134
+ " service_status,clientId=WS-E09806011111,Device=WS-ESP8266,Version=0.58-rc3,Location=Prague\\ ,CZ,WiFi=Bonitoo-ng,service=update state=0i" ,
2135
+ " service_status,clientId=WS-E09806011111,Device=WS-ESP8266,Version=0.58-rc3,Location=Prague\\ ,CZ,WiFi=Bonitoo-ng,service=astronomy state=2i,before_mem_free=16376i,before_mem_max_free_block=11336i,before_mem_framentation=28i,after_mem_free=16376i,after_mem_max_free_block=11336i,after_mem_framentation=28i" ,
2136
+ " service_status,clientId=WS-E09806011111,Device=WS-ESP8266,Version=0.58-rc3,Location=Prague\\ ,CZ,WiFi=Bonitoo-ng,service=current_weather state=2i,before_mem_free=16728i,before_mem_max_free_block=11336i,before_mem_framentation=30i,after_mem_free=16376i,after_mem_max_free_block=11336i,after_mem_framentation=28i" ,
2137
+ " service_status,clientId=WS-E09806011111,Device=WS-ESP8266,Version=0.58-rc3,Location=Prague\\ ,CZ,WiFi=Bonitoo-ng,service=forecast state=2i,before_mem_free=16704i,before_mem_max_free_block=11336i,before_mem_framentation=30i,after_mem_free=16376i,after_mem_max_free_block=11336i,after_mem_framentation=28i" ,
2138
+ " service_status,clientId=WS-E09806011111,Device=WS-ESP8266,Version=0.58-rc3,Location=Prague\\ ,CZ,WiFi=Bonitoo-ng,service=iot_center state=0i" ,
2139
+ };
2140
+ WriteOptions wo;
2141
+ WS_DEBUG_RAM (" Before inst" );
2142
+ InfluxDBClient *client = new InfluxDBClient (Test::apiUrl, Test::orgName, Test::bucketName, Test::token);
2143
+ WS_DEBUG_RAM (" after inst" );
2144
+
2145
+ // TEST not keeping batch for retry
2146
+ Serial.println (" Stop server" );
2147
+ TEST_ASSERT (waitServer (Test::managementUrl, false ));
2148
+ client->setHTTPOptions (HTTPOptions ().httpReadTimeout (500 ));
2149
+ TEST_ASSERT (!client->validateConnection ());
2150
+ // Disable retry
2151
+ wo.maxRetryAttempts (0 );
2152
+ client->setWriteOptions (wo);
2153
+ client->setHTTPOptions (HTTPOptions ().connectionReuse (true ));
2154
+ TEST_ASSERT (!client->writeRecord (lines[0 ]));
2155
+ TEST_ASSERT (!client->_writeBuffer [0 ]);
2156
+
2157
+ TEST_ASSERT (waitServer (Test::managementUrl, true ));
2158
+ TEST_ASSERT (client->validateConnection ());
2159
+
2160
+ uint8_t size = sizeof (lines)/sizeof (lines[0 ]);
2161
+ uint16_t batchSize = size +1 ;
2162
+ wo.batchSize (batchSize).bufferSize (batchSize);
2163
+ client->setWriteOptions (wo);
2164
+
2165
+ WS_DEBUG_RAM (" Before" );
2166
+ for (int i=0 ;i<size;i++) {
2167
+ TEST_ASSERTM (client->writeRecord (lines[i]), client->getLastErrorMessage ());
2168
+ WS_DEBUG_RAM (" After write Line" );
2169
+ }
2170
+ TEST_ASSERTM (client->flushBuffer (), client->getLastErrorMessage ());
2171
+ WS_DEBUG_RAM (" After flush" );
2172
+ delete client;
2173
+ WS_DEBUG_RAM (" After delete" );
2174
+ TEST_END ();
2175
+ deleteAll (Test::apiUrl);
2176
+ }
2177
+
2178
+
2124
2179
void Test::setServerUrl (InfluxDBClient &client, String serverUrl) {
2125
2180
client._connInfo .serverUrl = serverUrl;
2126
2181
client._service ->_apiURL = serverUrl + " /api/v2/" ;
0 commit comments