@@ -44,12 +44,18 @@ def elasticsearch8_responsive(scheme: str, host: str, port: int, user: str, pass
4444 return False
4545
4646
47+ @pytest .fixture (scope = "session" )
48+ def elasticsearch_service_memory_limit () -> str :
49+ return "1g"
50+
51+
4752@contextlib .contextmanager
4853def _provide_elasticsearch_service (
4954 docker_service : DockerService ,
5055 image : str ,
5156 name : str ,
5257 client_cls : type [Elasticsearch7 | Elasticsearch8 ],
58+ memory_limit : str ,
5359) -> Generator [ElasticsearchService , None , None ]:
5460 user = "elastic"
5561 password = "changeme"
@@ -79,6 +85,7 @@ def check(_service: ServiceContainer) -> bool:
7985 timeout = 120 ,
8086 pause = 1 ,
8187 transient = True ,
88+ mem_limit = "1g" ,
8289 ) as service :
8390 yield ElasticsearchService (
8491 host = service .host ,
@@ -91,23 +98,31 @@ def check(_service: ServiceContainer) -> bool:
9198
9299
93100@pytest .fixture (autouse = False , scope = "session" )
94- def elasticsearch_7_service (docker_service : DockerService ) -> Generator [ElasticsearchService , None , None ]:
101+ def elasticsearch_7_service (
102+ docker_service : DockerService ,
103+ elasticsearch_service_memory_limit : str ,
104+ ) -> Generator [ElasticsearchService , None , None ]:
95105 with _provide_elasticsearch_service (
96106 docker_service = docker_service ,
97107 image = "elasticsearch:7.17.19" ,
98108 name = "elasticsearch-7" ,
99109 client_cls = Elasticsearch7 ,
110+ memory_limit = elasticsearch_service_memory_limit ,
100111 ) as service :
101112 yield service
102113
103114
104115@pytest .fixture (autouse = False , scope = "session" )
105- def elasticsearch_8_service (docker_service : DockerService ) -> Generator [ElasticsearchService , None , None ]:
116+ def elasticsearch_8_service (
117+ docker_service : DockerService ,
118+ elasticsearch_service_memory_limit : str ,
119+ ) -> Generator [ElasticsearchService , None , None ]:
106120 with _provide_elasticsearch_service (
107121 docker_service = docker_service ,
108122 image = "elasticsearch:8.13.0" ,
109123 name = "elasticsearch-8" ,
110124 client_cls = Elasticsearch8 ,
125+ memory_limit = elasticsearch_service_memory_limit ,
111126 ) as service :
112127 yield service
113128
0 commit comments