Skip to content

Commit

Permalink
Update to GeoServer/GeoTools 2.14.3/20.3. Add test_index.py script.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjudeng committed May 13, 2019
1 parent f2f4793 commit 1c380ad
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jdk:
- oraclejdk8
env:
matrix:
- GEOTOOLS_VERSION='20.2' GEOSERVER_VERSION='2.14.2' ES_VERSION='7.0.1'
- GEOTOOLS_VERSION='20.2' GEOSERVER_VERSION='2.14.2' ES_VERSION='6.7.2'
- GEOTOOLS_VERSION='20.2' GEOSERVER_VERSION='2.14.2' ES_VERSION='5.6.15'
- GEOTOOLS_VERSION='20.2' GEOSERVER_VERSION='2.14.2' ES_VERSION='2.4.4' ARGS='-Ddocker.image=elasticsearch'
- GEOTOOLS_VERSION='20.3' GEOSERVER_VERSION='2.14.3' ES_VERSION='7.0.1'
- GEOTOOLS_VERSION='20.3' GEOSERVER_VERSION='2.14.3' ES_VERSION='6.7.2'
- GEOTOOLS_VERSION='20.3' GEOSERVER_VERSION='2.14.3' ES_VERSION='5.6.15'
- GEOTOOLS_VERSION='20.3' GEOSERVER_VERSION='2.14.3' ES_VERSION='2.4.4' ARGS='-Ddocker.image=elasticsearch'
cache:
directories:
- "$HOME/.m2"
Expand Down
2 changes: 2 additions & 0 deletions gt-elasticsearch/src/test/resources/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requests

46 changes: 46 additions & 0 deletions gt-elasticsearch/src/test/resources/test_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
Script creates status_s index for testing.
"""
import argparse
import json
import os

import requests

script_dir = os.path.dirname(os.path.realpath(__file__))

parser = argparse.ArgumentParser()
parser.add_argument('--attributes', nargs='+', default=[])
args = parser.parse_args()

index_name = 'status_s'
f_mappings = 'active_mappings.json'
f_docs = 'wifiAccessPoint.json'
elastic_url = 'http://localhost:9200'
auth = ('elastic', 'changeme')

version = float(json.loads(requests.get('http://localhost:9200', auth=auth).text)['version']['number'].split('.')[0])
type_name = 'active' if version < 7 else '_doc'

requests.delete(f'{elastic_url}/{index_name}', auth=auth)
requests.put(f'{elastic_url}/{index_name}', auth=auth)

with open(f'{script_dir}/{f_mappings}') as f:
mappings = json.loads(f.read())

if args.attributes:
[mappings['properties'].pop(key) for key in list(mappings['properties'].keys()) if key not in args.attributes]

requests.put(f'{elastic_url}/{index_name}/_mapping/{type_name if version < 7 else ""}', json=mappings, auth=auth)

with open(f'{script_dir}/{f_docs}') as f:
features = json.load(f)['features']

for item in [item for item in features if item['status_s'] == 'active']:
if args.attributes:
[item.pop(key) for key in list(item.keys()) if key not in args.attributes]

requests.put(f'{elastic_url}/{index_name}/{type_name}/{item["id"]}', json=item, auth=auth)

requests.put(f'{elastic_url}//_xpack/security/role/status_admin', json={'indices': [{'privileges': ['all'], 'names': ['status*']}]}, auth=auth)
requests.put(f'{elastic_url}/_xpack/security/user/admin', json={'password': 'statusadmin', 'roles': ['status_admin']}, auth=auth)
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<geotools.version>20.2</geotools.version>
<geoserver.version>2.14.2</geoserver.version>
<geotools.version>20.3</geotools.version>
<geoserver.version>2.14.3</geoserver.version>
<!-- Elasticsearch version for HTTP client and select Joda classes -->
<es.version>7.0.1</es.version>
<!-- Elasticsearch version used for integration testing -->
Expand Down

0 comments on commit 1c380ad

Please sign in to comment.