Skip to content

Commit 7b65908

Browse files
author
Frank Natividad
committedSep 2, 2017
Adding tests for endpoints-backend
1 parent 667e397 commit 7b65908

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
 

‎appengine-java8/endpoints-v2-backend/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ endpointsServer {
5454
hostname = "${projectId}.appspot.com"
5555
}
5656

57+
appengine { // App Engine tasks configuration
58+
deploy { // deploy configuration
59+
version = findProperty("appengine.deploy.version")
60+
61+
def promoteProp = findProperty("appengine.deploy.promote")
62+
if (promoteProp != null) {
63+
promote = new Boolean(promoteProp)
64+
}
65+
}
66+
}
67+
5768
sourceCompatibility = 1.8
5869
targetCompatibility = 1.8
5970

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2017 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Fail on non-zero return and print command to stdout
18+
set -xe
19+
20+
# Jenkins Test Script
21+
function TestEndpoints () {
22+
# Test getGreeting Endpoint (hello world!)
23+
curl -H "Content-Type: application/json" \
24+
-X POST \
25+
-d "{'message':'hello ${3} version-${2}'}" \
26+
"https://${2}-dot-${1}.appspot.com/_ah/api/echo/v1/echo" | \
27+
tee "$ERROR_OUTPUT_DIR/response.json" | \
28+
grep "hello ${3} version-${2}"
29+
}
30+
31+
# Jenkins provides values for GOOGLE_PROJECT_ID and GOOGLE_VERSION_ID
32+
# Update Greetings.java
33+
UNIQUE_MAVEN_STRING="maven"
34+
sed -i'.bak' -e "s/YOUR_PROJECT_ID/${GOOGLE_PROJECT_ID}/g" pom.xml
35+
36+
# Test with Maven
37+
mvn clean appengine:deploy \
38+
-Dapp.deploy.version="${GOOGLE_VERSION_ID}" \
39+
-Dapp.deploy.promote=false
40+
41+
# End-2-End tests
42+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" "${UNIQUE_MAVEN_STRING}"
43+
44+
# Clean
45+
mvn clean
46+
47+
# Test with Gradle
48+
# Modify Greetings.java for Gradle
49+
UNIQUE_GRADLE_STRING="gradle"
50+
sed -i'.bak' -e "s/YOUR_PROJECT_ID/${GOOGLE_PROJECT_ID}/g" build.gradle
51+
52+
# Deploy Gradle
53+
gradle -Pappengine.deploy.promote=false \
54+
-Pappengine.deploy.version="${GOOGLE_VERSION_ID}" \
55+
appengineDeploy
56+
57+
# End-2-End tests
58+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" "${UNIQUE_GRADLE_STRING}"
59+
60+
# Clean
61+
gradle clean

0 commit comments

Comments
 (0)