Skip to content

Commit 9a3c375

Browse files
ludochgae-java-bot
authored andcommitted
Add the allinone bundled services prober into open source, and using the latest runtime jars. The entrypoint is changed to point to this latest jars so we can test the prober on up to date code if needed.
PiperOrigin-RevId: 445137435 Change-Id: I5f619e9496b9b0776c7d12e3195e3de8f10787a8
1 parent 76dd9b3 commit 9a3c375

16 files changed

Lines changed: 1976 additions & 0 deletions

applications/pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2021 Google LLC
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+
https://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+
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
<artifactId>applications</artifactId>
21+
<name>AppEngine :: application projects</name>
22+
<parent>
23+
<groupId>com.google.appengine</groupId>
24+
<artifactId>parent</artifactId>
25+
<version>2.0.5-SNAPSHOT</version>
26+
</parent>
27+
<packaging>pom</packaging>
28+
29+
<modules>
30+
<module>proberapp</module>
31+
</modules>
32+
</project>

applications/proberapp/pom.xml

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2021 Google LLC
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+
https://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+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
21+
<modelVersion>4.0.0</modelVersion>
22+
<packaging>war</packaging>
23+
24+
<groupId>com.google.appengine.demos</groupId>
25+
<artifactId>proberapp</artifactId>
26+
<name>AppEngine :: proberapp</name>
27+
<parent>
28+
<groupId>com.google.appengine</groupId>
29+
<artifactId>applications</artifactId>
30+
<version>2.0.5-SNAPSHOT</version>
31+
</parent>
32+
33+
<prerequisites>
34+
<maven>3.1.0</maven>
35+
</prerequisites>
36+
37+
<properties>
38+
<maven.deploy.skip>true</maven.deploy.skip>
39+
<appengine.runtime.version>${project.version}</appengine.runtime.version>
40+
<appengine.runtime.location>target/${project.artifactId}-${project.version}</appengine.runtime.location>
41+
<!--INSTANCE_CONNECTION_NAME>ludo-in-in:us-central1:mysql-instance</INSTANCE_CONNECTION_NAME-->
42+
<MYSQL_DB_DATABASE>mysql-database</MYSQL_DB_DATABASE>
43+
<MYSQL_DATABASE_NAME>mysql-instance</MYSQL_DATABASE_NAME>
44+
<DB_REGION>us-central1</DB_REGION>
45+
<DB_USER>prober-user</DB_USER>
46+
<DB_PASSOWRD>prober_connectivity_test_database</DB_PASSOWRD>
47+
48+
<appengine.target.version>${project.version}</appengine.target.version>
49+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
50+
</properties>
51+
52+
<dependencies>
53+
<!-- Compile/runtime dependencies -->
54+
<dependency>
55+
<groupId>com.google.appengine</groupId>
56+
<artifactId>appengine-api-1.0-sdk</artifactId>
57+
</dependency>
58+
<dependency>
59+
<groupId>com.google.appengine</groupId>
60+
<artifactId>runtime-deployment</artifactId>
61+
<version>${appengine.runtime.version}</version>
62+
<type>zip</type>
63+
</dependency>
64+
<dependency>
65+
<groupId>jstl</groupId>
66+
<artifactId>jstl</artifactId>
67+
<version>1.2</version>
68+
</dependency>
69+
<dependency>
70+
<groupId>com.google.cloud</groupId>
71+
<artifactId>google-cloud-spanner</artifactId>
72+
<version>6.17.3</version>
73+
</dependency>
74+
<dependency>
75+
<groupId>com.google.api</groupId>
76+
<artifactId>gax</artifactId>
77+
<version>2.16.0</version>
78+
</dependency>
79+
<dependency>
80+
<groupId>com.google.api</groupId>
81+
<artifactId>gax-httpjson</artifactId>
82+
<version>0.101.0</version>
83+
</dependency>
84+
<dependency>
85+
<groupId>com.google.api</groupId>
86+
<artifactId>gax-grpc</artifactId>
87+
<version>2.16.0</version>
88+
</dependency>
89+
<dependency>
90+
<groupId>com.google.api-client</groupId>
91+
<artifactId>google-api-client</artifactId>
92+
</dependency>
93+
<dependency>
94+
<groupId>com.google.appengine</groupId>
95+
<artifactId>appengine-remote-api</artifactId>
96+
</dependency>
97+
<dependency>
98+
<groupId>com.google.cloud</groupId>
99+
<artifactId>google-cloud-bigquery</artifactId>
100+
<version>2.10.10</version>
101+
</dependency>
102+
<dependency>
103+
<groupId>com.google.cloud</groupId>
104+
<artifactId>google-cloud-core</artifactId>
105+
<version>2.6.1</version>
106+
</dependency>
107+
<dependency>
108+
<groupId>com.google.cloud</groupId>
109+
<artifactId>google-cloud-datastore</artifactId>
110+
<version>2.4.0</version>
111+
</dependency>
112+
<dependency>
113+
<groupId>com.google.cloud</groupId>
114+
<artifactId>google-cloud-logging</artifactId>
115+
<version>3.7.5</version>
116+
</dependency>
117+
<dependency>
118+
<groupId>com.google.cloud</groupId>
119+
<artifactId>google-cloud-storage</artifactId>
120+
<version>2.6.1</version>
121+
</dependency>
122+
<dependency>
123+
<groupId>com.google.cloud.sql</groupId>
124+
<artifactId>mysql-socket-factory</artifactId>
125+
<version>1.5.0</version>
126+
</dependency>
127+
<dependency>
128+
<groupId>com.google.guava</groupId>
129+
<artifactId>guava</artifactId>
130+
</dependency>
131+
<dependency>
132+
<groupId>com.google.truth</groupId>
133+
<artifactId>truth</artifactId>
134+
<scope>compile</scope>
135+
</dependency>
136+
<dependency>
137+
<groupId>com.google.truth.extensions</groupId>
138+
<artifactId>truth-java8-extension</artifactId>
139+
<scope>compile</scope>
140+
</dependency>
141+
<dependency>
142+
<groupId>javax.servlet</groupId>
143+
<artifactId>javax.servlet-api</artifactId>
144+
<version>3.1.0</version>
145+
</dependency>
146+
<dependency>
147+
<groupId>junit</groupId>
148+
<artifactId>junit</artifactId>
149+
<scope>compile</scope>
150+
</dependency>
151+
<dependency>
152+
<groupId>mysql</groupId>
153+
<artifactId>mysql-connector-java</artifactId>
154+
<version>8.0.28</version>
155+
</dependency>
156+
<dependency>
157+
<groupId>org.apache.httpcomponents</groupId>
158+
<artifactId>httpclient</artifactId>
159+
<version>4.5.13</version>
160+
</dependency>
161+
<dependency>
162+
<groupId>org.apache.httpcomponents</groupId>
163+
<artifactId>httpcore</artifactId>
164+
<version>4.4.15</version>
165+
</dependency>
166+
<dependency>
167+
<groupId>org.apache.httpcomponents</groupId>
168+
<artifactId>httpmime</artifactId>
169+
<version>4.5.13</version>
170+
</dependency>
171+
<dependency>
172+
<groupId>com.google.http-client</groupId>
173+
<artifactId>google-http-client-jackson</artifactId>
174+
<version>1.29.2</version>
175+
</dependency>
176+
<!-- Test Dependencies -->
177+
<dependency>
178+
<groupId>org.mockito</groupId>
179+
<artifactId>mockito-all</artifactId>
180+
<version>2.0.2-beta</version>
181+
<scope>test</scope>
182+
</dependency>
183+
<dependency>
184+
<groupId>com.google.appengine</groupId>
185+
<artifactId>appengine-testing</artifactId>
186+
<scope>test</scope>
187+
</dependency>
188+
<dependency>
189+
<groupId>com.google.appengine</groupId>
190+
<artifactId>appengine-api-stubs</artifactId>
191+
<scope>test</scope>
192+
</dependency>
193+
</dependencies>
194+
195+
<build>
196+
<outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>
197+
198+
<plugins>
199+
<plugin>
200+
<groupId>com.coderplus.maven.plugins</groupId>
201+
<artifactId>copy-rename-maven-plugin</artifactId>
202+
<version>1.0</version>
203+
<executions>
204+
<execution>
205+
<id>rename-file</id>
206+
<phase>pre-integration-test</phase>
207+
<goals>
208+
<goal>rename</goal>
209+
</goals>
210+
<configuration>
211+
<fileSets>
212+
<fileSet>
213+
<sourceFile>${appengine.runtime.location}/WEB-INF/lib/runtime-impl-${appengine.runtime.version}.jar</sourceFile>
214+
<destinationFile>${appengine.runtime.location}/runtime-impl.jar</destinationFile>
215+
</fileSet>
216+
<fileSet>
217+
<sourceFile>${appengine.runtime.location}/WEB-INF/lib/runtime-shared-${appengine.runtime.version}.jar</sourceFile>
218+
<destinationFile>${appengine.runtime.location}/runtime-shared.jar</destinationFile>
219+
</fileSet>
220+
<fileSet>
221+
<sourceFile>${appengine.runtime.location}/WEB-INF/lib/runtime-main-${appengine.runtime.version}.jar</sourceFile>
222+
<destinationFile>${appengine.runtime.location}/runtime-main.jar</destinationFile>
223+
</fileSet>
224+
</fileSets>
225+
</configuration>
226+
</execution>
227+
</executions>
228+
</plugin>
229+
<plugin>
230+
<groupId>org.apache.maven.plugins</groupId>
231+
<artifactId>maven-war-plugin</artifactId>
232+
<version>2.6</version>
233+
<configuration>
234+
<archiveClasses>true</archiveClasses>
235+
<webResources>
236+
<!-- in order to interpolate version from pom into appengine-web.xml -->
237+
<resource>
238+
<directory>${basedir}/src/main/webapp/WEB-INF</directory>
239+
<filtering>true</filtering>
240+
<targetPath>WEB-INF</targetPath>
241+
</resource>
242+
</webResources>
243+
</configuration>
244+
</plugin>
245+
246+
<plugin>
247+
<groupId>com.google.cloud.tools</groupId>
248+
<artifactId>appengine-maven-plugin</artifactId>
249+
<version>2.4.1</version>
250+
<configuration>
251+
<projectId>ludo-in-in</projectId>
252+
<version>liveruntimejava8maven</version>
253+
<promote>false</promote>
254+
<automaticRestart>true</automaticRestart>
255+
</configuration>
256+
</plugin>
257+
<plugin>
258+
<artifactId>maven-compiler-plugin</artifactId>
259+
<version>3.10.1</version>
260+
<configuration>
261+
<source>1.8</source>
262+
<target>1.8</target>
263+
</configuration>
264+
</plugin>
265+
</plugins>
266+
</build>
267+
268+
</project>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package app;
18+
19+
import static com.google.common.truth.Truth.assertThat;
20+
21+
import com.google.appengine.api.blobstore.BlobKey;
22+
import com.google.appengine.api.blobstore.BlobstoreService;
23+
import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
24+
import java.io.IOException;
25+
import java.util.List;
26+
import java.util.logging.Logger;
27+
import javax.servlet.ServletException;
28+
import javax.servlet.annotation.WebServlet;
29+
import javax.servlet.http.HttpServlet;
30+
import javax.servlet.http.HttpServletRequest;
31+
import javax.servlet.http.HttpServletResponse;
32+
33+
/**
34+
* Servlet that gets the blob information and serves the blob in the blob upload callback request.
35+
* The BlobKey of the uploaded blob is stored as the value of the response header BLOBKEY_HEADER.
36+
*/
37+
@WebServlet(name = "GetAndServeBlobServlet", value = "/blob")
38+
public class GetAndServeBlobServlet extends HttpServlet {
39+
private static final Logger logger = Logger.getLogger(GetAndServeBlobServlet.class.getName());
40+
private static final String UPLOAD_NAME = "java-blobstore-test";
41+
private static final String BLOBKEY_HEADER = "Test-Blobkey";
42+
43+
@Override
44+
public void doPost(HttpServletRequest request, HttpServletResponse response)
45+
throws ServletException, IOException {
46+
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
47+
48+
// Must be called from a blob upload callback request.
49+
assertThat(blobstoreService.getFileInfos(request).get(UPLOAD_NAME)).isNotEmpty();
50+
51+
// Must be called from a blob upload callback request.
52+
assertThat(blobstoreService.getBlobInfos(request).get(UPLOAD_NAME)).isNotEmpty();
53+
54+
// Must be called from a blob upload callback request.
55+
List<BlobKey> blobKeys = blobstoreService.getUploads(request).get(UPLOAD_NAME);
56+
assertThat(blobKeys).hasSize(1);
57+
response.setHeader(BLOBKEY_HEADER, blobKeys.get(0).getKeyString());
58+
logger.info(
59+
"GetAndServeBlobServlet setting blob key header: " + blobKeys.get(0).getKeyString());
60+
61+
// The response should be assumed to be committed after invoking `serve()`, but custom headers
62+
// can be appended. If no exception is thrown, we can think `serve()` succeeds.
63+
blobstoreService.serve(blobKeys.get(0), response);
64+
}
65+
}

0 commit comments

Comments
 (0)