@@ -154,7 +154,7 @@ class BasicFuncTests : public ::testing::Test,
154154 }
155155 int port = server.addListeningPort (HTTP_PORT );
156156 std::ostringstream os;
157- os << " localhost :" << port;
157+ os << " 127.0.0.1 :" << port;
158158 serverAddress = " http://" + os.str () + " /simple/" ;
159159 server.setServerName (os.str ());
160160 server.addHandler (" /simple/" , *this );
@@ -179,6 +179,11 @@ class BasicFuncTests : public ::testing::Test,
179179 fileName += PATH_SEPARATOR_CHAR ;
180180 fileName += TEST_STORAGE_FILENAME ;
181181 std::remove (fileName.c_str ());
182+ // SQLite WAL mode creates companion journal files that must also
183+ // be removed to avoid "vnode unlinked while in use" on iOS.
184+ std::remove ((fileName + " -wal" ).c_str ());
185+ std::remove ((fileName + " -shm" ).c_str ());
186+ std::remove ((fileName + " -journal" ).c_str ());
182187 }
183188
184189 virtual void Initialize ()
@@ -196,9 +201,13 @@ class BasicFuncTests : public ::testing::Test,
196201
197202 configuration[CFG_INT_RAM_QUEUE_SIZE ] = 4096 * 20 ;
198203 configuration[CFG_STR_CACHE_FILE_PATH ] = TEST_STORAGE_FILENAME ;
204+ configuration[CFG_INT_CACHE_FILE_SIZE ] = 4096 * 1024 ; // 4MB default
199205 configuration[CFG_INT_MAX_TEARDOWN_TIME ] = 2 ; // 2 seconds wait on shutdown
206+ configuration[CFG_INT_STORAGE_FULL_PCT ] = 75 ; // default
207+ configuration[CFG_INT_STORAGE_FULL_CHECK_TIME ] = 5000 ; // default 5s
200208 configuration[CFG_STR_COLLECTOR_URL ] = serverAddress.c_str ();
201209 configuration[CFG_MAP_HTTP ][CFG_BOOL_HTTP_COMPRESSION ] = false ; // disable compression for now
210+ configuration[CFG_MAP_TPM ][CFG_STR_TPM_BACKOFF ] = " E,500,5000,2,1" ; // faster retry for localhost tests
202211 configuration[CFG_MAP_METASTATS_CONFIG ][CFG_INT_METASTATS_INTERVAL ] = 30 * 60 ; // 30 mins
203212 configuration[CFG_MAP_METASTATS_CONFIG ][" enabled" ] = true ; // opt in to stats (disabled by default since #1420)
204213
@@ -207,6 +216,7 @@ class BasicFuncTests : public ::testing::Test,
207216 configuration[" config" ] = { { " host" , __FILE__ } }; // Host instance
208217
209218 LogManager::Initialize (TEST_TOKEN , configuration);
219+ LogManager::SetTransmitProfile (TransmitProfile_RealTime);
210220 LogManager::SetLevelFilter (DIAG_LEVEL_DEFAULT , { DIAG_LEVEL_DEFAULT_MIN , DIAG_LEVEL_DEFAULT_MAX });
211221 LogManager::ResumeTransmission ();
212222
@@ -258,15 +268,16 @@ class BasicFuncTests : public ::testing::Test,
258268 size_t lastIdx = 0 ;
259269 while ( ((PAL::getUtcSystemTimeMs ()-start)<(1000 * timeOutSec)) && (receivedEvents!=expected_count) )
260270 {
261- /* Give time for our friendly HTTP server thread to process incoming request */
262- std::this_thread::yield ();
271+ /* Give time for HTTP server thread to process incoming request.
272+ * sleep(10) instead of yield() reduces CPU contention on single-core
273+ * iOS simulator runners and gives the network stack time to deliver. */
274+ PAL::sleep (10 );
263275 {
264276 LOCKGUARD (mtx_requests);
265277 if (receivedRequests.size ())
266278 {
267279 size_t size = receivedRequests.size ();
268280
269- // requests can come within 100 milisec sleep
270281 for (size_t index = lastIdx; index < size; index++)
271282 {
272283 auto request = receivedRequests.at (index);
@@ -574,6 +585,7 @@ TEST_F(BasicFuncTests, sendNoPriorityEvents)
574585 event2.SetProperty (" property2" , " another value" );
575586 logger->LogEvent (event2);
576587
588+ LogManager::SetTransmitProfile (TransmitProfile_RealTime);
577589 LogManager::UploadNow ();
578590 waitForEvents (1 , 3 );
579591 EXPECT_GE (receivedRequests.size (), (size_t )1 );
@@ -672,6 +684,7 @@ TEST_F(BasicFuncTests, sendDifferentPriorityEvents)
672684
673685 logger->LogEvent (event2);
674686
687+ LogManager::SetTransmitProfile (TransmitProfile_RealTime);
675688 LogManager::UploadNow ();
676689 // 2 x customer events + 1 x evt_stats on start
677690 waitForEvents (1 , 3 );
@@ -719,6 +732,7 @@ TEST_F(BasicFuncTests, sendMultipleTenantsTogether)
719732
720733 logger2->LogEvent (event2);
721734
735+ LogManager::SetTransmitProfile (TransmitProfile_RealTime);
722736 LogManager::UploadNow ();
723737
724738 // 2 x customer events + 1 x evt_stats on start
@@ -749,6 +763,7 @@ TEST_F(BasicFuncTests, configDecorations)
749763 EventProperties event4 (" 4th_event" );
750764 logger->LogEvent (event4);
751765
766+ LogManager::SetTransmitProfile (TransmitProfile_RealTime);
752767 LogManager::UploadNow ();
753768 waitForEvents (2 , 5 );
754769
@@ -786,10 +801,11 @@ TEST_F(BasicFuncTests, restartRecoversEventsFromStorage)
786801 fooEvent.SetLatency (EventLatency_RealTime);
787802 fooEvent.SetPersistence (EventPersistence_Critical);
788803 LogManager::GetLogger ()->LogEvent (fooEvent);
804+ LogManager::SetTransmitProfile (TransmitProfile_RealTime);
789805 LogManager::UploadNow ();
790806
791807 // 1st request for realtime event
792- waitForEvents (3 , 5 ); // start, first_event, second_event, ongoing, stop, start, fooEvent
808+ waitForEvents (10 , 5 ); // start, first_event, second_event, ongoing, stop, start, fooEvent
793809 // we drop two of the events during pause, though.
794810 EXPECT_GE (receivedRequests.size (), (size_t )1 );
795811 if (receivedRequests.size () != 0 )
@@ -853,7 +869,7 @@ TEST_F(BasicFuncTests, storageFileSizeDoesntExceedConfiguredSize)
853869
854870 {
855871 Initialize();
856- waitForEvents(2 , 8);
872+ waitForEvents(5 , 8);
857873 if (receivedRequests.size())
858874 {
859875 auto payload = decodeRequest(receivedRequests[0], false);
@@ -898,8 +914,9 @@ TEST_F(BasicFuncTests, sendMetaStatsOnStart)
898914 // Check
899915 Initialize ();
900916 LogManager::ResumeTransmission (); // ?
917+ LogManager::SetTransmitProfile (TransmitProfile_RealTime);
901918 LogManager::UploadNow ();
902- PAL::sleep ( 2000 );
919+ waitForEvents ( 5 , 4 ); // (start + stop) + (2 events + start)
903920
904921 auto r2 = records ();
905922 ASSERT_GE (r2.size (), (size_t )4 ); // (start + stop) + (2 events + start)
@@ -928,8 +945,9 @@ TEST_F(BasicFuncTests, DiagLevelRequiredOnly_OneEventWithoutLevelOneWithButNotAl
928945 eventWithAllowedLevel.SetLevel (DIAG_LEVEL_REQUIRED );
929946 logger->LogEvent (eventWithAllowedLevel);
930947
948+ LogManager::SetTransmitProfile (TransmitProfile_RealTime);
931949 LogManager::UploadNow ();
932- waitForEvents (1 /* timeout*/ , 2 /* expected count*/ ); // Start and EventWithAllowedLevel
950+ waitForEvents (5 /* timeout*/ , 2 /* expected count*/ ); // Start and EventWithAllowedLevel
933951
934952 ASSERT_EQ (records ().size (), static_cast <size_t >(2 )); // Start and EventWithAllowedLevel
935953
@@ -971,8 +989,9 @@ TEST_F(BasicFuncTests, DiagLevelRequiredOnly_SendTwoEventsUpdateAllowedLevelsSen
971989 LogManager::SetLevelFilter (DIAG_LEVEL_OPTIONAL , { DIAG_LEVEL_OPTIONAL , DIAG_LEVEL_REQUIRED });
972990 SendEventWithOptionalThenRequired (logger);
973991
992+ LogManager::SetTransmitProfile (TransmitProfile_RealTime);
974993 LogManager::UploadNow ();
975- waitForEvents (2 /* timeout*/ , 4 /* expected count*/ ); // Start and EventWithAllowedLevel
994+ waitForEvents (5 /* timeout*/ , 4 /* expected count*/ ); // Start and EventWithAllowedLevel
976995
977996 auto sentRecords = records ();
978997 ASSERT_EQ (sentRecords.size (), static_cast <size_t >(4 )); // Start and EventWithAllowedLevel
@@ -1175,7 +1194,8 @@ TEST_F(BasicFuncTests, killSwitchWorks)
11751194 myLogger->LogEvent (event2);
11761195 }
11771196 }
1178- // Try to upload and wait for 2 seconds to complete
1197+ // Try to upload and wait for completion
1198+ LogManager::SetTransmitProfile (TransmitProfile_RealTime);
11791199 LogManager::UploadNow ();
11801200 PAL::sleep (2000 );
11811201
0 commit comments