From 76c823860715b887591ee3bbf084365e3a50d81c Mon Sep 17 00:00:00 2001 From: baloola <baloola-mu@hotmail.com> Date: Fri, 30 Oct 2020 13:04:30 +0100 Subject: [PATCH] adding more assertation test --- testing/gitlab_test.sh | 2 +- testing/preprocessed_list.csv | 2 ++ testing/preprocessor_test.py | 32 -------------------------------- testing/preprocessor_test.sh | 20 ++++++++++++++------ testing/registrar_test.py | 18 ++++++++++++++++-- 5 files changed, 33 insertions(+), 41 deletions(-) create mode 100644 testing/preprocessed_list.csv delete mode 100644 testing/preprocessor_test.py diff --git a/testing/gitlab_test.sh b/testing/gitlab_test.sh index d2205d17..ef7b316d 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 00000000..1d1936fc --- /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 e798b270..00000000 --- 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 981aa1ff..051e3876 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 022aceea..7223e0ae 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 -- GitLab