Fix test flakiness related to background task cancellation changes (#174)

This commit is contained in:
Paul Beusterien authored and GitHub committed 2026-07-27 10:47:34 -07:00
1 parent 840d723f01
commit 80e91edbda
5 files changed
+14

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
# Unreleased
- Fix `EXC_BAD_ACCESS` crash in `GDTCORLogAssert` when a user's project path contains `%` characters. ([#16455](https://github.com/firebase/firebase-ios-sdk/issues/16455))
- Fix test flakiness in `GDTCCTIntegrationTest` and `GDTCCTUploaderTest` related to background task cancellation.
- Cancel upload operation when background task expires.
- Log error when handling directory enumeration.
@@ -630,6 +630,10 @@ typedef void (^GDTCCTUploaderEventBatchBlock)(NSNumber *_Nullable batchID,
}
- (void)start {
if (self.isCancelled) {
[self finishOperation];
return;
}
[self startOperation];
GDTCORLogDebug(@"Upload operation started: %@", self);
@@ -28,7 +28,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface GDTCCTUploader () <NSURLSessionDelegate, GDTCCTUploadMetadataProvider>
#if !GDT_TEST
@property(nonatomic, readonly) NSOperationQueue *uploadOperationQueue;
#endif
@property(nonatomic, readonly) dispatch_queue_t uploadQueue;
@property(nonatomic, readonly)
@@ -33,6 +33,9 @@ NS_ASSUME_NONNULL_BEGIN
/** An upload URL used across all targets. For testing only. */
@property(class, nullable, nonatomic) NSURL *testServerURL;
/** The queue on which upload operations run. For testing only. */
@property(nonatomic, readonly) NSOperationQueue *uploadOperationQueue;
/** Spins runloop until upload finishes or timeout.
* @return YES if upload finishes, NO in the case of timeout.
*/
@@ -64,6 +64,10 @@ static NSString *const kMetricEventMappingID = @"1710";
@implementation GDTCCTIntegrationTest
- (void)setUp {
// Cancel pending operations from previous tests and wait for them to finish.
[[GDTCCTUploader sharedInstance].uploadOperationQueue cancelAllOperations];
[[GDTCCTUploader sharedInstance] waitForUploadFinishedWithTimeout:5];
// Make sure clean storage state before start.
[[GDTCORFlatFileStorage sharedInstance] reset];