@@ -28,6 +28,7 @@ type IndexWorkerTestSuite struct {
2828 logger * logrus.Entry
2929 maxUsersThreshold int64
3030 ensureUserSearchIndexesExist bool
31+ isOrioleDB bool
3132}
3233
3334func (ts * IndexWorkerTestSuite ) SetupSuite () {
@@ -59,6 +60,14 @@ func (ts *IndexWorkerTestSuite) SetupSuite() {
5960 require .NoError (ts .T (), popConn .Open ())
6061 ts .popDB = popConn
6162
63+ // Detect if the users table uses OrioleDB
64+ isOrioleDB , err := isOrioleDBTable (popConn , config .DB .Namespace , "users" )
65+ if err != nil {
66+ ts .T ().Logf ("Failed to detect OrioleDB, assuming standard PostgreSQL: %v" , err )
67+ } else {
68+ ts .isOrioleDB = isOrioleDB
69+ }
70+
6271 // Ensure we have a clean state for testing
6372 ts .cleanupIndexes ()
6473}
@@ -90,6 +99,9 @@ func (ts *IndexWorkerTestSuite) cleanupIndexes() {
9099}
91100
92101func (ts * IndexWorkerTestSuite ) TestCreateIndexesHappyPath () {
102+ if ts .isOrioleDB {
103+ ts .T ().Skip ("OrioleDB does not support CREATE INDEX CONCURRENTLY" )
104+ }
93105 ctx := context .Background ()
94106
95107 err := CreateIndexes (ctx , ts .config , ts .logger )
@@ -132,6 +144,9 @@ func (ts *IndexWorkerTestSuite) TestGetIndexStatuses() {
132144}
133145
134146func (ts * IndexWorkerTestSuite ) TestIdempotency () {
147+ if ts .isOrioleDB {
148+ ts .T ().Skip ("OrioleDB does not support CREATE INDEX CONCURRENTLY" )
149+ }
135150 ctx := context .Background ()
136151
137152 // First run - create all indexes
@@ -188,6 +203,9 @@ func (ts *IndexWorkerTestSuite) TestIdempotency() {
188203
189204// If an index is removed out of band, it will be created when the method is called
190205func (ts * IndexWorkerTestSuite ) TestOutOfBandIndexRemoval () {
206+ if ts .isOrioleDB {
207+ ts .T ().Skip ("OrioleDB does not support CREATE INDEX CONCURRENTLY" )
208+ }
191209 ctx := context .Background ()
192210
193211 // First, create all indexes
@@ -235,6 +253,9 @@ func (ts *IndexWorkerTestSuite) TestOutOfBandIndexRemoval() {
235253
236254// Test concurrent access - workers coordinate via advisory lock
237255func (ts * IndexWorkerTestSuite ) TestConcurrentWorkers () {
256+ if ts .isOrioleDB {
257+ ts .T ().Skip ("OrioleDB does not support CREATE INDEX CONCURRENTLY" )
258+ }
238259 ctx := context .Background ()
239260
240261 numWorkers := 5
@@ -292,6 +313,9 @@ func getIndexNames(indexes []struct {
292313// TestMaxUsersThresholdSkipsIndexCreation verifies when EnsureUserSearchIndexesExist=false and MaxUsersThreshold > 0,
293314// index creation is skipped if user count exceeds the threshold.
294315func (ts * IndexWorkerTestSuite ) TestMaxUsersThresholdSkipsIndexCreation () {
316+ if ts .isOrioleDB {
317+ ts .T ().Skip ("OrioleDB does not support CREATE INDEX CONCURRENTLY" )
318+ }
295319 ctx := context .Background ()
296320
297321 // No explicit user opt-in - rely on threshold behavior
@@ -328,6 +352,9 @@ func (ts *IndexWorkerTestSuite) TestMaxUsersThresholdSkipsIndexCreation() {
328352// TestUserOptInAlwaysCreatesIndexes verifies that when EnsureUserSearchIndexesExist=true,
329353// indexes are always created regardless of user count or threshold setting.
330354func (ts * IndexWorkerTestSuite ) TestUserOptInAlwaysCreatesIndexes () {
355+ if ts .isOrioleDB {
356+ ts .T ().Skip ("OrioleDB does not support CREATE INDEX CONCURRENTLY" )
357+ }
331358 ctx := context .Background ()
332359
333360 // Insert test users so there's a non-zero user count
@@ -361,6 +388,9 @@ func (ts *IndexWorkerTestSuite) TestUserOptInAlwaysCreatesIndexes() {
361388// TestUserOptInWithZeroThreshold verifies that EnsureUserSearchIndexesExist=true
362389// with MaxUsersThreshold=0 (disabled) still creates indexes.
363390func (ts * IndexWorkerTestSuite ) TestUserOptInWithZeroThreshold () {
391+ if ts .isOrioleDB {
392+ ts .T ().Skip ("OrioleDB does not support CREATE INDEX CONCURRENTLY" )
393+ }
364394 ctx := context .Background ()
365395
366396 ts .config .IndexWorker .EnsureUserSearchIndexesExist = true
@@ -383,6 +413,9 @@ func (ts *IndexWorkerTestSuite) TestUserOptInWithZeroThreshold() {
383413// This test simulates a scenario where indexes become invalid (e.g., from interrupted CONCURRENT creation)
384414// and verifies that CreateIndexes properly handles them by dropping and recreating.
385415func (ts * IndexWorkerTestSuite ) TestCreateIndexesWithInvalidIndexes () {
416+ if ts .isOrioleDB {
417+ ts .T ().Skip ("OrioleDB does not support CREATE INDEX CONCURRENTLY" )
418+ }
386419 ctx := context .Background ()
387420
388421 // Step 1: Run CreateIndexes to create all indexes
@@ -477,6 +510,27 @@ func (ts *IndexWorkerTestSuite) TestCreateIndexesWithInvalidIndexes() {
477510 ts .logger .Infof ("Successfully recovered from %d invalid indexes" , len (indexesToInvalidate ))
478511}
479512
513+ func (ts * IndexWorkerTestSuite ) TestIsOrioleDBTableNonExistentTable () {
514+ _ , err := isOrioleDBTable (ts .popDB , ts .namespace , "nonexistent_table" )
515+ assert .Error (ts .T (), err , "Should return error for non-existent table" )
516+ }
517+
518+ func (ts * IndexWorkerTestSuite ) TestCreateIndexesSkipsOnOrioleDB () {
519+ if ! ts .isOrioleDB {
520+ ts .T ().Skip ("Test only runs on OrioleDB" )
521+ }
522+ ctx := context .Background ()
523+
524+ err := CreateIndexes (ctx , ts .config , ts .logger )
525+ require .ErrorIs (ts .T (), err , ErrOrioleDBUnsupported )
526+
527+ // Verify no indexes were created
528+ indexes := getUsersIndexes (ts .namespace )
529+ existingIndexes , err := getIndexStatuses (ts .popDB , ts .namespace , getIndexNames (indexes ))
530+ require .NoError (ts .T (), err )
531+ assert .Empty (ts .T (), existingIndexes , "No indexes should be created when OrioleDB is detected" )
532+ }
533+
480534// Run the test suite
481535func TestIndexWorker (t * testing.T ) {
482536 suite .Run (t , new (IndexWorkerTestSuite ))
0 commit comments