Skip to content

Commit c32dc22

Browse files
committed
Merge branch 'pubsub-alpha' into logging-alpha
2 parents 1fb496c + e32afa6 commit c32dc22

File tree

416 files changed

+37021
-61442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

416 files changed

+37021
-61442
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ before_install:
1010
install: mvn install -DskipTests=true -Dgpg.skip=true
1111
script:
1212
- utilities/verify.sh
13-
branches:
14-
only:
15-
- master
1613
after_success:
1714
- utilities/after_success.sh
1815
env:

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ Using maven for build/test
1515
After you cloned the repository use Maven for building and running the tests.
1616
Maven 3.0+ is required.
1717

18+
When downloading the source, we recommend you obtain service account credentials.
19+
These credentials will allow you to run integration tests using `mvn verify` in command line.
20+
Follow step 2 of the [authentication instructions](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) to generate and use JSON service account credentials.
21+
22+
It's also important to test that changes don't break compatibility with App/Compute Engine and when running elsewhere.
23+
To run tests on different platforms, try deploying the apps available on the [gcloud-java-examples](https://github.com/GoogleCloudPlatform/gcloud-java-examples) repository.
24+
End-to-end tests should ensure that gcloud-java works when running on the
25+
26+
* App Engine production environment (see the docs for [uploading your app to production App Engine](https://cloud.google.com/appengine/docs/java/tools/maven#uploading_your_app_to_production_app_engine))
27+
* App Engine development server (see the docs for [testing your app with the development server](https://cloud.google.com/appengine/docs/java/tools/maven#testing_your_app_with_the_development_server))
28+
* Compute Engine (see the [Getting Started Guide](https://cloud.google.com/compute/docs/quickstart), and be sure to [enable the appropriate APIs](https://github.com/GoogleCloudPlatform/gcloud-common/tree/master/authentication#on-google-compute-engine))
29+
* Your desktop (using `mvn exec:java`, for example)
30+
31+
When changes are made to authentication and project ID-related code, authentication and project ID inference should be tested using all relevant methods detailed in the [authentication docs](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) and [project ID docs](https://github.com/GoogleCloudPlatform/gcloud-java#specifying-a-project-id).
32+
33+
Known issue: If you have installed the Google Cloud SDK, be sure to log in (using `gcloud auth login`) before running tests. Though the Datastore tests use a local Datastore emulator that doesn't require authentication, they will not run if you have the Google Cloud SDK installed but aren't authenticated.
1834

1935
Adding Features
2036
---------------

README.md

Lines changed: 222 additions & 30 deletions
Large diffs are not rendered by default.

RELEASING.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,23 @@ This script takes an optional argument denoting the new version. By default, if
1010
2. Create a PR to update the pom.xml version.
1111
The PR should look something like [#225](https://github.com/GoogleCloudPlatform/gcloud-java/pull/225). After this PR is merged into GoogleCloudPlatform/gcloud-java, Travis CI will push a new website to GoogleCloudPlatform/gh-pages, push a new artifact to the Maven Central Repository, and update versions in the README files.
1212

13-
3. Create a release on Github manually.
14-
Go to the [releases page](https://github.com/GoogleCloudPlatform/gcloud-java/releases) and click "Draft a new release." Use `vX.Y.Z` as the "Tag Version" and `X.Y.Z` as the "Release Title", where `X.Y.Z` is the release version as listed in the `pom.xml` files.
13+
3. Before moving on, verify that the artifacts have successfully been pushed to the Maven Central Repository. Open Travis CI, click the ["Build History" tab](https://travis-ci.org/GoogleCloudPlatform/gcloud-java/builds), and open the second build's logs for Step 2's PR. Be sure that you are not opening the "Pull Request" build logs. When the build finishes, scroll to the end of the log and verify that the artifacts were successfully staged and deployed. You can also search for `gcloud-java` on the [Sonatype website](https://oss.sonatype.org/#nexus-search;quick~gcloud-java) and check the latest version number. If the deployment didn't succeed because of a flaky test, rerun the build.
1514

16-
4. Run `utilities/update_pom_version.sh` again (to include "-SNAPSHOT" in the project version).
15+
4. Publish a release on Github manually.
16+
Go to the [releases page](https://github.com/GoogleCloudPlatform/gcloud-java/releases) and open the appropriate release draft. Make sure the "Tag Version" is `vX.Y.Z` and the "Release Title" is `X.Y.Z`, where `X.Y.Z` is the release version as listed in the `pom.xml` files. The draft should already have all changes that impact users since the previous release. To double check this, you can use the `git log` command and look through the merged master branch pull requests. Here is an example of the log command to get non-merge commits between v0.0.12 and v0.1.0:
17+
18+
```
19+
git --no-pager log v0.0.12..v0.1.0 --pretty=oneline --abbrev-commit --no-merges
20+
```
21+
22+
Ensure that the format is consistent with previous releases (for an example, see the [0.1.0 release](https://github.com/GoogleCloudPlatform/gcloud-java/releases/tag/v0.1.0)). After adding any missing updates and reformatting as necessary, publish the draft. Finally, create a new draft for the next release.
23+
24+
5. Run `utilities/update_pom_version.sh` again (to include "-SNAPSHOT" in the project version).
1725
As mentioned before, there is an optional version argument. By default, the script will update the version from "X.Y.Z" to "X.Y.Z+1-SNAPSHOT". Suppose a different version is desired, for example X+1.0.0-SNAPSHOT. Then the appropriate command to run would be `utilities/update_pom_version.sh X+1.0.0-SNAPSHOT`.
1826

19-
5. Create and merge in another PR to reflect the updated project version. For an example of what this PR should look like, see [#227](https://github.com/GoogleCloudPlatform/gcloud-java/pull/227).
27+
6. Create and merge in another PR to reflect the updated project version. For an example of what this PR should look like, see [#227](https://github.com/GoogleCloudPlatform/gcloud-java/pull/227).
28+
29+
7. Be sure to update App Engine documentation and [java-docs-samples](https://github.com/GoogleCloudPlatform/java-docs-samples) code as necessary. See directions [here](https://docs.google.com/a/google.com/document/d/1SS3xNn2v0qW7EadGUPBUAPIQAH5VY6WSFmT17ZjjUVE/edit?usp=sharing).
2030

2131
### To push a snapshot version
2232

TESTING.md

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
## gcloud-java tools for testing
22

3-
This library provides tools to help write tests for code that uses gcloud-java services.
3+
This library provides tools to help write tests for code that uses the following gcloud-java services:
4+
5+
- [Datastore] (#testing-code-that-uses-datastore)
6+
- [Storage] (#testing-code-that-uses-storage)
7+
- [Resource Manager] (#testing-code-that-uses-resource-manager)
8+
- [BigQuery] (#testing-code-that-uses-bigquery)
49

510
### Testing code that uses Datastore
611

@@ -51,7 +56,8 @@ Currently, there isn't an emulator for Google Cloud Storage, so an alternative i
5156
3. Create a `RemoteGcsHelper` object using your project ID and JSON key.
5257
Here is an example that uses the `RemoteGcsHelper` to create a bucket.
5358
```java
54-
RemoteGcsHelper gcsHelper = RemoteGcsHelper.create(PROJECT_ID, "/path/to/my/JSON/key.json");
59+
RemoteGcsHelper gcsHelper =
60+
RemoteGcsHelper.create(PROJECT_ID, new FileInputStream("/path/to/my/JSON/key.json"));
5561
Storage storage = gcsHelper.options().service();
5662
String bucket = RemoteGcsHelper.generateBucketName();
5763
storage.create(BucketInfo.of(bucket));
@@ -65,5 +71,67 @@ Here is an example that clears the bucket created in Step 3 with a timeout of 5
6571
RemoteGcsHelper.forceDelete(storage, bucket, 5, TimeUnit.SECONDS);
6672
```
6773

74+
### Testing code that uses Resource Manager
75+
76+
#### On your machine
77+
78+
You can test against a temporary local Resource Manager by following these steps:
79+
80+
1. Before running your testing code, start the Resource Manager emulator `LocalResourceManagerHelper`. This can be done as follows:
81+
82+
```java
83+
import com.google.gcloud.resourcemanager.testing.LocalResourceManagerHelper;
84+
85+
LocalResourceManagerHelper helper = LocalResourceManagerHelper.create();
86+
helper.start();
87+
```
88+
89+
This will spawn a server thread that listens to `localhost` at an ephemeral port for Resource Manager requests.
90+
91+
2. In your program, create and use a Resource Manager service object whose host is set to `localhost` at the appropriate port. For example:
92+
93+
```java
94+
ResourceManager resourceManager = LocalResourceManagerHelper.options().service();
95+
```
96+
97+
3. Run your tests.
98+
99+
4. Stop the Resource Manager emulator.
100+
101+
```java
102+
helper.stop();
103+
```
104+
105+
This method will block until the server thread has been terminated.
106+
107+
### Testing code that uses BigQuery
108+
109+
Currently, there isn't an emulator for Google BigQuery, so an alternative is to create a test
110+
project. `RemoteBigQueryHelper` contains convenience methods to make setting up and cleaning up the
111+
test project easier. To use this class, follow the steps below:
112+
113+
1. Create a test Google Cloud project.
114+
115+
2. Download a [JSON service account credentials file][create-service-account] from the Google
116+
Developer's Console.
117+
118+
3. Create a `RemoteBigQueryHelper` object using your project ID and JSON key.
119+
Here is an example that uses the `RemoteBigQueryHelper` to create a dataset.
120+
```java
121+
RemoteBigQueryHelper bigqueryHelper =
122+
RemoteBigQueryHelper.create(PROJECT_ID, new FileInputStream("/path/to/my/JSON/key.json"));
123+
BigQuery bigquery = bigqueryHelper.options().service();
124+
String dataset = RemoteBigQueryHelper.generateDatasetName();
125+
bigquery.create(DatasetInfo.builder(dataset).build());
126+
```
127+
128+
4. Run your tests.
129+
130+
5. Clean up the test project by using `forceDelete` to clear any datasets used.
131+
Here is an example that clears the dataset created in Step 3.
132+
```java
133+
RemoteBigQueryHelper.forceDelete(bigquery, dataset);
134+
```
68135

69136
[cloud-platform-storage-authentication]:https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts
137+
[create-service-account]:https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount

codacy-conf.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)