-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RUMM-334 Integration&Benchmark moved to Datadog.xcworkspace
Integration and Benchmark projects are removed
- Loading branch information
Showing
48 changed files
with
540 additions
and
2,045 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,3 @@ | |
/.build | ||
/.swiftpm | ||
xcuserdata/ | ||
|
||
# SPM-generated .xcodedproj | ||
Datadog.xcodeproj |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
Datadog/TargetSupport/DatadogIntegrationTests/DatadogIntegrationTests.xcconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MOCK_SERVER_ADDRESS= |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// TestHelpers.swift | ||
// IntegrationTests | ||
// | ||
// Created by Mert Buran on 15/04/2020. | ||
// Copyright © 2020 Datadog. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
func clearPersistedLogs() throws { | ||
let logFilesSubdirectory = "com.datadoghq.logs/v1" | ||
let cachesDirectoryURL = FileManager.default.urls( | ||
for: .cachesDirectory, | ||
in: .userDomainMask | ||
).first | ||
let subdirectoryURL = cachesDirectoryURL?.appendingPathComponent( | ||
logFilesSubdirectory, | ||
isDirectory: true | ||
) | ||
if let dirToRemove = subdirectoryURL { | ||
try FileManager.default.removeItem(at: dirToRemove) | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
Tests/DatadogTests/Datadog/Core/Persistence/LoggingIOBenchmarkTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// | ||
// LoggingIOBenchmarkTests.swift | ||
// DatadogTests | ||
// | ||
// Created by Mert Buran on 15/04/2020. | ||
// Copyright © 2020 Datadog. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import Datadog | ||
|
||
class LoggingIOBenchmarkTests: XCTestCase { | ||
// swiftlint:disable implicitly_unwrapped_optional | ||
private var queue: DispatchQueue! | ||
private var directory: Directory! | ||
private var strategy: LogsPersistenceStrategy! | ||
// swiftlint:enable implicitly_unwrapped_optional | ||
|
||
override func setUp() { | ||
super.setUp() | ||
self.queue = DispatchQueue(label: "com.datadoghq.benchmark-logs-io", target: .global(qos: .utility)) | ||
self.directory = try! Directory(withSubdirectoryPath: "logging-benchmark") | ||
self.strategy = .default(in: directory, using: SystemDateProvider(), readWriteQueue: queue) | ||
XCTAssertTrue(try! directory.files().count == 0) | ||
} | ||
|
||
override func tearDown() { | ||
try! FileManager.default.removeItem(at: directory.url) | ||
queue = nil | ||
directory = nil | ||
strategy = nil | ||
super.tearDown() | ||
} | ||
|
||
func testWrittingLogsOnDisc() throws { | ||
let writer = strategy.writer | ||
let log = createRandomizedLog() | ||
|
||
measure { | ||
writer.write(value: log) | ||
queue.sync {} // wait to complete async write | ||
} | ||
} | ||
|
||
func testReadingLogsFromDisc() throws { | ||
let writer = strategy.writer | ||
let reader = strategy.reader | ||
|
||
while try directory.files().count < 10 { // `measureMetrics {}` is fired 10 times so 10 batch files are required | ||
writer.write(value: createRandomizedLog()) | ||
queue.sync {} // wait to complete async write | ||
} | ||
|
||
// Wait enough time for `reader` to accept the youngest batch file | ||
Thread.sleep(forTimeInterval: LogsPersistenceStrategy.Constants.minFileAgeForRead + 0.1) | ||
|
||
measureMetrics([.wallClockTime], automaticallyStartMeasuring: false) { | ||
self.startMeasuring() | ||
let batch = reader.readNextBatch() | ||
self.stopMeasuring() | ||
|
||
XCTAssertNotNil(batch, "Not enough batch files were created for this benchmark.") | ||
|
||
if let batch = batch { | ||
reader.markBatchAsRead(batch) | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Helpers | ||
|
||
private func createRandomizedLog() -> Log { | ||
return Log( | ||
date: Date(), | ||
status: .info, | ||
message: "message \(Int.random(in: 0..<100))", | ||
serviceName: "service-name", | ||
loggerName: "logger-name", | ||
loggerVersion: "0.0.0", | ||
threadName: "main", | ||
applicationVersion: "0.0.0", | ||
userInfo: .init(id: "abc-123", name: "foo", email: "foo@bar.com"), | ||
networkConnectionInfo: .init( | ||
reachability: .yes, | ||
availableInterfaces: [.cellular], | ||
supportsIPv4: true, | ||
supportsIPv6: true, | ||
isExpensive: false, | ||
isConstrained: false | ||
), | ||
mobileCarrierInfo: nil, | ||
attributes: ["attribute": EncodableValue("value")], | ||
tags: ["tag:value"] | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.