-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from ajkannan/pull-updates
Pull updates from master branch
- Loading branch information
Showing
80 changed files
with
7,207 additions
and
1,248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
### Overview | ||
|
||
Most of the release process is handled by the `after_success.sh` script, triggered after Travis CI successfully completes a non-PR build. A new artifact will be released to Maven Central Repository via Travis CI when "-SNAPSHOT" is not included in the version (as listed in the base directory's `pom.xml`). The website and README files will also be updated automatically in this case. When "-SNAPSHOT" is included in the version, Travis only updates the artifact in the snapshot repository. | ||
|
||
### To push a release version | ||
|
||
1. Run `utilities/update_pom_version.sh` from the repository's base directory. | ||
This script takes an optional argument denoting the new version. By default, if the current version is X.Y.Z-SNAPSHOT, the script will update the version in all the pom.xml files to X.Y.Z. If desired, another version can be supplied via command line argument instead. | ||
|
||
2. Create a PR to update the pom.xml version. | ||
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. | ||
|
||
3. Create a release on Github manually. | ||
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. | ||
|
||
4. Run `utilities/update_pom_version.sh` again (to include "-SNAPSHOT" in the project version). | ||
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`. | ||
|
||
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). | ||
|
||
### To push a snapshot version | ||
|
||
Pushing a snapshot is completely automated. If "-SNAPSHOT" is included in the version denoted by the base directory's pom.xml, then an updated artifact will be pushed to the snapshot repository when Travis CI successfully completes a non-PR build. | ||
|
||
### Improvements | ||
|
||
Automatic tagging is not currently implemented, though it was discussed in [#119](https://github.com/GoogleCloudPlatform/gcloud-java/pull/119). If the version updates continue to be manual, a one-line git tag command can be added to `after_success.sh` to correctly tag releases. However, automatically creating useful annotations for this tag will be difficult. Also, if the release process becomes fully automated, tagging becomes a harder problem, as mentioned in that issue. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
## gcloud-java tools for testing | ||
|
||
This library provides tools to help write tests for code that uses gcloud-java services. | ||
|
||
### Testing code that uses Datastore | ||
|
||
#### On your machine | ||
|
||
You can test against a temporary local datastore by following these steps: | ||
|
||
1. Start the local datastore emulator using `LocalGcdHelper`. This can be done in two ways: | ||
- Run `LocalGcdHelper.java`'s `main` method with arguments `START` and (optionally) `--port=<port number>`. This will create a temporary folder on your computer and bind `localhost:<port number>` for communication with the local datastore. The port number is an optional argument. If no port number is specified, port 8080 will be used. | ||
- Call `LocalGcdHelper.start(<project ID>, <port number>)` before running your tests. Save the `LocalGcdHelper` object returned so that you can stop the emulator later. | ||
|
||
2. In your program, create and use a datastore whose host is set host to `localhost:<port number>`. For example, | ||
```java | ||
DatastoreOptions options = DatastoreOptions.builder() | ||
.projectId(PROJECT_ID) | ||
.host("http://localhost:8080") | ||
.build(); | ||
Datastore localDatastore = DatastoreFactory.instance().get(options); | ||
``` | ||
3. Run your tests. | ||
|
||
4. Stop the local datastore emulator. | ||
- If you ran `LocalGcdHelper.java`'s `main` function to start the emulator, run `LocalGcdHelper.java`'s `main` method with arguments `STOP` and (optionally) `--port=<port number>`. If the port is not supplied, the program will attempt to close the last port started. | ||
- If you ran `LocalGcdHelper.start()` to start the emulator, call the `stop()` method on the `LocalGcdHelper` object returned by `LocalGcdHelper.start()`. | ||
|
||
#### On a remote machine | ||
|
||
You can test against a remote datastore emulator as well. To do this, set the `DatastoreOptions` project endpoint to the hostname of the remote machine, like the example below. | ||
|
||
```java | ||
DatastoreOptions options = DatastoreOptions.builder() | ||
.projectId(PROJECT_ID) | ||
.host("http://<hostname of machine>:<port>") | ||
.build(); | ||
Datastore localDatastore = DatastoreFactory.instance().get(options); | ||
``` | ||
|
||
Note that the remote datastore must be running before your tests are run. | ||
|
||
### Testing code that uses Storage | ||
|
||
Currently, there isn't an emulator for Google Cloud Storage, so an alternative is to create a test project. `RemoteGcsHelper` contains convenience methods to make setting up and cleaning up the test project easier. To use this class, follow the steps below: | ||
1. Create a test Google Cloud project. | ||
2. Download a JSON service account credentials file from the Google Developer's Console. See more about this on the [Google Cloud Platform Storage Authentication page][cloud-platform-storage-authentication]. | ||
|
||
3. Create a `RemoteGcsHelper` object using your project ID and JSON key. | ||
Here is an example that uses the `RemoteGcsHelper` to create a bucket. | ||
```java | ||
RemoteGcsHelper gcsHelper = RemoteGcsHelper.create(PROJECT_ID, "/path/to/my/JSON/key.json"); | ||
Storage storage = StorageFactory.instance().get(gcsHelper.options()); | ||
String bucket = RemoteGcsHelper.generateBucketName(); | ||
storage.create(BucketInfo.of(bucket)); | ||
``` | ||
|
||
4. Run your tests. | ||
|
||
5. Clean up the test project by using `forceDelete` to clear any buckets used. | ||
Here is an example that clears the bucket created in Step 3 with a timeout of 5 seconds. | ||
```java | ||
RemoteGcsHelper.forceDelete(storage, bucket, 5, TimeUnit.SECONDS); | ||
``` | ||
|
||
|
||
[cloud-platform-storage-authentication]:https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.