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 09f68b4b8240f2930d27153ec7f84d441ed8642f Author: wujimin <[email protected]> AuthorDate: Wed Oct 31 02:49:03 2018 +0800 [SCB-1001] avoid waiting for update instances after close a instance --- .../org/apache/servicecomb/it/ConsumerMain.java | 131 +++++++-------------- .../org/apache/servicecomb/it/deploy/Deploys.java | 4 +- .../servicecomb/it/deploy/MicroserviceDeploy.java | 20 +--- .../it-edge/src/main/resources/microservice.yaml | 26 ++-- 4 files changed, 67 insertions(+), 114 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 61db446..f6ebdbc 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 @@ -19,6 +19,7 @@ package org.apache.servicecomb.it; import org.apache.servicecomb.core.SCBEngine; import org.apache.servicecomb.foundation.common.utils.BeanUtils; import org.apache.servicecomb.it.deploy.Deploys; +import org.apache.servicecomb.it.deploy.MicroserviceDeploy; import org.apache.servicecomb.it.junit.ITJUnitUtils; import org.apache.servicecomb.it.schema.TestApiOperation; import org.apache.servicecomb.it.testcase.TestAnnotatedAttribute; @@ -53,10 +54,12 @@ public class ConsumerMain { BeanUtils.init(); ITUtils.waitBootFinished(); - run(); - - SCBEngine.getInstance().destroy(); - deploys.getServiceCenter().stop(); + try { + run(); + } finally { + SCBEngine.getInstance().destroy(); + deploys.getServiceCenter().stop(); + } resultPrinter.print(); @@ -70,51 +73,22 @@ public class ConsumerMain { // if not ready, will start a new instance and wait for ready deploys.getEdge().ensureReady(); // deploys.getZuul().ensureReady(zuul); - ITJUnitUtils.run(TestIgnoreStaticMethod.class); - ITJUnitUtils.run(TestIgnoreMethod.class); - ITJUnitUtils.run(TestApiParam.class); - ITJUnitUtils.run(TestApiOperation.class); - - // 1.base test case - // include all extension point abnormal scenes test case - - // deploy standalone base-producer - // only run one case for "any" transport - // run highway - // run rest - // run native restTemplate to edge/zuul - // stop standalone base-producer - testStandalone(); - - // deploy tomcat base-producer - // run vertx-servlet - // run native restTemplate to edge/zuul - // stop tomcat base-producer - - // deploy spring boot base-producer - // run vertx-servlet - // run native restTemplate to edge/zuul - // stop spring boot base-producer - - // 2.complex test case - // 1)start new producer version - // consumer/edge/zuul should ...... - // 2)delete new producer version - // consumer/edge/zuul should ...... - // ...... - - // 3.deploy development mode producer - // ...... - - testSpringBoot2Standalone(); - - testHttp2CStandalone(); - - testSpringBoot2Servlet(); - //http2 - testHttp2Standalone(); - - deploys.getEdge().stop(); + + try { + ITJUnitUtils.run(TestIgnoreStaticMethod.class); + ITJUnitUtils.run(TestIgnoreMethod.class); + ITJUnitUtils.run(TestApiParam.class); + ITJUnitUtils.run(TestApiOperation.class); + + testOneProducer(deploys.getBaseProducer(), ConsumerMain::testStandalone); + testOneProducer(deploys.getBaseHttp2Producer(), ConsumerMain::testH2Standalone); + testOneProducer(deploys.getBaseHttp2CProducer(), ConsumerMain::testH2CStandalone); + + testOneProducer(deploys.getSpringBoot2StandaloneProducer(), ConsumerMain::testSpringBoot2Standalone); + testOneProducer(deploys.getSpringBoot2ServletProducer(), ConsumerMain::testSpringBoot2Servlet); + } finally { + deploys.getEdge().stop(); + } } private static void runShareTestCases() throws Throwable { @@ -136,11 +110,23 @@ public class ConsumerMain { ITJUnitUtils.run(TestRestController.class); } - private static void testStandalone() throws Throwable { - deploys.getBaseProducer().ensureReady(); + interface ITTask { + void run() throws Throwable; + } - ITJUnitUtils.addProducer("it-producer"); + private static void testOneProducer(MicroserviceDeploy microserviceDeploy, ITTask task) throws Throwable { + microserviceDeploy.ensureReady(); + ITJUnitUtils.addProducer(microserviceDeploy.getMicroserviceDeployDefinition().getMicroserviceName()); + try { + task.run(); + } finally { + ITJUnitUtils.popProducer(); + microserviceDeploy.stop(); + } + } + + private static void testStandalone() throws Throwable { runShareTestCases(); // currently not support update 3rd url, so only test once @@ -149,66 +135,29 @@ public class ConsumerMain { // about url len, different deploy have different url len, so only test standalone ITJUnitUtils.runWithRest(TestRestServerConfig.class); ITJUnitUtils.run(TestRestServerConfigEdge.class); - - ITJUnitUtils.popProducer(); - deploys.getBaseProducer().stop(); } - private static void testHttp2CStandalone() throws Throwable { - deploys.getBaseHttp2CProducer().ensureReady(); - - ITJUnitUtils.addProducer("it-producer"); - + private static void testH2CStandalone() throws Throwable { 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(); - - ITJUnitUtils.addProducer("it-producer"); - + private static void testH2Standalone() throws Throwable { 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.getBaseHttp2Producer().stop(); } private static void testSpringBoot2Standalone() throws Throwable { - deploys.getSpringBoot2StandaloneProducer().ensureReady(); - - ITJUnitUtils.addProducer("it-producer-deploy-springboot2-standalone"); - runShareTestCases(); - - ITJUnitUtils.popProducer(); - deploys.getSpringBoot2StandaloneProducer().stop(); } private static void testSpringBoot2Servlet() throws Throwable { - deploys.getSpringBoot2ServletProducer().ensureReady(); - - ITJUnitUtils.addProducer("it-producer-deploy-springboot2-servlet"); - runShareTestCases(); - - ITJUnitUtils.popProducer(); - deploys.getSpringBoot2ServletProducer().stop(); } } 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 f71f1c7..0b5a2a2 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 @@ -217,7 +217,7 @@ public class Deploys { }); } definition.setAppId("integration-test"); - definition.setMicroserviceName("it-producer"); + definition.setMicroserviceName("it-producer-h2"); definition.setVersion(DEFAULT_MICROSERVICE_VERSION); initDeployDefinition(definition); @@ -231,7 +231,7 @@ public class Deploys { 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.setMicroserviceName("it-producer-h2c"); definition.setVersion(DEFAULT_MICROSERVICE_VERSION); initDeployDefinition(definition); diff --git a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/deploy/MicroserviceDeploy.java b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/deploy/MicroserviceDeploy.java index 94d1180..e24cfcb 100644 --- a/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/deploy/MicroserviceDeploy.java +++ b/integration-tests/it-consumer/src/main/java/org/apache/servicecomb/it/deploy/MicroserviceDeploy.java @@ -35,6 +35,10 @@ public class MicroserviceDeploy extends NormalDeploy { this.microserviceDeployDefinition.setStartCompleteLog("ServiceComb is ready."); } + public MicroserviceDeployDefinition getMicroserviceDeployDefinition() { + return microserviceDeployDefinition; + } + @Override protected String[] createCmds() { // must set jar at the end of the cmds @@ -45,7 +49,8 @@ public class MicroserviceDeploy extends NormalDeploy { protected String[] addArgs(String[] cmds) { // add jar return ArrayUtils.addAll(super.addArgs(cmds), - "-DselfController=" + RegistryUtils.getMicroserviceInstance().getInstanceId(), + "-DselfController=" + RegistryUtils.getMicroserviceInstance().getInstanceId(), + "-Dservice_description.name=" + microserviceDeployDefinition.getMicroserviceName(), deployDefinition.getCmd()); } @@ -75,18 +80,5 @@ public class MicroserviceDeploy extends NormalDeploy { sendCommand("ms-stop"); waitStop(); - - MicroserviceVersionRule microserviceVersionRule = RegistryUtils.getServiceRegistry().getAppManager() - .getOrCreateMicroserviceVersionRule(microserviceDeployDefinition.getAppId(), - microserviceDeployDefinition.getMicroserviceName(), - microserviceDeployDefinition.getVersion()); - while (microserviceVersionRule.getInstances().size() > 0) { - try { - LOGGER.info("{} not stop finished wait.", microserviceDeployDefinition.getDisplayName()); - Thread.sleep(3000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } } } diff --git a/integration-tests/it-edge/src/main/resources/microservice.yaml b/integration-tests/it-edge/src/main/resources/microservice.yaml index e5c6ea9..476f3e9 100644 --- a/integration-tests/it-edge/src/main/resources/microservice.yaml +++ b/integration-tests/it-edge/src/main/resources/microservice.yaml @@ -25,13 +25,13 @@ servicecomb: default: loadbalance service: it-auth: loadbalance -# this is not the majority, not testing this feature by default -# rest: -# parameter: -# decodeAsObject: true -# query: -# ignoreDefaultValue: true -# emptyAsNull: true + # this is not the majority, not testing this feature by default + # rest: + # parameter: + # decodeAsObject: true + # query: + # ignoreDefaultValue: true + # emptyAsNull: true operation: it-producer: defaultJsonValueJaxrs: @@ -39,6 +39,18 @@ servicecomb: transport: rest queryInput: transport: rest + it-producer-h2: + defaultJsonValueJaxrs: + jsonInput: + transport: rest + queryInput: + transport: rest + it-producer-h2c: + defaultJsonValueJaxrs: + jsonInput: + transport: rest + queryInput: + transport: rest it-producer-deploy-springboot2-servlet: defaultJsonValueJaxrs: jsonInput:
