Skip to content

Commit 3a6327c

Browse files
committed
validate against "main" swift cluster membership after async changes
1 parent dd39636 commit 3a6327c

File tree

10 files changed

+27
-27
lines changed

10 files changed

+27
-27
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ var dependencies: [Package.Dependency] = [
142142

143143
// .package(url: "https://github.com/apple/swift-cluster-membership", from: "0.3.0"),
144144
// .package(name: "swift-cluster-membership", path: "Packages/swift-cluster-membership"), // FIXME: just work in progress
145-
.package(url: "https://github.com/yim-lee/swift-cluster-membership", branch: "async-await"),
145+
.package(url: "https://github.com/apple/swift-cluster-membership", branch: "main"),
146146

147147
.package(url: "https://github.com/apple/swift-nio", from: "2.40.0"),
148148
.package(url: "https://github.com/apple/swift-nio-extras", from: "1.2.0"),

Sources/DistributedActors/ActorLogging.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Logging
2020
/// - Warning: NOT thread safe! Only use from Actors, properly synchronize access, or create multiple instances for each execution context.
2121
internal final class LoggingContext {
2222
// TODO: deprecate, we should not need this explicit type
23-
23+
2424
let identifier: String
2525

2626
// TODO: want to eventually not have this; also move to more structured logging perhaps...

Sources/DistributedActors/Cluster/SWIM/SWIMActorShell.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import SWIM
2525
internal distributed actor SWIMActorShell: SWIMPeer, SWIMAddressablePeer, CustomStringConvertible {
2626
typealias ActorSystem = ClusterSystem
2727
typealias SWIMInstance = SWIM.Instance<SWIMActorShell, SWIMActorShell, SWIMActorShell>
28-
28+
2929
private let settings: SWIM.Settings
3030
private let clusterRef: ClusterShell.Ref
3131

@@ -38,9 +38,10 @@ internal distributed actor SWIMActorShell: SWIMPeer, SWIMAddressablePeer, Custom
3838
protocol: self.id.uniqueNode.node.protocol,
3939
host: self.id.uniqueNode.host,
4040
port: self.id.uniqueNode.port,
41-
uid: self.id.uniqueNode.nid.value)
41+
uid: self.id.uniqueNode.nid.value
42+
)
4243
}
43-
44+
4445
private lazy var log: Logger = {
4546
var log = Logger(actor: self)
4647
log.logLevel = self.settings.logger.logLevel
@@ -445,7 +446,7 @@ internal distributed actor SWIMActorShell: SWIMPeer, SWIMAddressablePeer, Custom
445446

446447
throw SWIMActorError.noResponse
447448
}
448-
449+
449450
nonisolated func pingRequest(
450451
target: SWIMActorShell,
451452
payload: SWIM.GossipPayload<SWIMActorShell>,
@@ -463,7 +464,6 @@ internal distributed actor SWIMActorShell: SWIMPeer, SWIMAddressablePeer, Custom
463464
}
464465
}
465466

