Skip to content

Commit 441a9a3

Browse files
author
Frank Natividad
committed
Add jenkins tests to endpoints backend and guice
1 parent 249f0b4 commit 441a9a3

File tree

6 files changed

+324
-0
lines changed

6 files changed

+324
-0
lines changed

appengine/endpoints-frameworks-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.7 // App Engine Standard uses Java 7
5869
targetCompatibility = 1.7 // App Engine Standard uses Java 7
5970

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
mvn clean endpoints-framework:openApiDocs
37+
38+
gcloud service-management deploy target/openapi-docs/openapi.json
39+
40+
# Test with Maven
41+
mvn appengine:deploy \
42+
-Dapp.deploy.version="${GOOGLE_VERSION_ID}" \
43+
-Dapp.deploy.promote=false
44+
45+
# End-2-End tests
46+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" "${UNIQUE_MAVEN_STRING}"
47+
48+
# Clean
49+
mvn clean
50+
51+
# Test with Gradle
52+
# Modify Greetings.java for Gradle
53+
UNIQUE_GRADLE_STRING="gradle"
54+
sed -i'.bak' -e "s/YOUR_PROJECT_ID/${GOOGLE_PROJECT_ID}/g" build.gradle
55+
56+
gradle clean endpointsOpenApiDocs
57+
58+
gcloud service-management deploy build/endpointsOpenApiDocs/openapi.json
59+
60+
# Deploy Gradle
61+
gradle -Pappengine.deploy.promote=false \
62+
-Pappengine.deploy.version="${GOOGLE_VERSION_ID}" \
63+
appengineDeploy
64+
65+
# End-2-End tests
66+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" "${UNIQUE_GRADLE_STRING}"
67+
68+
# Clean
69+
gradle clean
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright 2017 Google Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// [START buildscript]
16+
buildscript { // Configuration for building
17+
repositories {
18+
mavenCentral()
19+
jcenter() // Bintray's repository - a fast Maven Central mirror & more
20+
}
21+
dependencies {
22+
// App Engine Gradle plugin
23+
classpath 'com.google.cloud.tools:appengine-gradle-plugin:+'
24+
25+
// Endpoints Frameworks Gradle plugin
26+
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:+'
27+
}
28+
}
29+
// [END buildscript]
30+
31+
repositories { // repositories for Jar's you access in your code
32+
mavenCentral()
33+
jcenter()
34+
}
35+
36+
apply plugin: 'java' // standard Java tasks
37+
apply plugin: 'war' // standard Web Archive plugin
38+
39+
// [START apply_appengine]
40+
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
41+
// [END apply_appengine]
42+
43+
// [START apply_endpoints-framework-server]
44+
apply plugin: 'com.google.cloud.tools.endpoints-framework-server'
45+
// [END apply_endpoints-framework-server]
46+
47+
dependencies {
48+
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
49+
compile 'jstl:jstl:1.2'
50+
compile group: 'javax.inject', name: 'javax.inject', version: '1'
51+
compile group: 'com.google.appengine', name: 'appengine-api-1.0-sdk', version: '+'
52+
53+
// [START endpoints-tools]
54+
compile group: 'com.google.endpoints', name: 'endpoints-framework', version: '+'
55+
compile group: 'com.google.endpoints', name: 'endpoints-framework-guice', version: '+'
56+
// [END endpoints-tools]
57+
}
58+
59+
appengine { // App Engine tasks configuration
60+
deploy { // deploy configuration
61+
version = findProperty("appengine.deploy.version")
62+
63+
def promoteProp = findProperty("appengine.deploy.promote")
64+
if (promoteProp != null) {
65+
promote = new Boolean(promoteProp)
66+
}
67+
}
68+
}
69+
70+
// [START endpoints-server]
71+
endpointsServer {
72+
// Endpoints Framework Plugin server-side configuration
73+
hostname = "YOUR-PROJECT-ID.appspot.com"
74+
}
75+
// [END endpoints-server]
76+
77+
group = 'com.example.helloendpoints' // Generated output GroupId
78+
version = '1' // Version in generated output
79+
80+
sourceCompatibility = 1.7 // App Engine Standard uses Java 7
81+
targetCompatibility = 1.7 // App Engine Standard uses Java 7
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 -X GET \
24+
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/0" | \
25+
tee "$ERROR_OUTPUT_DIR/response.json" | \
26+
grep "hello ${3} version-${2}"
27+
28+
# Test getGreeting Endpoint (goodbye world!)
29+
curl -X GET \
30+
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \
31+
tee "$ERROR_OUTPUT_DIR/response.json" | \
32+
grep "goodbye world!"
33+
34+
# Test listGreeting Endpoint (hello world! and goodbye world!)
35+
curl -X GET \
36+
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting" | \
37+
tee "$ERROR_OUTPUT_DIR/response.json" | \
38+
grep "hello world!\|goodbye world!"
39+
40+
# Test multiply Endpoint (This is a greeting.)
41+
curl -X POST \
42+
-H "Content-Type: application/json" \
43+
--data "{'message':'This is a greeting from instance ${2}'}." \
44+
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \
45+
tee "$ERROR_OUTPUT_DIR/response.json" | \
46+
grep "This is a greeting from instance ${2}."
47+
}
48+
49+
# Jenkins provides values for GOOGLE_PROJECT_ID and GOOGLE_VERSION_ID
50+
# Update Greetings.java
51+
UNIQUE_MAVEN_STRING="maven"
52+
sed -i'.bak' \
53+
-e "s/hello world!/hello ${UNIQUE_MAVEN_STRING} version-${GOOGLE_VERSION_ID}!/g" \
54+
src/main/java/com/example/helloendpoints/Greetings.java
55+
56+
# Test with Maven
57+
mvn clean appengine:deploy \
58+
-Dapp.deploy.version="${GOOGLE_VERSION_ID}" \
59+
-Dapp.deploy.promote=false
60+
61+
# End-2-End tests
62+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" "${UNIQUE_MAVEN_STRING}"
63+
64+
# Clean
65+
mvn clean
66+
67+
# Test with Gradle
68+
# Modify Greetings.java for Gradle
69+
UNIQUE_GRADLE_STRING="gradle"
70+
sed -i'.bak' \
71+
-e "s/hello ${UNIQUE_MAVEN_STRING} version-${GOOGLE_VERSION_ID}!/hello ${UNIQUE_GRADLE_STRING} version-${GOOGLE_VERSION_ID}!/g" \
72+
src/main/java/com/example/helloendpoints/Greetings.java
73+
74+
# Deploy Gradle
75+
gradle -Pappengine.deploy.promote=false \
76+
-Pappengine.deploy.version="${GOOGLE_VERSION_ID}" \
77+
appengineDeploy
78+
79+
# End-2-End tests
80+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" "${UNIQUE_GRADLE_STRING}"
81+
82+
# Clean
83+
gradle clean

