Skip to content
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
13 changes: 10 additions & 3 deletions test/database/postgres-vector.int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ import { test } from '../__helpers/int/vitest.js'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)

// Read through the primary. `payload.db.drizzle` is the withReplicas() handle whose reads
// default to a replica, which races replication lag right after a write.
const primaryDb = (payload: BasePayload): PostgresDB => {
const adapter = payload.db as PostgresAdapter
return adapter.primaryDrizzle ?? adapter.drizzle
}

test.suite({ db: (adapter) => adapter.startsWith('postgres') })(
'postgres vector custom column',
() => {
Expand Down Expand Up @@ -112,7 +119,7 @@ test.suite({ db: (adapter) => adapter.startsWith('postgres') })(

const similarity = sql<number>`1 - (${cosineDistance(payload.db.tables.posts.embedding, catEmbedding)})`

const db = payload.db.drizzle as PostgresDB
const db = primaryDb(payload)

const res = await db
.select()
Expand Down Expand Up @@ -234,7 +241,7 @@ test.suite({ db: (adapter) => adapter.startsWith('postgres') })(

const distance = sql<number>`(${l2Distance(payload.db.tables.posts.embedding, catEmbedding)})`

const db = payload.db.drizzle as PostgresDB
const db = primaryDb(payload)

const res = await db
.select()
Expand Down Expand Up @@ -346,7 +353,7 @@ test.suite({ db: (adapter) => adapter.startsWith('postgres') })(

const similarity = sql<number>`1 - (${jaccardDistance(payload.db.tables.posts.embedding, catEmbedding)})`

const db = payload.db.drizzle as PostgresDB
const db = primaryDb(payload)

const res = await db
.select()
Expand Down
6 changes: 3 additions & 3 deletions test/queues/int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1464,8 +1464,8 @@ test.suite({ config: './config.ts' })('Queues - Payload', () => {
expect(payload.config.jobs.processingLease.duration).toBe(20 * 60 * 1000)
expect(payload.config.jobs.processingLease.safetyBuffer).toBe(30_000)
payload.config.jobs.deleteJobOnComplete = false
payload.config.jobs.processingLease.duration = 600
payload.config.jobs.processingLease.safetyBuffer = 50
payload.config.jobs.processingLease.duration = 5000
payload.config.jobs.processingLease.safetyBuffer = 300

const postTitle = 'created by the healthy worker'
const job = await payload.jobs.queue({
Expand All @@ -1486,7 +1486,7 @@ test.suite({ config: './config.ts' })('Queues - Payload', () => {
)
.toBeTruthy()
// Wait longer than the original lease. Heartbeats must keep the first worker active.
await wait(900)
await wait(6000)

const secondWorkerResult = await payload.jobs.run({ silent: true })
const firstWorkerResult = await firstWorker
Expand Down
Loading