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

scheduler: skip evict-leader-scheduler when setting schedule deny label #8303

Merged
merged 31 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ coverage
*.txt
go.work*
embedded_assets_handler.go
*.log
1 change: 1 addition & 0 deletions client/http/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@ func (c *client) CreateScheduler(ctx context.Context, name string, storeID uint6
WithBody(inputJSON))
}

// DeleteScheduler deletes a scheduler from PD cluster.
func (c *client) DeleteScheduler(ctx context.Context, name string) error {
return c.request(ctx, newRequestInfo().
WithName(deleteSchedulerName).
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/realcluster/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ if [ ! -d "bin" ] || [ ! -e "bin/tikv-server" ] && [ ! -e "bin/tidb-server" ] &&
color-green "downloading binaries..."
color-green "this may take a few minutes, you can also download them manually and put them in the bin directory."
make pd-server WITH_RACE=1
$TIUP_BIN_DIR playground nightly --kv 3 --tiflash 1 --db 1 --pd 3 --without-monitor --tag pd_test \
okJiang marked this conversation as resolved.
Show resolved Hide resolved
$TIUP_BIN_DIR playground nightly --kv 3 --tiflash 1 --db 1 --pd 3 --without-monitor --tag pd_real_cluster_test \
--pd.binpath ./bin/pd-server \
> $CUR_PATH/playground.log 2>&1 &
else
color-green "using existing binaries..."
$TIUP_BIN_DIR playground nightly --kv 3 --tiflash 1 --db 1 --pd 3 --without-monitor \
--pd.binpath ./bin/pd-server --kv.binpath ./bin/tikv-server --db.binpath ./bin/tidb-server --tiflash.binpath ./bin/tiflash --tag pd_test \
--pd.binpath ./bin/pd-server --kv.binpath ./bin/tikv-server --db.binpath ./bin/tidb-server --tiflash.binpath ./bin/tiflash --tag pd_real_cluster_test \
> $CUR_PATH/playground.log 2>&1 &
fi

Expand Down
17 changes: 12 additions & 5 deletions tests/integrations/realcluster/scheduler_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 TiKV Authors
// Copyright 2024 TiKV Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@ import (
"testing"
"time"

"github.com/pingcap/log"
"github.com/stretchr/testify/require"
pd "github.com/tikv/pd/client/http"
"github.com/tikv/pd/client/testutil"
Expand Down Expand Up @@ -79,7 +80,7 @@ func TestTransferLeader(t *testing.T) {
re.Len(res, oldSchedulersLen)
}

func TestRegionLabel_DenyScheduler(t *testing.T) {
func TestRegionLabelDenyScheduler(t *testing.T) {
re := require.New(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -141,11 +142,12 @@ func TestRegionLabel_DenyScheduler(t *testing.T) {
}
}
// check shuffle leader scheduler of region1 has been disabled
for i := 0; i < 10; i++ {
for i := 0; i < 20; i++ {
regions, err := pdHTTPCli.GetRegions(ctx)
re.NoError(err)
for _, region := range regions.Regions {
if region.ID == region1.ID {
log.Info("hit region 1")
re.True(region.Leader.StoreID == region1.Leader.StoreID)
}
}
Expand All @@ -156,18 +158,23 @@ func TestRegionLabel_DenyScheduler(t *testing.T) {
regions, err := pdHTTPCli.GetRegions(ctx)
re.NoError(err)
for _, region := range regions.Regions {
if region.ID == region2.ID {
log.Info("hit region 2")
}
if region.ID == region2.ID && region.Leader.StoreID != region2.Leader.StoreID {
return true
}
}
return false
})

oldRegions, err := pdHTTPCli.GetRegionsByStoreID(ctx, uint64(region1.Leader.StoreID))
oldRegions, err := pdHTTPCli.GetRegions(ctx)
re.NoError(err)
oldRegionMap := make(map[int64]bool, len(oldRegions.Regions))
for _, region := range oldRegions.Regions {
oldRegionMap[region.ID] = true
if region.Leader.ID == region1.Leader.ID {
oldRegionMap[region.ID] = true
}
}
// enable evict leader scheduler, and check it works
re.NoError(pdHTTPCli.CreateScheduler(ctx, schedulers.EvictLeaderName, uint64(region1.Leader.StoreID)))
Expand Down
Loading