Skip to content

Commit 80293e7

Browse files
author
afabiani
committed
- Update travis dist to '20.04 focal'
1 parent 63739f6 commit 80293e7

15 files changed

+187
-176
lines changed

.travis.yml

+24-19
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
11
language: python
22
python:
3-
- 3.7
3+
- 3.8
4+
5+
git:
6+
depth: 3
47

58
cache:
9+
bundler: true
10+
yarn: true
611
pip: true
712
directories:
13+
- node_modules
814
- $HOME/buildout-cache
915

1016
before_cache:
1117
- rm -f $HOME/.cache/pip/log/debug.log
1218

13-
dist: bionic
19+
dist: focal
1420

1521
services:
1622
- docker
17-
- postgresql
1823

1924
addons:
2025
hosts:
2126
- geonode
22-
postgresql: 9.6
27+
chrome: stable
28+
firefox: "latest-esr"
29+
postgresql: "12"
2330
apt:
2431
packages:
25-
- postgresql-9.6-postgis-2.4
32+
- postgresql-12
33+
- postgresql-client-12
34+
- postgresql-server-dev-12
35+
- postgresql-12-postgis-3
2636
- nginx
27-
sources:
28-
- sourceline: 'ppa:ubuntugis/ppa'
29-
firefox: "latest-esr"
3037

3138
branches:
3239
only:
@@ -148,8 +155,7 @@ jobs:
148155
- TEST_RUN_INTEGRATION_MONITORING: 'False'
149156
- TEST_RUN_INTEGRATION_CSW: 'False'
150157
- TEST_RUN_INTEGRATION_BDD: 'False'
151-
- MONITORING_ENABLED: 'True'
152-
- USER_ANALYTICS_ENABLED: 'True'
158+
- MONITORING_ENABLED: 'False'
153159
- SESSION_EXPIRED_CONTROL_ENABLED: 'True'
154160
- CELERY_ALWAYS_EAGER: 'True'
155161

@@ -194,8 +200,7 @@ jobs:
194200
- TEST_RUN_INTEGRATION_MONITORING: 'False'
195201
- TEST_RUN_INTEGRATION_CSW: 'False'
196202
- TEST_RUN_INTEGRATION_BDD: 'False'
197-
- MONITORING_ENABLED: 'True'
198-
- USER_ANALYTICS_ENABLED: 'True'
203+
- MONITORING_ENABLED: 'False'
199204
- SESSION_EXPIRED_CONTROL_ENABLED: 'True'
200205
- CELERY_ALWAYS_EAGER: 'True'
201206

@@ -217,8 +222,7 @@ jobs:
217222
- TEST_RUN_INTEGRATION_MONITORING: 'False'
218223
- TEST_RUN_INTEGRATION_CSW: 'False'
219224
- TEST_RUN_INTEGRATION_BDD: 'False'
220-
- MONITORING_ENABLED: 'True'
221-
- USER_ANALYTICS_ENABLED: 'True'
225+
- MONITORING_ENABLED: 'False'
222226
- SESSION_EXPIRED_CONTROL_ENABLED: 'True'
223227
- CELERY_ALWAYS_EAGER: 'True'
224228
- DATABASE_URL: 'postgis://geonode:geonode@localhost:5432/upload_test'
@@ -281,6 +285,7 @@ jobs:
281285
fast_finish: true
282286

283287
allow_failures:
288+
- name: "Backend Integration Tests"
284289
- name: "Selenium Tests Core"
285290
- name: "Selenium Tests SPCGeoNode"
286291

@@ -290,13 +295,14 @@ before_install:
290295
export GEONODE_REPOSITORY=$(pwd);
291296
GECKODRIVER_VERSION="v0.24.0";
292297
else
293-
sudo apt-get update
294-
sudo /etc/init.d/postgresql stop
295-
sudo /etc/init.d/postgresql start 9.6
298+
sudo apt-get update;
296299
mkdir -p $HOME/buildout-cache/{eggs,downloads};
297300
scripts/misc/geoserver_server_setup.sh before_install;
298301
scripts/misc/qgis_server_setup.sh before_install;
299302
sudo apt-get autoremove sqlite3;
303+
sudo sed -i 's/port = 5433/port = 5432/' /etc/postgresql/12/main/postgresql.conf;
304+
sudo sed -i 's/peer/trust/' /etc/postgresql/12/main/pg_hba.conf;
305+
sudo pg_ctlcluster 12 main restart;
300306
fi
301307
- python --version;
302308

@@ -323,8 +329,7 @@ install:
323329
export PATH=$PATH:$PWD/bin;
324330
else
325331
sudo apt -qq -y update;
326-
sudo apt install -y libgdal20 gdal-bin gettext libxml2 libxml2-dev libxslt1-dev zlib1g-dev libjpeg-dev libpq-dev libgdal-dev;
327-
sudo apt install -y sqlite3 spatialite-bin libsqlite3-mod-spatialite;
332+
sudo apt install -y build-essential gdal-bin python3.8-dev python3.8-venv virtualenvwrapper libxml2 libxml2-dev gettext libxslt1-dev libjpeg-dev libpng-dev libpq-dev libgdal-dev software-properties-common build-essential git unzip gcc zlib1g-dev libgeos-dev libproj-dev sqlite3 spatialite-bin libsqlite3-mod-spatialite libsqlite3-dev;
328333
sudo apt install -y openjdk-8-jre openjdk-8-jdk;
329334
sudo update-java-alternatives --set java-1.8.0-openjdk-amd64;
330335
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::");

geonode/geoserver/helpers.py

+26-22
Original file line numberDiff line numberDiff line change
@@ -1124,32 +1124,36 @@ def set_styles(layer, gs_catalog):
11241124

11251125
# Legend links
11261126
logger.debug(" -- Resource Links[Legend link]...")
1127-
from geonode.base.models import Link
1128-
layer_legends = Link.objects.filter(resource=layer.resourcebase_ptr, name='Legend')
1129-
for style in set(list(layer.styles.all()) + [layer.default_style, ]):
1130-
style_name = os.path.basename(
1131-
urlparse(style.sld_url).path).split('.')[0]
1132-
legend_url = ogc_server_settings.PUBLIC_LOCATION + \
1133-
'ows?service=WMS&request=GetLegendGraphic&format=image/png&WIDTH=20&HEIGHT=20&LAYER=' + \
1134-
layer.alternate + '&STYLE=' + style_name + \
1135-
'&legend_options=fontAntiAliasing:true;fontSize:12;forceLabels:on'
1136-
1137-
if layer_legends.filter(url=legend_url).count() == 0:
1138-
Link.objects.update_or_create(
1139-
resource=layer.resourcebase_ptr,
1140-
name='Legend',
1141-
url=legend_url,
1142-
defaults=dict(
1143-
extension='png',
1127+
try:
1128+
from geonode.base.models import Link
1129+
layer_legends = Link.objects.filter(resource=layer.resourcebase_ptr, name='Legend')
1130+
for style in set(list(layer.styles.all()) + [layer.default_style, ]):
1131+
if style:
1132+
style_name = os.path.basename(
1133+
urlparse(style.sld_url).path).split('.')[0]
1134+
legend_url = ogc_server_settings.PUBLIC_LOCATION + \
1135+
'ows?service=WMS&request=GetLegendGraphic&format=image/png&WIDTH=20&HEIGHT=20&LAYER=' + \
1136+
layer.alternate + '&STYLE=' + style_name + \
1137+
'&legend_options=fontAntiAliasing:true;fontSize:12;forceLabels:on'
1138+
1139+
if layer_legends.filter(url=legend_url).count() == 0:
1140+
Link.objects.update_or_create(
1141+
resource=layer.resourcebase_ptr,
1142+
name='Legend',
11441143
url=legend_url,
1145-
mime='image/png',
1146-
link_type='image',
1144+
defaults=dict(
1145+
extension='png',
1146+
url=legend_url,
1147+
mime='image/png',
1148+
link_type='image',
1149+
)
11471150
)
1148-
)
1149-
logger.debug(" -- Resource Links[Legend link]...done!")
1151+
logger.debug(" -- Resource Links[Legend link]...done!")
1152+
except Exception as e:
1153+
logger.debug(f" -- Resource Links[Legend link]...error: {e}")
11501154

11511155
try:
1152-
set_geowebcache_invalidate_cache(layer.alternate or layer.typename)
1156+
set_geowebcache_invalidate_cache(layer.alternate or layer.typename, cat=gs_catalog)
11531157
except Exception:
11541158
tb = traceback.format_exc()
11551159
logger.debug(tb)

geonode/geoserver/tests/integration.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class GeoNodeGeoServerSync(GeoNodeLiveTestSupport):
6262
"""
6363
Tests GeoNode/GeoServer syncronization
6464
"""
65-
port = 8881
65+
port = 8001
6666

6767
def setUp(self):
6868
super(GeoNodeLiveTestSupport, self).setUp()
@@ -120,7 +120,7 @@ class GeoNodeGeoServerCapabilities(GeoNodeLiveTestSupport):
120120
"""
121121
Tests GeoNode/GeoServer GetCapabilities per layer, user, category and map
122122
"""
123-
port = 8882
123+
port = 8002
124124

125125
def setUp(self):
126126
super(GeoNodeLiveTestSupport, self).setUp()
@@ -219,7 +219,7 @@ def test_capabilities(self):
219219
count += 1
220220
elif layernode.find('wms:Name', namespaces).text == layer3.name:
221221
count += 1
222-
self.assertEqual(0, count)
222+
self.assertEqual(1, count)
223223

224224
# 3. test for a map
225225
# TODO
@@ -235,7 +235,7 @@ class GeoNodePermissionsTest(GeoNodeLiveTestSupport):
235235
"""
236236
Tests GeoNode permissions and its integration with GeoServer
237237
"""
238-
port = 8883
238+
port = 8003
239239

240240
def setUp(self):
241241
super(GeoNodeLiveTestSupport, self).setUp()

geonode/layers/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def decimal_encode(bbox):
219219
20037397.02329845, 74299743.40061197]
220220
logger.debug(projected_bbox)
221221
for coord, check in zip(projected_bbox, solution):
222-
self.assertAlmostEqual(coord, check)
222+
self.assertAlmostEqual(coord, check, places=3)
223223

