From 15c86beba08eaaeb6dae3c06af3350193e8cd531 Mon Sep 17 00:00:00 2001 From: Lukas Mueller Date: Fri, 24 Sep 2021 16:39:48 -0400 Subject: [PATCH 1/5] fix t/unit_fixture/CXGN/Uploading/ValidateNIRS.t test. The success message of a function was changed and that change needed to be reflected in the test. --- t/unit_fixture/CXGN/Stock/MergeStock.t | 18 +++++++----------- t/unit_fixture/CXGN/Uploading/ValidateNIRS.t | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/t/unit_fixture/CXGN/Stock/MergeStock.t b/t/unit_fixture/CXGN/Stock/MergeStock.t index 4802951050..bb401273e7 100644 --- a/t/unit_fixture/CXGN/Stock/MergeStock.t +++ b/t/unit_fixture/CXGN/Stock/MergeStock.t @@ -10,43 +10,39 @@ use CXGN::Stock; my $f = SGN::Test::Fixture->new(); my $schema = $f->bcs_schema(); -my $dbh = $f->dbh(); -$dbh->begin_work(); +$schema->txn_begin(); eval { my $this_stock_id = 39041; my $other_stock_id = 38844; my $stock = CXGN::Stock->new( { schema => $schema, stock_id => $this_stock_id } ); - + my $initial_counts = get_counts($this_stock_id); # try self merge, should fail: my $error = $stock->merge($this_stock_id); is($error, "Error: cannot merge stock into itself", "merge stock into itself test"); - + my $initial_counts_other = get_counts($other_stock_id); $error = $stock->merge(38844); is($error, 1, "merge stock should give no error"); - + # all data should be transferred, so these need to add up my $combined_counts = get_counts($this_stock_id); - + $initial_counts_other->{prop_count}++; # take added synonym into account foreach my $k (keys %$combined_counts) { print STDERR "Checking key $k...\n"; is($combined_counts->{$k}, ($initial_counts->{$k} + $initial_counts_other->{$k}), "$k test"); - } - - - + } }; print STDERR "ERROR = $@\n"; -$dbh->rollback(); +$schema->txn_rollback(); done_testing(); diff --git a/t/unit_fixture/CXGN/Uploading/ValidateNIRS.t b/t/unit_fixture/CXGN/Uploading/ValidateNIRS.t index 056302485b..f4297af764 100644 --- a/t/unit_fixture/CXGN/Uploading/ValidateNIRS.t +++ b/t/unit_fixture/CXGN/Uploading/ValidateNIRS.t @@ -82,7 +82,7 @@ my $message_hash = decode_json $message; print STDERR Dumper $message_hash; ok($message_hash->{figure}); is(scalar(@{$message_hash->{success}}), 8); -is($message_hash->{success}->[6], 'All values in your file are now saved in the database!'); +like($message_hash->{success}->[6], qr/All values in your file have been successfully processed!/, "return message test"); my $nirs_protocol_id = $message_hash->{nd_protocol_id}; my $ds = CXGN::Dataset->new( people_schema => $f->people_schema(), schema => $f->bcs_schema()); From e75c44d224e608ae99b71c851ca3db7c5882e7ba Mon Sep 17 00:00:00 2001 From: Lukas Mueller Date: Fri, 24 Sep 2021 17:49:26 -0400 Subject: [PATCH 2/5] fix python path for drone test. --- sgn_test.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sgn_test.conf b/sgn_test.conf index cffc38a9f5..e13a989c8e 100644 --- a/sgn_test.conf +++ b/sgn_test.conf @@ -40,6 +40,10 @@ brapi_POST any brapi_PUT any brapi_OPTIONS any +# for drone stuff +python_executable /usr/bin/python3.5 +python_executable_maskrcnn_env /usr/bin/python3.5 + # slurm config backend Slurm From 17b4e9377ffea8c13926ba8970ee1c4173b77001 Mon Sep 17 00:00:00 2001 From: Lukas Mueller Date: Fri, 24 Sep 2021 18:11:32 -0400 Subject: [PATCH 3/5] tweaking Storebrapiobservations.t test. When not logged in, should probably return 401 (not authorized) and not 400 as it previously expected. Currently the string returned is ERROR, which should be fixed in the backend to 401??? --- t/unit_fixture/CXGN/Uploading/Storebrapiobservations.t | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/unit_fixture/CXGN/Uploading/Storebrapiobservations.t b/t/unit_fixture/CXGN/Uploading/Storebrapiobservations.t index ba60d9eb2e..b360848c94 100644 --- a/t/unit_fixture/CXGN/Uploading/Storebrapiobservations.t +++ b/t/unit_fixture/CXGN/Uploading/Storebrapiobservations.t @@ -65,7 +65,7 @@ is_deeply($response, { 'metadata' => { 'status' => [ { - 'messageType' => '400', + 'messageType' => 'ERROR', 'message' => 'You must login and have permission to access this BrAPI call.' } ], @@ -129,7 +129,7 @@ is_deeply($response, { 'observationTimeStamp' => '2015-06-16T00:53:26Z', 'germplasmName' => 'test_accession3', 'observationUnitName' => 'test_trial210', - 'uploadedBy' => 41, + 'uploadedBy' => 'collector1', 'collector' => 'collector1', 'germplasmDbId' => 38842, 'observationUnitDbId' => 38866, @@ -143,7 +143,7 @@ is_deeply($response, { 'observationTimeStamp' => '2015-06-16T00:53:26Z', 'germplasmName' => 'test_accession4', 'observationUnitName' => 'test_trial214', - 'uploadedBy' => 41, + 'uploadedBy' => 'collector1', 'collector' => 'collector1', 'germplasmDbId' => 38843, 'observationUnitDbId' => 38870, @@ -179,7 +179,7 @@ is_deeply($response, { }, { 'messageType' => 'INFO', - 'message' => 'All values in your file are now saved in the database!' + 'message' => 'All values in your file have been successfully processed!

2 new values stored
0 previously stored values skipped
0 previously stored values overwritten

' } ], 'pagination' => { From f659a9815c1b875e9e41bb2dfc8c9a4b84c19b54 Mon Sep 17 00:00:00 2001 From: Lukas Mueller Date: Fri, 24 Sep 2021 23:03:55 -0400 Subject: [PATCH 4/5] give layout deletion a little bit of time before continuing (sleep(30)). --- t/unit_fixture/CXGN/VerifyDeletion/TrialDeletion.t | 3 +++ 1 file changed, 3 insertions(+) diff --git a/t/unit_fixture/CXGN/VerifyDeletion/TrialDeletion.t b/t/unit_fixture/CXGN/VerifyDeletion/TrialDeletion.t index 1c06c81dfb..1f8300d10a 100644 --- a/t/unit_fixture/CXGN/VerifyDeletion/TrialDeletion.t +++ b/t/unit_fixture/CXGN/VerifyDeletion/TrialDeletion.t @@ -63,6 +63,9 @@ print STDERR Dumper $response; is_deeply($response, {'success' => 1}); $mech->get_ok('http://localhost:3010/ajax/breeders/trial/'.$project_id.'/delete/layout'); + +sleep(30); # deletion script takes time... (?) + $response = decode_json $mech->content; print STDERR Dumper $response; is_deeply($response, {'message' => 'Successfully deleted trial data.','success' => 1}, 'test trial layout + entry deletion'); From 58df152daf51158120287fb44ae5363661db1bae Mon Sep 17 00:00:00 2001 From: Lukas Mueller Date: Sun, 26 Sep 2021 22:53:56 -0400 Subject: [PATCH 5/5] Skip some tests if required files are not available. --- .../ValidateAllDroneImageryFunctions.t | 173 +++++++++--------- 1 file changed, 91 insertions(+), 82 deletions(-) diff --git a/t/unit_fixture/CXGN/Uploading/ValidateAllDroneImageryFunctions.t b/t/unit_fixture/CXGN/Uploading/ValidateAllDroneImageryFunctions.t index 3d1475f9f0..fcd1b0df85 100644 --- a/t/unit_fixture/CXGN/Uploading/ValidateAllDroneImageryFunctions.t +++ b/t/unit_fixture/CXGN/Uploading/ValidateAllDroneImageryFunctions.t @@ -531,95 +531,104 @@ print STDERR Dumper $message_hash_remove_image; ok($message_hash_remove_image->{status}); #Testing upload of bulk imaging events -my $bulk_loading_csv = $f->config->{basepath}."/t/data/imagebreed/bulk_loading/BTI_rig_images.xls"; -my $bulk_loading_image_zip = $f->config->{basepath}."/t/data/imagebreed/bulk_loading/BTI_rig_images.zip"; -$ua = LWP::UserAgent->new; -$ua->timeout(3600); -my $response_raster = $ua->post( - 'http://localhost:3010/drone_imagery/upload_drone_imagery_bulk', - Content_Type => 'form-data', - Content => [ - "sgn_session_id"=>$sgn_session_id, - upload_drone_imagery_bulk_images_zipfile => [ $bulk_loading_image_zip, basename($bulk_loading_image_zip) ], - upload_drone_imagery_bulk_imaging_events => [ $bulk_loading_csv, basename($bulk_loading_csv) ], - ] - ); - -ok($response_raster->is_success); -my $message_raster = $response_raster->decoded_content; -print STDERR Dumper $message_raster; -ok($message_raster =~ /Successfully uploaded!/); my $file_previous_geotiff_image_zip = "/home/production/public/static_content/imagebreed/RiceExampleRGBandDSMOrthophotosGeoTIFFs.zip"; my $file_previous_geojson_zip = "/home/production/public/static_content/imagebreed/RiceExampleGeoJSONs.zip"; my $file_previous_imaging_events = "/home/production/public/static_content/imagebreed/RiceExampleRGBandDSMGeoJSONImagingEvent.xls"; -$ua = LWP::UserAgent->new; -$ua->timeout(3600); -my $response_raster = $ua->post( - 'http://localhost:3010/drone_imagery/upload_drone_imagery_bulk_previous', - Content_Type => 'form-data', - Content => [ - "sgn_session_id"=>$sgn_session_id, - upload_drone_imagery_bulk_images_zipfile_previous => [ $file_previous_geotiff_image_zip, basename($file_previous_geotiff_image_zip) ], - upload_drone_imagery_bulk_geojson_zipfile_previous => [ $file_previous_geojson_zip, basename($file_previous_geojson_zip) ], - upload_drone_imagery_bulk_imaging_events_previous => [ $file_previous_imaging_events, basename($file_previous_imaging_events) ], - ] - ); +my $bulk_loading_csv = $f->config->{basepath}."/t/data/imagebreed/bulk_loading/BTI_rig_images.xls"; +my $bulk_loading_image_zip = $f->config->{basepath}."/t/data/imagebreed/bulk_loading/BTI_rig_images.zip"; -ok($response_raster->is_success); -my $message_raster = $response_raster->decoded_content; -print STDERR Dumper $message_raster; -ok($message_raster =~ /Successfully uploaded!/); -my $rasterblue = $f->config->{basepath}."/t/data/imagebreed/RasterBlue.png"; -my $rastergreen = $f->config->{basepath}."/t/data/imagebreed/RasterGreen.png"; -my $rasterred= $f->config->{basepath}."/t/data/imagebreed/RasterRed.png"; -my $rasternir = $f->config->{basepath}."/t/data/imagebreed/RasterNIR.png"; -my $rasterrededge = $f->config->{basepath}."/t/data/imagebreed/RasterRedEdge.png"; -$ua = LWP::UserAgent->new; -$ua->timeout(3600); -my $response_raster = $ua->post( - 'http://localhost:3010/drone_imagery/upload_drone_imagery', - Content_Type => 'form-data', - Content => [ - "sgn_session_id"=>$sgn_session_id, - "drone_run_field_trial_id"=>$field_trial_id, - "drone_run_name"=>"NewStitchedMicasense5BandDroneRunProjectTESTING", - "drone_run_type"=>"Aerial Medium to High Res", - "drone_run_date"=>"2019/02/01 13:14:15", - "drone_run_description"=>"test new drone run", - "drone_image_upload_camera_info"=>"micasense_5", - "drone_run_imaging_vehicle_id"=>$new_vehicle_id, - "drone_run_imaging_vehicle_battery_name"=>"blue", - "drone_image_upload_drone_run_band_stitching"=>"no", - "drone_run_band_number"=>5, - "drone_run_band_name_1"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Blue", - "drone_run_band_description_1"=>"raster blue", - "drone_run_band_type_1"=>"Blue (450-520nm)", - drone_run_band_stitched_ortho_image_1 => [ $rasterblue, basename($rasterblue) ], - "drone_run_band_name_2"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Green", - "drone_run_band_description_2"=>"raster green", - "drone_run_band_type_2"=>"Green (515-600nm)", - drone_run_band_stitched_ortho_image_2 => [ $rastergreen, basename($rastergreen) ], - "drone_run_band_name_3"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Red", - "drone_run_band_description_3"=>"raster red", - "drone_run_band_type_3"=>"Red (600-690nm)", - drone_run_band_stitched_ortho_image_3 => [ $rasterred, basename($rasterred) ], - "drone_run_band_name_4"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_NIR", - "drone_run_band_description_4"=>"raster NIR", - "drone_run_band_type_4"=>"NIR (780-3000nm)", - drone_run_band_stitched_ortho_image_4 => [ $rasternir, basename($rasternir) ], - "drone_run_band_name_5"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_RedEdge", - "drone_run_band_description_5"=>"raster rededge", - "drone_run_band_type_5"=>"Red Edge (690-750nm)", - drone_run_band_stitched_ortho_image_5 => [ $rasterrededge, basename($rasterrededge) ], - ] - ); + SKIP: { + skip 'Some required files not available for these tests', 6, unless ( (-e $file_previous_geotiff_image_zip) && (-e $file_previous_geojson_zip) && (-e $file_previous_imaging_events) && (-e $bulk_loading_csv) && (-e $bulk_loading_image_zip)); -ok($response_raster->is_success); -my $message_raster = $response_raster->decoded_content; -print STDERR Dumper $message_raster; -ok($message_raster =~ /Successfully uploaded!/); + $ua = LWP::UserAgent->new; + $ua->timeout(3600); + my $response_raster = $ua->post( + 'http://localhost:3010/drone_imagery/upload_drone_imagery_bulk', + Content_Type => 'form-data', + Content => [ + "sgn_session_id"=>$sgn_session_id, + upload_drone_imagery_bulk_images_zipfile => [ $bulk_loading_image_zip, basename($bulk_loading_image_zip) ], + upload_drone_imagery_bulk_imaging_events => [ $bulk_loading_csv, basename($bulk_loading_csv) ], + ] + ); + + ok($response_raster->is_success); + my $message_raster = $response_raster->decoded_content; + print STDERR Dumper $message_raster; + ok($message_raster =~ /Successfully uploaded!/); + + + $ua = LWP::UserAgent->new; + $ua->timeout(3600); + my $response_raster = $ua->post( + 'http://localhost:3010/drone_imagery/upload_drone_imagery_bulk_previous', + Content_Type => 'form-data', + Content => [ + "sgn_session_id"=>$sgn_session_id, + upload_drone_imagery_bulk_images_zipfile_previous => [ $file_previous_geotiff_image_zip, basename($file_previous_geotiff_image_zip) ], + upload_drone_imagery_bulk_geojson_zipfile_previous => [ $file_previous_geojson_zip, basename($file_previous_geojson_zip) ], + upload_drone_imagery_bulk_imaging_events_previous => [ $file_previous_imaging_events, basename($file_previous_imaging_events) ], + ] + ); + + ok($response_raster->is_success); + my $message_raster = $response_raster->decoded_content; + print STDERR Dumper $message_raster; + ok($message_raster =~ /Successfully uploaded!/); + + my $rasterblue = $f->config->{basepath}."/t/data/imagebreed/RasterBlue.png"; + my $rastergreen = $f->config->{basepath}."/t/data/imagebreed/RasterGreen.png"; + my $rasterred= $f->config->{basepath}."/t/data/imagebreed/RasterRed.png"; + my $rasternir = $f->config->{basepath}."/t/data/imagebreed/RasterNIR.png"; + my $rasterrededge = $f->config->{basepath}."/t/data/imagebreed/RasterRedEdge.png"; + $ua = LWP::UserAgent->new; + $ua->timeout(3600); + my $response_raster = $ua->post( + 'http://localhost:3010/drone_imagery/upload_drone_imagery', + Content_Type => 'form-data', + Content => [ + "sgn_session_id"=>$sgn_session_id, + "drone_run_field_trial_id"=>$field_trial_id, + "drone_run_name"=>"NewStitchedMicasense5BandDroneRunProjectTESTING", + "drone_run_type"=>"Aerial Medium to High Res", + "drone_run_date"=>"2019/02/01 13:14:15", + "drone_run_description"=>"test new drone run", + "drone_image_upload_camera_info"=>"micasense_5", + "drone_run_imaging_vehicle_id"=>$new_vehicle_id, + "drone_run_imaging_vehicle_battery_name"=>"blue", + "drone_image_upload_drone_run_band_stitching"=>"no", + "drone_run_band_number"=>5, + "drone_run_band_name_1"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Blue", + "drone_run_band_description_1"=>"raster blue", + "drone_run_band_type_1"=>"Blue (450-520nm)", + drone_run_band_stitched_ortho_image_1 => [ $rasterblue, basename($rasterblue) ], + "drone_run_band_name_2"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Green", + "drone_run_band_description_2"=>"raster green", + "drone_run_band_type_2"=>"Green (515-600nm)", + drone_run_band_stitched_ortho_image_2 => [ $rastergreen, basename($rastergreen) ], + "drone_run_band_name_3"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_Red", + "drone_run_band_description_3"=>"raster red", + "drone_run_band_type_3"=>"Red (600-690nm)", + drone_run_band_stitched_ortho_image_3 => [ $rasterred, basename($rasterred) ], + "drone_run_band_name_4"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_NIR", + "drone_run_band_description_4"=>"raster NIR", + "drone_run_band_type_4"=>"NIR (780-3000nm)", + drone_run_band_stitched_ortho_image_4 => [ $rasternir, basename($rasternir) ], + "drone_run_band_name_5"=>"NewStitchedMicasense5BandDroneRunProjectTESTING_RedEdge", + "drone_run_band_description_5"=>"raster rededge", + "drone_run_band_type_5"=>"Red Edge (690-750nm)", + drone_run_band_stitched_ortho_image_5 => [ $rasterrededge, basename($rasterrededge) ], + ] + ); + + ok($response_raster->is_success); + my $message_raster = $response_raster->decoded_content; + print STDERR Dumper $message_raster; + ok($message_raster =~ /Successfully uploaded!/); +}; + done_testing();