Skip to content

Commit

Permalink
Merge branch 'master' into monitoring-quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
lesv authored Mar 16, 2017
2 parents 71dd194 + adc9d2a commit f2a276f
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 49 deletions.
4 changes: 4 additions & 0 deletions appengine/endpoints-frameworks-v2/discovery/jenkins.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,27 @@ function TestEndpoints () {
# Test getGreeting Endpoint (hello world!)
curl -X GET \
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/0" | \
tee "$ERROR_OUTPUT_DIR/response.json" | \
grep "hello version-${2}"

# Test getGreeting Endpoint (goodbye world!)
curl -X GET \
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \
tee "$ERROR_OUTPUT_DIR/response.json" | \
grep "goodbye world!"

# Test listGreeting Endpoint (hello world! and goodbye world!)
curl -X GET \
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting" | \
tee "$ERROR_OUTPUT_DIR/response.json" | \
grep "hello world!\|goodbye world!"

# Test multiply Endpoint (This is a greeting.)
curl -X POST \
-H "Content-Type: application/json" \
--data "{'message':'This is a greeting from instance ${2}'}." \
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \
tee "$ERROR_OUTPUT_DIR/response.json" | \
grep "This is a greeting from instance ${2}."
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Greetings {
public static ArrayList<HelloGreeting> greetings = new ArrayList<HelloGreeting>();

static {
greetings.add(new HelloGreeting("hello version-jerjou-test!"));
greetings.add(new HelloGreeting("hello world!"));
greetings.add(new HelloGreeting("goodbye world!"));
}
//[END api_def]
Expand Down
6 changes: 1 addition & 5 deletions appengine/helloworld-new-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,13 @@ Copyright 2015 Google Inc.
<configuration>
<!-- dev appserver configuration (standard environment only) -->
<!--
<devserver.host>127.0.0.1</devserver.port>
<devserver.host>127.0.0.1</devserver.host>
<devserver.port>8080</devserver.port>
-->
<!-- staging configuration (standard/flex-compat environment only) -->
<!--
<stage.enableJarSplitting>true</stage.enableJarSplitting>
-->
<!-- staging configuration (flexible environment only) -->
<!--
<stage.artifact>target/some-customer-artifact.jar</stage.artifact>
-->
<!-- deploy configuration -->
<deploy.promote>true</deploy.promote>
<deploy.stopPreviousVersion>true</deploy.stopPreviousVersion>
Expand Down
2 changes: 1 addition & 1 deletion datastore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This directory contains sample code used in Google Cloud Datastore documentation

1. Ensure that you have:
* Created a Google Developers Console project with the Datastore API enabled. Follow [these instructions](https://cloud.google.com/docs/authentication#preparation) to get your project set up.
* Installed the Google Cloud SDK and run the following commands in command line: `gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`.
* Installed the Google Cloud SDK and run the following commands in command line: `gcloud auth application-default login` and `gcloud config set project [YOUR PROJECT ID]`.
* Installed [Maven](https://maven.apache.org/) and Java 7 (or above).

2. Compile the program by typing `mvn clean compile` in command line.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private void assertArgsLength(String[] args, int expectedLength) {
* Exercises the methods defined in this class.
*
* <p>Assumes that you are authenticated using the Google Cloud SDK (using
* {@code gcloud auth login}).
* {@code gcloud auth application-default login}).
*/
public static void main(String[] args) throws Exception {
TaskList taskList = new TaskList();
Expand Down
2 changes: 1 addition & 1 deletion flexible/async-rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ First, complete the following steps:
- Obtain an app key for the Google Places WebService API.
- Download and install [the Beta build of the Google Cloud SDK](https://developers.google.com/cloud/sdk/#Quick_Start).
- Install the Cloud SDK `app-engine-java` component.
- Authenticate wth the gcloud SDK: gcloud auth login.
- Authenticate wth the gcloud SDK: gcloud auth application-default login.
- Install [Maven](http://maven.apache.org/download.cgi) if you haven't already.


Expand Down
2 changes: 1 addition & 1 deletion flexible/sparkjava/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Setup

2. Set up the local development environment by [installing the Google Cloud
SDK](https://cloud.google.com/sdk/) and running the following commands in
command line: `gcloud auth login` and `gcloud config set project [YOUR
command line: `gcloud auth application-default login` and `gcloud config set project [YOUR
PROJECT ID]`.

3. Ensure that you have Maven installed and configured to use Java 8. See
Expand Down
1 change: 1 addition & 0 deletions flexible/sparkjava/jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set -xe
function runtests () {
curl -X GET \
"https://${2}-dot-${1}.appspot.com/api/users" | \
tee "$ERROR_OUTPUT_DIR/response.json" | \
grep "^\\["
}

Expand Down
39 changes: 27 additions & 12 deletions jenkins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,58 @@ shopt -s globstar
# We spin up some subprocesses. Don't kill them on hangup
trap '' HUP

app_version=""
# Temporary directory to store any output to display on error
export ERROR_OUTPUT_DIR
ERROR_OUTPUT_DIR="$(mktemp -d)"
trap 'rm -r "${ERROR_OUTPUT_DIR}"' EXIT

# shellcheck disable=SC2120
delete_app_version() {
yes | gcloud --project="${GOOGLE_PROJECT_ID}" \
app versions delete "${1}"
}

handle_error() {
errcode=$? # Remember the error code so we can exit with it after cleanup

# Clean up
delete_app_version "$@"
# Clean up remote app version
delete_app_version "${1}" &

# Display any errors
if [ -n "$(find "${2}" -mindepth 1 -print -quit)" ]; then
cat "${2:?}"/* 1>&2
fi

wait

exit ${errcode}
}

cleanup() {
delete_app_version "${GOOGLE_VERSION_ID}" &
rm -r "${ERROR_OUTPUT_DIR:?}/"*
}

# First, style-check the shell scripts
shellcheck ./**/*.sh

# Find all jenkins.sh's and run them.
find . -mindepth 2 -maxdepth 5 -name jenkins.sh -type f | while read -r path; do
dir="${path%/jenkins.sh}"
# Use just the first letter of each subdir in version name
# Need different app versions because flex can't deploy over an existing
# version. Use just the first letter of each subdir in version name
export GOOGLE_VERSION_ID
# shellcheck disable=SC2001
app_version="jenkins-$(echo "${dir#./}" | sed 's#\([a-z]\)[^/]*/#\1-#g')"
GOOGLE_VERSION_ID="jenkins-$(echo "${dir#./}" | sed 's#\([a-z]\)[^/]*/#\1-#g')"

trap 'handle_error $app_version' ERR
trap 'handle_error "${GOOGLE_VERSION_ID}" "${ERROR_OUTPUT_DIR}"' ERR
(
# If there's an error, clean up

pushd "${dir}"
# Need different app versions because flex can't deploy over an existing
# version
GOOGLE_VERSION_ID="${app_version}" /bin/bash ./jenkins.sh
/bin/bash ./jenkins.sh

# Clean up the app version in the background
delete_app_version "${app_version}" &
# Clean up the app version
cleanup
)
# Clear the trap
trap - ERR
Expand Down
22 changes: 12 additions & 10 deletions pubsub/cloud-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,33 @@

[Google Cloud Pub/Sub][pubsub] is a fully-managed real-time messaging service that allows you to
send and receive messages between independent applications.
These sample Java applications demonstrate how to access the Pub/Sub API using
This sample Java application demonstrates how to access the Pub/Sub API using
the [Google Cloud Client Library for Java][google-cloud-java].

[pubsub]: https://cloud.google.com/pubsub/
[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java

## Quickstart

Install [Maven](http://maven.apache.org/).
#### Setup
- Install [Maven](http://maven.apache.org/) <p>
- Install the [Google Cloud SDK](https://cloud.google.com/sdk/) and run :

Build your project with:

mvn clean package -DskipTests
gcloud config set project [YOUR PROJECT ID]

## Testing

To run the tests for this sample, first set the `GOOGLE_CLOUD_PROJECT`
environment variable.
- Build your project with:

export GOOGLE_CLOUD_PROJECT=my-project

Then run the tests with Maven.
mvn clean package -DskipTests

#### Testing

Run the tests with Maven.

mvn clean verify

### Creating a new topic (using the quickstart sample)
#### Creating a new topic (using the quickstart sample)

mvn exec:java -Dexec.mainClass=com.example.pubsub.QuickstartSample
2 changes: 1 addition & 1 deletion pubsub/cloud-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>0.9.2-alpha</version>
<version>0.9.4-alpha</version>
</dependency>

<!-- Test dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@
// [START pubsub_quickstart]
// Imports the Google Cloud client library

import com.google.cloud.ServiceOptions;
import com.google.cloud.pubsub.spi.v1.PublisherClient;
import com.google.pubsub.v1.TopicName;

public class QuickstartSample {

public static void main(String... args) throws Exception {

// Your Google Cloud Platform project ID
String projectId = ServiceOptions.getDefaultProjectId();

// Your topic ID
String topicId = "my-new-topic";

// Create a new topic
String projectId = args[0];
TopicName topic = TopicName.create(projectId, "my-new-topic");
TopicName topic = TopicName.create(projectId, topicId);
try (PublisherClient publisherClient = PublisherClient.create()) {
publisherClient.createTopic(topic);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.cloud.ServiceOptions;
import com.google.cloud.pubsub.spi.v1.PublisherClient;
import com.google.pubsub.v1.TopicName;

Expand All @@ -40,11 +41,11 @@ public class QuickstartSampleIT {

private ByteArrayOutputStream bout;
private PrintStream out;
private String projectId;

private void deleteTestTopic(String projectId) throws Exception {
private void deleteTestTopic() throws Exception {
try (PublisherClient publisherClient = PublisherClient.create()) {
publisherClient.deleteTopic(TopicName.create(projectId, "my-new-topic"));
publisherClient.deleteTopic(
TopicName.create(ServiceOptions.getDefaultProjectId(), "my-new-topic"));
} catch (IOException e) {
System.err.println("Error deleting topic " + e.getMessage());
}
Expand All @@ -55,10 +56,8 @@ public void setUp() {
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
System.setOut(out);
projectId = System.getenv("GOOGLE_CLOUD_PROJECT");
assertThat(projectId).isNotNull();
try {
deleteTestTopic(projectId);
deleteTestTopic();
} catch (Exception e) {
//empty catch block
}
Expand All @@ -67,12 +66,12 @@ public void setUp() {
@After
public void tearDown() throws Exception {
System.setOut(null);
deleteTestTopic(projectId);
deleteTestTopic();
}

@Test
public void testQuickstart() throws Exception {
QuickstartSample.main(projectId);
QuickstartSample.main();
String got = bout.toString();
assertThat(got).contains("my-new-topic created.");
}
Expand Down
10 changes: 5 additions & 5 deletions speech/grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ limitations under the License.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<codehaus-versions-maven-plugin-version>2.3</codehaus-versions-maven-plugin-version>
<grpc-protobuf-version>1.1.2</grpc-protobuf-version>
<grpc-version>1.0.3</grpc-version> <!-- 1.1.2 doesn't work - DO NOT UPGRADE -->
<maven-compiler-plugin-version>3.6.0</maven-compiler-plugin-version>
<xolstice-protobuf-maven-plugin-version>0.5.0</xolstice-protobuf-maven-plugin-version>

Expand Down Expand Up @@ -113,22 +113,22 @@ limitations under the License.
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-auth</artifactId>
<version>1.1.2</version>
<version>${grpc-version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>1.1.2</version>
<version>${grpc-version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc-protobuf-version}</version>
<version>${grpc-version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.1.2</version>
<version>${grpc-version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
Expand Down
2 changes: 1 addition & 1 deletion storage/json-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Google Cloud Storage Service features a REST-based API that allows developers to
Note that if it's been a while, you may need to login with gcloud.

```
gcloud auth login
gcloud auth application-default login
```

## Products
Expand Down

0 comments on commit f2a276f

Please sign in to comment.