diff --git a/testing/gitlab_test.sh b/testing/gitlab_test.sh index d2205d17529547c7cc0e8a7c48137ca7fb7b5d63..ef7b316d5f920ac80504a84d82c3add2e467117b 100755 --- a/testing/gitlab_test.sh +++ b/testing/gitlab_test.sh @@ -46,7 +46,7 @@ pip3 install -r requirements.txt docker service ls # perform the testing -bash ./preprocessor_test.sh +bash ./preprocessor_test.sh preprocessed_list.csv bash ./registrar_test.sh product_list.csv if [ $? -ne 0 ] diff --git a/testing/preprocessed_list.csv b/testing/preprocessed_list.csv new file mode 100644 index 0000000000000000000000000000000000000000..1d1936fc26ab49d2c6d6d86b6fa771a5815be679 --- /dev/null +++ b/testing/preprocessed_list.csv @@ -0,0 +1,2 @@ +RS02_SAR_QF_SLC_20140518T050904_20140518T050909_TRS_33537_0000.tar +KS03_AIS_PSH_1G_20160101T113020_20160101T113022_KGS_019339_75CE.tar diff --git a/testing/preprocessor_test.py b/testing/preprocessor_test.py deleted file mode 100644 index e798b27014e9f90b1228d8c91c891af07d6af642..0000000000000000000000000000000000000000 --- a/testing/preprocessor_test.py +++ /dev/null @@ -1,32 +0,0 @@ - -import os -from dotenv import load_dotenv -from osgeo import gdal - - -# ST_AUTH_VERSION=3 -# OS_AUTH_URL_SHORT=https://auth.cloud.ovh.net/ -# OS_AUTH_URL=https://auth.cloud.ovh.net/v3/ -# OS_USERNAME=xqNChf3Rz5vs -# OS_TENANT_NAME=7398560954290261 -# OS_TENANT_ID=1b418c4359064774af5d55da3f4bcac0 -# OS_REGION_NAME=SERCO-DIAS1 - -# load_dotenv(dotenv_path='../env/emg_obs.env') - -# gdal.SetConfigOption('SWIFT_AUTH_V3_URL', os.environ['ST_AUTH_VERSION']) -# gdal.SetConfigOption('SWIFT_USER', os.environ['OS_AUTH_URL_SHORT']) -# gdal.SetConfigOption('SWIFT_KEY', os.environ['OS_AUTH_URL']) -# gdal.SetConfigOption('SWIFT_STORAGE_URL', os.environ['OS_USERNAME']) -# gdal.SetConfigOption('SWIFT_AUTH_TOKEN', os.environ['']) - - -image = gdal.Open('/vsiswift/preprocessor_results/KS03_AIS_PSH_1G_20160101T113020_20160101T113022_KGS_019339_75CE.tar/K3_20160101113014_19339_02281264_L1G.tif', gdal.GA_ReadOnly) -srcband = image.GetRasterBand(1) - -print ("[ NO DATA VALUE ] = ", srcband.GetNoDataValue()) -print ("[ MIN ] = ", srcband.GetMinimum()) -print ("[ MAX ] = ", srcband.GetMaximum()) -print ("[ SCALE ] = ", srcband.GetScale()) -print ("[ UNIT TYPE ] = ", srcband.GetUnitType()) - diff --git a/testing/preprocessor_test.sh b/testing/preprocessor_test.sh index 981aa1ff471f909ab04570e2dae9a88b800daa07..051e387612823208e33c285ce90039278549083d 100755 --- a/testing/preprocessor_test.sh +++ b/testing/preprocessor_test.sh @@ -1,11 +1,8 @@ -#!/bin/sh +#!/bin/bash +product_list_file=$1 OS_PASSWORD=$(docker exec -i $(docker ps -qf "name=emg-pvs_preprocessor") cat /run/secrets/OS_PASSWORD) -#preprocessing the images and save the results in the result bucket -docker exec -e OS_PASSWORD=$OS_PASSWORD -i $(docker ps -qf "name=emg-pvs_preprocessor") \ -preprocessor preprocess --config-file testing/testing_preprocessor_config.yml KS03_AIS_PSH_1G_20160101T113020_20160101T113022_KGS_019339_75CE.tar - ST_AUTH_VERSION=3 OS_AUTH_URL_SHORT=https://auth.cloud.ovh.net/ OS_AUTH_URL=https://auth.cloud.ovh.net/v3/ @@ -28,5 +25,16 @@ while read key value ; do fi done < preprocessor_test.txt -python3 preprocessor_test.py + +while read product; do + echo $product + # preprocessing the images and save the results in the result bucket + docker exec -e OS_PASSWORD=$OS_PASSWORD -i $(docker ps -qf "name=emg-pvs_preprocessor") \ + preprocessor preprocess --config-file testing/testing_preprocessor_config.yml $product < "$product_list_file" + + +done < "$product_list_file" + + + rm preprocessor_test.txt \ No newline at end of file diff --git a/testing/registrar_test.py b/testing/registrar_test.py index 022aceea306d38bb50d833101c67b5684c5b3352..7223e0aee8ab5887e4d63256630c12e792a6e165 100644 --- a/testing/registrar_test.py +++ b/testing/registrar_test.py @@ -1,6 +1,7 @@ import os import csv +from osgeo import gdal import pytest import psycopg2 import paramiko @@ -49,7 +50,11 @@ def query_eo_object(connection, eo_id): def test_db_name(connection, identifiers): for row in identifiers: identifier = row[0].split('/')[4] - query_eo_object(connection, identifier) + coverage_id = query_eo_object(connection, identifier) + db_name = connection.get_dsn_parameters()["dbname"] + + assert coverage_id == identifier + assert db_name == os.environ['DB_USER'] def compare_links(sftp, product_xml, product): @@ -68,6 +73,7 @@ def compare_links(sftp, product_xml, product): wcs_capabilities = 'emg.pass.copernicus.eu/ows?service=wcs&request=GetCapabilities&&cql=identifier=' expected_wms_link = '%s"%s"' % (wms_capabilities, product) expected_wcs_link = '%s"%s"' % (wcs_capabilities, product) + assert expected_wms_link.replace('&&', '&') == wms_link assert expected_wcs_link.replace('&&', '&') == wcs_link @@ -80,4 +86,12 @@ def test_reporting(sftp_connection, identifiers): identifier = row[0].split('/')[4] if identifier in item: - compare_links(sftp_connection, item, identifier) \ No newline at end of file + compare_links(sftp_connection, item, identifier) + + +def test_preprocessor(): + + image = gdal.Open('/vsiswift/preprocessor_results/KS03_AIS_PSH_1G_20160101T113020_20160101T113022_KGS_019339_75CE.tar/K3_20160101113014_19339_02281264_L1G.tif', gdal.GA_ReadOnly) + srcband = image.GetRasterBand(1) + assert srcband.Checksum() != None + assert srcband.Checksum() > 0 \ No newline at end of file