appengine/endpoints-frameworks-v2/guice-example/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ endpointsServer {
5656
serviceClasses = ['com.example.echo.Echo']
5757
}
5858

59+
appengine { // App Engine tasks configuration
60+
deploy { // deploy configuration
61+
version = findProperty("appengine.deploy.version")
62+
63+
def promoteProp = findProperty("appengine.deploy.promote")
64+
if (promoteProp != null) {
65+
promote = new Boolean(promoteProp)
66+
}
67+
}
68+
}
69+
5970
sourceCompatibility = 1.7 // App Engine Standard uses Java 7
6071
targetCompatibility = 1.7 // App Engine Standard uses Java 7
6172

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
mvn clean endpoints-framework:openApiDocs
37+
38+
gcloud service-management deploy target/openapi-docs/openapi.json
39+
40+
# Test with Maven
41+
mvn appengine:deploy \
42+
-Dapp.deploy.version="${GOOGLE_VERSION_ID}" \
43+
-Dapp.deploy.promote=false
44+
45+
# End-2-End tests
46+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" "${UNIQUE_MAVEN_STRING}"
47+
48+
# Clean
49+
mvn clean
50+
51+
# Test with Gradle
52+
# Modify Greetings.java for Gradle
53+
UNIQUE_GRADLE_STRING="gradle"
54+
sed -i'.bak' -e "s/YOUR_PROJECT_ID/${GOOGLE_PROJECT_ID}/g" build.gradle
55+
56+
gradle clean endpointsOpenApiDocs
57+
58+
gcloud service-management deploy build/endpointsOpenApiDocs/openapi.json
59+
60+
# Deploy Gradle
61+
gradle -Pappengine.deploy.promote=false \
62+
-Pappengine.deploy.version="${GOOGLE_VERSION_ID}" \
63+
appengineDeploy
64+
65+
# End-2-End tests
66+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}" "${UNIQUE_GRADLE_STRING}"
67+
68+
# Clean
69+
gradle clean

0 commit comments

Comments
 (0)