fix consumer metadata checking (#217)

1 file changed
tree: 29d202479ffa0c7d7be75c044ef5f15e6e6fd4af
  1. .github/
  2. .mvn/
  3. codestyle/
  4. dubbo-maven-address-plugin/
  5. dubbo-samples-annotation/
  6. dubbo-samples-api/
  7. dubbo-samples-async/
  8. dubbo-samples-attachment/
  9. dubbo-samples-basic/
  10. dubbo-samples-cache/
  11. dubbo-samples-callback/
  12. dubbo-samples-chain/
  13. dubbo-samples-cloud-native/
  14. dubbo-samples-compatible/
  15. dubbo-samples-configcenter/
  16. dubbo-samples-consul/
  17. dubbo-samples-context/
  18. dubbo-samples-default-config/
  19. dubbo-samples-direct/
  20. dubbo-samples-docker/
  21. dubbo-samples-echo/
  22. dubbo-samples-edas/
  23. dubbo-samples-environment-keys/
  24. dubbo-samples-gateway/
  25. dubbo-samples-generic/
  26. dubbo-samples-governance/
  27. dubbo-samples-group/
  28. dubbo-samples-grpc/
  29. dubbo-samples-http/
  30. dubbo-samples-jetty/
  31. dubbo-samples-local/
  32. dubbo-samples-merge/
  33. dubbo-samples-metadata-report/
  34. dubbo-samples-metrics/
  35. dubbo-samples-mock/
  36. dubbo-samples-monitor/
  37. dubbo-samples-multi-registry/
  38. dubbo-samples-nacos/
  39. dubbo-samples-notify/
  40. dubbo-samples-perf/
  41. dubbo-samples-protobuf/
  42. dubbo-samples-protobuf-json/
  43. dubbo-samples-protostuff/
  44. dubbo-samples-resilience4j/
  45. dubbo-samples-rest/
  46. dubbo-samples-scala/
  47. dubbo-samples-sentinel/
  48. dubbo-samples-serialization/
  49. dubbo-samples-simplified-registry/
  50. dubbo-samples-spi-compatible/
  51. dubbo-samples-spring-boot-hystrix/
  52. dubbo-samples-spring-hystrix/
  53. dubbo-samples-ssl/
  54. dubbo-samples-stub/
  55. dubbo-samples-switch-serialization-thread/
  56. dubbo-samples-tengine/
  57. dubbo-samples-thrift/
  58. dubbo-samples-transaction/
  59. dubbo-samples-validation/
  60. dubbo-samples-version/
  61. dubbo-samples-webservice/
  62. dubbo-samples-zipkin/
  63. dubbo-samples-zookeeper/
  64. test/
  65. .gitignore
  66. LICENSE
  67. mvnw
  68. mvnw.cmd
  69. pom.xml
  70. README.md
README.md

Dubbo Samples

Samples for Apache Dubbo

Build Status license

This repository contains a number of projects to illustrate various usages of Dubbo from basic to advanced, pls. check README in each individual sub projects. It is also helpful to cross reference to Dubbo User Manual to understand the features demoed in this project.

What's more, dubbo-go samples are moved to dubbo-go-samples.

Build and Run Samples

To compile all samples, run the following command in the top directory of this project, or step into the sub directories to compile one single sample:

mvn clean package

You may need to read each individual README under the sub directories if you have to understand how to build and run.

Integration Test

This project is also used for integration tests for dubbo.

How to build and run a integration test

Dubbo integration test base on docker container, and relies on an image used to run the provider application and test cases.

Integration test leverages docker to setup test environment, more accurately, to start dubbo provider instance, and any other supporting systems like registry center if necessary, in docker.

Please install docker and docker-compose first, then build the test image dubb/sample-test.

cd dubbo-samples/test
./build-test-image.sh

Use a debian mirror through env DEBIAN_MIRROR if apt download files slowly, the following example uses aliyun mirror server http://mirrors.aliyun.com/ubuntu/ :

cd dubbo-samples/test
DEBIAN_MIRROR=http://mirrors.aliyun.com ./build-test-image.sh

Then we use the run-tests.sh script to run the test cases.

  • Run single test case

    cd dubbo-samples/test
    ./run-tests.sh <project.basedir>
    

    For example, run the dubbo-samples-annotation test case:

    ./run-tests.sh ../dubbo-samples-annotation
    
  • Run all test cases

    cd dubbo-samples/test
    BUILD=all ./run-tests.sh 
    

If docker container fails to startup successfully in any case, you can check log files in directory ${project.basedir}/target/logs to understand what happens.

Pls. note integration tests rely on a Docker environment, make sure the docker environment is available before running them.

How to add more integration test

If you are interested in contributing more integration test for dubbo, pls. read further to understand how to enable integration test for one particular sample from the scratch.

Please follow the steps below:

  1. Add a file named case-configuration.yml to integration test project.

  2. Configure test environment:

Take the case dubbo-samples-annotation as an example:

services:
  dubbo-samples-annotation:
    type: app
    basedir: .
    mainClass: org.apache.dubbo.samples.annotation.AnnotationProviderBootstrap

  dubbo-samples-annotation-test:
    type: test
    basedir: .
    tests:
      - "**/*IT.class"
    systemProps:
      - zookeeper.address=dubbo-samples-annotation
      - zookeeper.port=2181
      - dubbo.address=dubbo-samples-annotation
      - dubbo.port=20880
    waitPortsBeforeRun:
      - dubbo-samples-annotation:2181
      - dubbo-samples-annotation:20880
    depends_on:
      - dubbo-samples-annotation

The project contains a dubbo provider AnnotationProviderBootstrap and an embedded zookeeper server, as well as a test class AnnotationServicesIT.

Therefore, we have to define two services, one service runs AnnotationProviderBootstrap, and the other service runs test classes.

The service type of running dubbo provider is app, and the service type of running test is test.

The project directory is the same as the case configuration directory, so basedir is . .

Use hostname to access between containers, the default hostname of the container is the same as serviceName.

So through dubbo-samples-annotation:2181, the embedded zookeeper server can be accessed from the test container.

There are many test cases similar to this example, only need to modify the mainClass and hostname. Extract the changed as variables, and the unchanged content as templates. When using the template, you only need to modify the variable value, which makes the case configuration easier.

The above example can use a template app-builtin-zookeeper.yml, use from to reference it and override the variable value in props:

from: app-builtin-zookeeper.yml

props:
  project_name: dubbo-samples-annotation
  main_class: org.apache.dubbo.samples.annotation.AnnotationProviderBootstrap
  zookeeper_port: 2181
  dubbo_port: 20880

Another template is app-external-zookeeper.yml, which supports an external zookeeper service. you can find all the templates in the directory test/dubbo-scenario-builder/src/main/resources/configs.

For more details, please refer to the following case configurations:

That's it, then feel free to add more integration test for the Dubbo project, have fun.