Skip to content

Commit

Permalink
replace it
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <jinhao.hu@pingcap.com>
  • Loading branch information
HuSharp committed May 20, 2024
1 parent 6ded6f8 commit 283137d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ failpoint-disable: install-tools

ut: pd-ut
@$(FAILPOINT_ENABLE)
./bin/pd-ut run --race
# only run unit tests
./bin/pd-ut run --ignore tests --race
@$(CLEAN_UT_BINARY)
@$(FAILPOINT_DISABLE)

Expand Down
7 changes: 4 additions & 3 deletions scripts/ci-subtask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ case $1 in
;;
4)
# integration test client
./bin/pd-ut it run client --race --coverprofile $ROOT_PATH_COV || exit 1
# client tests
cd ./client && make ci-test-job && cat covprofile >> $ROOT_PATH_COV || exit 1
cd $integrations_dir && make ci-test-job test_name=client && cat ./client/covprofile >> $ROOT_PATH_COV || exit 1
;;
5)
# integration test tso
cd $integrations_dir && make ci-test-job test_name=tso && cat ./tso/covprofile >> $ROOT_PATH_COV || exit 1
./bin/pd-ut it run tso --race --coverprofile $ROOT_PATH_COV || exit 1
;;
6)
# integration test mcs
cd $integrations_dir && make ci-test-job test_name=mcs && cat ./mcs/covprofile >> $ROOT_PATH_COV || exit 1
./bin/pd-ut it run mcs --race --coverprofile $ROOT_PATH_COV || exit 1
;;
esac
26 changes: 24 additions & 2 deletions tools/pd-ut/ut.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ go tool cover --func=xxx`
return true
}

const modulePath = "github.com/tikv/pd"
var modulePath = "github.com/tikv/pd"
var integrationsTestPath = "tests/integrations"

var (
// runtime
Expand Down Expand Up @@ -139,6 +140,18 @@ func main() {
isSucceed = cmdBuild(os.Args[2:]...)
case "run":
isSucceed = cmdRun(os.Args[2:]...)
case "it":
// run integration tests
if len(os.Args) >= 3 {
modulePath = path.Join(modulePath, integrationsTestPath)
workDir = path.Join(workDir, integrationsTestPath)
switch os.Args[2] {
case "run":
isSucceed = cmdRun(os.Args[3:]...)
default:
isSucceed = usage()
}
}
default:
isSucceed = usage()
}
Expand Down Expand Up @@ -628,7 +641,7 @@ func (*numa) testCommand(pkg string, fn string) *exec.Cmd {
}

func skipDIR(pkg string) bool {
skipDir := []string{"bin", "cmd", "realcluster", "tests/integrations"}
skipDir := []string{"bin", "cmd", "realcluster"}
if ignoreDir != "" {
skipDir = append(skipDir, ignoreDir)
}
Expand All @@ -645,6 +658,11 @@ func generateBuildCache() error {
cmd := exec.Command("go", "test", "-exec=true", "-vet", "off", "--tags=tso_function_test,deadlock")
goCompileWithoutLink := fmt.Sprintf("-toolexec=%s/tools/pd-ut/go-compile-without-link.sh", workDir)
cmd.Dir = fmt.Sprintf("%s/cmd/pd-server", workDir)
if strings.Contains(workDir, integrationsTestPath) {
cmd.Dir = fmt.Sprintf("%s/cmd/pd-server", workDir[:strings.LastIndex(workDir, integrationsTestPath)])
goCompileWithoutLink = fmt.Sprintf("-toolexec=%s/tools/pd-ut/go-compile-without-link.sh",
workDir[:strings.LastIndex(workDir, integrationsTestPath)])
}
cmd.Args = append(cmd.Args, goCompileWithoutLink)

cmd.Stdout = os.Stdout
Expand All @@ -664,7 +682,11 @@ func buildTestBinaryMulti(pkgs []string) error {
}

// go test --exec=xprog --tags=tso_function_test,deadlock -vet=off --count=0 $(pkgs)
// workPath just like `/data/nvme0n1/husharp/proj/pd/tests/integrations`
xprogPath := path.Join(workDir, "bin/xprog")
if strings.Contains(workDir, integrationsTestPath) {
xprogPath = path.Join(workDir[:strings.LastIndex(workDir, integrationsTestPath)], "bin/xprog")
}
packages := make([]string, 0, len(pkgs))
for _, pkg := range pkgs {
packages = append(packages, path.Join(modulePath, pkg))
Expand Down

0 comments on commit 283137d

Please sign in to comment.