Hi All,
In my project, The Unit Test need the dependency of Couchbase instance, so I create a docker image and start it up with the UT.
I have create an Index when build the docker image: CREATE INDEX class_index ON flowgatetest(_class) USING GSI WITH {\"defer_build\":false}
The issue is, When the UT run and call the couchbase, it failed frequently by saying:
No index available on keyspace flowgatetest that matches your query. Use CREATE INDEX or CREATE PRIMARY INDEX to create an index, or check that your expected index is online.
I must sleep several minutes to wait the Index online, and sometimes even wait a long time the index is still not available.
So how can I fix this issue, what should I do to make the Index online immediately , Thanks a lot for your help
Are you loading data into the database and then creating the index? If so, it might make more sense to do it the other way around so that the index gets “built” on an empty dataset and then keeps itself up-to-date as the data comes in.
I’d also suggest you have a look at our integration with TestContainers. It may not directly solve your issue here, but it will be a more standardized way of implementing your tests.
Understood thank you. Also just to confirm, the query you’re running matches that index correct?
I’m surprised that it’s taking several minutes to come online, but if there are very few CPU/disk resources available then I suppose it could take a little bit of time. Another approach might be to use cbq to query for the state of the index and then you’ll know exactly when it is online: Getting System Information | Couchbase Docs