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

[close #175] Add br apiv2 integration test #186

Merged
merged 9 commits into from
Aug 2, 2022
Merged
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
5 changes: 2 additions & 3 deletions .github/config/br_rawkv.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ pd-heartbeat-tick-interval = "2s"
pd-store-heartbeat-tick-interval = "5s"
split-region-check-tick-interval = "1s"

[storage]
enable-ttl = true

[rocksdb]
max-open-files = 10000

[raftdb]
max-open-files = 10000

[storage]
enable-ttl = true
11 changes: 9 additions & 2 deletions .github/workflows/ci-br.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ jobs:
cd br
make test
br-integration-test:
name: br-integration-test-${{ matrix.tikv_version }}
name: br-integration-test-${{ matrix.tikv_version }}-apiv${{ matrix.api_version }}
runs-on: ubuntu-latest
strategy:
matrix:
tikv_version: [nightly]
api_version: [1, 2]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
Expand All @@ -74,18 +75,24 @@ jobs:
run: curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
- name: start tikv cluster
run: |
# start tikv in apiv1ttl
# start tikv
echo -e "\napi-version = ${{ matrix.api_version }}\n" >> /home/runner/work/migration/migration/.github/config/br_rawkv.toml
/home/runner/.tiup/bin/tiup playground ${{ matrix.tikv_version }} --mode tikv-slim --kv 1 --without-monitor --kv.config /home/runner/work/migration/migration/.github/config/br_rawkv.toml --pd.config /home/runner/work/migration/migration/.github/config/br_pd.toml &> raw.out 2>&1 &
# The first run of `tiup` has to download all components so it'll take longer.
sleep 1m 30s
# Parse PD address from `tiup` output
echo "PD_ADDR=$(cat raw.out | grep -oP '(?<=PD client endpoints: \[)[0-9\.:]+(?=\])')" >> $GITHUB_ENV
# Output the api version
echo "API_VERSION=${{ matrix.api_version }}" >> $GITHUB_ENV
# Log the output
echo "$(cat raw.out)" >&2
- name: run integration test
haojinming marked this conversation as resolved.
Show resolved Hide resolved
run: |
cd br
make test/integration
- name: display backup log
run: |
cat /tmp/br.log*
# comments low version CI as they fail without checksum & split region capability.
# Plan to support low version with feature gate in the future.
# br-integration-test-5X:
Expand Down
14 changes: 8 additions & 6 deletions br/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ COVERAGE_DIR ?= build
TEST_PARALLEL ?= 8
PD_ADDR ?= 127.0.0.1:2379
BR_LOCAL_STORE ?= /tmp/backup_restore_test
API_VERSION ?= 1

LDFLAGS += -X "github.com/tikv/migration/br/pkg/version/build.ReleaseVersion=$(shell git describe --tags --dirty --always)"
LDFLAGS += -X "github.com/tikv/migration/br/pkg/version/build.BuildTS=$(shell date -u '+%Y-%m-%d %H:%M:%S')"
Expand Down Expand Up @@ -57,10 +58,11 @@ test: tools/bin/gocov tools/bin/gocov-xml
tools/bin/gocov convert $(COVERAGE_DIR)/coverage.raw | tools/bin/gocov-xml > $(COVERAGE_DIR)/coverage.xml
make failpoint/disable

test/integration: build/br-test build/rawkv-helper
./tests/rawkv/run.py --test-helper=bin/rawkv --pd=$(PD_ADDR) \
--br='$(TEST_BIN_PATH) -test.coverprofile=cov.br_rawkv.out.log DEVEL' \
--br-storage=local://$(BR_LOCAL_STORE)
test/integration: build/br-test build/rawkv-integration-test
./bin/rawkv_test --pd=${PD_ADDR} \
--br='${TEST_BIN_PATH}' \
--br-storage=${BR_LOCAL_STORE} \
--api-version=${API_VERSION}

failpoint/enable: tools/bin/failpoint-ctl
find `pwd` -type d | grep -vE "(\.git|tools)" | xargs tools/bin/failpoint-ctl enable
Expand All @@ -86,8 +88,8 @@ build:
release:
CGO_ENABLED=1 $(GO) build -tags codes -ldflags '$(LDFLAGS)' -o $(BR_BIN_PATH) cmd/br/*.go

build/rawkv-helper:
cd tests/rawkv && $(GO) build -mod=mod -o ../../bin/rawkv client.go
build/rawkv-integration-test:
cd tests/rawkv && $(GO) build -mod=mod -o ../../bin/rawkv_test *.go

build/br-test:
@make failpoint/enable
Expand Down
2 changes: 1 addition & 1 deletion br/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.7.0
github.com/tikv/client-go/v2 v2.0.1-0.20220720064224-aa9ded37d17d
github.com/tikv/client-go/v2 v2.0.1-0.20220721031657-e38d2b07de3f
github.com/tikv/pd/client v0.0.0-20220307081149-841fa61e9710
go.uber.org/goleak v1.1.12
go.uber.org/multierr v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions br/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2/go.mod h1:2PfKggNGDuadAa0LElHrByyrz4JPZ9fFx6Gs7nx7ZZU=
github.com/tikv/client-go/v2 v2.0.0-rc.0.20220217140116-589cf79b2ab5/go.mod h1:gaHSp8rnxZ0w36qb6QPPNPh9P0Mu5vAEwCQcc0Brni4=
github.com/tikv/client-go/v2 v2.0.1-0.20220720064224-aa9ded37d17d h1:xllx8pkveVLcnAkWIa+cRpCVckbJF7LHS+9pURqp0Ig=
github.com/tikv/client-go/v2 v2.0.1-0.20220720064224-aa9ded37d17d/go.mod h1:UmDQEoeHXza8RSHBXVFERpxH54VBOf8yKZVphyel3l4=
github.com/tikv/client-go/v2 v2.0.1-0.20220721031657-e38d2b07de3f h1:fCAWVzUJYee1pDqYTBt5j2G1WuUfOL7A2mZoONoaHgs=
github.com/tikv/client-go/v2 v2.0.1-0.20220721031657-e38d2b07de3f/go.mod h1:UmDQEoeHXza8RSHBXVFERpxH54VBOf8yKZVphyel3l4=
github.com/tikv/pd/client v0.0.0-20220216070739-26c668271201/go.mod h1:fEvI5fhAuJn1Fn87VJF8ByE9Vc16EzWGoePZB21/nL8=
github.com/tikv/pd/client v0.0.0-20220216080339-1b8f82378ee7/go.mod h1:fEvI5fhAuJn1Fn87VJF8ByE9Vc16EzWGoePZB21/nL8=
github.com/tikv/pd/client v0.0.0-20220307081149-841fa61e9710 h1:jxgmKOscXSjaFEKQGRyY5qOpK8hLqxs2irb/uDJMtwk=
Expand Down
10 changes: 9 additions & 1 deletion br/pkg/rtree/rtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ var _ btree.Item = &Range{}
// All the ranges it stored do not overlap.
type RangeTree struct {
*btree.BTree
hasValidRange bool
}

// NewRangeTree returns an empty range tree.
func NewRangeTree() RangeTree {
return RangeTree{
BTree: btree.New(32),
BTree: btree.New(32),
hasValidRange: false,
}
}

Expand Down Expand Up @@ -140,6 +142,7 @@ func (rangeTree *RangeTree) Update(rg Range) {
rangeTree.Delete(item)
}
rangeTree.ReplaceOrInsert(&rg)
rangeTree.hasValidRange = true
}

// Put forms a range and inserts it into tree.
Expand Down Expand Up @@ -215,5 +218,10 @@ func (rangeTree *RangeTree) GetIncompleteRange(
append(incomplete, Range{StartKey: start, EndKey: end})
}
}
// is no valid range in Btree, and startKey/endKey are both empty, incomplete is empty too.
// This is not the result we need, append the whole input range.
if !rangeTree.hasValidRange && len(incomplete) == 0 {
incomplete = append(incomplete, Range{StartKey: startKey, EndKey: endKey})
}
return incomplete
}
8 changes: 8 additions & 0 deletions br/pkg/rtree/rtree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ func newRange(start, end []byte) *rtree.Range {
}
}

func TestEmptyRange(t *testing.T) {
rangeTree := rtree.NewRangeTree()
inCompelete := rangeTree.GetIncompleteRange([]byte(""), []byte(""))
require.Equal(t, len(inCompelete), 1)
require.Equal(t, inCompelete[0].StartKey, []byte(""))
require.Equal(t, inCompelete[0].EndKey, []byte(""))
}

func TestRangeTree(t *testing.T) {
rangeTree := rtree.NewRangeTree()
require.Nil(t, rangeTree.Get(newRange([]byte(""), []byte(""))))
Expand Down
Loading