@@ -479,4 +479,49 @@ class TowerClientTest extends Specification {
479
479
" local-platform::${ ProcessHelper.selfPid()} " | null | null | [TOWER_ALLOW_NEXTFLOW_LOGS :' true' ]
480
480
' aws-batch::1234z' | ' xyz.out' | ' hola.log' | [TOWER_ALLOW_NEXTFLOW_LOGS :' true' , AWS_BATCH_JOB_ID : ' 1234z' , NXF_OUT_FILE : ' xyz.out' , NXF_LOG_FILE : ' hola.log' ]
481
481
}
482
+
483
+ def ' should deduplicate containers' () {
484
+ given :
485
+ def client = Spy (new TowerClient ())
486
+ and :
487
+ def c1 = new ContainerMeta (requestId : ' 12345' , sourceImage : ' ubuntu:latest' , targetImage : ' wave.io/12345/ubuntu:latest' )
488
+ def c2 = new ContainerMeta (requestId : ' 54321' , sourceImage : ' ubuntu:latest' , targetImage : ' wave.io/54321/ubuntu:latest' )
489
+ and :
490
+ def trace1 = new TraceRecord (
491
+ taskId : 1 ,
492
+ process : ' foo' ,
493
+ workdir : " /work/dir" ,
494
+ cpus : 1 ,
495
+ submit : System . currentTimeMillis(),
496
+ start : System . currentTimeMillis(),
497
+ complete : System . currentTimeMillis())
498
+ trace1. containerMeta = c1
499
+ and :
500
+ def trace2 = new TraceRecord (
501
+ taskId : 2 ,
502
+ process : ' foo' ,
503
+ workdir : " /work/dir" ,
504
+ cpus : 1 ,
505
+ submit : System . currentTimeMillis(),
506
+ start : System . currentTimeMillis(),
507
+ complete : System . currentTimeMillis())
508
+ trace2. containerMeta = c2
509
+ and :
510
+ def trace3 = new TraceRecord (
511
+ taskId : 3 ,
512
+ process : ' foo' ,
513
+ workdir : " /work/dir" ,
514
+ cpus : 1 ,
515
+ submit : System . currentTimeMillis(),
516
+ start : System . currentTimeMillis(),
517
+ complete : System . currentTimeMillis())
518
+ trace3. containerMeta = c2
519
+
520
+ expect :
521
+ client. getNewContainers([trace1]) == [c1]
522
+ and :
523
+ client. getNewContainers([trace1]) == []
524
+ and :
525
+ client. getNewContainers([trace1, trace2, trace3]) == [c2]
526
+ }
482
527
}
0 commit comments