This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
backupmeta: add cluster_version and br_version info in backupmeta #734
Merged
Merged
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
968de9f
add version info
lichunzhu 395022e
update go.mod1
lichunzhu 567ec92
resolve conflicts
lichunzhu 14a0e81
merge master and resolve conflicts
lichunzhu 73b1ff6
update tidb dependency
lichunzhu 5723389
update go.sum
lichunzhu 9393900
fix make check
lichunzhu e28d063
fix cluster_id field
lichunzhu 93ae63f
refine br_backup_version test
lichunzhu 4a1d975
update test
lichunzhu e7dca2e
try fix
lichunzhu dcf5933
fix test
lichunzhu 9e40e81
fix test
lichunzhu 35bc9a3
Merge branch 'master' into addVersions
lichunzhu 7b4365c
add unit tests
lichunzhu 1bc3f63
Merge branch 'master' into addVersions
lichunzhu bdd2b24
Merge branch 'master' into addVersions
lichunzhu 8b25a61
Merge branch 'master' into addVersions
lichunzhu 101a347
Update pkg/glue/glue.go
lichunzhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,3 +55,8 @@ func (Glue) StartProgress(ctx context.Context, cmdName string, total int64, redi | |
func (Glue) Record(name string, val uint64) { | ||
summary.CollectUint(name, val) | ||
} | ||
|
||
// GetVersion implements glue.Glue. | ||
func (Glue) GetVersion() string { | ||
return "BR\n" + utils.BRInfo() | ||
} | ||
Comment on lines
+60
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a unit test to make sure the version matches a certain pattern. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed in 7b4365c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package gluetikv | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/pingcap/check" | ||
) | ||
|
||
type testGlue struct{} | ||
|
||
var _ = Suite(&testGlue{}) | ||
|
||
func TestT(t *testing.T) { | ||
TestingT(t) | ||
} | ||
|
||
func (r *testGlue) TestGetVersion(c *C) { | ||
g := Glue{} | ||
c.Assert(g.GetVersion(), Matches, "BR(.|\n)*Release Version(.|\n)*Git Commit Hash(.|\n)*") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2021 PingCAP, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -eu | ||
DB="$TEST_NAME" | ||
|
||
# example | ||
# "cluster_id": 6931331682760961243 | ||
expected_cluster_id=`run_curl "https://$PD_ADDR/pd/api/v1/members" | grep "cluster_id"` | ||
# example | ||
#"4.0.10" | ||
expected_cluster_version=`run_curl "https://$PD_ADDR/pd/api/v1/config/cluster-version"` | ||
unset BR_LOG_TO_TERM | ||
|
||
function check_version() { | ||
folder=$1 | ||
expected_br_version=$2 | ||
br_version=`run_br -s "local://$TEST_DIR/$folder" debug decode --field "BrVersion"` | ||
[[ $br_version =~ $expected_br_version ]] | ||
cluster_version=`run_br -s "local://$TEST_DIR/$folder" debug decode --field "ClusterVersion"` | ||
[[ $cluster_version =~ $expected_cluster_version ]] | ||
cluster_id=`run_br -s "local://$TEST_DIR/$folder" debug decode --field "ClusterId" | sed -n -e '1p'` | ||
[[ $expected_cluster_id =~ $cluster_id ]] | ||
} | ||
|
||
# backup empty using BR | ||
echo "backup start..." | ||
run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/br_version_1" --ratelimit 5 --concurrency 4 | ||
if [ $? -ne 0 ]; then | ||
echo "TEST: [$TEST_NAME] failed on backup empty cluster version!" | ||
exit 1 | ||
fi | ||
|
||
check_version "br_version_1" "BR" | ||
|
||
# backup empty using BR via SQL | ||
echo "backup start..." | ||
run_sql "BACKUP DATABASE $DB TO \"local://$TEST_DIR/br_version_2\"" | ||
|
||
# FIXME: uncomment this after TiDB updates this BR dependency | ||
# check_version "br_version_2" "TiDB" | ||
|
||
# create a database and insert some data | ||
run_sql "CREATE DATABASE $DB;" | ||
run_sql "CREATE TABLE $DB.usertable1 ( \ | ||
YCSB_KEY varchar(64) NOT NULL, \ | ||
FIELD0 varchar(1) DEFAULT NULL, \ | ||
PRIMARY KEY (YCSB_KEY) \ | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;" | ||
# insert one row to make sure table is restored. | ||
run_sql "INSERT INTO $DB.usertable1 VALUES (\"a\", \"b\");" | ||
|
||
# backup tables using BR | ||
echo "backup start..." | ||
run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/br_version_3" --ratelimit 5 --concurrency 4 | ||
if [ $? -ne 0 ]; then | ||
echo "TEST: [$TEST_NAME] failed on backup empty cluster version!" | ||
exit 1 | ||
fi | ||
|
||
check_version "br_version_3" "BR" | ||
|
||
# backup tables using BR via SQL | ||
echo "backup start..." | ||
run_sql "BACKUP DATABASE $DB TO \"local://$TEST_DIR/br_version_4\"" | ||
|
||
# FIXME: uncomment this after TiDB updates this BR dependency | ||
# check_version "br_version_4" "TiDB" | ||
|
||
run_sql "DROP DATABASE $DB" | ||
echo "TEST: [$TEST_NAME] successed!" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a unit test to tests if these three fields are set correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 7b4365c