Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ci #2812

Merged
merged 3 commits into from
Oct 18, 2023
Merged

Fix ci #2812

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Clang Formatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
# fetch everything to be able to compare with any ref
fetch-depth: 0
Expand Down
83 changes: 83 additions & 0 deletions scripts/ci/check_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash

### Check coverage from coverage reports

set -e

if [ ! -d coverage ]; then
echo "coverage report not found"
exit -1
fi

check_repo_line_coverage() {
expected_coverage=$1
actual_coverage=$(cat coverage/index.html | grep -A5 "Lines" | grep % | awk -F'>' '{ print $2 }' | awk '{ print $1 }')

if (($(echo "$actual_coverage >= $expected_coverage" | bc -l))); then
echo "repo line coverage ratio: $actual_coverage"
else
echo "repo line coverage isn't ok, actual coverage ratio: $actual_coverage, expected coverage ratio: $expected_coverage"
exit -1
fi
}

check_repo_branch_coverage() {
expected_coverage=$1
actual_coverage=$(cat coverage/index.html | grep -A5 "Branches" | grep % | awk -F'>' '{ print $2 }' | awk '{ print $1 }' | grep -v tr)

if (($(echo "$actual_coverage >= $expected_coverage" | bc -l))); then
echo "repo branch coverage ratio: $actual_coverage"
else
echo "repo branch coverage isn'tvim ok, actual coverage ratio: $actual_coverage, expected coverage ratio: $expected_coverage"
exit -1
fi
}

check_module_branch_coverage() {
base_dir=$1
expected_coverage=$2

find coverage/$base_dir -name index.html | xargs cat | grep -A5 "Branches" | grep % | awk -F'>' '{ print $2 }' | awk '{ print $1 }' | grep -v tr >dummy.all
if [ -s dummy.all ]; then
actual_coverage=$(cat dummy.all | awk '{ sum+= $1 } END { print sum/NR }')
rm dummy.all || true
else
actual_coverage=0
fi

if (($(echo "$actual_coverage >= $expected_coverage" | bc -l))); then
echo "$base_dir branch coverage ratio: ${actual_coverage}"
else
echo "$base_dir branch coverage is not ok, actual branch coverage ratio: ${actual_coverage}, expected branch coverage ratio: ${expected_coverage}"
exit -1
fi
}
if [ $1 == "curvebs" ];then

check_repo_branch_coverage 59
check_repo_line_coverage 73

## two arguments are module and expected branch coverage ratio
check_module_branch_coverage "src/mds" 70
check_module_branch_coverage "src/client" 78
check_module_branch_coverage "src/chunkserver" 65
check_module_branch_coverage "src/snapshotcloneserver" 65
check_module_branch_coverage "src/common" 65
check_module_branch_coverage "src/fs" 65
check_module_branch_coverage "src/idgenerator" 79
check_module_branch_coverage "src/kvstorageclient" 70
check_module_branch_coverage "src/leader_election" 100
check_module_branch_coverage "nebd" 75

elif [ $1 == "curvefs" ];then

check_module_branch_coverage "mds" 59
check_module_branch_coverage "client" 59
check_module_branch_coverage "metaserver" 65
check_module_branch_coverage "common" 16
check_module_branch_coverage "tools" 0
fi

echo "Checking repo coverage succeeded!"

