gae-interop-testing: Remove jdk7 test

GAE Java 7 is dead as of January 16.
https://cloud.google.com/appengine/docs/deprecations/java7
This commit is contained in:
Eric Anderson 2019-01-24 08:54:47 -08:00 committed by GitHub
parent 1d97b50315
commit c2f8d83663
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 3 additions and 455 deletions

View File

@ -258,7 +258,6 @@ subprojects {
if (!(project.name in [ if (!(project.name in [
'grpc-benchmarks', 'grpc-benchmarks',
'grpc-interop-testing', 'grpc-interop-testing',
'grpc-gae-interop-testing-jdk7',
'grpc-gae-interop-testing-jdk8', 'grpc-gae-interop-testing-jdk8',
])) { ])) {
resolutionStrategy.failOnVersionConflict() resolutionStrategy.failOnVersionConflict()

View File

@ -24,11 +24,10 @@ Running the tests in GAE
You can run the gradle task to execute the interop tests. You can run the gradle task to execute the interop tests.
```bash ```bash
# cd into either gae-jdk7 or gae-jdk8 # cd into gae-jdk8
$ ../../gradlew runInteropTestRemote $ ../../gradlew runInteropTestRemote
# Or run one of these from the root gRPC Java directory: # Or run one of these from the root gRPC Java directory:
$ ./gradlew :grpc-gae-interop-testing-jdk7:runInteropTestRemote
$ ./gradlew :grpc-gae-interop-testing-jdk8:runInteropTestRemote $ ./gradlew :grpc-gae-interop-testing-jdk8:runInteropTestRemote
``` ```

View File

@ -1,154 +0,0 @@
// Copyright 2017 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
description = 'gRPC: gae interop testing (jdk7)'
buildscript {
// Configuration for building
repositories {
jcenter() // Bintray's repository - a fast Maven Central mirror & more
maven { // The google mirror is less flaky than mavenCentral()
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.5'
classpath 'com.squareup.okhttp:okhttp:2.5.0'
}
}
repositories {
// repositories for Jar's you access in your code
mavenLocal()
maven { // The google mirror is less flaky than mavenCentral()
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
jcenter()
}
apply plugin: 'java' // standard Java tasks
apply plugin: 'war' // standard Web Archive plugin
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
dependencies {
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.59'
// Deps needed by all gRPC apps in GAE
compile libraries.google_api_protos
compile project(":grpc-okhttp")
compile project(":grpc-protobuf")
compile project(":grpc-stub")
compile (project(":grpc-interop-testing")) {
exclude group: 'io.opencensus', module: 'opencensus-impl'
}
// The lite version of opencensus is required for jdk7 GAE
runtime libraries.opencensus_impl_lite
}
compileJava {
// Disable "No processor claimed any of these annotations: org.junit.Ignore"
options.compilerArgs += ["-Xlint:-processing"]
}
def createDefaultVersion() {
return new java.text.SimpleDateFormat("yyyyMMdd't'HHmmss").format(new Date())
}
// [START model]
appengine {
// App Engine tasks configuration
run { // local (dev_appserver) configuration (standard environments only)
port = 8080 // default
}
deploy {
// deploy configuration
// default - stop the current version
stopPreviousVersion = System.getProperty('gaeStopPreviousVersion') ?: true
// default - do not make this the promoted version
promote = System.getProperty('gaePromote') ?: false
// Use -DgaeDeployVersion if set, otherwise the version is null and the plugin will generate it
version = System.getProperty('gaeDeployVersion', createDefaultVersion())
}
}
// [END model]
group = 'io.grpc' // Generated output GroupId
version = '1.0-SNAPSHOT' // Version in generated output
sourceCompatibility = 1.7
targetCompatibility = 1.7
/** Returns the service name. */
String getGaeProject() {
def stream = new ByteArrayOutputStream()
exec {
executable 'gcloud'
args = [
'config',
'get-value',
'project'
]
standardOutput = stream
}
return stream.toString().trim()
}
String getService(java.nio.file.Path projectPath) {
Node xml = new XmlParser().parse(projectPath.resolve("src/main/webapp/WEB-INF/appengine-web.xml").toFile())
if (xml.service.isEmpty()) {
return "default"
} else {
return xml.service.text()
}
}
String getAppUrl(String project, String service, String version) {
return "http://${version}.${service}.${project}.appspot.com"
}
task runInteropTestRemote(dependsOn: 'appengineDeploy') {
doLast {
// give remote app some time to settle down
sleep(20000)
def appUrl = getAppUrl(
getGaeProject(),
getService(project.getProjectDir().toPath()),
appengine.deploy.version)
logger.log(LogLevel.INFO, "the appURL=" + appUrl)
def client = new com.squareup.okhttp.OkHttpClient()
// The test suite can take a while to run
client.setReadTimeout(3, java.util.concurrent.TimeUnit.MINUTES)
// The '?jdk8' argument is ignored by the server, it exists only to tag the request log entry
def interopRequest = new com.squareup.okhttp.Request.Builder()
.url("${appUrl}/?jdk7").build()
// Retry in case GAE is slow and times out
int maxRetries = 5
String result = null
Throwable caught = null
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
def response = client.newCall(interopRequest).execute()
result = response.body().string()
project.println(result)
if (response.code() == 200) {
return
}
} catch (Throwable t) {
caught = t
logger.log(LogLevel.ERROR, "caught exception. will retry if possible", t)
}
}
throw new GradleException("Interop test failed:\nthrowable:${caught}")
}
}

View File

@ -1,255 +0,0 @@
/*
* Copyright 2017 The gRPC Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.grpc.testing.integration;
import static junit.framework.TestCase.assertEquals;
import static org.junit.Assert.assertTrue;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.internal.MoreThrowables;
import io.grpc.okhttp.OkHttpChannelBuilder;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.internal.AssumptionViolatedException;
/**
* This servlet communicates with {@code grpc-test.sandbox.googleapis.com}, which is a server
* managed by the gRPC team. For more information, see
* <a href="https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md">
* Interoperability Test Case Descriptions</a>.
*/
@SuppressWarnings("serial")
public final class OkHttpClientInteropServlet extends HttpServlet {
private static final String INTEROP_TEST_ADDRESS = "grpc-test.sandbox.googleapis.com:443";
private static final class LogEntryRecorder extends Handler {
private Queue<LogRecord> loggedMessages = new ConcurrentLinkedQueue<>();
@Override
public void publish(LogRecord logRecord) {
loggedMessages.add(logRecord);
}
@Override
public void flush() {}
@Override
public void close() {}
public String getLogOutput() {
SimpleFormatter formatter = new SimpleFormatter();
StringBuilder sb = new StringBuilder();
for (LogRecord loggedMessage : loggedMessages) {
sb.append(formatter.format(loggedMessage));
}
return sb.toString();
}
}
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
LogEntryRecorder handler = new LogEntryRecorder();
Logger.getLogger("").addHandler(handler);
try {
doGetHelper(req, resp);
} finally {
Logger.getLogger("").removeHandler(handler);
}
resp.getWriter().append("=======================================\n")
.append("Server side java.util.logging messages:\n")
.append(handler.getLogOutput());
}
private void doGetHelper(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/plain");
PrintWriter writer = resp.getWriter();
writer.println("Test invoked at: ");
writer.println(new SimpleDateFormat("yyyy/MM/dd HH:mm:ss Z")
.format(Calendar.getInstance().getTime()));
// We can not use JUnit because it tries to spawn backgrounds threads.
// GAE+JDK7 does not allow arbitrary background threads.
// Let's use reflection to run test methods.
List<Method> befores = new ArrayList<>();
List<Method> afters = new ArrayList<>();
List<Method> testMethods = new ArrayList<>();
int ignored = 0;
for (Method method : Tester.class.getMethods()) {
if (method.getAnnotation(Test.class) != null) {
if (method.getAnnotation(Ignore.class) != null) {
ignored++;
} else {
testMethods.add(method);
}
} else if (method.getAnnotation(Before.class) != null) {
befores.add(method);
} else if (method.getAnnotation(After.class) != null) {
afters.add(method);
}
}
StringBuilder sb = new StringBuilder();
int failures = 0;
for (Method method : testMethods) {
// JUnit creates a new instance per test method, we will emulate that behavior.
Tester tester = new Tester();
try {
for (Method before : befores) {
before.invoke(tester);
}
try (AutoCloseable unused = toCloseable(tester, afters)) {
method.invoke(tester);
}
sb.append("================\n");
sb.append("PASS: Test method: ").append(method).append("\n");
} catch (Throwable t) {
// The default JUnit4 test runner skips tests with failed assumptions.
// We will do the same here.
boolean assumptionViolated = false;
for (Throwable iter = t; iter != null; iter = iter.getCause()) {
if (iter instanceof AssumptionViolatedException) {
assumptionViolated = true;
break;
}
}
if (assumptionViolated) {
continue;
}
sb.append("================\n");
sb.append("FAILED: Test method: ").append(method).append("\n");
failures++;
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
t.printStackTrace(printWriter);
sb.append(stringWriter);
}
}
if (failures == 0) {
resp.setStatus(200);
writer.println(
String.format(
"PASS! Tests ran %d, tests ignored %d",
testMethods.size(),
ignored));
} else {
resp.setStatus(500);
writer.println(
String.format(
"FAILED! Tests ran %d, tests failed %d, tests ignored %d",
testMethods.size(),
failures,
ignored));
}
writer.println(sb);
}
private static AutoCloseable toCloseable(final Object o, final List<Method> methods) {
return new AutoCloseable() {
@Override
public void close() throws Exception {
Throwable failure = null;
for (Method method : methods) {
try {
method.invoke(o);
} catch (Throwable t) {
if (failure == null) {
failure = t;
} else {
failure.addSuppressed(t);
}
}
}
if (failure != null) {
MoreThrowables.throwIfUnchecked(failure);
throw new Exception(failure);
}
}
};
}
public static final class Tester extends AbstractInteropTest {
@Override
protected ManagedChannel createChannel() {
assertEquals(
"jdk7 required",
"1.7",
System.getProperty("java.specification.version"));
assertEquals(
"Can not run in dev servers because they lack org.conscrypt.OpenSSLProvider support",
"Production",
System.getProperty("com.google.appengine.runtime.environment"));
ManagedChannelBuilder<?> builder =
ManagedChannelBuilder.forTarget(INTEROP_TEST_ADDRESS)
.maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE);
assertTrue(builder instanceof OkHttpChannelBuilder);
return builder.build();
}
@Override
protected boolean metricsExpected() {
// Server-side metrics won't be found because the server is running remotely.
return false;
}
// grpc-test.sandbox.googleapis.com does not support these tests
@Ignore
@Override
public void customMetadata() { }
@Ignore
@Override
public void statusCodeAndMessage() { }
@Ignore
@Override
public void exchangeMetadataUnaryCall() { }
@Ignore
@Override
public void exchangeMetadataStreamingCall() { }
@Ignore
@Override
public void specialStatusMessage() {}
// grpc-java/issues/4626: this test has become flakey on GAE JDK7
@Ignore
@Override
public void timeoutOnSleepingServer() {}
}
}

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2017 The gRPC Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- [START config] -->
<appengine-web-app xmlns='http://appengine.google.com/ns/1.0'>
<threadsafe>true</threadsafe>
<service>java-gae-interop-test</service>
<runtime>java7</runtime>
</appengine-web-app>
<!-- [END config] -->

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>interoptest</servlet-name>
<servlet-class>io.grpc.testing.integration.OkHttpClientInteropServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>interoptest</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -23,13 +23,8 @@ dependencies {
project(':grpc-testing'), project(':grpc-testing'),
libraries.google_auth_oauth2_http, libraries.google_auth_oauth2_http,
libraries.junit, libraries.junit,
libraries.mockito libraries.mockito,
compile (libraries.truth) { libraries.truth
// Disable because it uses Java 8 bytecode, which breaks gae-java7
exclude group: 'com.google.auto.value', module: 'auto-value-annotations'
// Disable because it uses Java 8 bytecode, which breaks gae-java7
exclude group: 'org.checkerframework', module: 'checker-qual'
}
compileOnly libraries.javax_annotation compileOnly libraries.javax_annotation
runtime libraries.opencensus_impl, runtime libraries.opencensus_impl,
libraries.netty_tcnative libraries.netty_tcnative

View File

@ -13,7 +13,6 @@ include ":grpc-grpclb"
include ":grpc-testing" include ":grpc-testing"
include ":grpc-testing-proto" include ":grpc-testing-proto"
include ":grpc-interop-testing" include ":grpc-interop-testing"
include ":grpc-gae-interop-testing-jdk7"
include ":grpc-gae-interop-testing-jdk8" include ":grpc-gae-interop-testing-jdk8"
include ":grpc-all" include ":grpc-all"
include ":grpc-alts" include ":grpc-alts"
@ -35,7 +34,6 @@ project(':grpc-grpclb').projectDir = "$rootDir/grpclb" as File
project(':grpc-testing').projectDir = "$rootDir/testing" as File project(':grpc-testing').projectDir = "$rootDir/testing" as File
project(':grpc-testing-proto').projectDir = "$rootDir/testing-proto" as File project(':grpc-testing-proto').projectDir = "$rootDir/testing-proto" as File
project(':grpc-interop-testing').projectDir = "$rootDir/interop-testing" as File project(':grpc-interop-testing').projectDir = "$rootDir/interop-testing" as File
project(':grpc-gae-interop-testing-jdk7').projectDir = "$rootDir/gae-interop-testing/gae-jdk7" as File
project(':grpc-gae-interop-testing-jdk8').projectDir = "$rootDir/gae-interop-testing/gae-jdk8" as File project(':grpc-gae-interop-testing-jdk8').projectDir = "$rootDir/gae-interop-testing/gae-jdk8" as File
project(':grpc-all').projectDir = "$rootDir/all" as File project(':grpc-all').projectDir = "$rootDir/all" as File
project(':grpc-alts').projectDir = "$rootDir/alts" as File project(':grpc-alts').projectDir = "$rootDir/alts" as File