Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mobile: Fix missing logging output in Swift integration tests #36040

Merged
merged 9 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/CancelGRPCStreamTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class CancelGRPCStreamTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testCancelGRPCStream() {
let filterName = "cancel_validation_filter"

Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/CancelStreamTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class CancelStreamTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testCancelStream() {
let filterName = "cancel_validation_filter"

Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/EndToEndNetworkingTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ final class EndToEndNetworkingTest: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testNetworkRequestReturnsHeadersAndData() {
EnvoyTestServer.startHttp1PlaintextServer()
EnvoyTestServer.setHeadersAndData(
Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/EngineApiTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ final class EngineApiTest: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testEngineApis() throws {
let engineExpectation = self.expectation(description: "Engine Running")

Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/FilterResetIdleTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class FilterResetIdleTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testFilterResetIdle() {
let filterName = "reset_idle_test_filter"

Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/GRPCReceiveErrorTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class GRPCReceiveErrorTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testReceiveError() {
let filterName = "error_validation_filter"

Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/IdleTimeoutTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class IdleTimeoutTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testIdleTimeout() {
let filterName = "reset_idle_test_filter"

Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/KeyValueStoreTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class KeyValueStoreTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testKeyValueStore() {
// swiftlint:disable:next line_length
let kvStoreType = "type.googleapis.com/envoymobile.extensions.filters.http.test_kv_store.TestKeyValueStore"
Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/ReceiveDataTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class ReceiveDataTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testReceiveData() {
let directResponseBody = "response_body"
EnvoyTestServer.startHttp1PlaintextServer()
Expand Down
10 changes: 7 additions & 3 deletions mobile/test/swift/integration/ReceiveErrorTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ final class ReceiveErrorTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testReceiveError() {
let filterName = "error_validation_filter"

Expand Down Expand Up @@ -59,9 +66,6 @@ final class ReceiveErrorTests: XCTestCase {
.setLogger { _, msg in
print(msg, terminator: "")
}
.setLogger { _, msg in
print(msg, terminator: "")
}
.addPlatformFilter(
name: filterName,
factory: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class ResetConnectivityStateTest: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testResetConnectivityState() {
EnvoyTestServer.startHttp1PlaintextServer()

Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/SendDataTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class SendDataTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testSendData() throws {
EnvoyTestServer.startHttp1PlaintextServer()
EnvoyTestServer.setHeadersAndData("x-response-foo", header_value: "aaa", response_body: "data")
Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/SendHeadersTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class SendHeadersTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testSendHeaders() {
EnvoyTestServer.startHttp1PlaintextServer()

Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/SendTrailersTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class SendTrailersTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testSendTrailers() throws {
// swiftlint:disable:next line_length
let assertionFilterType = "type.googleapis.com/envoymobile.extensions.filters.http.assertion.Assertion"
Expand Down
7 changes: 7 additions & 0 deletions mobile/test/swift/integration/SetEventTrackerTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class SetEventTrackerTest: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testSetEventTracker() throws {
EnvoyTestServer.startHttp1PlaintextServer()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class SetEventTrackerTestNoTracker: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testEmitEventWithoutSettingEventTracker() throws {
EnvoyTestServer.startHttp1PlaintextServer()

Expand Down
15 changes: 10 additions & 5 deletions mobile/test/swift/integration/SetLoggerTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ final class LoggerTests: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

func testSetLogger() throws {
let engineExpectation = self.expectation(description: "Run started engine")
let loggingExpectation = self.expectation(description: "Run used platform logger")
Expand All @@ -24,16 +31,14 @@ final class LoggerTests: XCTestCase {
.setLogLevel(.debug)
.setLogger { _, msg in
print(msg, terminator: "")
if msg.contains("starting main dispatch loop") {
loggingExpectation.fulfill()
}
}
.addNativeFilter(
name: "test_logger",
// swiftlint:disable:next line_length
typedConfig: "[type.googleapis.com/envoymobile.extensions.filters.http.test_logger.TestLogger]{}")
.setLogger { _, msg in
if msg.contains("starting main dispatch loop") {
loggingExpectation.fulfill()
}
}
.setOnEngineRunning {
engineExpectation.fulfill()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ final class HTTPRequestUsingProxyTest: XCTestCase {
register_test_extensions()
}

override static func tearDown() {
super.tearDown()
// Flush the stdout and stderror to show the print output.
fflush(stdout)
fflush(stderr)
}

private func executeRequest(engine: Engine, scheme: String, authority: String) -> String? {
let responseHeadersExpectation =
self.expectation(description: "Successful response headers received")
Expand Down