Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GEOS-8069] Add documentation and tests about using MongoDB as a data store for app-schema #2205

Merged
merged 1 commit into from
Apr 9, 2017

Conversation

nmco
Copy link
Contributor

@nmco nmco commented Apr 5, 2017

This pull request adds documentation bout how to use MongoDB with App-Schema and adds online tests (integration test).

Depends on pull request: geotools/geotools#1546

Associated issue: https://osgeo-org.atlassian.net/browse/GEOS-8069

@@ -0,0 +1,273 @@
package org.geoserver.test.onlineTest;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Contributor

@bencaradocdavies bencaradocdavies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmco I do not know much about MongoDB but this looks like a tidy and thorough piece of work.

@@ -0,0 +1,436 @@
.. _app-schema.tutorial:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate label (same as the app-schema tutorial). Should be:

.. _app-schema.mongo-tutorial:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

</DataStore>
</sourceDataStores>

Check the MongoDB tutorial for a more detailed description about how to use MongoDB with app-schema.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please link to the mongo tutorial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct thanks, fixed.


Check the MongoDB tutorial for a more detailed description about how to use MongoDB with app-schema.

.. note:: You must install the Oracle plugin to connect to Oracle Spatial databases.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your mean MongoDB here. Cut and paste error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup fixed thanks.


db.stations.insert({
"id": "1",
"name": "station 1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comma at end of line here. Hooray for GitHub syntax highlighting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


db.stations.insert({
"id": "2",
"name": "station 2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comma at end of line here. Hooray for GitHub syntax highlighting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

})

db.stations.createIndex({
geometry: "2dsphere"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub JSON syntax highlighting suggests that something is wrong with geometry. Missing quotes perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -0,0 +1,36 @@
{
"id": "1",
"name": "station 1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! Unlike the tutorial, this line has a comma at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah no sure what happen, I copy paste test cases to doc 😥.

@BeforeClass
public static void setup() throws Exception {
// check that we have access to a mongodb and instantiate the client
String hostAsString = getProperty("mongo.host", "127.0.0.1");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fixture should use settings stored in a properties file ~/.geoserver/mongodb.properties or similar. GeoTools fixture configuration support is more reusable, but GeoServer is messier. ReferenceDataPostgisSetup uses JDBCTestSetup but I expect that this will be less useful for Mongo. GeoTools MongoTestSupport does the right thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, fixed.

Running MongoDB Online Tests
----------------------------

MongoDB online tests expected by default that a MongoDB instance can be reached using host `127.0.0.1` and port `27017`. A different host can be provided using environment variable `mongo.host` and a different port can be provided using variable `mongo.port`. If no MongoDB instance can be reached the online tests will be skipped.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted elsewhere, it would be preferable that these setting were stored in a mongodb.properties file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@bencaradocdavies
Copy link
Contributor

bencaradocdavies commented Apr 7, 2017

With no MongoDB installed, this PR causes app-schema online tests (-Papp-schema-online-test) to fail with:

Tests in error: 
  org.geoserver.test.onlineTest.ComplexMongoDBTest: got: <false>, expected: is <true>
  org.geoserver.test.onlineTest.ComplexMongoDBTest: Timed out after 2000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=127.0.0.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]

Looking a little deeper, one fails in setup:

org.geoserver.test.onlineTest.ComplexMongoDBTest  Time elapsed: 4518 sec  <<< ERROR!
org.junit.internal.AssumptionViolatedException: got: <false>, expected: is <true>
	at org.junit.Assume.assumeThat(Assume.java:95)
	at org.geoserver.test.onlineTest.ComplexMongoDBTest.setup(ComplexMongoDBTest.java:84)
[...]

and the other fails in tearDown:

org.geoserver.test.onlineTest.ComplexMongoDBTest  Time elapsed: 4520 sec  <<< ERROR!
com.mongodb.MongoTimeoutException: Timed out after 2000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=127.0.0.1:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
	at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:375)
	at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:104)
	at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75)
	at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71)
	at com.mongodb.binding.ClusterBinding.getWriteConnectionSource(ClusterBinding.java:68)
	at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:159)
	at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:134)
	at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:124)
	at com.mongodb.operation.CommandWriteOperation.execute(CommandWriteOperation.java:55)
	at com.mongodb.Mongo.execute(Mongo.java:827)
	at com.mongodb.Mongo$2.execute(Mongo.java:810)
	at com.mongodb.DB.executeCommand(DB.java:648)
	at com.mongodb.DB.dropDatabase(DB.java:216)
	at org.geoserver.test.onlineTest.ComplexMongoDBTest.tearDown(ComplexMongoDBTest.java:111)

@nmco
Copy link
Contributor Author

nmco commented Apr 8, 2017

Thanks for the review @bencaradocdavies ! I amend has requested and online should work has expected now.

* tests hence they require a MongoDB instance. Host 127.0.0.1 and port 27017 will
* be used by default but is possible to provide another host and port using Java
* variables mongo.host and mongo.port respectively.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should mention mongodb.properties not Java properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I forget about this Java doc. Fixed.

@bencaradocdavies
Copy link
Contributor

@nmco that looks great. Tidy work. Full builds and app-schema online tests allpass (without a mongodb instance). I plan to merge this and geotools/geotools#1546 as soon as the geoserver-master build on ares Jenkins has recovered (I think its last failure was some intermittent resource problem). There is the one little note about the test javadoc that could be fixed to mention mongodb.properties but this is not enough to hold up the merge. Feel free to fix now if you can beat me to the merge or fix later at your convenience.

@nmco
Copy link
Contributor Author

nmco commented Apr 9, 2017

Java doc amended and a mean-full message will be displayed pointing to the mongodb.properties when tests are skipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants