EOX GitLab Instance

Skip to content
Snippets Groups Projects
Commit 269f8539 authored by Mussab Abdalla's avatar Mussab Abdalla
Browse files

Merge branch 'staging_ingestor_test' into 'staging'

add ingestion error report test

See merge request !68
parents ca12c42f 3eabfc66
No related branches found
No related tags found
2 merge requests!82Staging to master,!68add ingestion error report test
......@@ -7,4 +7,6 @@ sleep 60
docker exec -t $(docker ps -qf name="emg-pvs_ingestor") ls /var/ingestor/success > success_list.csv
docker exec -t $(docker ps -qf name="emg-pvs_ingestor") ls /var/ingestor/fail > failure_list.csv
# test the existance of ingested item
sleep 10
docker service logs emg-pvs_ingestor >& ingestor_log.txt
pytest ingestor_test.py
\ No newline at end of file
......@@ -4,6 +4,8 @@ import sys
import pytest
import subprocess
import csv
import re
import datetime
from osgeo import gdal
from swiftclient.service import SwiftService
......@@ -11,7 +13,8 @@ from swiftclient.service import SwiftService
def set_gdal_swift_auth():
# parsing command line output of swift auth
auth_keys = subprocess.check_output(["swift", "auth"]).decode(sys.stdout.encoding).split("\n")
auth_keys = subprocess.check_output(["swift", "auth"]).decode(
sys.stdout.encoding).split("\n")
storage_url = auth_keys[0].split("OS_STORAGE_URL=")[1]
auth_token = auth_keys[1].split("OS_AUTH_TOKEN=")[1]
# setting gdal config
......@@ -62,7 +65,37 @@ def test_preprocessor(list_tifs):
container = os.getenv('PREPROCESSOR_RESULTS_BUCKET')
for item in list_tifs:
set_gdal_swift_auth()
image = gdal.Open('/vsiswift/%s/%s' % (container, item), gdal.GA_ReadOnly)
image = gdal.Open(
'/vsiswift/%s/%s' % (container, item), gdal.GA_ReadOnly)
srcband = image.GetRasterBand(1)
assert srcband.Checksum() is not None
assert srcband.Checksum() > 0
def test_error_logging():
with open('ingestor_log.txt', 'r') as log_file:
lines = log_file.read().splitlines()
log_file.close()
for line in lines:
if 'ERROR:' in line:
# check the error notification
assert 'Failed to parse XML.' in line
match = re.search(
'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}', line)
date = datetime.datetime.strptime(
match.group(), "%Y-%m-%d %H:%M:%S").date()
# check the associated error time
assert type(date) == datetime.date
if 'lxml.etree.XMLSyntaxError' in line:
# Check the specific expected error reprot
error_msg = "Start tag expected, '<' not found, line 1, column 1"
assert error_msg in line
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment