diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml deleted file mode 100644 index c0bdb7ea492c..000000000000 --- a/.github/workflows/check.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: Check PD -on: [push, pull_request] -concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true -jobs: - statics: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/setup-go@v3 - with: - go-version: '1.21' - - name: Checkout code - uses: actions/checkout@v3 - - name: Restore cache - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - **/.dashboard_download_cache - key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-golang - - name: Make Check - run: | - SWAGGER=1 make build - make tools - make check diff --git a/.github/workflows/pd-docker-image.yaml b/.github/workflows/pd-docker-image.yaml deleted file mode 100644 index 2a04c030016f..000000000000 --- a/.github/workflows/pd-docker-image.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: PD Docker Image -on: - push: - branches: - - master - pull_request: - branches: - - master -concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true -jobs: - chunks: - runs-on: ubuntu-latest - strategy: - fail-fast: true - steps: - - uses: actions/setup-go@v3 - with: - go-version: '1.21' - - name: Checkout code - uses: actions/checkout@v3 - - name: Make - run: make docker-image diff --git a/.github/workflows/pd-tests.yaml b/.github/workflows/pd-tests.yaml index 73e31fd4ad1b..4ced6c1b1f58 100644 --- a/.github/workflows/pd-tests.yaml +++ b/.github/workflows/pd-tests.yaml @@ -23,9 +23,9 @@ jobs: strategy: fail-fast: true matrix: - worker_id: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] + worker_id: [1] outputs: - job-total: 13 + job-total: 1 steps: - uses: actions/setup-go@v3 with: @@ -48,31 +48,31 @@ jobs: JOB_COUNT: 10 # 11, 12 13 are for other integrations jobs run: | make ci-test-job JOB_COUNT=$(($JOB_COUNT)) JOB_INDEX=$WORKER_ID - mv covprofile covprofile_$WORKER_ID - sed -i "/failpoint_binding/d" covprofile_$WORKER_ID - - name: Upload coverage result ${{ matrix.worker_id }} - uses: actions/upload-artifact@v2 - with: - name: cover-reports - path: covprofile_${{ matrix.worker_id }} - report-coverage: - needs: chunks - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Download chunk report - uses: actions/download-artifact@v2 - with: - name: cover-reports - - name: Merge - env: - TOTAL_JOBS: ${{needs.chunks.outputs.job-total}} - run: for i in $(seq 1 $TOTAL_JOBS); do cat covprofile_$i >> covprofile; done - - name: Send coverage - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV }} - file: ./covprofile - flags: unittests - name: codecov-umbrella +# mv covprofile covprofile_$WORKER_ID +# sed -i "/failpoint_binding/d" covprofile_$WORKER_ID +# - name: Upload coverage result ${{ matrix.worker_id }} +# uses: actions/upload-artifact@v2 +# with: +# name: cover-reports +# path: covprofile_${{ matrix.worker_id }} +# report-coverage: +# needs: chunks +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v3 +# - name: Download chunk report +# uses: actions/download-artifact@v2 +# with: +# name: cover-reports +# - name: Merge +# env: +# TOTAL_JOBS: ${{needs.chunks.outputs.job-total}} +# run: for i in $(seq 1 $TOTAL_JOBS); do cat covprofile_$i >> covprofile; done +# - name: Send coverage +# uses: codecov/codecov-action@v1 +# with: +# token: ${{ secrets.CODECOV }} +# file: ./covprofile +# flags: unittests +# name: codecov-umbrella diff --git a/.github/workflows/tso-consistency-test.yaml b/.github/workflows/tso-consistency-test.yaml deleted file mode 100644 index 570cbbc5da8f..000000000000 --- a/.github/workflows/tso-consistency-test.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: TSO Consistency Test -on: - # Only run when the new code is merged into master. - push: - branches: - - master -jobs: - tso-consistency-test: - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v3 - with: - go-version: '1.21' - - name: Checkout code - uses: actions/checkout@v3 - - name: Make TSO Consistency Test - run: make test-tso-consistency diff --git a/.github/workflows/tso-function-test.yaml b/.github/workflows/tso-function-test.yaml deleted file mode 100644 index ee7679602f50..000000000000 --- a/.github/workflows/tso-function-test.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: TSO Function Test -on: - push: - branches: - - master - - release-5.* - - release-6.* - - release-7.* - pull_request: - branches: - - master - - release-5.* - - release-6.* - - release-7.* -concurrency: - group: ${{ github.ref }}-${{ github.workflow }} - cancel-in-progress: true -jobs: - tso-function-test: - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v3 - with: - go-version: '1.21' - - name: Checkout code - uses: actions/checkout@v3 - - name: Make TSO Function Test - run: make test-tso-function diff --git a/Makefile b/Makefile index 77ad51a1a870..31194eab4bc4 100644 --- a/Makefile +++ b/Makefile @@ -225,12 +225,8 @@ basic-test: install-tools @$(FAILPOINT_DISABLE) ci-test-job: install-tools dashboard-ui - @$(FAILPOINT_ENABLE) - if [[ $(JOB_INDEX) -le 10 ]]; then \ - CGO_ENABLED=1 go test -timeout=15m -tags deadlock -race -covermode=atomic -coverprofile=covprofile -coverpkg=./... $(shell ./scripts/ci-subtask.sh $(JOB_COUNT) $(JOB_INDEX)); \ - else \ - for mod in $(shell ./scripts/ci-subtask.sh $(JOB_COUNT) $(JOB_INDEX)); do cd $$mod && $(MAKE) ci-test-job && cd $(ROOT_PATH) > /dev/null && cat $$mod/covprofile >> covprofile; done; \ - fi + CGO_ENABLED=1 go test -v -timeout=15m -tags deadlock -race github.com/tikv/pd/tests/dashboard + @$(FAILPOINT_DISABLE) TSO_INTEGRATION_TEST_PKGS := $(PD_PKG)/tests/server/tso @@ -286,4 +282,4 @@ clean-build: rm -rf $(BUILD_BIN_PATH) rm -rf $(GO_TOOLS_BIN_PATH) -.PHONY: clean clean-test clean-build \ No newline at end of file +.PHONY: clean clean-test clean-build diff --git a/pkg/dashboard/adapter/manager.go b/pkg/dashboard/adapter/manager.go index a3691242c8fc..3ea7ccb1a84f 100644 --- a/pkg/dashboard/adapter/manager.go +++ b/pkg/dashboard/adapter/manager.go @@ -16,9 +16,11 @@ package adapter import ( "context" + "go.uber.org/zap" "sync" "time" + "github.com/pingcap/failpoint" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" "github.com/pingcap/tidb-dashboard/pkg/apiserver" @@ -78,10 +80,15 @@ func (m *Manager) serviceLoop() { ticker := time.NewTicker(CheckInterval) defer ticker.Stop() + failpoint.Inject("fastCheckAddress", func() { + ticker.Stop() + ticker = time.NewTicker(100 * time.Millisecond) + }) for { select { case <-m.ctx.Done(): + log.Info("dashboard manager is closed") m.stopService() return case <-ticker.C: @@ -94,6 +101,7 @@ func (m *Manager) serviceLoop() { // updateInfo updates information from the server. func (m *Manager) updateInfo() { if !m.srv.GetMember().IsLeader() { + log.Info("dashboard is not leader", zap.String("svr-name", m.srv.Name())) m.isLeader = false m.members = nil if err := m.srv.GetPersistOptions().Reload(m.srv.GetStorage()); err != nil { @@ -110,6 +118,7 @@ func (m *Manager) updateInfo() { m.members = nil return } + log.Info("get members", zap.String("svr-name", m.srv.Name())) for _, member := range m.members { if len(member.GetClientUrls()) == 0 { @@ -123,18 +132,22 @@ func (m *Manager) updateInfo() { // checkDashboardAddress checks if the dashboard service needs to change due to dashboard address is changed. func (m *Manager) checkAddress() { dashboardAddress := m.srv.GetPersistOptions().GetDashboardAddress() + log.Info("check dashboard address", zap.String("svr-name", m.srv.Name()), logutil.ZapRedactString("dashboardAddress", dashboardAddress)) switch dashboardAddress { case "auto": + log.Info("dashboard address is auto", zap.Int("members", len(m.members)), zap.Bool("isLeader", m.isLeader)) if m.isLeader && len(m.members) > 0 { m.setNewAddress() } return case "none": + log.Info("dashboard address is none") m.redirector.SetAddress("") m.stopService() return default: if m.isLeader && m.needResetAddress(dashboardAddress) { + log.Info("dashboard address is changed") m.setNewAddress() return } @@ -144,8 +157,10 @@ func (m *Manager) checkAddress() { clientUrls := m.srv.GetMemberInfo().GetClientUrls() if len(clientUrls) > 0 && clientUrls[0] == dashboardAddress { + log.Info("dashboard server is running", zap.String("svr-name", m.srv.Name()), zap.String("svr-addr", m.srv.GetAddr()), zap.Int("clientUrls", len(clientUrls))) m.startService() } else { + log.Info("dashboard server is not running", zap.String("svr-name", m.srv.Name()), zap.String("svr-addr", m.srv.GetAddr()), zap.Int("clientUrls", len(clientUrls))) m.stopService() } } @@ -199,6 +214,7 @@ func (m *Manager) startService() { func (m *Manager) stopService() { if !m.service.IsRunning() { + log.Info("dashboard server is not running by check") return } if err := m.service.Stop(context.Background()); err != nil { diff --git a/server/config/config.go b/server/config/config.go index 5b9088ac8eaf..0485e077c676 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -505,7 +505,7 @@ type PDServerConfig struct { // RuntimeServices is the running extension services. RuntimeServices typeutil.StringSlice `toml:"runtime-services" json:"runtime-services"` // MetricStorage is the cluster metric storage. - // Currently we use prometheus as metric storage, we may use PD/TiKV as metric storage later. + // Currently, we use prometheus as metric storage, we may use PD/TiKV as metric storage later. MetricStorage string `toml:"metric-storage" json:"metric-storage"` // There are some values supported: "auto", "none", or a specific address, default: "auto" DashboardAddress string `toml:"dashboard-address" json:"dashboard-address"` diff --git a/tests/dashboard/service_test.go b/tests/dashboard/service_test.go index f75e047d8f13..bbbcf81450b0 100644 --- a/tests/dashboard/service_test.go +++ b/tests/dashboard/service_test.go @@ -25,12 +25,15 @@ import ( "github.com/stretchr/testify/suite" "go.uber.org/goleak" + "github.com/pingcap/failpoint" + "github.com/pingcap/log" "github.com/tikv/pd/pkg/dashboard" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server/config" "github.com/tikv/pd/tests" "github.com/tikv/pd/tests/pdctl" pdctlCmd "github.com/tikv/pd/tools/pd-ctl/pdctl" + "go.uber.org/zap" ) func TestMain(m *testing.M) { @@ -69,12 +72,14 @@ func (suite *dashboardTestSuite) TearDownSuite() { } func (suite *dashboardTestSuite) TestDashboardRedirect() { + println("TestDashboardRedirect") suite.testDashboard(false) } -func (suite *dashboardTestSuite) TestDashboardProxy() { - suite.testDashboard(true) -} +//func (suite *dashboardTestSuite) TestDashboardProxy() { +// println("TestDashboardProxy") +// suite.testDashboard(true) +//} func (suite *dashboardTestSuite) checkRespCode(url string, code int) { resp, err := suite.httpClient.Get(url) @@ -96,6 +101,8 @@ func (suite *dashboardTestSuite) checkServiceIsStarted(internalProxy bool, serve for _, srv := range servers { suite.Equal(dashboardAddress, srv.GetPersistOptions().GetDashboardAddress()) addr := srv.GetAddr() + log.Info("checkServiceIsStarted", zap.String("addr", addr), zap.String("dashboardAddress", dashboardAddress), + zap.String("now", srv.GetPersistOptions().GetDashboardAddress()), zap.Bool("internalProxy", internalProxy)) if addr == dashboardAddress || internalProxy { suite.checkRespCode(fmt.Sprintf("%s/dashboard/", addr), http.StatusOK) suite.checkRespCode(fmt.Sprintf("%s/dashboard/api/keyvisual/heatmaps", addr), http.StatusUnauthorized) @@ -122,6 +129,11 @@ func (suite *dashboardTestSuite) checkServiceIsStopped(servers map[string]*tests } func (suite *dashboardTestSuite) testDashboard(internalProxy bool) { + re := suite.Require() + re.NoError(failpoint.Enable("github.com/tikv/pd/pkg/dashboard/adapter/fastCheckAddress", `return(true)`)) + defer func() { + re.NoError(failpoint.Disable("github.com/tikv/pd/pkg/dashboard/adapter/fastCheckAddress")) + }() cluster, err := tests.NewTestCluster(suite.ctx, 3, func(conf *config.Config, serverName string) { conf.Dashboard.InternalProxy = internalProxy }) @@ -138,7 +150,9 @@ func (suite *dashboardTestSuite) testDashboard(internalProxy bool) { leaderAddr := leader.GetAddr() // auto select node + log.Info("auto select node") dashboardAddress1 := suite.checkServiceIsStarted(internalProxy, servers, leader) + log.Info("auto select node finished") // pd-ctl set another addr var dashboardAddress2 string @@ -151,7 +165,10 @@ func (suite *dashboardTestSuite) testDashboard(internalProxy bool) { args := []string{"-u", leaderAddr, "config", "set", "dashboard-address", dashboardAddress2} _, err = pdctl.ExecuteCommand(cmd, args...) suite.NoError(err) + + log.Info("ctl check node") suite.checkServiceIsStarted(internalProxy, servers, leader) + log.Info("ctl check node finished") suite.Equal(dashboardAddress2, leader.GetServer().GetPersistOptions().GetDashboardAddress()) // pd-ctl set stop