apple / apple/swift-distributed-actors

Revive clustered swim test: test_swim_shouldNotifyClusterAboutUnreachableNode_whenUnreachableDiscoveredByOtherNode

Open
#757 1 comment 0 reactions 0 assignees View on GitHub
1 - triaged size/S
Dominant language
Swift
Stars
679
Forks
84
PR merge metrics
No merged PRs in 30d

Description

```swift
func test_swim_shouldNotifyClusterAboutUnreachableNode_whenUnreachableDiscoveredByOtherNode() throws {
let first = self.setUpFirst { settings in
// purposefully too large timeouts, we want the first node to be informed by the third node
// about the second node being unreachable/dead, and ensure that the first node also signals an
// unreachability event to the cluster upon such discovery.
settings.cluster.swim.lifeguard.suspicionTimeoutMax = .seconds(100)
settings.cluster.swim.lifeguard.suspicionTimeoutMin = .seconds(10)
settings.cluster.swim.pingTimeout = .seconds(3)
}
let second = self.setUpSecond()
let secondNode = second.cluster.uniqueNode
let third = self.setUpNode("third") { settings in
settings.cluster.swim.lifeguard.suspicionTimeoutMin = .nanoseconds(2)
settings.cluster.swim.lifeguard.suspicionTimeoutMax = .nanoseconds(2)
settings.cluster.swim.pingTimeout = .milliseconds(300)
}

first.cluster.join(node: second.cluster.uniqueNode.node)
third.cluster.join(node: second.cluster.uniqueNode.node)
try assertAssociated(first, withExactly: [second.cluster.uniqueNode, third.cluster.uniqueNode])
try assertAssociated(second, withExactly: [first.cluster.uniqueNode, third.cluster.uniqueNode])
try assertAssociated(third, withExactly: [first.cluster.uniqueNode, second.cluster.uniqueNode])

let firstTestKit = self.testKit(first)
let p1 = firstTestKit.spawnTestProbe(expecting: Cluster.Event.self)
first.cluster.events.subscribe(p1.ref)

let thirdTestKit = self.testKit(third)
let p3 = thirdTestKit.spawnTestProbe(expecting: Cluster.Event.self)
third.cluster.events.subscribe(p3.ref)

try self.expectReachabilityInSnapshot(firstTestKit, node: secondNode, expect: .reachable)
try self.expectReachabilityInSnapshot(thirdTestKit, node: secondNode, expect: .reachable)

// kill the second node
second.shutdown()

try self.expectReachabilityEvent(thirdTestKit, p3, node: secondNode, expect: .unreachable)
try self.expectReachabilityEvent(firstTestKit, p1, node: secondNode, expect: .unreachable)

// we also expect the snapshot to include the right reachability information now
try self.expectReachabilityInSnapshot(firstTestKit, node: secondNode, expect: .unreachable)
try self.expectReachabilityInSnapshot(thirdTestKit, node: secondNode, expect: .unreachable)
}

```

Contributor guide

Open the contributing guide

Research direction

Locate the named test, test_swim_shouldNotifyClusterAboutUnreachableNode_whenUnreachableDiscoveredByOtherNode, and inspect the surrounding SWIM test helpers such as setUpFirst, setUpSecond, setUpNode, and the reachability assertions. Run the test after determining what prevents it from being revived; done means the cluster reports the killed second node as unreachable in both events and snapshots.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
distributed-systems, testing
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.