Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions TRYLATESTBITSINPROD.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ top of your web application and change the entrypoint to boot with these jars in
./mvnw clean install
```

Let's assume the current build version is `5.0.3-SNAPSHOT`.
Let's assume the current build version is `5.0.3-beta-SNAPSHOT`.

See the output of the runtime deployment module which contains all the jars needed by the runtime:

Expand All @@ -67,7 +67,7 @@ Add the dependency for the GAE runtime jars in your application pom.xml file:

```
<properties>
<appengine.runtime.version>5.0.3-SNAPSHOT</appengine.runtime.version>
<appengine.runtime.version>5.0.3-beta-SNAPSHOT</appengine.runtime.version>
<appengine.runtime.location>target/${project.artifactId}-${project.version}</appengine.runtime.location>
<properties>
...
Expand Down Expand Up @@ -185,13 +185,13 @@ fi
if grep -q "<properties>" "$POM_FILE"; then
# Inserts the properties before the closing </properties> tag
sed -i '/<\/properties>/i \
<appengine.runtime.version>5.0.3-SNAPSHOT<\/appengine.runtime.version>\
<appengine.runtime.version>5.0.3-beta-SNAPSHOT<\/appengine.runtime.version>\
<appengine.runtime.location>target/${project.artifactId}-${project.version}<\/appengine.runtime.location>' "$POM_FILE"
else
# If no properties tag exists, insert it before dependencies
sed -i '/<dependencies>/i \
<properties>\
<appengine.runtime.version>5.0.3-SNAPSHOT<\/appengine.runtime.version>\
<appengine.runtime.version>5.0.3-beta-SNAPSHOT<\/appengine.runtime.version>\
<appengine.runtime.location>target/${project.artifactId}-${project.version}<\/appengine.runtime.location>\
<\/properties>' "$POM_FILE"
fi
Expand Down Expand Up @@ -266,14 +266,14 @@ If you are using the Gradle build system, you can apply the following changes to

These instructions configure the `war` task to do two important things:
1. **Move the jars to the top of the WAR directory:** The `into("")` (or `into('.')`) block combined with `eachFile { path = name }` extracts the jars and flattens the directory structure, placing them directly in the root of the generated WAR.
2. **Rename the jars:** The `rename` block strips the version string (e.g., `-5.0.3-SNAPSHOT`) from the extracted jars so their names exactly match the `-Djava.class.path=runtime-main.jar` argument specified in the `appengine-web.xml` entrypoint.
2. **Rename the jars:** The `rename` block strips the version string (e.g., `-5.0.3-beta-SNAPSHOT`) from the extracted jars so their names exactly match the `-Djava.class.path=runtime-main.jar` argument specified in the `appengine-web.xml` entrypoint.

### Kotlin
```
import org.gradle.api.tasks.bundling.War

// 1. Define the target runtime version
val gaeRuntimeVersion = "5.0.3-SNAPSHOT" // Change this to your desired version
val gaeRuntimeVersion = "5.0.3-beta-SNAPSHOT" // Change this to your desired version

// 2. Create a custom configuration for the runtime zip
val gaeRuntimeZip by configurations.creating
Expand Down Expand Up @@ -309,7 +309,7 @@ tasks.named<War>("war") {

```
// 1. Define the target runtime version
def gaeRuntimeVersion = "5.0.3-SNAPSHOT" // Change this to your desired version
def gaeRuntimeVersion = "5.0.3-beta-SNAPSHOT" // Change this to your desired version