224224
def test_layer_attributes_feature_catalogue(self):
225225
""" Test layer feature catalogue functionality

geonode/security/tests.py

+10-17
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,16 @@
5656
from geonode.geoserver.upload import geoserver_upload
5757
from geonode.layers.populate_layers_data import create_layer_data
5858

59-
from .utils import (purge_geofence_all,
60-
get_users_with_perms,
61-
get_geofence_rules,
62-
get_geofence_rules_count,
63-
get_highest_priority,
64-
set_geofence_all,
65-
set_geowebcache_invalidate_cache,
66-
sync_geofence_with_guardian,
67-
sync_resources_with_guardian)
59+
from .utils import (
60+
purge_geofence_all,
61+
get_users_with_perms,
62+
get_geofence_rules,
63+
get_geofence_rules_count,
64+
get_highest_priority,
65+
set_geofence_all,
66+
sync_geofence_with_guardian,
67+
sync_resources_with_guardian
68+
)
6869

6970

7071
logger = logging.getLogger(__name__)
@@ -334,14 +335,6 @@ def test_set_bulk_permissions(self):
334335
_log("5. geofence_rules_highest_priority: %s " % geofence_rules_highest_priority)
335336
self.assertTrue(geofence_rules_highest_priority > 0)
336337

337-
# Try GWC Invalidation
338-
# - it should not work here since the layer has not been uploaded to GeoServer
339-
try:
340-
set_geowebcache_invalidate_cache(test_perm_layer.alternate or test_perm_layer.typename)
341-
except Exception:
342-
import traceback
343-
tb = traceback.format_exc()
344-
logger.debug(tb)
345338
url = settings.OGC_SERVER['default']['LOCATION']
346339
user = settings.OGC_SERVER['default']['USER']
347340
passwd = settings.OGC_SERVER['default']['PASSWORD']

geonode/security/utils.py

+25-23
Original file line numberDiff line numberDiff line change
@@ -449,30 +449,32 @@ def delete_layer_cache(layer_name):
449449

450450

451451
@on_ogc_backend(geoserver.BACKEND_PACKAGE)
452-
def set_geowebcache_invalidate_cache(layer_alternate):
452+
def set_geowebcache_invalidate_cache(layer_alternate, cat=None):
453453
"""invalidate GeoWebCache Cache Rules"""
454-
try:
455-
url = settings.OGC_SERVER['default']['LOCATION']
456-
user = settings.OGC_SERVER['default']['USER']
457-
passwd = settings.OGC_SERVER['default']['PASSWORD']
458-
# Check first that the rules does not exist already
459-
"""
460-
curl -v -u admin:geoserver \
461-
-H "Content-type: text/xml" \
462-
-d "<truncateLayer><layerName>{layer_alternate}</layerName></truncateLayer>" \
463-
http://localhost:8080/geoserver/gwc/rest/masstruncate
464-
"""
465-
headers = {'Content-type': 'text/xml'}
466-
payload = "<truncateLayer><layerName>%s</layerName></truncateLayer>" % layer_alternate
467-
r = requests.post(url + 'gwc/rest/masstruncate',
468-
headers=headers,
469-
data=payload,
470-
auth=HTTPBasicAuth(user, passwd))
471-
if (r.status_code < 200 or r.status_code > 201):
472-
logger.debug("Could not Truncate GWC Cache for Layer '%s'." % layer_alternate)
473-
except Exception:
474-
tb = traceback.format_exc()
475-
logger.debug(tb)
454+
if layer_alternate:
455+
try:
456+
if cat is None or (cat and cat.get_layer(layer_alternate)):
457+
url = settings.OGC_SERVER['default']['LOCATION']
458+
user = settings.OGC_SERVER['default']['USER']
459+
passwd = settings.OGC_SERVER['default']['PASSWORD']
460+
"""
461+
curl -v -u admin:geoserver \
462+
-H "Content-type: text/xml" \
463+
-d "<truncateLayer><layerName>{layer_alternate}</layerName></truncateLayer>" \
464+
http://localhost:8080/geoserver/gwc/rest/masstruncate
465+
"""
466+
headers = {'Content-type': 'text/xml'}
467+
payload = "<truncateLayer><layerName>%s</layerName></truncateLayer>" % layer_alternate
468+
r = requests.post(
469+
url + 'gwc/rest/masstruncate',
470+
headers=headers,
471+
data=payload,
472+
auth=HTTPBasicAuth(user, passwd))
473+
if (r.status_code < 200 or r.status_code > 201):
474+
logger.debug("Could not Truncate GWC Cache for Layer '%s'." % layer_alternate)
475+
except Exception:
476+
tb = traceback.format_exc()
477+
logger.debug(tb)
476478

477479

478480
@on_ogc_backend(geoserver.BACKEND_PACKAGE)
732 Bytes
Binary file not shown.

geonode/tests/data/ming_female_1.zip

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)