Skip to content

Commit 5574790

Browse files
committed
Add Datastore indexes samples. (GoogleCloudPlatform#214)
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.
1 parent f2e19b6 commit 5574790

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

test-devserver.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2016 Google Inc. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Usage:
17+
# test-devserver.sh path/to/project
18+
#
19+
# This script runs the local appengine:devserver Maven plugin and verifies that
20+
# a request to http://localhost:8080/ does not return an error code.
21+
#
22+
# As an example, this is useful for verifying that datastore-indexes.xml is
23+
# correct (only if autoGenerate=false and the / handler does all queries used),
24+
# as an example.
25+
26+
set -e
27+
set -x
28+
29+
if [ -z "$1" ]; then
30+
echo "Missing directory parameter."
31+
echo "Usage:"
32+
echo " $0 path/to/project"
33+
exit 1
34+
fi
35+
36+
(
37+
cd "$1"
38+
expect -c '
39+
spawn mvn --batch-mode clean appengine:devserver -DskipTests
40+
set timeout 600
41+
expect localhost:8080
42+
sleep 10
43+
spawn curl --silent --output /dev/stderr --write-out "%{http_code}" http://localhost:8080/
44+
expect {
45+
"200" {
46+
exit
47+
}
48+
}
49+
exit 1
50+
'
51+
)
52+

0 commit comments

Comments
 (0)