Skip to content

Commit

Permalink
Add Datastore indexes samples. (#214)
Browse files Browse the repository at this point in the history
Samples are moved from:
https://cloud.google.com/appengine/docs/java/datastore/indexes

Note: I add a new script `test-devserver.sh` to the testing config. This
script runs the `mvn appengine:devserver` plugin, waits for it to start,
then verifies that it gets a non-error response from the `/` path. I use
this to verify that the `datastore-indexes.xml` files are correct (by
disabling autoGenerate, the local devserver throws an error when a query
is used without the correct index defined, just as production does).

We should probably add any "hello world" or other projects to this
check, as well. Anywhere we say to run `mvn appengine:devserver`, it
would be good to test that it is correct.
  • Loading branch information
tswast authored and lesv committed Apr 29, 2016
1 parent d8daafd commit 90a880e
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test-devserver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Copyright 2016 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Usage:
# test-devserver.sh path/to/project
#
# This script runs the local appengine:devserver Maven plugin and verifies that
# a request to http://localhost:8080/ does not return an error code.
#
# As an example, this is useful for verifying that datastore-indexes.xml is
# correct (only if autoGenerate=false and the / handler does all queries used),
# as an example.

set -e
set -x

if [ -z "$1" ]; then
echo "Missing directory parameter."
echo "Usage:"
echo " $0 path/to/project"
exit 1
fi

(
cd "$1"
expect -c '
spawn mvn --batch-mode clean appengine:devserver -DskipTests
set timeout 600
expect localhost:8080
sleep 10
spawn curl --silent --output /dev/stderr --write-out "%{http_code}" http://localhost:8080/
expect {
"200" {
exit
}
}
exit 1
'
)

0 comments on commit 90a880e

Please sign in to comment.