Java version (#5)

* Create github-actions-demoyml

* this is for action test

* Create github-actions-demo.yml

* Create rocketmqTest.yml

* Update entry.sh

* Update entry.sh

* Update entry.sh

* Update entry.sh

* Update entry.sh

* Update entry.sh

* Delete .github/workflows directory

* Update entry.sh

* Delete rocketmqTest.yml

* Delete testAction.txt

* feat: add java module

* fix: dockerfile

* fix: add wait time

* fix: find bug

* fix: delete timeout

* feat: add test

* fix: add default values

* fix: revise README.md

* fix: add projectName

* fix: revise README.md

* fix: revise README.md

* fix: revise README.md
45 files changed
tree: 63d4667de6584aa861911142213f443d0871e864
  1. src/
  2. .gitignore
  3. action.yml
  4. Dockerfile
  5. LICENSE
  6. NOTICE
  7. pom.xml
  8. README.md
README.md

Apache RocketMQ Test Tool

This tool uses Helm and KubeVela to deploy applications and execute tests in Kubernetes. KubeVela needs to be installed in Kubernetes before use.

Preparation

  • Install kubevela in Kubernetes.
    • An account in vela system.
      • If you have an account, you should set this velauxUsername and velauxPassword in yamlString.
      • If velauxUsername and velauxPassword is not included in yamlString, you should create an account in vela system, password and username should be created by following function, this tool will genarate username and password by ask config:
    /**
      * get velaUX username and password
      *
      * @param kubeConfig ask config
      * @return username:password
      */
    public String getAuthInfoFromConfig(String kubeConfig) {
          String text = kubeConfig.length() > 150 ? kubeConfig.substring(kubeConfig.length() - 150) : kubeConfig;
          StringBuilder userName = new StringBuilder();
          StringBuilder password = new StringBuilder();
          boolean digitMark = false;
          for (int index = text.length() - 1; index >= 0; index--) {
              if (userName.length() >= 6 && password.length() >= 12) {
                  break;
              }
              boolean isLetter = Character.isLetter(text.charAt(index));
              boolean isDigit = Character.isDigit(text.charAt(index));
              if (isDigit || isLetter) {
                  if (isLetter && userName.length() < 6) {
                      userName.append(Character.toLowerCase(text.charAt(index)));
                  }
                  if (password.length() < 12) {
                      if (digitMark && isDigit) {
                          password.append(text.charAt(index));
                          digitMark = false;
                      } else if (!digitMark && isLetter) {
                          password.append(text.charAt(index));
                          digitMark = true;
                      }
                  }
              }
          }
          return userName + ":" + password;
      }

example

you should input a yaml format string. Attention:

  • AskConfig must be encoder by base64.
  • If some of the parameters are not included, set it to null.
  • You can add or delete params in “helm” and “ENV” segment .
deploy

use kubevela API to deploy application.

yamlString: 
  action: deploy
  namespace: rocketmq-457628-0
  askConfig: ***********
  velauxUsername: ***
  velauxPassword: ***
  projectName: wyftest
  waitTimes: 1200
  velaAppDescription: rocketmq-push-ci-123456@abcdefg
  repoName: rocketmq
  helm:
    chart: ./rocketmq-k8s-helm
    git:
      branch: master
    repoType: git
    retries: 3
    url: https://ghproxy.com/https://github.com/apache/rocketmq-docker.git
    values:
      nameserver:
        image:
          repository: wuyfeedocker/rocketm-ci
          tag: develop-3b416669-cab7-41b4-8cc8-4af851944de2-ubuntu
      broker:
        image:
          repository: wuyfeedocker/rocketm-ci
          tag: develop-3b416669-cab7-41b4-8cc8-4af851944de2-ubuntu
      proxy:
        image:
          repository: wuyfeedocker/rocketm-ci
          tag: develop-3b416669-cab7-41b4-8cc8-4af851944de2-ubuntu
optiondescriptiondefaultnecessary
actiondeploynullyes
velauxUsernamevela usernamenullno
velauxPasswordvela passwordnullno
projectNamevela projectwyftestno
namespacepod namespacenullyes
askConfigask confignullyes
waitTimesdeploy max time (second)900no
velaAppDescriptionvela app description""no
repoNamerepo name(such as “nacos”, “rocketmq” .etc)nullyes
helmhelm chartnullyes
test

use kubernetes API to execute test.

yamlString: |
  action: test
  namespace: rocketmq-457628-0
  askConfig: ***********
  API_VERSION: v1
  KIND: Pod
  RESTART_POLICY: Never
  ENV:
    WAIT_TIME: 600 
    REPO_NAME: apache/rocketmq-e2e
    CODE: https://github.com/apache/rocketmq-e2e
    BRANCH: master
    CODE_PATH: java/e2e-v4
    CMD: mvn -B test
    ALL_IP: null
  CONTAINER:
    IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
    RESOURCE_LIMITS:
      cpu: 8
      memory: 8Gi
    RESOURCE_REQUIRE:
      cpu: 8
      memory: 8Gi
optiondescriptiondefaultnecessary
actiontestnullyes
namespacepod namespacenullyes
askConfigask confignullyes
API_VERSIONKubernetes API versionv1no
KINDpod kindPodno
RESTART_POLICYpod restart policyNeverno
ENV.WAIT_TIMEtest pod expiration time (second)900no
ENV.REPO_NAMErepository whole namenullyes
ENV.CODEtest code urlnullyes
ENV.BRANCHcode branchnullyes
ENV.CODE_PATHtest code pathnullyes
ENV.CMDtest commandnullyes
ENV.ALL_IPcluster ipsnullno
CONTAINER.IMAGEpod container imagenullyes
CONTAINER.RESOURCE_LIMITS.cpupod container cpu limitnullno
CONTAINER.RESOURCE_LIMITS.memorypod container memory limitnullno
CONTAINER.RESOURCE_REQUIRE.cpupod container cpu requirenullno
CONTAINER.RESOURCE_REQUIRE.memorypod container memory requirenullno
clean

use kubernetes API and kubevela API to clean resource.

yamlString: |
  action: clean
  namespace: rocketmq-457628-0
  velauxUsername: ***
  velauxPassword: ***
  askConfig: ***********
optiondescriptiondefaultnecessary
actioncleannullyes
velauxUsernamevela usernamenullno
velauxPasswordvela passwordnullno
namespacepod namespacenullyes
askConfigask confignullyes

Usage

start project

by java jar

cd test-tools
mvn clean install -Dmaven.test.skip=true
mv /target/rocketmq-test-tool-*-SNAPSHOT-jar-*.jar ./rocketmq-test-tool.jar
# quick start run
jar -jar rocketmq-test-tool.jar -yamlString=${your yamlString}

by docker images

# build docker images
docker build -t test-tool
# quick start run
docker run -it test-tool -yamlString=${your yamlString}

in github action

deploy

- uses: apache/rocketmq-test-tool@java-dev
  name: Deploy nacos
  with:
    yamlString: |
      action: deploy
      namespace: nacos-123456789-0
      askConfig: ******
      waitTimes: 2000
      velaAppDescription: nacos-push-ci-123@$abcdefg
      repoName: nacos
      helm:
        chart: ./cicd/helm
        git:
          branch: main
        repoType: git
        retries: 3
        url: https://ghproxy.com/https://github.com/nacos-group/nacos-e2e.git
        values:
          namespace: nacos-123456789-0
          global:
            mode: cluster
          nacos:
            replicaCount: 3
            image:
              repository: wuyfeedocker/nacos-ci
              tag: develop-cee62800-0cb5-478f-9e42-aeb1124db716-8
            storage:
              type: mysql
              db:
                port: 3306
                username: nacos
                password: nacos
                param: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
          service:
            nodePort: 30000
            type: ClusterIP

test

steps:
  - uses: apache/rocketmq-test-tool@java-dev
    name: java e2e test
    with:
      yamlString: |
        action: test
        namespace: nacos-123456789-0
        askConfig: ******
        API_VERSION: v1
        KIND: Pod
        RESTART_POLICY: Never
        ENV:
          WAIT_TIME: 900
          REPO_NAME: nacos-group/nacos-e2e
          CODE: https://github.com/nacos-group/nacos-e2e
          BRANCH: main
          CODE_PATH: java/nacos-2X
          CMD: mvn clean test -B
          ALL_IP: null
        CONTAINER:
          IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
          RESOURCE_LIMITS:
            cpu: 8
            memory: 8Gi
          RESOURCE_REQUIRE:
            cpu: 8
            memory: 8Gi

clean

steps:
  - uses: apache/rocketmq-test-tool@java-dev
    name: clean
    with:
      yamlString: |
        action: clean
        namespace: nacos-123456789-0
        askConfig: ******

License

Apache License, Version 2.0 Copyright (C) Apache Software Foundation