@@ -33,10 +33,11 @@ class Configuration(BaseModel):
3333 log_area_provider : str
3434
3535
36- async def configure_testrun (configuration : Configuration ) -> None :
36+ async def configure_testrun (configuration : Configuration , expire : int ) -> None :
3737 """Configure an ETOS testrun with the configuration passed by user.
3838
3939 :param configuration: The configuration to save.
40+ :param expire: etcd lease expiration time in seconds
4041 """
4142 testrun = ETCDPath (f"/testrun/{ configuration .suite_id } " )
4243 providers = ETCDPath ("/environment/provider" )
@@ -45,30 +46,34 @@ async def configure_testrun(configuration: Configuration) -> None:
4546 providers .join (f"log-area/{ configuration .log_area_provider } " ),
4647 configuration .log_area_provider ,
4748 testrun .join ("provider/log-area" ),
49+ expire ,
4850 )
4951 await do_configure (
5052 providers .join (f"execution-space/{ configuration .execution_space_provider } " ),
5153 configuration .execution_space_provider ,
5254 testrun .join ("provider/execution-space" ),
55+ expire ,
5356 )
5457 await do_configure (
5558 providers .join (f"iut/{ configuration .iut_provider } " ),
5659 configuration .iut_provider ,
5760 testrun .join ("provider/iut" ),
61+ expire ,
5862 )
59- await save_json (testrun .join ("provider/dataset" ), configuration .dataset )
63+ await save_json (testrun .join ("provider/dataset" ), configuration .dataset , expire )
6064
6165
62- async def do_configure (path : ETCDPath , provider_id : str , testrun : ETCDPath ) -> None :
66+ async def do_configure (path : ETCDPath , provider_id : str , testrun : ETCDPath , expire : int ) -> None :
6367 """Configure a provider based on provider ID and save it to a testrun.
6468
6569 :param path: Path to load provider from.
6670 :param provider_id: The ID of the provider to load.
6771 :param testrun: Where to store the loaded provider.
72+ :param expire: etcd lease expiration time in seconds
6873 """
6974 if (provider := await load (path )) is None :
7075 raise AssertionError (f"{ provider_id } does not exist" )
71- await save_json (testrun , provider )
76+ await save_json (testrun , provider , expire )
7277
7378
7479async def load (path : ETCDPath ) -> Optional [dict ]:
@@ -82,7 +87,7 @@ async def load(path: ETCDPath) -> Optional[dict]:
8287 return None
8388
8489
85- async def save_json (path : ETCDPath , data : dict , expire = 3600 ) -> None :
90+ async def save_json (path : ETCDPath , data : dict , expire : int ) -> None :
8691 """Save data as json to an ETCD path.
8792
8893 :param path: The path to store data on.
0 commit comments