Skip to content

Commit

Permalink
Updated the table lock policy test timings to attempt to stabilize CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnoon committed May 2, 2018
1 parent 6a26aae commit 35dcf04
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions Tests/Tests/Database/TableLockPolicyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
// When
DispatchQueue.userInitiated.async {
do {
try TestTables.insertDummyAgents(count: 1_000, connection: writeConnection)
try TestTables.insertDummyAgents(count: 10_000, connection: writeConnection)
} catch {
writeError = error
}

writeExpectation.fulfill()
}

DispatchQueue.userInitiated.asyncAfter(seconds: 0.01) {
DispatchQueue.userInitiated.asyncAfter(seconds: 0.1) {
do {
readCount = try readConnection.query("SELECT count(*) FROM agents")
} catch {
Expand Down Expand Up @@ -99,7 +99,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
sharedCache: true
)

try TestTables.insertDummyAgents(count: 1_000, connection: writeConnection)
try TestTables.insertDummyAgents(count: 5_000, connection: writeConnection)

let writeExpectation = self.expectation(description: "Write should fail")
let readExpectation = self.expectation(description: "Read should succeed")
Expand All @@ -119,9 +119,9 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
readExpectation.fulfill()
}

DispatchQueue.userInitiated.asyncAfter(seconds: 0.01) {
DispatchQueue.userInitiated.asyncAfter(seconds: 0.1) {
do {
try TestTables.insertDummyAgents(count: 1_000, connection: writeConnection)
try TestTables.insertDummyAgents(count: 5_000, connection: writeConnection)
} catch {
writeError = error
}
Expand All @@ -132,7 +132,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
waitForExpectations(timeout: timeout, handler: nil)

// Then
XCTAssertEqual(agents.count, 1_002)
XCTAssertEqual(agents.count, 5_002)
XCTAssertNil(readError)
XCTAssertNotNil(writeError)

Expand All @@ -156,7 +156,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
sharedCache: true
)

try TestTables.insertDummyAgents(count: 1_000, connection: writeConnection)
try TestTables.insertDummyAgents(count: 5_000, connection: writeConnection)

let writeExpectation = self.expectation(description: "Write should fail")
let readExpectation = self.expectation(description: "Read should succeed")
Expand All @@ -176,7 +176,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
readExpectation.fulfill()
}

DispatchQueue.userInitiated.asyncAfter(seconds: 0.01) {
DispatchQueue.userInitiated.asyncAfter(seconds: 0.1) {
do {
let dateString = bindingDateFormatter.string(from: Date())

Expand All @@ -196,7 +196,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
waitForExpectations(timeout: timeout, handler: nil)

// Then
XCTAssertEqual(agents.count, 1_002)
XCTAssertEqual(agents.count, 5_002)
XCTAssertNil(readError)
XCTAssertNotNil(writeError)

Expand Down Expand Up @@ -232,15 +232,15 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
// When
DispatchQueue.userInitiated.async {
do {
try TestTables.insertDummyAgents(count: 1_000, connection: writeConnection)
try TestTables.insertDummyAgents(count: 5_000, connection: writeConnection)
} catch {
writeError = error
}

writeExpectation.fulfill()
}

DispatchQueue.userInitiated.asyncAfter(seconds: 0.01) {
DispatchQueue.userInitiated.asyncAfter(seconds: 0.1) {
do {
readCount = try readConnection.query("SELECT count(*) FROM agents")
} catch {
Expand All @@ -255,7 +255,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
// Then
XCTAssertNil(writeError)
XCTAssertNil(readError)
XCTAssertEqual(readCount, 1_002)
XCTAssertEqual(readCount, 5_002)
}

func testThatConnectionDoesNotThrowErrorWhenReadLockBlocksWriteLockWithTableLockPolicyEnabled() throws {
Expand All @@ -273,7 +273,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
sharedCache: true
)

try TestTables.insertDummyAgents(count: 1_000, connection: writeConnection)
try TestTables.insertDummyAgents(count: 5_000, connection: writeConnection)

let writeExpectation = self.expectation(description: "Write should succeed")
let readExpectation = self.expectation(description: "Read should succeed")
Expand All @@ -293,9 +293,9 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
readExpectation.fulfill()
}

DispatchQueue.userInitiated.asyncAfter(seconds: 0.01) {
DispatchQueue.userInitiated.asyncAfter(seconds: 0.1) {
do {
try TestTables.insertDummyAgents(count: 1_000, connection: writeConnection)
try TestTables.insertDummyAgents(count: 5_000, connection: writeConnection)
} catch {
writeError = error
}
Expand All @@ -306,7 +306,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
waitForExpectations(timeout: timeout, handler: nil)

// Then
XCTAssertEqual(agents.count, 1_002)
XCTAssertEqual(agents.count, 5_002)
XCTAssertNil(readError)
XCTAssertNil(writeError)
}
Expand All @@ -326,7 +326,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
sharedCache: true
)

try TestTables.insertDummyAgents(count: 1_000, connection: writeConnection)
try TestTables.insertDummyAgents(count: 5_000, connection: writeConnection)

let writeExpectation = self.expectation(description: "Write should succeed")
let readExpectation = self.expectation(description: "Read should succeed")
Expand All @@ -346,7 +346,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
readExpectation.fulfill()
}

DispatchQueue.userInitiated.asyncAfter(seconds: 0.01) {
DispatchQueue.userInitiated.asyncAfter(seconds: 0.1) {
do {
let dateString = bindingDateFormatter.string(from: Date())

Expand All @@ -366,7 +366,7 @@ class TableLockPolicyTestCase: BaseConnectionTestCase {
waitForExpectations(timeout: timeout, handler: nil)

// Then
XCTAssertEqual(agents.count, 1_002)
XCTAssertEqual(agents.count, 5_002)
XCTAssertNil(readError)
XCTAssertNil(writeError)
}
Expand Down

0 comments on commit 35dcf04

Please sign in to comment.