@@ -466,7 +466,10 @@ def app
466
466
file_name = "test_file_name"
467
467
content = "This is a test file, with content 1."
468
468
request = {
469
- file_name => content
469
+ files : [ {
470
+ filename : file_name ,
471
+ content : content
472
+ } ]
470
473
}
471
474
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /file/write" , request )
472
475
expect ( last_response . status ) . to eq ( 200 )
@@ -499,7 +502,12 @@ def app
499
502
it 'requests a file from the workspace' do
500
503
# Write a file to the workspace
501
504
workspace_id = Vulcan ::Workspace . all [ 0 ] . id
502
- request = { "test_file_name" : "This is a test file, with content 1" }
505
+ request = {
506
+ files : [ {
507
+ filename : "test_file_name" ,
508
+ content : "This is a test file, with content 1"
509
+ } ]
510
+ }
503
511
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace_id } /file/write" , request )
504
512
expect ( last_response . status ) . to eq ( 200 )
505
513
@@ -558,6 +566,27 @@ def app
558
566
expect ( last_response . status ) . to eq ( 200 )
559
567
end
560
568
569
+ it 'alerts if snakemake is still running' do
570
+ auth_header ( :editor )
571
+ workspace = Vulcan ::Workspace . all [ 0 ]
572
+ write_files_to_workspace ( workspace . id )
573
+ request = {
574
+ params : {
575
+ count_bytes : true ,
576
+ count_chars : false ,
577
+ add : 2 ,
578
+ add_and_multiply_by : 4
579
+ }
580
+ }
581
+ post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /config" , request )
582
+ config_id = json_body [ :config_id ]
583
+ post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ config_id } " )
584
+ post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ config_id } " )
585
+ expect ( last_response . status ) . to eq ( 429 )
586
+ expect ( json_body [ :error ] ) . to eq ( "workflow is still running..." )
587
+ end
588
+
589
+
561
590
it 'can run the first step of a workflow' do
562
591
auth_header ( :editor )
563
592
workspace = Vulcan ::Workspace . all [ 0 ]
@@ -572,6 +601,7 @@ def app
572
601
}
573
602
}
574
603
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /config" , request )
604
+ expect ( last_response . status ) . to eq ( 200 )
575
605
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ json_body [ :config_id ] } " )
576
606
run_id = json_body [ :run_id ]
577
607
expect ( last_response . status ) . to eq ( 200 )
@@ -609,7 +639,7 @@ def app
609
639
expect ( json_body [ :run_id ] ) . to_not be_nil
610
640
run_id = json_body [ :run_id ]
611
641
# Make sure jobs are finished
612
- check_jobs_status ( [ "count" , "arithmetic" , "checker" ] ) do
642
+ check_jobs_status ( [ "count" , "arithmetic" , "checker" ] , 5 ) do
613
643
get ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ run_id } " )
614
644
end
615
645
# Outputs are created
@@ -624,7 +654,6 @@ def app
624
654
expect ( remote_manager . file_exists? ( obj . log_path ) ) . to be_truthy
625
655
end
626
656
627
-
628
657
it 'can run one step and then another' do
629
658
auth_header ( :editor )
630
659
workspace = Vulcan ::Workspace . all [ 0 ]
@@ -638,6 +667,7 @@ def app
638
667
}
639
668
640
669
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /config" , request )
670
+ expect ( last_response . status ) . to eq ( 200 )
641
671
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ json_body [ :config_id ] } " )
642
672
expect ( last_response . status ) . to eq ( 200 )
643
673
run_id = json_body [ :run_id ]
@@ -659,7 +689,7 @@ def app
659
689
expect ( last_response . status ) . to eq ( 200 )
660
690
config_id = json_body [ :config_id ]
661
691
# Sometimes snakemake still needs a minute to shut-down even though slurm reports the job as complete
662
- run_workflow_with_retry do
692
+ run_workflow_with_retry ( 5 ) do
663
693
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ config_id } " )
664
694
end
665
695
expect ( last_response . status ) . to eq ( 200 )
@@ -700,18 +730,27 @@ def app
700
730
}
701
731
}
702
732
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /config" , request )
703
- post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ json_body [ :config_id ] } " )
733
+ config_id = json_body [ :config_id ]
734
+ post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ config_id } " )
704
735
run_id = json_body [ :run_id ]
705
736
check_jobs_status ( [ "count" , "arithmetic" , "checker" ] ) do
706
737
get ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ run_id } " )
707
738
end
708
739
expect ( last_response . status ) . to eq ( 200 )
709
740
710
- # Next step involves writing files to the workspace
711
- request = { "test_file_name" : "This is a test file, with content 1" }
741
+ # Next step involves UI steps - so we just simulate this by writing files to the workspace
742
+ request = {
743
+ files : [ {
744
+ filename : "ui_job_one.txt" ,
745
+ content : "This is a test file, with content 1"
746
+ } , {
747
+ filename : "ui_job_two.txt" ,
748
+ content : "This is a test file, with content 2"
749
+ } ]
750
+ }
712
751
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /file/write" , request )
713
752
714
- # Run the last job, send the same params as before
753
+ # Run the last job, send the same params as before (this is what the UI does)
715
754
request = {
716
755
params : {
717
756
count_bytes : true ,
@@ -720,8 +759,9 @@ def app
720
759
add_and_multiply_by : 4
721
760
}
722
761
}
762
+
763
+ # The config has not changed - just the files
723
764
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /config" , request )
724
- config_id = json_body [ :config_id ]
725
765
run_workflow_with_retry do
726
766
post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ config_id } " )
727
767
end
@@ -751,26 +791,6 @@ def app
751
791
752
792
end
753
793
754
- it 'alerts if snakemake is still running' do
755
- auth_header ( :editor )
756
- workspace = Vulcan ::Workspace . all [ 0 ]
757
- write_files_to_workspace ( workspace . id )
758
- request = {
759
- params : {
760
- count_bytes : true ,
761
- count_chars : false ,
762
- add : 2 ,
763
- add_and_multiply_by : 4
764
- }
765
- }
766
- post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /config" , request )
767
- config_id = json_body [ :config_id ]
768
- post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ config_id } " )
769
- post ( "/api/v2/#{ PROJECT } /workspace/#{ workspace . id } /run/#{ config_id } " )
770
- expect ( last_response . status ) . to eq ( 429 )
771
- expect ( json_body [ :error ] ) . to eq ( "workflow is still running..." )
772
- end
773
-
774
794
end
775
795
776
796
context 'status checking' , long_running : true do
@@ -790,14 +810,14 @@ def app
790
810
791
811
end
792
812
793
- it 'invokes the first step of a workflow' do
813
+ it 'checks the status of the first step of a workflow' do
794
814
auth_header ( :editor )
795
815
workspace = Vulcan ::Workspace . all [ 0 ]
796
816
write_files_to_workspace ( workspace . id )
797
817
request = {
798
818
params : {
799
- count_bytes : true ,
800
- count_chars : false
819
+ count_bytes : false ,
820
+ count_chars : true
801
821
}
802
822
}
803
823
# TODO: add a meta key that can switch profiles
0 commit comments