Skip to content

Commit

Permalink
refactor(unit-test): cherry-pick unit-test commits from 4.2.x to 4.2.2 (
Browse files Browse the repository at this point in the history
#474)

* feat(unit-test): use cloud database as test cluster and adapt for github action (#411)

* add: unit test

* adapt: unit test

* add: workflow config

* fix: error ut

* fix: action config

* fix: ut and action config

* refine: workflow config

* fix: workflow config

* fix: workflow config

* fix: workflow config

* response to CR

* fix: low case env

* fix: low case env

* fix

* format

* refactor: ut

* check time zone

* check time zone

* fix: workflow config

* refactor: ut

* fix: error testcase

* fix

* fix

* fix

* refactor(unit-test): use blowfish encryption algorithm to replace aes (#443)

* refactor: use blowfish replace aes256

* fix ut

* fix
  • Loading branch information
smallsheeeep authored Oct 11, 2023
1 parent 882cee0 commit f82febe
Show file tree
Hide file tree
Showing 52 changed files with 689 additions and 577 deletions.
41 changes: 4 additions & 37 deletions .github/workflows/build_daily.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
# Jobs:
# 1. Check Code Format
# 2. PMD Scan
# 3. Unit Test (TODO)
# 4. Calculate Version Number
# 5. Build Web Artifact (include front resource and only x86_64 platform for now)
# 6. Build Client Artifact
# 3. Calculate Version Number
# 4. Build Web Artifact (include front resource and only x86_64 platform for now)
# 5. Build Client Artifact
###

name: Build Daily
Expand Down Expand Up @@ -85,41 +84,9 @@ jobs:
- name: Run PMD scan
run: mvn pmd:check

unit-test:
name: Unit Test (Skip for now)
needs: [ check-format, pmd-scan ]
runs-on: ubuntu-latest
steps:
- name: Checkout workspace
uses: actions/checkout@v3
- name: Setup JDK 8
uses: actions/setup-java@v3
with:
java-version: "8"
distribution: "temurin"
cache: maven
- name: Install db-browser
run: |
echo "Start install db-browser"
pushd libs/db-browser
echo "Current dir is "`pwd`
mvn clean install -Dmaven.test.skip=true
echo "Install db-browser success"
popd
- name: Install ob-sql-parser
run: |
echo "Start install ob-sql-parser"
pushd libs/ob-sql-parser
echo "Current dir is "`pwd`
mvn clean install -Dmaven.test.skip=true
echo "Install ob-sql-parser success"
popd
- name: Run unit test
run: echo "Skip for now 🤪"

calculate-version:
name: Calculate Version Number
needs: [ unit-test ]
needs: [ check-format, pmd-scan ]
runs-on: ubuntu-latest
outputs:
odc_rpm_release_number: ${{ steps.calculate_version.outputs.odc_rpm_release_number }}
Expand Down
105 changes: 98 additions & 7 deletions .github/workflows/build_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
# Jobs:
# 1. Check Code Format
# 2. PMD Scan
# 3. Unit Test (TODO)
# 3. Unit Test
# 4. Calculate Version Number
# 5. Build RPM (exclude front resources and only x86_64 platform for now)
# (Job 4 and 5 are executed only when Pull-Request)
# (Job 3 to 5 are executed only when Pull-Request)
###

name: Build Dev
Expand Down Expand Up @@ -74,10 +74,20 @@ jobs:
- name: Run PMD scan
run: mvn pmd:check

unit-test:
name: Unit Test (Skip for now)
needs: [ check-format, pmd-scan ]
unit-test-odc:
name: Unit Test (ODC)
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ut-group:
- group_1
- group_2
- group_3
- group_4
- group_5
- group_6
steps:
- name: Checkout workspace
uses: actions/checkout@v3
Expand All @@ -103,12 +113,93 @@ jobs:
mvn clean install -Dmaven.test.skip=true
echo "Install ob-sql-parser success"
popd
- name: Build project
run: mvn clean install -Dmaven.test.skip=true
- name: Run unit test
run: echo "Skip for now 🤪"
id: unit_test
run: |
export ODC_CONFIG_SECRET=${{ secrets.ODC_UT_SECRET }}
export ODC_OB_DEFAULT_MYSQL_COMMANDLINE=${{ secrets.ODC_OB_DEFAULT_MYSQL_COMMANDLINE }}
export ODC_OB_DEFAULT_ORACLE_COMMANDLINE=${{ secrets.ODC_OB_DEFAULT_ORACLE_COMMANDLINE }}
export ODC_MYSQL_DEFAULT_COMMANDLINE=${{ secrets.ODC_MYSQL_DEFAULT_COMMANDLINE }}
echo "Current dir is "`pwd`
ut_log_file="unit_test_${{ matrix.ut-group }}.log"
echo "ut_log_file=${ut_log_file}" >> $GITHUB_OUTPUT
rm -rf ${ut_log_file} && touch ${ut_log_file}
if [ ${{ matrix.ut-group }} = "group_1" ]; then ut_args='-Dtest="com.oceanbase.odc.core.**","com.oceanbase.odc.common.**"'; fi
if [ ${{ matrix.ut-group }} = "group_2" ]; then ut_args='-Dtest="%regex[^com.oceanbase.odc.service.[acegik]+.*$]"'; fi
if [ ${{ matrix.ut-group }} = "group_3" ]; then ut_args='-Dtest="%regex[^com.oceanbase.odc.service.[moqsuwy]+.*$]"'; fi
if [ ${{ matrix.ut-group }} = "group_4" ]; then ut_args='-Dtest="%regex[^com.oceanbase.odc.service.[bdfhjl]+.*$]"'; fi
if [ ${{ matrix.ut-group }} = "group_5" ]; then ut_args='-Dtest="%regex[^com.oceanbase.odc.service.[nprtvxz]+.*$]"'; fi
if [ ${{ matrix.ut-group }} = "group_6" ]; then ut_args='-Dtest="!com.oceanbase.odc.core.**","!com.oceanbase.odc.common.**","!com.oceanbase.odc.service.**"'; fi
mvn_test_cmd="mvn test -Dmaven.test.failure.ignore=true -DfailIfNoTests=false ${ut_args} > ${ut_log_file}"
echo "Execute unit test command: ${mvn_test_cmd}"
eval $mvn_test_cmd
- name: Upload unit test log
uses: actions/upload-artifact@v3
with:
name: ${{ steps.unit_test.outputs.ut_log_file }}
path: ${{ steps.unit_test.outputs.ut_log_file }}
- name: Check unit test result
run: |
if grep -q "There are test failures" ${{ steps.unit_test.outputs.ut_log_file }}; then echo "Unit test failed, please check ${{ steps.unit_test.outputs.ut_log_file }} for details"; exist 1; fi
unit-test-libs:
name: Unit Test (LIBS)
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
lib:
- db-browser
- ob-sql-parser
steps:
- name: Checkout workspace
uses: actions/checkout@v3
- name: Setup JDK 8
uses: actions/setup-java@v3
with:
java-version: "8"
distribution: "temurin"
cache: maven
- name: Build project
run: |
echo "Start install ${{ matrix.lib }}"
pushd libs/${{ matrix.lib }}
echo "Current dir is "`pwd`
mvn clean install -Dmaven.test.skip=true
echo "Install ${{ matrix.lib }} success"
- name: Run unit test
id: unit_test
run: |
export ODC_CONFIG_SECRET=${{ secrets.ODC_UT_SECRET }}
export ODC_OB_DEFAULT_MYSQL_COMMANDLINE=${{ secrets.ODC_OB_DEFAULT_MYSQL_COMMANDLINE }}
export ODC_OB_DEFAULT_ORACLE_COMMANDLINE=${{ secrets.ODC_OB_DEFAULT_ORACLE_COMMANDLINE }}
export ODC_MYSQL_DEFAULT_COMMANDLINE=${{ secrets.ODC_MYSQL_DEFAULT_COMMANDLINE }}
echo "Start test ${{ matrix.lib }}"
pushd libs/${{ matrix.lib }}
echo "Current dir is "`pwd`
ut_log_file="unit_test_${{ matrix.lib }}.log"
echo "ut_log_file=${ut_log_file}" >> $GITHUB_OUTPUT
rm -rf ${ut_log_file} && touch ${ut_log_file}
mvn_test_cmd="mvn test -Dmaven.test.failure.ignore=true -DfailIfNoTests=false > ${ut_log_file}"
echo "Execute unit test command: ${mvn_test_cmd}"
eval $mvn_test_cmd
- name: Upload unit test log
uses: actions/upload-artifact@v3
with:
name: ${{ steps.unit_test.outputs.ut_log_file }}
path: libs/${{ matrix.lib }}/${{ steps.unit_test.outputs.ut_log_file }}
- name: Check unit test result
run: |
pushd libs/${{ matrix.lib }}
echo "Current dir is "`pwd`
if grep -q "There are test failures" ${{ steps.unit_test.outputs.ut_log_file }}; then echo "Unit test failed, please check ${{ steps.unit_test.outputs.ut_log_file }} for details"; exist 1; fi
calculate-version:
name: Calculate Version Number
needs: [ unit-test ]
needs: [ check-format, pmd-scan, unit-test-odc, unit-test-libs ]
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
outputs:
Expand Down
29 changes: 6 additions & 23 deletions .github/workflows/build_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
# Jobs:
# 1. Check Code Format
# 2. PMD Scan
# 3. Unit Test (TODO)
# 4. Calculate Version Number
# 5. Build Web Artifact (include front resource and only x86_64 platform for now)
# 6. Build Client Artifact
# 7. Release (TODO)
# 8. Tag (TODO)
# 3. Calculate Version Number
# 4. Build Web Artifact (include front resource and only x86_64 platform for now)
# 5. Build Client Artifact
# 6. Release (TODO)
# 7. Tag (TODO)
###

name: Build Release
Expand Down Expand Up @@ -69,25 +68,9 @@ jobs:
- name: Run PMD scan
run: mvn pmd:check

unit-test:
name: Unit Test (Skip for now)
needs: [ check-format, pmd-scan ]
runs-on: ubuntu-latest
steps:
- name: Checkout workspace
uses: actions/checkout@v3
- name: Setup JDK 8
uses: actions/setup-java@v3
with:
java-version: "8"
distribution: "temurin"
cache: maven
- name: Run unit test
run: echo "Skip for now 🤪"

calculate-version:
name: Calculate Version Number
needs: [ unit-test ]
needs: [ check-format, pmd-scan ]
runs-on: ubuntu-latest
outputs:
odc_rpm_release_number: ${{ steps.calculate_version.outputs.odc_rpm_release_number }}
Expand Down
Loading

0 comments on commit f82febe

Please sign in to comment.