Skip to content

Commit

Permalink
[Fixes GeoNode#9016] Geoserver importer NO_CRS task status doesn't tr…
Browse files Browse the repository at this point in the history
…igger the CRS selection step (GeoNode#9099)

* [Fixes GeoNode#9016] Geoserver importer NO_CRS task status doesn't trigger the CRS selection step

* [Fixes GeoNode#9016] Geoserver importer NO_CRS task status doesn't trigger the CRS selection step

* [Fixes GeoNode#9016] Geoserver importer NO_CRS task status doesn't trigger the CRS selection step

* [CircleCI] Fix Tests

* [CircleCI] Fix Docker Build

* [CircleCI] Fix Tests

* [CircleCI] Fix Tests
  • Loading branch information
Alessio Fabiani committed Apr 14, 2022
1 parent 375ab6e commit 7b949bb
Show file tree
Hide file tree
Showing 19 changed files with 88 additions and 75 deletions.
11 changes: 11 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
COMPOSE_PROJECT_NAME=geonode
DOCKERHOST=
DOCKER_HOST_IP=
DOCKER_ENV=production
# See https://github.com/geosolutions-it/geonode-generic/issues/28
Expand All @@ -17,6 +18,8 @@ DJANGO_SETTINGS_MODULE=geonode.settings
GEONODE_INSTANCE_NAME=geonode
GEONODE_LB_HOST_IP=
GEONODE_LB_PORT=
PUBLIC_PORT=80
NGINX_BASE_URL=

# #################
# backend
Expand Down Expand Up @@ -198,6 +201,14 @@ EXIF_ENABLED=True
CREATE_LAYER=True
FAVORITE_ENABLED=True

# Advanced Workflow
RESOURCE_PUBLISHING=False
ADMIN_MODERATE_UPLOADS=False

# Upload Size Limiting
DEFAULT_MAX_UPLOAD_SIZE=5368709120
DEFAULT_MAX_PARALLEL_UPLOADS_PER_USER=100

# LDAP
LDAP_ENABLED=False
LDAP_SERVER_URL=ldap://<the_ldap_server>
Expand Down
7 changes: 7 additions & 0 deletions .env_dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
COMPOSE_PROJECT_NAME=geonode
DOCKERHOST=
DOCKER_HOST_IP=
DOCKER_ENV=production
# See https://github.com/geosolutions-it/geonode-generic/issues/28
Expand All @@ -17,6 +18,8 @@ DJANGO_SETTINGS_MODULE=geonode.settings
GEONODE_INSTANCE_NAME=geonode
GEONODE_LB_HOST_IP=
GEONODE_LB_PORT=
PUBLIC_PORT=80
NGINX_BASE_URL=

# #################
# backend
Expand Down Expand Up @@ -195,3 +198,7 @@ FAVORITE_ENABLED=True
# Advanced Workflow
RESOURCE_PUBLISHING=False
ADMIN_MODERATE_UPLOADS=False

# Upload Size Limiting
DEFAULT_MAX_UPLOAD_SIZE=5368709120
DEFAULT_MAX_PARALLEL_UPLOADS_PER_USER=100
13 changes: 12 additions & 1 deletion .env_local
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
COMPOSE_PROJECT_NAME=geonode
DOCKERHOST=
DOCKER_HOST_IP=
DOCKER_ENV=production
# See https://github.com/geosolutions-it/geonode-generic/issues/28
Expand All @@ -17,6 +18,8 @@ DJANGO_SETTINGS_MODULE=geonode.settings
GEONODE_INSTANCE_NAME=geonode
GEONODE_LB_HOST_IP=
GEONODE_LB_PORT=
PUBLIC_PORT=80
NGINX_BASE_URL=

# #################
# backend
Expand Down Expand Up @@ -190,4 +193,12 @@ MODIFY_TOPICCATEGORY=True
AVATAR_GRAVATAR_SSL=True
EXIF_ENABLED=True
CREATE_LAYER=True
FAVORITE_ENABLED=True
FAVORITE_ENABLED=True

# Advanced Workflow
RESOURCE_PUBLISHING=False
ADMIN_MODERATE_UPLOADS=False

# Upload Size Limiting
DEFAULT_MAX_UPLOAD_SIZE=5368709120
DEFAULT_MAX_PARALLEL_UPLOADS_PER_USER=100
3 changes: 3 additions & 0 deletions .env_test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
COMPOSE_PROJECT_NAME=geonode
DOCKERHOST=
DOCKER_HOST_IP=
DOCKER_ENV=production
# See https://github.com/geosolutions-it/geonode-generic/issues/28
Expand All @@ -17,6 +18,8 @@ DJANGO_SETTINGS_MODULE=geonode.settings
GEONODE_INSTANCE_NAME=geonode
GEONODE_LB_HOST_IP=
GEONODE_LB_PORT=
PUBLIC_PORT=80
NGINX_BASE_URL=

# #################
# backend
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-geoserver-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
volumes:
- geoserver-data-dir:/geoserver_data/data
env_file:
- ./scripts/docker/env/${DOCKER_ENV}/geoserver.env
- .env
ports:
- "${GEOSERVER_SERVER_PORT}:8080"
network_mode: "bridge"
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ services:
retries: 1
start_period: 60s
env_file:
- ./scripts/docker/env/${DOCKER_ENV}/geoserver.env
- .env_test
volumes:
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
Expand All @@ -116,7 +116,7 @@ services:
image: geonode/postgis:13
container_name: db4${COMPOSE_PROJECT_NAME}
env_file:
- ./scripts/docker/env/${DOCKER_ENV}/db.env
- .env_test
volumes:
- dbdata:/var/lib/postgresql/data
- dbbackups:/pg_backups
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ services:
retries: 1
start_period: 60s
env_file:
- ./scripts/docker/env/${DOCKER_ENV}/geoserver.env
- .env
volumes:
- statics:/mnt/volumes/statics
- geoserver-data-dir:/geoserver_data/data
Expand All @@ -116,7 +116,7 @@ services:
image: geonode/postgis:13
container_name: db4${COMPOSE_PROJECT_NAME}
env_file:
- ./scripts/docker/env/${DOCKER_ENV}/db.env
- .env
volumes:
- dbdata:/var/lib/postgresql/data
- dbbackups:/pg_backups
Expand Down
26 changes: 0 additions & 26 deletions geonode/base/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,6 @@ def label_from_instance(self, obj):
'<br/><strong>' + obj.gn_description + '</strong></span>'


# NOTE: This is commented as it needs updating to work with select2 and autocomlete light.
#
# class TreeWidget(autocomplete.TaggitSelect2):
# input_type = 'text'

# def render(self, name, value, attrs=None):
# if isinstance(value, basestring):
# vals = value
# elif value:
# vals = ','.join([i.tag.name for i in value])
# else:
# vals = ""
# output = ["""<div class="keywords-container"><span class="input-group">
# <input class="form-control"
# id="id_resource-keywords"
# name="resource-keywords"
# value="%s"><br/>""" % (vals)]
# output.append(
# '<div id="treeview" class="" style="display: none"></div>')
# output.append(
# '<span class="input-group-addon" id="treeview-toggle"><i class="fa fa-folder"></i></span>')
# output.append('</span></div>')

# return mark_safe(u'\n'.join(output))


class RegionsMultipleChoiceField(forms.MultipleChoiceField):

def validate(self, value):
Expand Down
2 changes: 1 addition & 1 deletion geonode/geoserver/tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ def test_revise_resource_value_in_replace_should_add_expected_rows_in_the_catalo
def test_revise_resource_value_in_replace_should_return_none_for_not_existing_dataset(self):
layer = create_single_dataset('fake_dataset')
_gs_import_session_info = self.geoserver_manager._execute_resource_import(layer, list(self.files_as_dict.values()), self.user, action_type="replace")
self.assertEqual(_gs_import_session_info.import_session.state, enumerations.STATE_PENDING)
self.assertEqual(_gs_import_session_info.import_session.state, enumerations.STATE_COMPLETE)
4 changes: 2 additions & 2 deletions geonode/tests/csw.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def test_csw_outputschema_dc(self):
self.assertTrue(record.title in "san_andres_y_providencia_location.shp")

# test that the ISO abstract maps correctly in Dublin Core
self.assertEqual(record.abstract, 'No abstract provided')
self.assertIsNone(record.abstract)

# test for correct service link articulation
for link in record.references:
Expand Down Expand Up @@ -251,7 +251,7 @@ def test_csw_outputschema_fgdc(self):
self.assertTrue(record.idinfo.citation.citeinfo['title'] in "san_andres_y_providencia_location.shp")

# test that the ISO abstract maps correctly in FGDC
self.assertEqual(record.idinfo.descript.abstract, 'No abstract provided')
self.assertIsNone(record.idinfo.descript.abstract)

def test_csw_query_bbox(self):
"""Verify that GeoNode CSW can handle bbox queries"""
Expand Down
Binary file added geonode/tests/data/n32_1991_0001_123.tif
Binary file not shown.
11 changes: 6 additions & 5 deletions geonode/thumbs/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,12 +720,13 @@ def test_UTM_dataset_thumbnail(self):
self.rm.ingest(dt_files)
# ingest with datasets
res = self.rm.ingest(dt_files, resource_type=Dataset, defaults=defaults)
self.assertTrue(isinstance(res, Dataset))
if res: # Since importing this dataset takes some time, the connection might be reset due to very low timeout set for testing.
self.assertTrue(isinstance(res.get_real_instance(), Dataset))

expected_results_dir = f"{EXPECTED_RESULTS_DIR}thumbnails/"
expected_thumb_path = f"{expected_results_dir}WY_USNG_thumb.png"
expected_thumb = Image.open(expected_thumb_path)
self._fetch_thumb_and_compare(res.thumbnail_url, expected_thumb)
expected_results_dir = f"{EXPECTED_RESULTS_DIR}thumbnails/"
expected_thumb_path = f"{expected_results_dir}WY_USNG_thumb.png"
expected_thumb = Image.open(expected_thumb_path)
self._fetch_thumb_and_compare(res.thumbnail_url, expected_thumb)
finally:
if res:
self.rm.delete(res.uuid)
33 changes: 33 additions & 0 deletions geonode/upload/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,39 @@ def test_rest_uploads_no_crs(self):
sleep(3.0)
self.assertEqual(upload_data['state'], enumerations.STATE_WAITING, upload_data['state'])

# Try to upload a GeoTIFF without a CRS def.
fname = os.path.join(os.getcwd(), 'geonode/tests/data/n32_1991_0001_123.tif')
resp, data = self.rest_upload_by_path(fname)
self.assertEqual(resp.status_code, 200)

# Admin
self.assertTrue(self.client.login(username=GEONODE_USER, password=GEONODE_PASSWD))
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data), 5, response.data)
self.assertEqual(response.data['total'], 2, response.data['total'])
# Pagination
self.assertEqual(len(response.data['uploads']), 2)
self.assertEqual(response.status_code, 200)
upload_data = response.data['uploads'][0]
self.assertIsNotNone(upload_data)
self.assertEqual(upload_data['name'], 'n32_1991_0001_123', upload_data['name'])
if upload_data['state'] != enumerations.STATE_WAITING:
for _cnt in range(0, 10):
response = self.client.get(url, format='json')
self.assertEqual(response.status_code, 200)
logger.error(f"[{_cnt + 1}] ... {response.data}")
upload_data = response.data['uploads'][0]
self.assertIsNotNone(upload_data)
self.assertEqual(upload_data['name'], 'n32_1991_0001_123', upload_data['name'])
if upload_data['state'] == enumerations.STATE_WAITING:
break
else:
for _upload in Upload.objects.filter(state=upload_data['state']):
_update_upload_session_state.apply((_upload.id,))
sleep(3.0)
self.assertEqual(upload_data['state'], enumerations.STATE_WAITING, upload_data['state'])

def test_emulate_upload_through_rest_apis(self):
"""
Emulating Upload via REST APIs with several datasets.
Expand Down
7 changes: 7 additions & 0 deletions geonode/upload/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,13 @@ def final_step(upload_session, user, charset="UTF-8", dataset_id=None):
_tasks_waiting = any([_task.state in ["NO_CRS", "NO_BOUNDS", "NO_FORMAT"] for _task in import_session.tasks])

if import_session.state != enumerations.STATE_COMPLETE or _tasks_waiting or _tasks_failed:
if import_session.state == enumerations.STATE_PENDING and _tasks_waiting:
if any([_task.state == "NO_CRS" for _task in import_session.tasks]):
_redirect_to = f"/upload/srs?id={import_session.id}"
_upload.set_resume_url(_redirect_to)
_upload.set_processing_state(enumerations.STATE_WAITING)
else:
_upload.set_processing_state(enumerations.STATE_INVALID)
return None

_log(f'Creating Django record for [{name}]')
Expand Down
2 changes: 1 addition & 1 deletion geonode/upload/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def get_kml_doc(kml_bytes):
_pages = {
'shp': ('srs', 'check', 'time', 'run', 'final'),
'csv': ('csv', 'srs', 'check', 'time', 'run', 'final'),
'tif': ('run', 'final'),
'tif': ('srs', 'run', 'final'),
'zip-mosaic': ('run', 'final'),
'asc': ('run', 'final'),
'kml': ('run', 'final'),
Expand Down
8 changes: 0 additions & 8 deletions scripts/docker/env/development/db.env

This file was deleted.

9 changes: 0 additions & 9 deletions scripts/docker/env/development/geoserver.env

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/docker/env/production/db.env

This file was deleted.

9 changes: 0 additions & 9 deletions scripts/docker/env/production/geoserver.env

This file was deleted.

0 comments on commit 7b949bb

Please sign in to comment.