From c2f8d83663773a8da6e13124e0363c7ced32fed6 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Thu, 24 Jan 2019 08:54:47 -0800 Subject: [PATCH] gae-interop-testing: Remove jdk7 test GAE Java 7 is dead as of January 16. https://cloud.google.com/appengine/docs/deprecations/java7 --- build.gradle | 1 - gae-interop-testing/README.md | 3 +- gae-interop-testing/gae-jdk7/build.gradle | 154 ----------- .../OkHttpClientInteropServlet.java | 255 ------------------ .../src/main/webapp/WEB-INF/appengine-web.xml | 20 -- .../gae-jdk7/src/main/webapp/WEB-INF/web.xml | 14 - interop-testing/build.gradle | 9 +- settings.gradle | 2 - 8 files changed, 3 insertions(+), 455 deletions(-) delete mode 100644 gae-interop-testing/gae-jdk7/build.gradle delete mode 100644 gae-interop-testing/gae-jdk7/src/main/java/io/grpc/testing/integration/OkHttpClientInteropServlet.java delete mode 100644 gae-interop-testing/gae-jdk7/src/main/webapp/WEB-INF/appengine-web.xml delete mode 100644 gae-interop-testing/gae-jdk7/src/main/webapp/WEB-INF/web.xml diff --git a/build.gradle b/build.gradle index e158936284..ca776a3835 100644 --- a/build.gradle +++ b/build.gradle @@ -258,7 +258,6 @@ subprojects { if (!(project.name in [ 'grpc-benchmarks', 'grpc-interop-testing', - 'grpc-gae-interop-testing-jdk7', 'grpc-gae-interop-testing-jdk8', ])) { resolutionStrategy.failOnVersionConflict() diff --git a/gae-interop-testing/README.md b/gae-interop-testing/README.md index f518a2b867..5b2dca929e 100644 --- a/gae-interop-testing/README.md +++ b/gae-interop-testing/README.md @@ -24,11 +24,10 @@ Running the tests in GAE You can run the gradle task to execute the interop tests. ```bash -# cd into either gae-jdk7 or gae-jdk8 +# cd into gae-jdk8 $ ../../gradlew runInteropTestRemote # 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 ``` diff --git a/gae-interop-testing/gae-jdk7/build.gradle b/gae-interop-testing/gae-jdk7/build.gradle deleted file mode 100644 index d27f336b63..0000000000 --- a/gae-interop-testing/gae-jdk7/build.gradle +++ /dev/null @@ -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}") - } -} diff --git a/gae-interop-testing/gae-jdk7/src/main/java/io/grpc/testing/integration/OkHttpClientInteropServlet.java b/gae-interop-testing/gae-jdk7/src/main/java/io/grpc/testing/integration/OkHttpClientInteropServlet.java deleted file mode 100644 index a0243049f2..0000000000 --- a/gae-interop-testing/gae-jdk7/src/main/java/io/grpc/testing/integration/OkHttpClientInteropServlet.java +++ /dev/null @@ -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 - * - * Interoperability Test Case Descriptions. - */ -@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 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 befores = new ArrayList<>(); - List afters = new ArrayList<>(); - List 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 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() {} - } -} diff --git a/gae-interop-testing/gae-jdk7/src/main/webapp/WEB-INF/appengine-web.xml b/gae-interop-testing/gae-jdk7/src/main/webapp/WEB-INF/appengine-web.xml deleted file mode 100644 index a1963ce0c9..0000000000 --- a/gae-interop-testing/gae-jdk7/src/main/webapp/WEB-INF/appengine-web.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - true - java-gae-interop-test - java7 - - diff --git a/gae-interop-testing/gae-jdk7/src/main/webapp/WEB-INF/web.xml b/gae-interop-testing/gae-jdk7/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 35d6f83362..0000000000 --- a/gae-interop-testing/gae-jdk7/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - interoptest - io.grpc.testing.integration.OkHttpClientInteropServlet - - - interoptest - / - - diff --git a/interop-testing/build.gradle b/interop-testing/build.gradle index ccec867003..44503aee89 100644 --- a/interop-testing/build.gradle +++ b/interop-testing/build.gradle @@ -23,13 +23,8 @@ dependencies { project(':grpc-testing'), libraries.google_auth_oauth2_http, libraries.junit, - libraries.mockito - compile (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' - } + libraries.mockito, + libraries.truth compileOnly libraries.javax_annotation runtime libraries.opencensus_impl, libraries.netty_tcnative diff --git a/settings.gradle b/settings.gradle index 4bc170691b..6564ea8a1b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -13,7 +13,6 @@ include ":grpc-grpclb" include ":grpc-testing" include ":grpc-testing-proto" include ":grpc-interop-testing" -include ":grpc-gae-interop-testing-jdk7" include ":grpc-gae-interop-testing-jdk8" include ":grpc-all" 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-proto').projectDir = "$rootDir/testing-proto" 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-all').projectDir = "$rootDir/all" as File project(':grpc-alts').projectDir = "$rootDir/alts" as File