exit 0
8 changes: 3 additions & 5 deletions src/tools/status_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,12 +926,12 @@ int StatusTool::PrintChunkserverStatus(bool checkLeftSize) {
int ret = 0;
if (res != 0) {
std::cout << "GetAndCheckChunkserverVersion fail" << std::endl;
return -1;
ret = -1;
} else {
std::cout << "version: " << version << std::endl;
if (!failedList.empty()) {
versionTool_->PrintFailedList(failedList);
return -1;
ret = -1;
}
}
// list chunkservers in cluster group by poolid
Expand All @@ -955,9 +955,7 @@ int StatusTool::PrintChunkserverStatus(bool checkLeftSize) {
// check use walpool
ret = CheckUseWalPool(poolChunkservers, &useWalPool,
&useChunkFilePoolAsWalPool, metricClient_);
if (0 != ret) {
return ret;
}

// get chunkserver left size
std::map<PoolIdType, std::vector<uint64_t>> poolChunkLeftSize;
std::map<PoolIdType, std::vector<uint64_t>> poolWalSegmentLeftSize;
Expand Down
1 change: 1 addition & 0 deletions util/cppcheck/cppcheck.suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ redundantInitialization
constVariable
knownConditionTrueFalse:curvefs/src/client/s3/client_s3_cache_manager.cpp
unusedStructMember:src/chunkserver/raftlog/curve_segment.cpp
redundantAssignment:src/tools/status_tool.cpp

# portability
arithOperationsOnVoidPointer
Expand Down
14 changes: 8 additions & 6 deletions util/ut_in_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ echo $test_bin_dirs

for i in 0 1 2 3; do mkdir -p $i/{copysets,recycler}; done

exclude_test_names="snapshot-server|snapshot_dummy_server|client-test|server-test|multi|topology_dummy|curve_client_workflow|curve_fake_mds|curve_tool_test"

# run all unittests background
for i in `find ${test_bin_dirs} -type f -executable -exec file -i '{}' \; | grep -E 'executable|sharedlib' | grep "charset=binary" | grep -v ".so"|grep test | grep -Ev 'snapshot-server|snapshot_dummy_server|client-test|server-test|multi|topology_dummy|curve_client_workflow|curve_fake_mds' | awk -F":" '{print $1}' | sed -n '1,40p' ` ;do sudo $i 2>&1 | tee $i.log & done
for i in `find ${test_bin_dirs} -type f -executable -exec file -i '{}' \; | grep -E 'executable|sharedlib' | grep "charset=binary" | grep -v ".so"|grep test | grep -Ev $exclude_test_names | awk -F":" '{print $1}' | sed -n '1,40p' ` ;do sudo $i 2>&1 | tee $i.log & done
if [ $1 == "curvebs" ];then
sleep 360
fi
for i in `find ${test_bin_dirs} -type f -executable -exec file -i '{}' \; | grep -E 'executable|sharedlib' | grep "charset=binary" | grep -v ".so"|grep test | grep -Ev 'snapshot-server|snapshot_dummy_server|client-test|server-test|multi|topology_dummy|curve_client_workflow|curve_fake_mds' | awk -F":" '{print $1}' | sed -n '41,$p' ` ;do sudo $i 2>&1 | tee $i.log & done
for i in `find ${test_bin_dirs} -type f -executable -exec file -i '{}' \; | grep -E 'executable|sharedlib' | grep "charset=binary" | grep -v ".so"|grep test | grep -Ev $exclude_test_names | awk -F":" '{print $1}' | sed -n '41,$p' ` ;do sudo $i 2>&1 | tee $i.log & done


count=2
Expand All @@ -131,8 +133,8 @@ do
now_test=`ps -ef | grep test | grep -v 'test[0-9]' | grep -v grep | awk '{print $8}'`
echo "now_test case is "$now_test

for i in `find ${test_bin_dirs} -type f -executable -exec file -i '{}' \; | grep -E 'executable|sharedlib' | grep "charset=binary" | grep -v ".so"|grep test | grep -Ev 'snapshot-server|snapshot_dummy_server|client-test|server-test|multi|topology_dummy|curve_client_workflow|curve_client_workflow|curve_fake_mds' | awk -F":" '{print $1'}`;do a=`cat $i.log | grep "FAILED ]" | wc -l`;if [ $a -gt 0 ];then f1=`cat $i.log | grep "FAILED ]"`;f1_file="${i}.log"; echo "fail test is $i"; check=1; fi;done
for i in `find ${test_bin_dirs} -type f -executable -exec file -i '{}' \; | grep -E 'executable|sharedlib' | grep "charset=binary" | grep -v ".so"|grep test | grep -Ev 'snapshot-server|snapshot_dummy_server|client-test|server-test|multi|topology_dummy|curve_client_workflow|curve_client_workflow|curve_fake_mds' | awk -F":" '{print $1'}`;do b=`cat $i.log | grep "Failure" | wc -l`;if [ $b -gt 0 ];then f2=`cat $i.log | grep "Failure"`; f2_file="${i}.log";echo "fail test is $i"; check=1; fi;done
for i in `find ${test_bin_dirs} -type f -executable -exec file -i '{}' \; | grep -E 'executable|sharedlib' | grep "charset=binary" | grep -v ".so"|grep test | grep -Ev $exclude_test_names | awk -F":" '{print $1'}`;do a=`cat $i.log | grep "FAILED ]" | wc -l`;if [ $a -gt 0 ];then f1=`cat $i.log | grep "FAILED ]"`;f1_file="${i}.log"; echo "fail test is $i"; check=1; fi;done
for i in `find ${test_bin_dirs} -type f -executable -exec file -i '{}' \; | grep -E 'executable|sharedlib' | grep "charset=binary" | grep -v ".so"|grep test | grep -Ev $exclude_test_names | awk -F":" '{print $1'}`;do b=`cat $i.log | grep "Failure" | wc -l`;if [ $b -gt 0 ];then f2=`cat $i.log | grep "Failure"`; f2_file="${i}.log";echo "fail test is $i"; check=1; fi;done
if [ $check -eq 1 ];then
echo "=========================test fail,Here is the logs of failed use cases========================="
echo "=========================test fail,Here is the logs of failed use cases========================="
Expand Down Expand Up @@ -165,10 +167,10 @@ tar xvf ci.tar.gz

if [ $1 == "curvebs" ];then
./gen-coverage_bs.py
./check_coverage.sh "curvebs"
${WORKSPACE}/scripts/ci/check_coverage.sh "curvebs"
elif [ $1 == "curvefs" ];then
./gen-coverage_fs.py
./check_coverage.sh "curvefs"
${WORKSPACE}/scripts/ci/check_coverage.sh "curvefs"
fi
cp -r coverage ${WORKSPACE}
if [ $1 == "curvebs" ];then
Expand Down