@@ -1241,14 +1241,8 @@ public void testExecuteSubtaskInScriptTask()
1241
1241
Table jobs = db .getSchema (SYSTEM_SCHEMA ).getTable ("Scripts" );
1242
1242
jobs .delete (row ("name" , parentJobName ));
1243
1243
db .dropSchemaIfExists ("ScriptWithFileUpload" );
1244
- jobs .insert (
1245
- row (
1246
- "name" ,
1247
- parentJobName ,
1248
- "type" ,
1249
- "python" ,
1250
- "script" ,
1251
- """
1244
+ String script =
1245
+ """
1252
1246
import asyncio
1253
1247
import logging
1254
1248
import os
@@ -1266,7 +1260,15 @@ async with Client('http://localhost:8081', token=os.environ['MOLGENIS_TOKEN'], j
1266
1260
if __name__ == '__main__':
1267
1261
asyncio.run(main())
1268
1262
1269
- """ ,
1263
+ """ ;
1264
+ jobs .insert (
1265
+ row (
1266
+ "name" ,
1267
+ parentJobName ,
1268
+ "type" ,
1269
+ "python" ,
1270
+ "script" ,
1271
+ script ,
1270
1272
"dependencies" ,
1271
1273
"--extra-index-url https://test.pypi.org/simple/\n "
1272
1274
+ "molgenis-emx2-pyclient>=11.22.0" ));
@@ -1279,8 +1281,39 @@ async with Client('http://localhost:8081', token=os.environ['MOLGENIS_TOKEN'], j
1279
1281
.asString ();
1280
1282
1281
1283
String url = new ObjectMapper ().readTree (result ).at ("/url" ).textValue ();
1284
+ assertTrue (testJobSuccess (url ));
1285
+
1286
+ String failingJobName = "failingJobTest" ;
1287
+ jobs .delete (row ("name" , failingJobName ));
1288
+ db .dropSchemaIfExists ("ScriptWithFileUpload" );
1289
+ String scriptFail = script .replace ("PET_STORE" , "PET_STORES" );
1290
+ jobs .insert (
1291
+ row (
1292
+ "name" ,
1293
+ failingJobName ,
1294
+ "type" ,
1295
+ "python" ,
1296
+ "script" ,
1297
+ scriptFail ,
1298
+ "dependencies" ,
1299
+ "--extra-index-url https://test.pypi.org/simple/\n "
1300
+ + "molgenis-emx2-pyclient>=11.22.0" ));
1282
1301
1283
- result = given ().sessionId (SESSION_ID ).get (url ).asString ();
1302
+ result =
1303
+ given ()
1304
+ .sessionId (SESSION_ID )
1305
+ .when ()
1306
+ .post ("/api/scripts/" + failingJobName )
1307
+ .getBody ()
1308
+ .asString ();
1309
+
1310
+ url = new ObjectMapper ().readTree (result ).at ("/url" ).textValue ();
1311
+ assertFalse (testJobSuccess (url ));
1312
+ }
1313
+
1314
+ private static boolean testJobSuccess (String url )
1315
+ throws InterruptedException , JsonProcessingException {
1316
+ String result = given ().sessionId (SESSION_ID ).get (url ).asString ();
1284
1317
1285
1318
String status = "WAITING" ;
1286
1319
int count = 0 ;
@@ -1292,9 +1325,7 @@ async with Client('http://localhost:8081', token=os.environ['MOLGENIS_TOKEN'], j
1292
1325
result = given ().sessionId (SESSION_ID ).get (url ).asString ();
1293
1326
status = new ObjectMapper ().readTree (result ).at ("/status" ).textValue ();
1294
1327
}
1295
- if (result .contains ("ERROR" )) {
1296
- fail (result );
1297
- }
1328
+ return !status .equals ("ERROR" );
1298
1329
}
1299
1330
1300
1331
private static String getToken (String email , String password ) throws JsonProcessingException {
0 commit comments