This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit c8c4bca3adb1339f36c6ff8cf7775ae38cf690b5
Author: heyile <[email protected]>
AuthorDate: Sat Oct 20 17:46:46 2018 +0800

    [SCB-837] make http2 production ready: add h2
---
 .../org/apache/servicecomb/it/ConsumerMain.java    |  21 +++++++++++
 .../org/apache/servicecomb/it/deploy/Deploys.java  |  34 ++++++++++++++++--
 .../src/main/resources/certificates/server.p12     | Bin 0 -> 4541 bytes
 .../src/main/resources/certificates/trust.jks      | Bin 0 -> 1828 bytes
 .../org/apache/servicecomb/it/DemoSSLCustom.java   |  40 +++++++++++++++++++++
 .../src/main/resources/certificates/server.p12     | Bin 0 -> 4541 bytes
 .../src/main/resources/certificates/trust.jks      | Bin 0 -> 1828 bytes
 .../src/main/resources/microservice.yaml           |  17 ++++++++-
 8 files changed, 108 insertions(+), 4 deletions(-)

diff --git 
a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java
 
b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java
index 25f9e95..b534c59 100644
--- 
a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java
+++ 
b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/ConsumerMain.java
@@ -106,6 +106,9 @@ public class ConsumerMain {
     // ......
 
     testSpringBoot2Standalone();
+
+    testHttp2CStandalone();
+
     testSpringBoot2Servlet();
     //http2
     testHttp2Standalone();
@@ -149,6 +152,24 @@ public class ConsumerMain {
     deploys.getBaseProducer().stop();
   }
 
+  private static void testHttp2CStandalone() throws Throwable {
+    deploys.getBaseHttp2CProducer().ensureReady();
+
+    ITJUnitUtils.addProducer("it-producer");
+
+    runShareTestCases();
+
+    // currently not support update 3rd url, so only test once
+    ITJUnitUtils.run(Test3rdPartyInvocation.class);
+
+    //as setMaxInitialLineLength() is not work for http2, do not need
+    // ITJUnitUtils.runWithRest(TestRestServerConfig.class)
+    ITJUnitUtils.run(TestRestServerConfigEdge.class);
+
+    ITJUnitUtils.popProducer();
+    deploys.getBaseHttp2CProducer().stop();
+  }
+
   private static void testHttp2Standalone() throws Throwable {
     deploys.getBaseHttp2Producer().ensureReady();
 
diff --git 
a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/deploy/Deploys.java
 
b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/deploy/Deploys.java
index 4ba0e89..f71f1c7 100644
--- 
a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/deploy/Deploys.java
+++ 
b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/deploy/Deploys.java
@@ -19,6 +19,7 @@ package org.apache.servicecomb.it.deploy;
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
+import java.net.URL;
 
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
@@ -38,6 +39,8 @@ public class Deploys {
 
   private MicroserviceDeploy baseProducer;
 
+  private MicroserviceDeploy baseHttp2CProducer;
+
   private MicroserviceDeploy baseHttp2Producer;
 
   private MicroserviceDeploy springBoot2StandaloneProducer;
@@ -66,6 +69,10 @@ public class Deploys {
     return baseHttp2Producer;
   }
 
+  public MicroserviceDeploy getBaseHttp2CProducer() {
+    return baseHttp2CProducer;
+  }
+
   public MicroserviceDeploy getSpringBoot2StandaloneProducer() {
     return springBoot2StandaloneProducer;
   }
@@ -81,6 +88,7 @@ public class Deploys {
     serviceCenter = new ServiceCenterDeploy();
     initEdge();
     initBaseProducer();
+    initBaseHttp2CProducer();
     initBaseHttp2Producer();
     initSpringBoot2StandaloneProducer();
     initSpringBoot2ServletProducer();
@@ -194,14 +202,20 @@ public class Deploys {
     baseProducer = new MicroserviceDeploy(definition);
   }
 
-
   private void initBaseHttp2Producer() {
     MicroserviceDeployDefinition definition = new 
MicroserviceDeployDefinition();
     definition.setDeployName("baseHttp2Producer");
     definition.setCmd("it-producer");
     definition.setArgs(new String[] {});
-    definition.setArgs(new String[] 
{"-Dservicecomb.rest.address=0.0.0.0:0?protocol=http2",
-        "-Dservicecomb.highway.address=0.0.0.0:0?protocol=http2"});
+    URL urlServer = 
Thread.currentThread().getContextClassLoader().getResource("certificates/server.p12");
+    URL urlTrust = 
Thread.currentThread().getContextClassLoader().getResource("certificates/trust.jks");
+    if (urlServer != null && urlTrust != null) {
+      definition.setArgs(new String[] 
{"-Dservicecomb.rest.address=0.0.0.0:0?sslEnabled=true&protocol=http2",
+          "-Dservicecomb.highway.address=0.0.0.0:0?sslEnabled=true",
+          "-Dserver.p12=" + urlServer.getPath(),
+          "-Dtrust.jks=" + urlTrust.getPath()
+      });
+    }
     definition.setAppId("integration-test");
     definition.setMicroserviceName("it-producer");
     definition.setVersion(DEFAULT_MICROSERVICE_VERSION);
@@ -211,6 +225,20 @@ public class Deploys {
     baseHttp2Producer = new MicroserviceDeploy(definition);
   }
 
+  private void initBaseHttp2CProducer() {
+    MicroserviceDeployDefinition definition = new 
MicroserviceDeployDefinition();
+    definition.setDeployName("baseHttp2CProducer");
+    definition.setCmd("it-producer");
+    definition.setArgs(new String[] 
{"-Dservicecomb.rest.address=0.0.0.0:0?protocol=http2"});
+    definition.setAppId("integration-test");
+    definition.setMicroserviceName("it-producer");
+    definition.setVersion(DEFAULT_MICROSERVICE_VERSION);
+
+    initDeployDefinition(definition);
+
+    baseHttp2CProducer = new MicroserviceDeploy(definition);
+  }
+
   private void initSpringBoot2ServletProducer() {
     MicroserviceDeployDefinition definition = new 
MicroserviceDeployDefinition();
     definition.setDeployName("springBoot2ServletProducer");
diff --git 
a/integration-tests/it-consumer/src/main/resources/certificates/server.p12 
b/integration-tests/it-consumer/src/main/resources/certificates/server.p12
new file mode 100644
index 0000000..631313e
Binary files /dev/null and 
b/integration-tests/it-consumer/src/main/resources/certificates/server.p12 
differ
diff --git 
a/integration-tests/it-consumer/src/main/resources/certificates/trust.jks 
b/integration-tests/it-consumer/src/main/resources/certificates/trust.jks
new file mode 100644
index 0000000..57aeff7
Binary files /dev/null and 
b/integration-tests/it-consumer/src/main/resources/certificates/trust.jks differ
diff --git 
a/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/DemoSSLCustom.java
 
b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/DemoSSLCustom.java
new file mode 100644
index 0000000..d27dc2e
--- /dev/null
+++ 
b/integration-tests/it-producer/src/main/java/org/apache/servicecomb/it/DemoSSLCustom.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.servicecomb.it;
+
+import java.net.URL;
+
+import org.apache.servicecomb.foundation.ssl.SSLCustom;
+
+public class DemoSSLCustom extends SSLCustom {
+  @Override
+  public char[] decode(char[] encrypted) {
+    return encrypted;
+  }
+
+  @Override
+  public String getFullPath(String filename) {
+    URL url = 
Thread.currentThread().getContextClassLoader().getResource("certificates/" + 
filename);
+    // can not get cert from jar
+    if (url == null || url.getPath().contains("!")) {
+      // get from env
+      return System.getProperty(filename);
+    }
+    return url.getPath();
+  }
+}
diff --git 
a/integration-tests/it-producer/src/main/resources/certificates/server.p12 
b/integration-tests/it-producer/src/main/resources/certificates/server.p12
new file mode 100644
index 0000000..631313e
Binary files /dev/null and 
b/integration-tests/it-producer/src/main/resources/certificates/server.p12 
differ
diff --git 
a/integration-tests/it-producer/src/main/resources/certificates/trust.jks 
b/integration-tests/it-producer/src/main/resources/certificates/trust.jks
new file mode 100644
index 0000000..57aeff7
Binary files /dev/null and 
b/integration-tests/it-producer/src/main/resources/certificates/trust.jks differ
diff --git a/integration-tests/it-producer/src/main/resources/microservice.yaml 
b/integration-tests/it-producer/src/main/resources/microservice.yaml
index 2621253..eaec944 100644
--- a/integration-tests/it-producer/src/main/resources/microservice.yaml
+++ b/integration-tests/it-producer/src/main/resources/microservice.yaml
@@ -21,4 +21,19 @@ service_description:
 servicecomb:
   rest:
     server:
-      maxInitialLineLength: 5000
\ No newline at end of file
+      maxInitialLineLength: 5000
+
+#########SSL options
+ssl.protocols: TLSv1.2
+ssl.authPeer: false
+ssl.checkCN.host: false
+
+#########certificates config
+ssl.trustStore: trust.jks
+ssl.trustStoreType: JKS
+ssl.trustStoreValue: Changeme_123
+ssl.keyStore: server.p12
+ssl.keyStoreType: PKCS12
+ssl.keyStoreValue: Changeme_123
+ssl.crl: revoke.crl
+ssl.sslCustomClass: org.apache.servicecomb.it.DemoSSLCustom

Reply via email to