|
| 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