@@ -32,13 +32,30 @@ def async_index(index_schema, async_client):
3232
3333
3434@pytest .fixture
35- def async_index_from_dict ():
36- return AsyncSearchIndex .from_dict ({"index" : {"name" : "my_index" }, "fields" : fields })
35+ def async_index_from_dict (request ):
36+ # In xdist, the config has "workerid" in workerinput
37+ workerinput = getattr (request .config , "workerinput" , {})
38+ worker_id = workerinput .get ("workerid" , "master" )
39+
40+ return AsyncSearchIndex .from_dict (
41+ {"index" : {"name" : "my_index" , "prefix" : f"rvl_{ worker_id } " }, "fields" : fields }
42+ )
3743
3844
3945@pytest .fixture
40- def async_index_from_yaml ():
41- return AsyncSearchIndex .from_yaml ("schemas/test_json_schema.yaml" )
46+ def async_index_from_yaml (request ):
47+ # In xdist, the config has "workerid" in workerinput
48+ workerinput = getattr (request .config , "workerinput" , {})
49+ worker_id = workerinput .get ("workerid" , "master" )
50+
51+ # Load the schema from YAML
52+ schema = IndexSchema .from_yaml ("schemas/test_json_schema.yaml" )
53+
54+ # Modify the prefix to include the worker ID
55+ schema .index .prefix = f"{ schema .index .prefix } _{ worker_id } "
56+
57+ # Create the AsyncSearchIndex with the modified schema
58+ return AsyncSearchIndex (schema = schema )
4259
4360
4461def test_search_index_properties (index_schema , async_index ):
0 commit comments