// 2. Create a custom configuration for the runtime zip
configurations {
Expand All @@ -336,7 +336,7 @@ war {
}

// Strip the version number from the jar files
// (e.g., 'runtime-main-5.0.3-SNAPSHOT.jar' becomes 'runtime-main.jar')
// (e.g., 'runtime-main-5.0.3-beta-SNAPSHOT.jar' becomes 'runtime-main.jar')
rename { String fileName ->
fileName.replace("-${gaeRuntimeVersion}", "")
}
Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>parent</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,40 @@ private static GoogleCredentials getApplicationDefaultCredentials() {
}

private String getTarget() {
String endpoint = environmentProvider.getenv("IMAGES_SERVICE_ENDPOINT");
String endpoint =
environmentProvider.getenv(ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV);
if (isNullOrEmpty(endpoint)) {
throw new IllegalStateException("IMAGES_SERVICE_ENDPOINT environment variable not set.");
throw new IllegalStateException(
ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV + " environment variable not set.");
}
try {
URI uri = new URI(endpoint);
String host = uri.getHost();
if (host == null) {
throw new IllegalStateException("Invalid URI in IMAGES_SERVICE_ENDPOINT: " + endpoint);
throw new IllegalStateException(
"Invalid URI in "
+ ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV
+ ": "
+ endpoint);
}
return host + ":443";
} catch (URISyntaxException e) {
throw new IllegalStateException("Invalid URI in IMAGES_SERVICE_ENDPOINT: " + endpoint, e);
throw new IllegalStateException(
"Invalid URI in "
+ ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV
+ ": "
+ endpoint,
e);
}
}

private static CallCredentials createOidcCredentials(
EnvironmentProvider environmentProvider, GoogleCredentials googleCredentials) {
String endpoint = environmentProvider.getenv("IMAGES_SERVICE_ENDPOINT");
String endpoint =
environmentProvider.getenv(ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV);
if (isNullOrEmpty(endpoint)) {
throw new IllegalStateException("IMAGES_SERVICE_ENDPOINT environment variable not set.");
throw new IllegalStateException(
ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV + " environment variable not set.");
}

if (!(googleCredentials instanceof IdTokenProvider idTokenProvider)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
final class ImagesServiceFactoryImpl implements IImagesServiceFactory {

@VisibleForTesting
static final String USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV = "USE_CUSTOM_IMAGES_GRPC_SERVICE";
static final String USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV =
"APPENGINE_USE_CUSTOM_IMAGES_GRPC_SERVICE";

@VisibleForTesting
static final String IMAGES_SERVICE_ENDPOINT_ENV = "APPENGINE_IMAGES_SERVICE_ENDPOINT";

private EnvironmentProvider environmentProvider = new SystemEnvironmentProvider();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ private ImagesServiceBlockingStub getGrpcStub() {

@VisibleForTesting
boolean useGrpc() {
String envVar = environmentProvider.getenv("USE_CUSTOM_IMAGES_GRPC_SERVICE");
String envVar =
environmentProvider.getenv(ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV);
return Boolean.parseBoolean(envVar);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class GrpcImagesClientTest {

@Test
public void constructor_validEndpointAndCreds_success() {
when(mockEnvironmentProvider.getenv("IMAGES_SERVICE_ENDPOINT"))
when(mockEnvironmentProvider.getenv(ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV))
.thenReturn("https://my-service.run.app");

GrpcImagesClient client = new GrpcImagesClient(mockEnvironmentProvider, mockCallCredentials);
Expand All @@ -46,37 +46,47 @@ public void constructor_validEndpointAndCreds_success() {

@Test
public void constructor_endpointNotSet_throwsException() {
when(mockEnvironmentProvider.getenv("IMAGES_SERVICE_ENDPOINT")).thenReturn(null);
when(mockEnvironmentProvider.getenv(ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV))
.thenReturn(null);
IllegalStateException e =
assertThrows(
IllegalStateException.class,
() -> new GrpcImagesClient(mockEnvironmentProvider, mockCallCredentials));
assertThat(e).hasMessageThat().contains("IMAGES_SERVICE_ENDPOINT environment variable not set");
assertThat(e)
.hasMessageThat()
.contains(
ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV + " environment variable not set");
}

@Test
public void constructor_invalidEndpoint_throwsException() {
when(mockEnvironmentProvider.getenv("IMAGES_SERVICE_ENDPOINT")).thenReturn("://my-service");
when(mockEnvironmentProvider.getenv(ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV))
.thenReturn("://my-service");
IllegalStateException e =
assertThrows(
IllegalStateException.class,
() -> new GrpcImagesClient(mockEnvironmentProvider, mockCallCredentials));
assertThat(e).hasMessageThat().contains("Invalid URI in IMAGES_SERVICE_ENDPOINT");
assertThat(e)
.hasMessageThat()
.contains("Invalid URI in " + ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV);
}

@Test
public void constructor_endpointMissingHost_throwsException() {
when(mockEnvironmentProvider.getenv("IMAGES_SERVICE_ENDPOINT")).thenReturn("https://");
when(mockEnvironmentProvider.getenv(ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV))
.thenReturn("https://");
IllegalStateException e =
assertThrows(
IllegalStateException.class,
() -> new GrpcImagesClient(mockEnvironmentProvider, mockCallCredentials));
assertThat(e).hasMessageThat().contains("Invalid URI in IMAGES_SERVICE_ENDPOINT");
assertThat(e)
.hasMessageThat()
.contains("Invalid URI in " + ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV);
}

@Test
public void getBlockingStub_returnsStub() {
when(mockEnvironmentProvider.getenv("IMAGES_SERVICE_ENDPOINT"))
when(mockEnvironmentProvider.getenv(ImagesServiceFactoryImpl.IMAGES_SERVICE_ENDPOINT_ENV))
.thenReturn("https://my-service.run.app");
GrpcImagesClient client = new GrpcImagesClient(mockEnvironmentProvider, mockCallCredentials);
assertThat(client.getBlockingStub()).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public void setUp() {

@Test
public void makeImageFromFilename_newBehavior_trueEnv_gsPrefix() {
when(mockEnvironmentProvider.getenv("USE_CUSTOM_IMAGES_GRPC_SERVICE")).thenReturn("true");
when(mockEnvironmentProvider.getenv(
ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV))
.thenReturn("true");
String filename = "/gs/bucket/object";

// Should NOT call BlobstoreServiceFactory (which would fail in this env)
Expand All @@ -53,7 +55,9 @@ public void makeImageFromFilename_newBehavior_trueEnv_gsPrefix() {

@Test
public void makeImageFromFilename_newBehavior_trueEnv_noGsPrefix_throwsException() {
when(mockEnvironmentProvider.getenv("USE_CUSTOM_IMAGES_GRPC_SERVICE")).thenReturn("true");
when(mockEnvironmentProvider.getenv(
ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV))
.thenReturn("true");
String filename = "not/gs/path";

IllegalArgumentException e =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ private void setupGrpcService(ImagesServiceGrpc.ImagesServiceImplBase serviceImp
new ImagesServiceImpl(
mockEnvironmentProvider, mockGrpcImagesClient, null, mockBlobstoreReference);

when(mockEnvironmentProvider.getenv("USE_CUSTOM_IMAGES_GRPC_SERVICE")).thenReturn("true");
when(mockEnvironmentProvider.getenv(
ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV))
.thenReturn("true");
}

@Test
Expand Down Expand Up @@ -354,7 +356,8 @@ public void loadImageData_withLegacyBlobKey_failure() throws Exception {

public void setUpGrpc(boolean useGrpc) throws Exception {
ImagesServiceImpl.setStorageForTesting(mockStorage);
when(mockEnvironmentProvider.getenv("USE_CUSTOM_IMAGES_GRPC_SERVICE"))
when(mockEnvironmentProvider.getenv(
ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV))
.thenReturn(Boolean.toString(useGrpc));

if (useGrpc) {
Expand Down Expand Up @@ -407,7 +410,9 @@ public void useGrpc_envVarSetFalse_returnsFalse() throws Exception {

@Test
public void useGrpc_envVarNotSet_returnsFalse() {
when(mockEnvironmentProvider.getenv("USE_CUSTOM_IMAGES_GRPC_SERVICE")).thenReturn(null);
when(mockEnvironmentProvider.getenv(
ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV))
.thenReturn(null);
imagesService =
new ImagesServiceImpl(
mockEnvironmentProvider, null, null, mockBlobstoreReference, null, mockBlobInfoFactory);
Expand All @@ -416,7 +421,9 @@ public void useGrpc_envVarNotSet_returnsFalse() {

@Test
public void useGrpc_envVarInvalid_returnsFalse() {
when(mockEnvironmentProvider.getenv("USE_CUSTOM_IMAGES_GRPC_SERVICE")).thenReturn("yes");
when(mockEnvironmentProvider.getenv(
ImagesServiceFactoryImpl.USE_CUSTOM_IMAGES_GRPC_SERVICE_ENV))
.thenReturn("yes");
imagesService =
new ImagesServiceImpl(
mockEnvironmentProvider, null, null, mockBlobstoreReference, null, mockBlobInfoFactory);
Expand Down
2 changes: 1 addition & 1 deletion api_dev/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>parent</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>

<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion api_legacy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>parent</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>

<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion appengine-api-1.0-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>parent</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<name>AppEngine :: appengine-api-1.0-sdk</name>
Expand Down
2 changes: 1 addition & 1 deletion appengine-api-stubs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>parent</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>

<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion appengine_init/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>parent</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>

<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion appengine_jsr107/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>parent</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion appengine_resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>parent</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<name>AppEngine :: appengine-resources</name>
Expand Down
2 changes: 1 addition & 1 deletion appengine_setup/apiserver_local/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>appengine_setup</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion appengine_setup/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>parent</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>
<modules>
<module>apiserver_local</module>
Expand Down
2 changes: 1 addition & 1 deletion appengine_setup/test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.google.appengine</groupId>
<artifactId>appengine_setup</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.appengine</groupId>
Expand Down
6 changes: 3 additions & 3 deletions appengine_setup/testapps/jetty12_testapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>testapps</artifactId>
<groupId>com.google.appengine</groupId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.appengine.setup.testapps</groupId>
Expand All @@ -32,7 +32,7 @@
<dependency>
<groupId>com.google.appengine.setup.testapps</groupId>
<artifactId>testapps_common</artifactId>
<version>5.0.3-SNAPSHOT</version>
<version>5.0.3-beta-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand Down Expand Up @@ -98,7 +98,7 @@
<projectId>srirammahavadi-dev</projectId>
<version>GCLOUD_CONFIG</version>
<automaticRestart>true</automaticRestart>
<artifact>${project.build.directory}/jetty11_testapp-5.0.3-SNAPSHOT-jar-with-dependencies.jar</artifact>
<artifact>${project.build.directory}/jetty11_testapp-5.0.3-beta-SNAPSHOT-jar-with-dependencies.jar</artifact>
</configuration>
</plugin>
<plugin>
Expand Down
Loading
Loading