@@ -33,10 +33,11 @@ class Configuration(BaseModel):
33
33
log_area_provider : str
34
34
35
35
36
- async def configure_testrun (configuration : Configuration ) -> None :
36
+ async def configure_testrun (configuration : Configuration , expire : int ) -> None :
37
37
"""Configure an ETOS testrun with the configuration passed by user.
38
38
39
39
:param configuration: The configuration to save.
40
+ :param expire: etcd lease expiration time in seconds
40
41
"""
41
42
testrun = ETCDPath (f"/testrun/{ configuration .suite_id } " )
42
43
providers = ETCDPath ("/environment/provider" )
@@ -45,30 +46,34 @@ async def configure_testrun(configuration: Configuration) -> None:
45
46
providers .join (f"log-area/{ configuration .log_area_provider } " ),
46
47
configuration .log_area_provider ,
47
48
testrun .join ("provider/log-area" ),
49
+ expire ,
48
50
)
49
51
await do_configure (
50
52
providers .join (f"execution-space/{ configuration .execution_space_provider } " ),
51
53
configuration .execution_space_provider ,
52
54
testrun .join ("provider/execution-space" ),
55
+ expire ,
53
56
)
54
57
await do_configure (
55
58
providers .join (f"iut/{ configuration .iut_provider } " ),
56
59
configuration .iut_provider ,
57
60
testrun .join ("provider/iut" ),
61
+ expire ,
58
62
)
59
- await save_json (testrun .join ("provider/dataset" ), configuration .dataset )
63
+ await save_json (testrun .join ("provider/dataset" ), configuration .dataset , expire )
60
64
61
65
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 :
63
67
"""Configure a provider based on provider ID and save it to a testrun.
64
68
65
69
:param path: Path to load provider from.
66
70
:param provider_id: The ID of the provider to load.
67
71
:param testrun: Where to store the loaded provider.
72
+ :param expire: etcd lease expiration time in seconds
68
73
"""
69
74
if (provider := await load (path )) is None :
70
75
raise AssertionError (f"{ provider_id } does not exist" )
71
- await save_json (testrun , provider )
76
+ await save_json (testrun , provider , expire )
72
77
73
78
74
79
async def load (path : ETCDPath ) -> Optional [dict ]:
@@ -82,7 +87,7 @@ async def load(path: ETCDPath) -> Optional[dict]:
82
87
return None
83
88
84
89
85
- async def save_json (path : ETCDPath , data : dict , expire = 3600 ) -> None :
90
+ async def save_json (path : ETCDPath , data : dict , expire : int ) -> None :
86
91
"""Save data as json to an ETCD path.
87
92
88
93
:param path: The path to store data on.
0 commit comments