Skip to content

Commit

Permalink
Unify CI script for unit test grouping (apache#8856)
Browse files Browse the repository at this point in the history
* Current unit test group for ci is scattered and error prone.
* This PR unifies all group declarations in single file for easier use and simpler management.
  • Loading branch information
aahmed-se authored Dec 9, 2020
1 parent 858109d commit a8a7993
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 76 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/ci-unit-broker-broker-gp1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,9 @@ jobs:
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp -q clean install -Pcore-modules -DskipTests

- name: run flaky test '**/AdminApiOffloadTest.java'
- name: run unit test 'BROKER_GROUP_1'
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp test -pl pulsar-broker -Dinclude='**/AdminApiOffloadTest.java' -DtestForkCount=1 -DtestReuseFork=true

- name: run unit tests for pulsar-broker
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp test -pl pulsar-broker -Dinclude='org/apache/pulsar/broker/**/*.java' -Dexclude='org/apache/pulsar/broker/zookeeper/**/*.java,org/apache/pulsar/broker/loadbalance/**/*.java,org/apache/pulsar/broker/service/**/*.java,**/AdminApiOffloadTest.java'
run: ./build/run_unit_group.sh BROKER_GROUP_1

- name: package surefire artifacts
if: failure()
Expand Down
20 changes: 2 additions & 18 deletions .github/workflows/ci-unit-broker-broker-gp2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,9 @@ jobs:
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp -q clean install -Pcore-modules -DskipTests

- name: run flaky test
- name: run unit test 'BROKER_GROUP_2'
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp test -pl pulsar-broker -Dinclude='**/MessagePublishBufferThrottleTest.java' -DtestForkCount=1 -DtestReuseFork=true

- name: run flaky test
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp test -pl pulsar-broker -Dinclude='**/ReplicatorTest.java' -DtestForkCount=1 -DtestReuseFork=true

- name: run flaky test
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp test -pl pulsar-broker -Dinclude='**/TopicOwnerTest.java' -DtestForkCount=1 -DtestReuseFork=true

- name: run flaky test
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp test -pl pulsar-broker -Dinclude='**/AntiAffinityNamespaceGroupTest.java' -DtestForkCount=1 -DtestReuseFork=true

- name: run unit tests for pulsar-broker "org/apache/pulsar/broker/"
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn ${MAVEN_CLI_OPTS} test -pl pulsar-broker -Dinclude='org/apache/pulsar/broker/zookeeper/**/*.java,org/apache/pulsar/broker/loadbalance/**/*.java,org/apache/pulsar/broker/service/**/*.java' -Dexclude='**/ReplicatorTest.java,**/MessagePublishBufferThrottleTest.java,**/TopicOwnerTest.java,**/AntiAffinityNamespaceGroupTest.java'
run: ./build/run_unit_group.sh BROKER_GROUP_2

- name: package surefire artifacts
if: failure()
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/ci-unit-broker-client-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,9 @@ jobs:
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp -q install -Pcore-modules -DskipTests

- name: run flaky test '**/DispatcherBlockConsumerTest.java'
- name: run unit test 'BROKER_CLIENT_API'
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp test -pl pulsar-broker -Dinclude='**/DispatcherBlockConsumerTest.java' -DtestForkCount=1 -DtestReuseFork=true

- name: run flaky test '**/SimpleProducerConsumerTest.java'
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp test -pl pulsar-broker -Dinclude='**/SimpleProducerConsumerTest.java' -DtestForkCount=1 -DtestReuseFork=true

- name: run unit tests for pulsar-broker "org/apache/pulsar/client/impl"
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp test -pl pulsar-broker -Dinclude='org/apache/pulsar/client/api/**/*.java' -Dexclude='**/DispatcherBlockConsumerTest.java,**/SimpleProducerConsumerTest.java'
run: ./build/run_unit_group.sh BROKER_CLIENT_API

- name: package surefire artifacts
if: failure()
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-unit-broker-client-impl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ jobs:
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp -q install -Pcore-modules -DskipTests

- name: run unit tests for pulsar-broker "org/apache/pulsar/client/impl"
- name: run unit test 'BROKER_CLIENT_IMPL'
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp test -pl pulsar-broker -Dinclude='org/apache/pulsar/client/impl/**/*.java'
run: ./build/run_unit_group.sh BROKER_CLIENT_IMPL

- name: package surefire artifacts
if: failure()
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-unit-broker-other.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ jobs:
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp -q clean install -Pcore-modules -DskipTests

- name: run unit tests for pulsar-broker exlcude "org/apache/pulsar/broker", "org/apache/pulsar/client"
- name: run unit test 'BROKER_CLIENT_OTHER'
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp test -pl pulsar-broker -Dexclude='org/apache/pulsar/broker/**/*.java,org/apache/pulsar/client/**/*.java'
run: ./build/run_unit_group.sh BROKER_CLIENT_OTHER

- name: package surefire artifacts
if: failure()
Expand Down
20 changes: 2 additions & 18 deletions .github/workflows/ci-unit-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,9 @@ jobs:
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp -q install -Pcore-modules -DskipTests

- name: run flaky test
- name: run unit test 'PROXY'
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp install -pl pulsar-proxy -DtestForkCount=1 -DtestReuseFork=true -Dexclude="**/ProxyRolesEnforcementTest.java,**/ProxyAuthenticationTest.java,**/ProxyTest.java,**/MessagePublishBufferThrottleTest.java"

- name: run flaky test "**/ProxyRolesEnforcementTest.java"
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp test -pl pulsar-proxy -DtestForkCount=1 -DtestReuseFork=true -Dinclude="**/ProxyRolesEnforcementTest.java" -DtestForkCount=1 -DtestReuseFork=true

- name: run flaky test "**/ProxyAuthenticationTest.java"
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp test -pl pulsar-proxy -DtestForkCount=1 -DtestReuseFork=true -Dinclude="**/ProxyAuthenticationTest.java" -DtestForkCount=1 -DtestReuseFork=true

- name: run flaky test "**/ProxyTest.java"
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp test -pl pulsar-proxy -DtestForkCount=1 -DtestReuseFork=true -Dinclude="**/ProxyTest.java" -DtestForkCount=1 -DtestReuseFork=true

- name: run flaky test "**/MessagePublishBufferThrottleTest.java"
if: steps.docs.outputs.changed_only == 'no'
run: mvn -B -ntp test -pl pulsar-proxy -DtestForkCount=1 -DtestReuseFork=true -Dinclude="**/MessagePublishBufferThrottleTest.java" -DtestForkCount=1 -DtestReuseFork=true
run: ./build/run_unit_group.sh PROXY

- name: package surefire artifacts
if: failure()
Expand Down
20 changes: 2 additions & 18 deletions .github/workflows/ci-unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,9 @@ jobs:
with:
args: site2 deployment .asf.yaml .ci ct.yaml

- name: build and run unit tests exclude pulsar-broker and pulsar-proxy
- name: run unit test 'OTHER'
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp install -PbrokerSkipTest -Dexclude="org/apache/pulsar/proxy/**/*.java,**/KafkaProducerSimpleConsumerTest.java,**/ManagedLedgerTest.java,**/TestPulsarKeyValueSchemaHandler.java,**/PrimitiveSchemaTest.java,**/BlobStoreManagedLedgerOffloaderTest.java"

- name: run flaky test "**/ManagedLedgerTest.java"
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp test -pl managed-ledger -Dinclude="**/ManagedLedgerTest.java" -DtestForkCount=1 -DtestReuseFork=true

- name: run flaky test "**/TestPulsarKeyValueSchemaHandler.java"
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp test -pl pulsar-sql/presto-pulsar-plugin -Dinclude="**/TestPulsarKeyValueSchemaHandler.java" -DtestForkCount=1 -DtestReuseFork=true

- name: run flaky test "**/PrimitiveSchemaTest.java"
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp test -pl pulsar-client -Dinclude="**/PrimitiveSchemaTest.java" -DtestForkCount=1 -DtestReuseFork=true

- name: run flaky test "**/BlobStoreManagedLedgerOffloaderTest.java"
if: steps.docs.outputs.changed_only == 'no'
run: ./build/retry.sh mvn -B -ntp test -pl tiered-storage/jcloud -Dinclude="**/BlobStoreManagedLedgerOffloaderTest.java" -DtestForkCount=1 -DtestReuseFork=true
run: ./build/run_unit_group.sh OTHER

- name: package surefire artifacts
if: failure()
Expand Down
4 changes: 2 additions & 2 deletions build/retry.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
Expand Down Expand Up @@ -40,4 +40,4 @@ function retry {
done
}

retry $@
retry "$@"
190 changes: 190 additions & 0 deletions build/run_unit_group.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
#!/usr/bin/env bash
#
# 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.
#

set -e
set -x
set -o pipefail
set -o errexit

MVN_TEST_COMMAND='build/retry.sh mvn -B -ntp test'

# Test Groups -- start --
function broker_group_1() {
$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="**/AdminApiOffloadTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="org/apache/pulsar/broker/**/*.java" \
-Dexclude="org/apache/pulsar/broker/zookeeper/**/*.java,
org/apache/pulsar/broker/loadbalance/**/*.java,
org/apache/pulsar/broker/service/**/*.java,
**/AdminApiOffloadTest.java"

}

function broker_group_2() {
$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="**/MessagePublishBufferThrottleTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="**/ReplicatorTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="**/TopicOwnerTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="**/AntiAffinityNamespaceGroupTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="org/apache/pulsar/broker/zookeeper/**/*.java,
org/apache/pulsar/broker/loadbalance/**/*.java,
org/apache/pulsar/broker/service/**/*.java" \
-Dexclude="**/ReplicatorTest.java,
**/MessagePublishBufferThrottleTest.java,
**/TopicOwnerTest.java,
**/AntiAffinityNamespaceGroupTest.java"
}

function broker_client_api() {
$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="**/DispatcherBlockConsumerTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="**/SimpleProducerConsumerTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="org/apache/pulsar/client/api/**/*.java" \
-Dexclude="**/DispatcherBlockConsumerTest.java,
**/SimpleProducerConsumerTest.java"
}

function broker_client_impl() {
$MVN_TEST_COMMAND -pl pulsar-broker -Dinclude="org/apache/pulsar/client/impl/**/*.java"
}

function broker_client_other() {
$MVN_TEST_COMMAND -pl pulsar-broker -Dexclude="org/apache/pulsar/broker/**/*.java,
org/apache/pulsar/client/**/*.java"
}

function proxy() {
$MVN_TEST_COMMAND -pl pulsar-proxy -DtestForkCount=1 \
-DtestReuseFork=true \
-Dinclude="**/ProxyRolesEnforcementTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-proxy -DtestForkCount=1 \
-DtestReuseFork=true \
-Dinclude="**/ProxyAuthenticationTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-proxy -DtestForkCount=1 \
-DtestReuseFork=true \
-Dinclude="**/ProxyTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-proxy -DtestForkCount=1 \
-DtestReuseFork=true \
-Dinclude="**/MessagePublishBufferThrottleTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-proxy -DtestForkCount=1 \
-Dexclude="**/ProxyRolesEnforcementTest.java,
**/ProxyAuthenticationTest.java,
**/ProxyTest.java,
**/MessagePublishBufferThrottleTest.java" \
-DtestReuseFork=true
}

function other() {
build/retry.sh mvn -B -ntp install -PbrokerSkipTest \
-Dexclude="org/apache/pulsar/proxy/**/*.java,
**/ManagedLedgerTest.java,
**/TestPulsarKeyValueSchemaHandler.java,
**/PrimitiveSchemaTest.java,
BlobStoreManagedLedgerOffloaderTest.java"

$MVN_TEST_COMMAND -pl managed-ledger -Dinclude="**/ManagedLedgerTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-sql/presto-pulsar-plugin -Dinclude="**/TestPulsarKeyValueSchemaHandler.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl pulsar-client -Dinclude="**/PrimitiveSchemaTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true

$MVN_TEST_COMMAND -pl tiered-storage/jcloud -Dinclude="**/BlobStoreManagedLedgerOffloaderTest.java" \
-DtestForkCount=1 \
-DtestReuseFork=true
}

# Test Groups -- end --

TEST_GROUP=$1

echo -n "Test Group : $TEST_GROUP"

case $TEST_GROUP in

BROKER_GROUP_1)
broker_group_1
;;

BROKER_GROUP_2)
broker_group_2
;;

BROKER_CLIENT_API)
broker_client_api
;;

BROKER_CLIENT_IMPL)
broker_client_impl
;;

BROKER_CLIENT_OTHER)
broker_client_other
;;

PROXY)
proxy
;;

OTHER)
other
;;

*)
echo -n "INVALID TEST GROUP"
exit 1
;;
esac

0 comments on commit a8a7993

Please sign in to comment.