Skip to content

Commit 77c3c1c

Browse files
committed
Merge branch 'main' into enable-logging-grpc-calloptions
2 parents 2319145 + 9829ff1 commit 77c3c1c

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

Sources/Instrumentation/URLSession/URLSessionInstrumentation.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ public class URLSessionInstrumentation {
388388
let block: @convention(block) (Any, URLSession, URLSessionDataTask, URLResponse, @escaping (URLSession.ResponseDisposition) -> Void) -> Void = { object, session, dataTask, response, completion in
389389
if objc_getAssociatedObject(session, &idKey) == nil {
390390
self.urlSession(session, dataTask: dataTask, didReceive: response, completionHandler: completion)
391-
completion(.allow)
392391
}
393392
let key = String(selector.hashValue)
394393
objc_setAssociatedObject(session, key, true, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)

Tests/ExportersTests/PersistenceExporter/Storage/OrchestratedFileWriterTests.swift

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -83,59 +83,60 @@ class OrchestratedFileWriterTests: XCTestCase {
8383
}
8484

8585
/// NOTE: Test added after incident-4797
86-
func testWhenIOExceptionsHappenRandomly_theFileIsNeverMalformed() throws {
87-
let expectation = self.expectation(description: "write completed")
88-
let writer = OrchestratedFileWriter(
89-
orchestrator: FilesOrchestrator(
90-
directory: temporaryDirectory,
91-
performance: StoragePerformanceMock(
92-
maxFileSize: .max,
93-
maxDirectorySize: .max,
94-
maxFileAgeForWrite: .distantFuture, // write to single file
95-
minFileAgeForRead: .distantFuture,
96-
maxFileAgeForRead: .distantFuture,
97-
maxObjectsInFile: .max, // write to single file
98-
maxObjectSize: .max
99-
),
100-
dateProvider: SystemDateProvider()
101-
)
102-
)
103-
104-
let ioInterruptionQueue = DispatchQueue(label: "com.otel.persistence.file-writer-random-io")
105-
106-
func randomlyInterruptIO(for file: File?) {
107-
ioInterruptionQueue.async { try? file?.makeReadonly() }
108-
ioInterruptionQueue.async { try? file?.makeReadWrite() }
109-
}
110-
111-
struct Foo: Codable {
112-
var foo = "bar"
113-
}
114-
115-
let jsonEncoder = JSONEncoder()
116-
117-
// Write 300 of `Foo`s and interrupt writes randomly
118-
try (0..<300).forEach { _ in
119-
var fooData = try jsonEncoder.encode(Foo())
120-
fooData.append(",".utf8Data)
121-
writer.write(data: fooData)
122-
randomlyInterruptIO(for: try? temporaryDirectory.files().first)
123-
}
124-
125-
ioInterruptionQueue.sync {}
126-
waitForWritesCompletion(on: writer.queue, thenFulfill: expectation)
127-
waitForExpectations(timeout: 7, handler: nil)
128-
XCTAssertEqual(try temporaryDirectory.files().count, 1)
129-
130-
let fileData = try temporaryDirectory.files()[0].read()
131-
let jsonDecoder = JSONDecoder()
132-
133-
// Assert that data written is not malformed
134-
let writtenData = try jsonDecoder.decode([Foo].self, from: "[".utf8Data + fileData + "]".utf8Data)
135-
// Assert that some (including all) `Foo`s were written
136-
XCTAssertGreaterThan(writtenData.count, 0)
137-
XCTAssertLessThanOrEqual(writtenData.count, 300)
138-
}
86+
/// NOTE 2: Test disabled after random failures/successes
87+
// func testWhenIOExceptionsHappenRandomly_theFileIsNeverMalformed() throws {
88+
// let expectation = self.expectation(description: "write completed")
89+
// let writer = OrchestratedFileWriter(
90+
// orchestrator: FilesOrchestrator(
91+
// directory: temporaryDirectory,
92+
// performance: StoragePerformanceMock(
93+
// maxFileSize: .max,
94+
// maxDirectorySize: .max,
95+
// maxFileAgeForWrite: .distantFuture, // write to single file
96+
// minFileAgeForRead: .distantFuture,
97+
// maxFileAgeForRead: .distantFuture,
98+
// maxObjectsInFile: .max, // write to single file
99+
// maxObjectSize: .max
100+
// ),
101+
// dateProvider: SystemDateProvider()
102+
// )
103+
// )
104+
//
105+
// let ioInterruptionQueue = DispatchQueue(label: "com.otel.persistence.file-writer-random-io")
106+
//
107+
// func randomlyInterruptIO(for file: File?) {
108+
// ioInterruptionQueue.async { try? file?.makeReadonly() }
109+
// ioInterruptionQueue.async { try? file?.makeReadWrite() }
110+
// }
111+
//
112+
// struct Foo: Codable {
113+
// var foo = "bar"
114+
// }
115+
//
116+
// let jsonEncoder = JSONEncoder()
117+
//
118+
// // Write 300 of `Foo`s and interrupt writes randomly
119+
// try (0..<300).forEach { _ in
120+
// var fooData = try jsonEncoder.encode(Foo())
121+
// fooData.append(",".utf8Data)
122+
// writer.write(data: fooData)
123+
// randomlyInterruptIO(for: try? temporaryDirectory.files().first)
124+
// }
125+
//
126+
// ioInterruptionQueue.sync {}
127+
// waitForWritesCompletion(on: writer.queue, thenFulfill: expectation)
128+
// waitForExpectations(timeout: 7, handler: nil)
129+
// XCTAssertEqual(try temporaryDirectory.files().count, 1)
130+
//
131+
// let fileData = try temporaryDirectory.files()[0].read()
132+
// let jsonDecoder = JSONDecoder()
133+
//
134+
// // Assert that data written is not malformed
135+
// let writtenData = try jsonDecoder.decode([Foo].self, from: "[".utf8Data + fileData + "]".utf8Data)
136+
// // Assert that some (including all) `Foo`s were written
137+
// XCTAssertGreaterThan(writtenData.count, 0)
138+
// XCTAssertLessThanOrEqual(writtenData.count, 300)
139+
// }
139140

140141
private func waitForWritesCompletion(on queue: DispatchQueue, thenFulfill expectation: XCTestExpectation) {
141142
queue.async { expectation.fulfill() }

0 commit comments

Comments
 (0)