@@ -941,6 +941,53 @@ async def test_limits_job_submissions(
941941 },
942942 ]
943943
944+ @pytest .mark .asyncio
945+ @pytest .mark .parametrize (
946+ "client_version,expected_probes" ,
947+ [
948+ ("0.20.7" , []),
949+ ("0.20.8" , None ),
950+ (None , None ),
951+ ],
952+ )
953+ @pytest .mark .parametrize ("test_db" , ["sqlite" , "postgres" ], indirect = True )
954+ async def test_patches_service_configuration_probes_for_old_clients (
955+ self ,
956+ test_db ,
957+ session : AsyncSession ,
958+ client : AsyncClient ,
959+ client_version : Optional [str ],
960+ expected_probes : Optional [list ],
961+ ) -> None :
962+ user = await create_user (session = session )
963+ project = await create_project (session = session , owner = user )
964+ repo = await create_repo (session = session , project_id = project .id )
965+
966+ service_conf = ServiceConfiguration (
967+ commands = ["echo hello" ],
968+ port = 80 ,
969+ probes = None , # This should be patched to [] for clients prior to 0.20.8
970+ )
971+ run_spec = get_run_spec (
972+ configuration = service_conf ,
973+ repo_id = repo .name ,
974+ )
975+ await create_run (session = session , project = project , repo = repo , user = user , run_spec = run_spec )
976+
977+ headers = get_auth_headers (user .token )
978+ if client_version is not None :
979+ headers ["X-API-Version" ] = client_version
980+ response = await client .post (
981+ "/api/runs/list" ,
982+ headers = headers ,
983+ json = {"project_name" : project .name },
984+ )
985+
986+ assert response .status_code == 200
987+ runs_list = response .json ()
988+ assert len (runs_list ) == 1
989+ assert runs_list [0 ]["run_spec" ]["configuration" ]["probes" ] == expected_probes
990+
944991
945992class TestGetRun :
946993 @pytest .mark .asyncio
@@ -1020,6 +1067,53 @@ async def test_returns_deleted_run_given_id(
10201067 assert response .status_code == 200 , response .json ()
10211068 assert response .json ()["id" ] == str (run .id )
10221069
1070+ @pytest .mark .asyncio
1071+ @pytest .mark .parametrize (
1072+ "client_version,expected_probes" ,
1073+ [
1074+ ("0.20.7" , []),
1075+ ("0.20.8" , None ),
1076+ (None , None ),
1077+ ],
1078+ )
1079+ @pytest .mark .parametrize ("test_db" , ["sqlite" , "postgres" ], indirect = True )
1080+ async def test_patches_service_configuration_probes_for_old_clients (
1081+ self ,
1082+ test_db ,
1083+ session : AsyncSession ,
1084+ client : AsyncClient ,
1085+ client_version : Optional [str ],
1086+ expected_probes : Optional [list ],
1087+ ) -> None :
1088+ user = await create_user (session = session )
1089+ project = await create_project (session = session , owner = user )
1090+ repo = await create_repo (session = session , project_id = project .id )
1091+
1092+ service_conf = ServiceConfiguration (
1093+ commands = ["echo hello" ],
1094+ port = 80 ,
1095+ probes = None , # This should be patched to [] for clients prior to 0.20.8
1096+ )
1097+ run_spec = get_run_spec (
1098+ configuration = service_conf ,
1099+ repo_id = repo .name ,
1100+ )
1101+ run = await create_run (
1102+ session = session , project = project , repo = repo , user = user , run_spec = run_spec
1103+ )
1104+
1105+ headers = get_auth_headers (user .token )
1106+ if client_version is not None :
1107+ headers ["X-API-Version" ] = client_version
1108+ response = await client .post (
1109+ f"/api/project/{ project .name } /runs/get" ,
1110+ headers = headers ,
1111+ json = {"run_name" : run .run_name },
1112+ )
1113+
1114+ assert response .status_code == 200
1115+ assert response .json ()["run_spec" ]["configuration" ]["probes" ] == expected_probes
1116+
10231117
10241118class TestGetRunPlan :
10251119 @pytest .mark .asyncio
@@ -1477,6 +1571,65 @@ async def test_generates_user_ssh_key(self, session: AsyncSession, client: Async
14771571 assert user .ssh_public_key == run_spec_ssh_public_key
14781572 assert user .ssh_private_key is not None
14791573
1574+ @pytest .mark .asyncio
1575+ @pytest .mark .parametrize (
1576+ "client_version,expected_probes" ,
1577+ [
1578+ ("0.20.7" , []),
1579+ ("0.20.8" , None ),
1580+ (None , None ),
1581+ ],
1582+ )
1583+ @pytest .mark .parametrize ("test_db" , ["sqlite" , "postgres" ], indirect = True )
1584+ async def test_patches_service_configuration_probes_for_old_clients (
1585+ self ,
1586+ test_db ,
1587+ session : AsyncSession ,
1588+ client : AsyncClient ,
1589+ client_version : Optional [str ],
1590+ expected_probes : Optional [list ],
1591+ ) -> None :
1592+ user = await create_user (session = session )
1593+ project = await create_project (session = session , owner = user )
1594+ repo = await create_repo (session = session , project_id = project .id )
1595+
1596+ service_conf = ServiceConfiguration (
1597+ commands = ["echo hello" ],
1598+ port = 80 ,
1599+ probes = None , # This should be patched to [] for clients prior to 0.20.8
1600+ )
1601+ run_spec = get_run_spec (
1602+ run_name = "test-service" ,
1603+ configuration = service_conf ,
1604+ repo_id = repo .name ,
1605+ )
1606+ await create_run (
1607+ session = session ,
1608+ project = project ,
1609+ repo = repo ,
1610+ user = user ,
1611+ run_spec = run_spec ,
1612+ run_name = "test-service" ,
1613+ )
1614+
1615+ body = {"run_spec" : run_spec .dict ()}
1616+ headers = get_auth_headers (user .token )
1617+ if client_version is not None :
1618+ headers ["X-API-Version" ] = client_version
1619+ response = await client .post (
1620+ f"/api/project/{ project .name } /runs/get_plan" ,
1621+ headers = headers ,
1622+ json = body ,
1623+ )
1624+
1625+ assert response .status_code == 200
1626+ run_plan = response .json ()
1627+ assert run_plan ["run_spec" ]["configuration" ]["probes" ] == expected_probes
1628+ assert run_plan ["effective_run_spec" ]["configuration" ]["probes" ] == expected_probes
1629+ assert (
1630+ run_plan ["current_resource" ]["run_spec" ]["configuration" ]["probes" ] == expected_probes
1631+ )
1632+
14801633
14811634class TestApplyPlan :
14821635 @pytest .mark .asyncio
@@ -1668,6 +1821,57 @@ async def test_generates_user_ssh_key(self, session: AsyncSession, client: Async
16681821 assert user .ssh_public_key == run_spec_ssh_public_key
16691822 assert user .ssh_private_key is not None
16701823
1824+ @pytest .mark .asyncio
1825+ @pytest .mark .parametrize (
1826+ "client_version,expected_probes" ,
1827+ [
1828+ ("0.20.7" , []), # Prior to 0.20.8, probes=None should be patched to []
1829+ ("0.20.8" , None ), # 0.20.8 and later should keep probes=None
1830+ (None , None ), # None client version should keep probes=None
1831+ ],
1832+ )
1833+ @pytest .mark .parametrize ("test_db" , ["sqlite" , "postgres" ], indirect = True )
1834+ async def test_patches_service_configuration_probes_for_old_clients (
1835+ self ,
1836+ test_db ,
1837+ session : AsyncSession ,
1838+ client : AsyncClient ,
1839+ client_version : Optional [str ],
1840+ expected_probes : Optional [list ],
1841+ ) -> None :
1842+ user = await create_user (session = session )
1843+ project = await create_project (session = session , owner = user )
1844+ repo = await create_repo (session = session , project_id = project .id )
1845+
1846+ service_conf = ServiceConfiguration (
1847+ commands = ["echo hello" ],
1848+ port = 80 ,
1849+ probes = None , # This should be patched to [] for clients prior to 0.20.8
1850+ )
1851+ run_spec = get_run_spec (
1852+ run_name = "test-service" ,
1853+ configuration = service_conf ,
1854+ repo_id = repo .name ,
1855+ )
1856+
1857+ headers = get_auth_headers (user .token )
1858+ if client_version is not None :
1859+ headers ["X-API-Version" ] = client_version
1860+ response = await client .post (
1861+ f"/api/project/{ project .name } /runs/apply" ,
1862+ headers = headers ,
1863+ json = {
1864+ "plan" : {
1865+ "run_spec" : run_spec .dict (),
1866+ "current_resource" : None ,
1867+ },
1868+ "force" : False ,
1869+ },
1870+ )
1871+
1872+ assert response .status_code == 200
1873+ assert response .json ()["run_spec" ]["configuration" ]["probes" ] == expected_probes
1874+
16711875
16721876class TestSubmitRun :
16731877 @pytest .mark .asyncio
0 commit comments