-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44db06f
commit 5b97627
Showing
4 changed files
with
41 additions
and
43 deletions.
There are no files selected for viewing
This file was deleted.
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
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,40 @@ | ||
import MongoDB | ||
import Testing | ||
|
||
@Suite | ||
struct Fsync | ||
{ | ||
@Test(arguments: [.single, .replicated] as [any Mongo.TestConfiguration]) | ||
func fsync(_ configuration:any Mongo.TestConfiguration) async throws | ||
{ | ||
let bootstrap:Mongo.DriverBootstrap = configuration.bootstrap(on: .singleton) | ||
try await bootstrap.withSessionPool(logger: .init(level: .error)) | ||
{ | ||
try await self.run(with: $0) | ||
} | ||
} | ||
|
||
func run(with pool:Mongo.SessionPool) async throws | ||
{ | ||
// We should ensure we are locking and unlocking the same node! | ||
let node:Mongo.ReadPreference = .nearest(tagSets: [["name": "A"]]) | ||
|
||
var lock:Mongo.FsyncLock | ||
|
||
lock = try await pool.run(command: Mongo.Fsync.init(lock: true), | ||
against: .admin, | ||
on: node) | ||
|
||
#expect(lock.count == 1) | ||
|
||
// We should always be able to run the ping command, even if the | ||
// node is write-locked. | ||
try await pool.run(command: Mongo.Ping.init(), against: .admin, on: node) | ||
|
||
lock = try await pool.run(command: Mongo.FsyncUnlock.init(), | ||
against: .admin, | ||
on: node) | ||
|
||
#expect(lock.count == 0) | ||
} | ||
} |