Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed Apr 8, 2024
1 parent affbae1 commit 6c7c590
Show file tree
Hide file tree
Showing 60 changed files with 1,386 additions and 267 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/pd-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@ jobs:
strategy:
fail-fast: true
matrix:
worker_id: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
include:
- worker_id: 1
name: 'Unit Test'
- worker_id: 2
name: 'Tools Test'
- worker_id: 3
name: 'Client Integration Test'
- worker_id: 4
name: 'TSO Integration Test'
- worker_id: 5
name: 'MicroService Integration Test'
outputs:
job-total: 13
job-total: 5
steps:
- uses: actions/setup-go@v3
with:
Expand All @@ -43,11 +53,11 @@ jobs:
**/.tools
**/.dashboard_download_cache
key: ${{ runner.os }}-go-${{ matrix.worker_id }}-${{ hashFiles('**/go.sum') }}
- name: Make Test
- name: ${{ matrix.name }}
env:
WORKER_ID: ${{ matrix.worker_id }}
WORKER_COUNT: 13
JOB_COUNT: 9 # 10 is tools test, 11, 12, 13 are for other integrations jobs
WORKER_COUNT: 5
JOB_COUNT: 5
run: |
make ci-test-job JOB_COUNT=$(($JOB_COUNT)) JOB_INDEX=$WORKER_ID
mv covprofile covprofile_$WORKER_ID
Expand Down
25 changes: 19 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ BUILD_BIN_PATH := $(ROOT_PATH)/bin

build: pd-server pd-ctl pd-recover

tools: pd-tso-bench pd-heartbeat-bench regions-dump stores-dump pd-api-bench
tools: pd-tso-bench pd-heartbeat-bench regions-dump stores-dump pd-api-bench pd-ut

PD_SERVER_DEP :=
ifeq ($(SWAGGER), 1)
Expand Down Expand Up @@ -108,7 +108,6 @@ pd-server-basic:
.PHONY: pre-build build tools pd-server pd-server-basic

# Tools

pd-ctl:
cd tools && GOEXPERIMENT=$(BUILD_GOEXPERIMENT) CGO_ENABLED=$(BUILD_TOOL_CGO_ENABLED) go build -gcflags '$(GCFLAGS)' -ldflags '$(LDFLAGS)' -o $(BUILD_BIN_PATH)/pd-ctl pd-ctl/main.go
pd-tso-bench:
Expand All @@ -127,8 +126,12 @@ regions-dump:
cd tools && CGO_ENABLED=0 go build -gcflags '$(GCFLAGS)' -ldflags '$(LDFLAGS)' -o $(BUILD_BIN_PATH)/regions-dump regions-dump/main.go
stores-dump:
cd tools && CGO_ENABLED=0 go build -gcflags '$(GCFLAGS)' -ldflags '$(LDFLAGS)' -o $(BUILD_BIN_PATH)/stores-dump stores-dump/main.go
pd-ut: pd-xprog
cd tools && GOEXPERIMENT=$(BUILD_GOEXPERIMENT) CGO_ENABLED=$(BUILD_TOOL_CGO_ENABLED) go build -gcflags '$(GCFLAGS)' -ldflags '$(LDFLAGS)' -o $(BUILD_BIN_PATH)/pd-ut pd-ut/ut.go pd-ut/coverProfile.go
pd-xprog:
cd tools && GOEXPERIMENT=$(BUILD_GOEXPERIMENT) CGO_ENABLED=$(BUILD_TOOL_CGO_ENABLED) go build -tags xprog -gcflags '$(GCFLAGS)' -ldflags '$(LDFLAGS)' -o $(BUILD_BIN_PATH)/xprog pd-ut/xprog.go

.PHONY: pd-ctl pd-tso-bench pd-recover pd-analysis pd-heartbeat-bench simulator regions-dump stores-dump pd-api-bench
.PHONY: pd-ctl pd-tso-bench pd-recover pd-analysis pd-heartbeat-bench simulator regions-dump stores-dump pd-api-bench pd-ut

#### Docker image ####

Expand Down Expand Up @@ -225,6 +228,12 @@ failpoint-disable: install-tools

#### Test ####

ut: pd-ut
@$(FAILPOINT_ENABLE)
./bin/pd-ut run --race
@$(CLEAN_UT_BINARY)
@$(FAILPOINT_DISABLE)

PACKAGE_DIRECTORIES := $(subst $(PD_PKG)/,,$(PACKAGES))
TEST_PKGS := $(filter $(shell find . -iname "*_test.go" -exec dirname {} \; | \
sort -u | sed -e "s/^\./github.com\/tikv\/pd/"),$(PACKAGES))
Expand All @@ -236,18 +245,19 @@ SUBMODULES := $(filter $(shell find . -iname "go.mod" -exec dirname {} \;),\
test: install-tools
# testing all pkgs...
@$(FAILPOINT_ENABLE)
CGO_ENABLED=1 go test -tags tso_function_test,deadlock -timeout 20m -race -cover $(TEST_PKGS) || { $(FAILPOINT_DISABLE); exit 1; }
CGO_ENABLED=1 go test -tags tso_function_test,deadlock -timeout 20m -race -cover $(TEST_PKGS) -coverprofile=all || { $(FAILPOINT_DISABLE); exit 1; }
@$(FAILPOINT_DISABLE)

basic-test: install-tools
# testing basic pkgs...
@$(FAILPOINT_ENABLE)
go test $(BASIC_TEST_PKGS) || { $(FAILPOINT_DISABLE); exit 1; }
CGO_ENABLED=1 go test -timeout 20m -race -cover $(BASIC_TEST_PKGS) -coverprofile=basic || { $(FAILPOINT_DISABLE); exit 1; }
@$(FAILPOINT_DISABLE)

ci-test-job: install-tools dashboard-ui
ci-test-job: install-tools dashboard-ui pd-ut
@$(FAILPOINT_ENABLE)
./scripts/ci-subtask.sh $(JOB_COUNT) $(JOB_INDEX) || { $(FAILPOINT_DISABLE); exit 1; }
@$(CLEAN_UT_BINARY)
@$(FAILPOINT_DISABLE)

TSO_INTEGRATION_TEST_PKGS := $(PD_PKG)/tests/server/tso
Expand Down Expand Up @@ -303,13 +313,16 @@ split:

clean: failpoint-disable clean-test clean-build

CLEAN_UT_BINARY := find . -name '*.test.bin'| xargs rm -f

clean-test:
# Cleaning test tmp...
rm -rf /tmp/test_pd*
rm -rf /tmp/pd-tests*
rm -rf /tmp/test_etcd*
rm -f $(REAL_CLUSTER_TEST_PATH)/playground.log
go clean -testcache
@$(CLEAN_UT_BINARY)

clean-build:
# Cleaning building files...
Expand Down
19 changes: 14 additions & 5 deletions client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ROOT_PATH := ..
GO_TOOLS_BIN_PATH := $(shell pwd)/../.tools/bin
PATH := $(GO_TOOLS_BIN_PATH):$(PATH)
SHELL := env PATH='$(PATH)' GOBIN='$(GO_TOOLS_BIN_PATH)' $(shell which bash)

default: static tidy test

test:
CGO_ENABLE=1 go test ./... -race -cover
test: failpoint-enable
CGO_ENABLE=1 go test ./... -v -tags deadlock -race -cover || { $(MAKE) failpoint-disable && exit 1; }
$(MAKE) failpoint-disable

basic-test:
CGO_ENABLE=1 go test ./...
basic-test: failpoint-enable
CGO_ENABLE=1 go test ./... || { $(MAKE) failpoint-disable && exit 1; }
$(MAKE) failpoint-disable

ci-test-job:
CGO_ENABLED=1 go test ./... -race -covermode=atomic -coverprofile=covprofile -coverpkg=../... github.com/tikv/pd/client
CGO_ENABLED=1 go test ./... -v -tags deadlock -race -cover -covermode=atomic -coverprofile=covprofile -coverpkg=../...

failpoint-enable:
cd $(ROOT_PATH) && $(MAKE) failpoint-enable

failpoint-disable:
cd $(ROOT_PATH) && $(MAKE) failpoint-disable

install-tools:
cd .. && $(MAKE) install-tools
Expand Down
2 changes: 0 additions & 2 deletions client/resource_group/controller/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type example struct {
}

func TestDurationJSON(t *testing.T) {
t.Parallel()
re := require.New(t)
example := &example{}

Expand All @@ -41,7 +40,6 @@ func TestDurationJSON(t *testing.T) {
}

func TestDurationTOML(t *testing.T) {
t.Parallel()
re := require.New(t)
example := &example{}

Expand Down
2 changes: 1 addition & 1 deletion client/testutil/tempurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func Alloc() string {
}

func tryAllocTestURL() string {
l, err := net.Listen("tcp", "127.0.0.1:0")
l, err := net.Listen("tcp", "127.0.0.1:")
if err != nil {
log.Fatal("listen failed", zap.Error(err))
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/audit/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
)

func TestLabelMatcher(t *testing.T) {
t.Parallel()
re := require.New(t)
matcher := &LabelMatcher{"testSuccess"}
labels1 := &BackendLabels{Labels: []string{"testFail", "testSuccess"}}
Expand All @@ -42,7 +41,6 @@ func TestLabelMatcher(t *testing.T) {
}

func TestPrometheusHistogramBackend(t *testing.T) {
t.Parallel()
re := require.New(t)
serviceAuditHistogramTest := prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Expand Down Expand Up @@ -90,7 +88,6 @@ func TestPrometheusHistogramBackend(t *testing.T) {
}

func TestLocalLogBackendUsingFile(t *testing.T) {
t.Parallel()
re := require.New(t)
backend := NewLocalLogBackend(true)
fname := testutil.InitTempFileLogger("info")
Expand Down
5 changes: 0 additions & 5 deletions pkg/autoscaling/calculation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
)

func TestGetScaledTiKVGroups(t *testing.T) {
t.Parallel()
re := require.New(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -214,7 +213,6 @@ func (q *mockQuerier) Query(options *QueryOptions) (QueryResult, error) {
}

func TestGetTotalCPUUseTime(t *testing.T) {
t.Parallel()
re := require.New(t)
querier := &mockQuerier{}
instances := []instance{
Expand All @@ -237,7 +235,6 @@ func TestGetTotalCPUUseTime(t *testing.T) {
}

func TestGetTotalCPUQuota(t *testing.T) {
t.Parallel()
re := require.New(t)
querier := &mockQuerier{}
instances := []instance{
Expand All @@ -260,7 +257,6 @@ func TestGetTotalCPUQuota(t *testing.T) {
}

func TestScaleOutGroupLabel(t *testing.T) {
t.Parallel()
re := require.New(t)
var jsonStr = []byte(`
{
Expand Down Expand Up @@ -303,7 +299,6 @@ func TestScaleOutGroupLabel(t *testing.T) {
}

func TestStrategyChangeCount(t *testing.T) {
t.Parallel()
re := require.New(t)
var count uint64 = 2
strategy := &Strategy{
Expand Down
6 changes: 0 additions & 6 deletions pkg/autoscaling/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ func (c *normalClient) Do(_ context.Context, req *http.Request) (response *http.
}

func TestRetrieveCPUMetrics(t *testing.T) {
t.Parallel()
re := require.New(t)
client := &normalClient{
mockData: make(map[string]*response),
Expand Down Expand Up @@ -225,7 +224,6 @@ func (c *emptyResponseClient) Do(_ context.Context, req *http.Request) (r *http.
}

func TestEmptyResponse(t *testing.T) {
t.Parallel()
re := require.New(t)
client := &emptyResponseClient{}
querier := NewPrometheusQuerier(client)
Expand Down Expand Up @@ -253,7 +251,6 @@ func (c *errorHTTPStatusClient) Do(_ context.Context, req *http.Request) (r *htt
}

func TestErrorHTTPStatus(t *testing.T) {
t.Parallel()
re := require.New(t)
client := &errorHTTPStatusClient{}
querier := NewPrometheusQuerier(client)
Expand All @@ -279,7 +276,6 @@ func (c *errorPrometheusStatusClient) Do(_ context.Context, req *http.Request) (
}

func TestErrorPrometheusStatus(t *testing.T) {
t.Parallel()
re := require.New(t)
client := &errorPrometheusStatusClient{}
querier := NewPrometheusQuerier(client)
Expand All @@ -290,7 +286,6 @@ func TestErrorPrometheusStatus(t *testing.T) {
}

func TestGetInstanceNameFromAddress(t *testing.T) {
t.Parallel()
re := require.New(t)
testCases := []struct {
address string
Expand Down Expand Up @@ -328,7 +323,6 @@ func TestGetInstanceNameFromAddress(t *testing.T) {
}

func TestGetDurationExpression(t *testing.T) {
t.Parallel()
re := require.New(t)
testCases := []struct {
duration time.Duration
Expand Down
3 changes: 0 additions & 3 deletions pkg/balancer/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
)

func TestBalancerPutAndDelete(t *testing.T) {
t.Parallel()
re := require.New(t)
balancers := []Balancer[uint32]{
NewRoundRobin[uint32](),
Expand Down Expand Up @@ -56,7 +55,6 @@ func TestBalancerPutAndDelete(t *testing.T) {
}

func TestBalancerDuplicate(t *testing.T) {
t.Parallel()
re := require.New(t)
balancers := []Balancer[uint32]{
NewRoundRobin[uint32](),
Expand All @@ -77,7 +75,6 @@ func TestBalancerDuplicate(t *testing.T) {
}

func TestRoundRobin(t *testing.T) {
t.Parallel()
re := require.New(t)
balancer := NewRoundRobin[uint32]()
for i := 0; i < 100; i++ {
Expand Down
6 changes: 0 additions & 6 deletions pkg/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
)

func TestExpireRegionCache(t *testing.T) {
t.Parallel()
re := require.New(t)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -121,7 +120,6 @@ func sortIDs(ids []uint64) []uint64 {
}

func TestLRUCache(t *testing.T) {
t.Parallel()
re := require.New(t)
cache := newLRU(3)

Expand Down Expand Up @@ -199,7 +197,6 @@ func TestLRUCache(t *testing.T) {
}

func TestFifoCache(t *testing.T) {
t.Parallel()
re := require.New(t)
cache := NewFIFO(3)
cache.Put(1, "1")
Expand Down Expand Up @@ -227,7 +224,6 @@ func TestFifoCache(t *testing.T) {
}

func TestFifoFromLastSameElems(t *testing.T) {
t.Parallel()
re := require.New(t)
type testStruct struct {
value string
Expand Down Expand Up @@ -260,7 +256,6 @@ func TestFifoFromLastSameElems(t *testing.T) {
}

func TestTwoQueueCache(t *testing.T) {
t.Parallel()
re := require.New(t)
cache := newTwoQueue(3)
cache.Put(1, "1")
Expand Down Expand Up @@ -345,7 +340,6 @@ func (pq PriorityQueueItemTest) ID() uint64 {
}

func TestPriorityQueue(t *testing.T) {
t.Parallel()
re := require.New(t)
testData := []PriorityQueueItemTest{0, 1, 2, 3, 4, 5}
pq := NewPriorityQueue(0)
Expand Down
2 changes: 0 additions & 2 deletions pkg/codec/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
)

func TestDecodeBytes(t *testing.T) {
t.Parallel()
re := require.New(t)
key := "abcdefghijklmnopqrstuvwxyz"
for i := 0; i < len(key); i++ {
Expand All @@ -32,7 +31,6 @@ func TestDecodeBytes(t *testing.T) {
}

func TestTableID(t *testing.T) {
t.Parallel()
re := require.New(t)
key := EncodeBytes([]byte("t\x80\x00\x00\x00\x00\x00\x00\xff"))
re.Equal(int64(0xff), key.TableID())
Expand Down
2 changes: 0 additions & 2 deletions pkg/core/rangetree/range_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func bucketDebrisFactory(startKey, endKey []byte, item RangeItem) []RangeItem {
}

func TestRingPutItem(t *testing.T) {
t.Parallel()
re := require.New(t)
bucketTree := NewRangeTree(2, bucketDebrisFactory)
bucketTree.Update(newSimpleBucketItem([]byte("002"), []byte("100")))
Expand Down Expand Up @@ -120,7 +119,6 @@ func TestRingPutItem(t *testing.T) {
}

func TestDebris(t *testing.T) {
t.Parallel()
re := require.New(t)
ringItem := newSimpleBucketItem([]byte("010"), []byte("090"))
var overlaps []RangeItem
Expand Down
Loading

0 comments on commit 6c7c590

Please sign in to comment.