466-
467467
distributed func pingRequest(
468468
target: SWIMActorShell,
469469
pingRequestOrigin: SWIMActorShell,

Sources/DistributedActorsTestKit/Cluster/ClusteredActorSystemsXCTestCase.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ open class ClusteredActorSystemsXCTestCase: XCTestCase {
9999
return (first, second)
100100
}
101101

102-
override open func tearDown() {
102+
override open func tearDown() async throws {
103103
let testsFailed = self.testRun?.totalFailureCount ?? 0 > 0
104104
if self.captureLogs, self.alwaysPrintCaptureLogs || testsFailed {
105105
self.printAllCapturedLogs()
106106
}
107107

108-
self._nodes.forEach { node in
108+
for node in self._nodes {
109109
node.log.warning("======================== TEST TEAR DOWN: SHUTDOWN ========================")
110-
try! node.shutdown().wait()
110+
try! await node.shutdown().wait()
111111
}
112112

113113
self._nodes = []

Sources/DistributedActorsTestKit/ClusterSystemXCTestCase.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ open class ClusterSystemXCTestCase: ClusteredActorSystemsXCTestCase {
4646
_ = await self.setUpNode(String(describing: type(of: self)))
4747
}
4848

49-
override open func tearDown() {
50-
super.tearDown()
49+
override open func tearDown() async throws {
50+
try await super.tearDown()
5151
}
5252

5353
override open func setUpNode(_ name: String, _ modifySettings: ((inout ClusterSystemSettings) -> Void)? = nil) async -> ClusterSystem {

Tests/DistributedActorsTests/Cluster/Protobuf/Membership+SerializationTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ final class MembershipSerializationTests: ClusterSystemXCTestCase {
2626
allocator: system.settings.serialization.allocator
2727
)
2828

29-
override func tearDown() {
30-
super.tearDown()
29+
override func tearDown() async throws {
30+
try await super.tearDown()
3131
self.context = nil
3232
}
3333

Tests/DistributedActorsTests/Cluster/SWIM/SWIMActorShellClusteredTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ final class SWIMShellClusteredTests: ClusteredActorSystemsXCTestCase {
3131
super.setUp()
3232
}
3333

34-
override func tearDown() {
35-
super.tearDown()
34+
override func tearDown() async throws {
35+
try await super.tearDown()
3636
self.metrics = nil
3737
MetricsSystem.bootstrapInternal(NOOPMetricsHandler.instance)
3838
}
@@ -109,7 +109,7 @@ final class SWIMShellClusteredTests: ClusteredActorSystemsXCTestCase {
109109
throw testKit(firstNode).fail("Expected ack, but got \(response)")
110110
}
111111

112-
(pinged as! SWIMActorShell).shouldEqual(first)
112+
pinged.shouldEqual(first)
113113
incarnation.shouldEqual(0)
114114
}
115115

@@ -218,7 +218,7 @@ final class SWIMShellClusteredTests: ClusteredActorSystemsXCTestCase {
218218
throw testKit(firstNode).fail("Expected ack, but got \(response)")
219219
}
220220

221-
(pinged as! SWIMActorShell).shouldEqual(third)
221+
pinged.shouldEqual(third)
222222
incarnation.shouldEqual(0)
223223
}
224224

@@ -392,8 +392,8 @@ final class SWIMShellClusteredTests: ClusteredActorSystemsXCTestCase {
392392
}
393393

394394
members.count.shouldEqual(2)
395-
members.shouldContain(where: { ($0.peer as! SWIMActorShell) == secondPeer && $0.status == .alive(incarnation: 0) })
396-
members.shouldContain(where: { ($0.peer as! SWIMActorShell) == first && $0.status == .alive(incarnation: 0) })
395+
members.shouldContain(where: { $0.peer == secondPeer && $0.status == .alive(incarnation: 0) })
396+
members.shouldContain(where: { $0.peer == first && $0.status == .alive(incarnation: 0) })
397397
}
398398

399399
func test_SWIMShell_shouldMonitorJoinedClusterMembers() async throws {
@@ -466,7 +466,7 @@ final class SWIMShellClusteredTests: ClusteredActorSystemsXCTestCase {
466466
} ?? []
467467

468468
let otherStatus = membership
469-
.first(where: { $0.peer as! SWIMActorShell == peer })
469+
.first(where: { $0.peer == peer })
470470
.map(\.status)
471471

472472
guard otherStatus == status else {

Tests/DistributedActorsTests/Metrics/ActorMetricsTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ final class ActorMetricsTests: ClusteredActorSystemsXCTestCase {
2929
MetricsSystem.bootstrapInternal(self.metrics)
3030
}
3131

32-
override func tearDown() {
33-
super.tearDown()
32+
override func tearDown() async throws {
33+
try await super.tearDown()
3434
self.metrics = nil
3535
MetricsSystem.bootstrapInternal(NOOPMetricsHandler.instance)
3636
}

Tests/DistributedActorsTests/Metrics/SWIMActorPeerMetricsTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ final class ActorMetricsSWIMActorPeerMetricsTests: ClusteredActorSystemsXCTestCa
2929
super.setUp()
3030
}
3131

32-
override func tearDown() {
33-
super.tearDown()
32+
override func tearDown() async throws {
33+
try await super.tearDown()
3434
self.metrics = nil
3535
MetricsSystem.bootstrapInternal(NOOPMetricsHandler.instance)
3636
}

Tests/DistributedActorsTests/SerializationPoolTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ final class SerializationPoolTests: XCTestCase {
106106
self.actorPath2 = try! ActorPath([ActorPathSegment("foo"), ActorPathSegment("baz")])
107107
}
108108

109-
override func tearDown() {
110-
try! self.system.shutdown().wait()
109+
override func tearDown() async throws {
110+
try! await self.system.shutdown().wait()
111111
self.system = nil
112112
self.testKit = nil
113113
try! self.elg.syncShutdownGracefully()

0 commit comments

Comments
 (0)