Skip to content

Commit 3004d47

Browse files
committed
NR-323013 trying to fix the flakey tests
1 parent 87338c4 commit 3004d47

File tree

3 files changed

+8
-70
lines changed

3 files changed

+8
-70
lines changed

Tests/Unit-Tests/NewRelicAgentTests/Analytics-Tests/PersistentStoreTests.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ - (void)testEventRemoval {
289289

290290
XCTestExpectation *waitForInitialWriteExpectation = [self expectationWithDescription:@"Waiting for the first time the file is written"];
291291
PersistentEventStore *sut = [[PersistentEventStore alloc] initWithFilename:testFilename
292-
andMinimumDelay:1];
292+
andMinimumDelay:.025];
293293

294294
NSError *error = nil;
295295

Tests/Unit-Tests/NewRelicAgentTests/Uncategorized/NRLoggerTests.m

Lines changed: 6 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,6 @@ - (void) tearDown
6868

6969
- (void) testNRLogger {
7070

71-
XCTestExpectation *delayExpectation1 = [self expectationWithDescription:@"Waiting for Log Queue"];
72-
73-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
74-
[delayExpectation1 fulfill];
75-
});
76-
77-
[self waitForExpectationsWithTimeout:5 handler:^(NSError * _Nullable error) {
78-
if (error) {
79-
XCTFail(@"Timeout error");
80-
}
81-
}];
82-
8371
[NewRelic logInfo: @"Info Log..."];
8472
[NewRelic logError: @"Error Log..."];
8573
[NewRelic logVerbose:@"Verbose Log..."];
@@ -93,20 +81,9 @@ - (void) testNRLogger {
9381
@"additionalAttribute2": @"attribute2"
9482
}];
9583

96-
XCTestExpectation *delayExpectation2 = [self expectationWithDescription:@"Waiting for Log Queue"];
97-
98-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
99-
[delayExpectation2 fulfill];
100-
});
101-
102-
[self waitForExpectationsWithTimeout:5 handler:^(NSError * _Nullable error) {
103-
if (error) {
104-
XCTFail(@"Timeout error");
105-
}
106-
}];
84+
sleep(5);
10785

10886
NSError* error;
109-
NSString *path = [NRLogger logFilePath];
11087
NSData* logData = [NRLogger logFileData:&error];
11188
if(error){
11289
NSLog(@"%@", error.localizedDescription);
@@ -174,17 +151,7 @@ - (void) testRemoteLogLevels {
174151
// Set the remote log level to Debug.
175152
[NRLogger setRemoteLogLevel:NRLogLevelDebug];
176153

177-
XCTestExpectation *delayExpectation1 = [self expectationWithDescription:@"Waiting for Log Queue"];
178-
179-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
180-
[delayExpectation1 fulfill];
181-
});
182-
183-
[self waitForExpectationsWithTimeout:5 handler:^(NSError * _Nullable error) {
184-
if (error) {
185-
XCTFail(@"Timeout error");
186-
}
187-
}];
154+
sleep(1);
188155

189156
// Seven messages should reach the remote log file for upload.
190157

@@ -201,17 +168,7 @@ - (void) testRemoteLogLevels {
201168
@"additionalAttribute2": @"attribute2"
202169
}];
203170

204-
XCTestExpectation *delayExpectation2 = [self expectationWithDescription:@"Waiting for Log Queue"];
205-
206-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
207-
[delayExpectation2 fulfill];
208-
});
209-
210-
[self waitForExpectationsWithTimeout:5 handler:^(NSError * _Nullable error) {
211-
if (error) {
212-
XCTFail(@"Timeout error");
213-
}
214-
}];
171+
sleep(5);
215172

216173
NSError* error;
217174
NSData* logData = [NRLogger logFileData:&error];
@@ -264,17 +221,7 @@ - (void) testLocalLogLevels {
264221
// Set the remote log level to Info.
265222
[NRLogger setRemoteLogLevel:NRLogLevelInfo];
266223

267-
XCTestExpectation *delayExpectation1 = [self expectationWithDescription:@"Waiting for Log Queue"];
268-
269-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
270-
[delayExpectation1 fulfill];
271-
});
272-
273-
[self waitForExpectationsWithTimeout:5 handler:^(NSError * _Nullable error) {
274-
if (error) {
275-
XCTFail(@"Timeout error");
276-
}
277-
}];
224+
sleep(1);
278225

279226
// Seven messages should reach the remote log file for upload.
280227

@@ -291,17 +238,7 @@ - (void) testLocalLogLevels {
291238
@"additionalAttribute2": @"attribute2"
292239
}];
293240

294-
XCTestExpectation *delayExpectation2 = [self expectationWithDescription:@"Waiting for Log Queue"];
295-
296-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
297-
[delayExpectation2 fulfill];
298-
});
299-
300-
[self waitForExpectationsWithTimeout:5 handler:^(NSError * _Nullable error) {
301-
if (error) {
302-
XCTFail(@"Timeout error");
303-
}
304-
}];
241+
sleep(5);
305242

306243
NSError* error;
307244
NSData* logData = [NRLogger logFileData:&error];
@@ -352,7 +289,7 @@ - (void) testAutoCollectedLogs {
352289
[NRLogger setRemoteLogLevel:NRLogLevelDebug];
353290
XCTAssertTrue([NRAutoLogCollector redirectStandardOutputAndError]);
354291

355-
sleep(5);
292+
sleep(1);
356293

357294
// Three messages should reach the remote log file for upload.
358295
NSLog(@"NSLog Test \n\n");

Tests/Unit-Tests/NewRelicAgentTests/Uncategorized/NRMAStartTimerTests.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ -(void)test {
4949
[[NRMAStartTimer sharedInstance] createDurationMetric];
5050

5151
[NRMASupportMetricHelper processDeferredMetrics];
52+
sleep(1);
5253
[NRMATaskQueue synchronousDequeue];
5354

5455
NRMANamedValueMeasurement* measurement = ((NRMANamedValueMeasurement*)helper.result);

0 commit comments

Comments
 (0)