Skip to content

Commit

Permalink
Merge branch 'master' into pkg-filter-testify
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Sep 30, 2021
2 parents 530ad5f + 5a68e86 commit 722335a
Show file tree
Hide file tree
Showing 56 changed files with 133 additions and 37 deletions.
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func NewCmdCli() *cobra.Command {
util.LogHTTPProxies()
return nil
},
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
// Whether to run interactively or not.
if o.interact {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func newCmdCapture(f factory.Factory) *cobra.Command {
cmds := &cobra.Command{
Use: "capture",
Short: "Manage capture (capture is a CDC server instance)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return o.run(f)
},
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_capture_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func newCmdListCapture(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "list",
Short: "List all captures in TiCDC cluster",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func newCmdChangefeed(f factory.Factory) *cobra.Command {
cmds := &cobra.Command{
Use: "changefeed",
Short: "Manage changefeed (changefeed is a replication task)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return o.run(f)
},
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_changefeed_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ func newCmdCreateChangefeed(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "create",
Short: "Create a new replication task (changefeed)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmdcontext.GetDefaultContext()

Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_changefeed_cyclic_create_marktables.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func newCmdCyclicCreateMarktables(f factory.Factory) *cobra.Command {
&cobra.Command{
Use: "create-marktables",
Short: "Create cyclic replication mark tables",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_changefeed_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func newCmdListChangefeed(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "list",
Short: "List all replication tasks (changefeeds) in TiCDC cluster",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_changefeed_pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func newCmdPauseChangefeed(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "pause",
Short: "Pause a replication task (changefeed)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_changefeed_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func newCmdQueryChangefeed(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "query",
Short: "Query information and status of a replication task (changefeed)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_changefeed_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func newCmdRemoveChangefeed(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "remove",
Short: "Remove a replication task (changefeed)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_changefeed_resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func newCmdResumeChangefeed(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "resume",
Short: "Resume a paused replication task (changefeed)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_changefeed_statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func newCmdStatisticsChangefeed(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "statistics",
Short: "Periodically check and output the status of a replication task (changefeed)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_changefeed_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ func newCmdUpdateChangefeed(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "update",
Short: "Update config of an existing replication task (changefeed)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func newCmdProcessor(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "processor",
Short: "Manage processor (processor is a sub replication task running on a specified capture)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return o.run(f)
},
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_processor_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func newCmdListProcessor(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "list",
Short: "List all processors in TiCDC cluster",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_processor_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func newCmdQueryProcessor(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "query",
Short: "Query information and status of a sub replication task (processor)",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
43 changes: 43 additions & 0 deletions pkg/cmd/cli/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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.

package cli

import (
"os"

"github.com/pingcap/check"
"github.com/pingcap/ticdc/pkg/util/testleak"
)

type cliSuite struct{}

var _ = check.Suite(&cliSuite{})

func (s *cliSuite) TestCliCmdNoArgs(c *check.C) {
defer testleak.AfterTest(c)
cmd := NewCmdCli()
// There is a DBC space before the flag pd.
flags := []string{"--log-level=info", " --pd="}
os.Args = flags
err := cmd.Execute()
c.Assert(err, check.NotNil)
c.Assert(err, check.ErrorMatches, ".*unknown command.*u3000--pd.*for.*cli.*")

// There is an unknown args "aa".
flags = []string{"--log-level=info", "aa"}
os.Args = flags
err = cmd.Execute()
c.Assert(err, check.NotNil)
c.Assert(err, check.ErrorMatches, ".*unknown command.*aa.*for.*cli.*")
}
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_tso_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func newCmdQueryTso(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "query",
Short: "Get tso from PD",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_unsafe_delete_service_gc_safepoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func newCmdDeleteServiceGcSafepoint(f factory.Factory, commonOptions *unsafeComm
command := &cobra.Command{
Use: "delete-service-gc-safepoint",
Short: "Delete CDC service GC safepoint in PD, confirm that you know what this command will do and use it at your own risk",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if err := commonOptions.confirmMetaDelete(cmd); err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_unsafe_reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func newCmdReset(f factory.Factory, commonOptions *unsafeCommonOptions) *cobra.C
command := &cobra.Command{
Use: "reset",
Short: "Reset the status of the TiCDC cluster, delete all meta data in etcd, confirm that you know what this command will do and use it at your own risk",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if err := commonOptions.confirmMetaDelete(cmd); err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cli/cli_unsafe_show_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func newCmdShowMetadata(f factory.Factory) *cobra.Command {
command := &cobra.Command{
Use: "show-metadata",
Short: "Show metadata stored in PD",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(f)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func NewCmdServer() *cobra.Command {
command := &cobra.Command{
Use: "server",
Short: "Start a TiCDC capture server",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
err := o.complete(cmd)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func NewCmdVersion() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Output version information",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
cmd.Println(version.GetRawInfo())
},
Expand Down
30 changes: 30 additions & 0 deletions tests/_utils/run_cdc_cli_tso_query
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#
# Copyright 2020 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 -eux

# parameter 1: pd host
# parameter 2: pd port
pd_host=${1}
pd_port=${2}

tso=$(run_cdc_cli tso query --pd=http://${pd_host}:${pd_port})
# make sure get tso only
# the tso got above is:
# "427768583921860609 PASS coverage: 2.7% of statements in github.com/pingcap/ticdc/..."
# and only "427768583921860609" is a real tso
echo $tso | awk -F " " '{print $1}'

set +x
2 changes: 1 addition & 1 deletion tests/availability/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function prepare() {
cd $WORK_DIR

# record tso before we create tables to skip the system table DDLs
start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})

run_sql "CREATE table test.availability1(id int primary key, val int);"
run_sql "CREATE table test.availability2(id int primary key, val int);"
Expand Down
1 change: 1 addition & 0 deletions tests/bank/bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func main() {
cmd := &cobra.Command{
Use: "bank",
Short: "bank is a testcase case that simulates bank scenarios",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
if len(upstream) == 0 || len(downstream) == 0 {
log.Fatal("upstream and downstream should not be empty")
Expand Down
2 changes: 1 addition & 1 deletion tests/batch_add_table/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function run() {
run_sql_file $CUR/data/prepare.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT}
run_sql_file $CUR/data/prepare.sql ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
# record tso before we create tables to skip the system table DDLs
start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})

run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY

Expand Down
2 changes: 1 addition & 1 deletion tests/capture_session_done_during_task/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function run() {
run_sql "CREATE table capture_session_done_during_task.t (id int primary key auto_increment, a int)" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
run_sql "CREATE DATABASE capture_session_done_during_task;" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
run_sql "CREATE table capture_session_done_during_task.t (id int primary key auto_increment, a int)" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})
run_sql "INSERT INTO capture_session_done_during_task.t values (),(),(),(),(),(),()" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
export GO_FAILPOINTS='github.com/pingcap/ticdc/cdc/processor/processorManagerHandleNewChangefeedDelay=sleep(2000)'
run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --addr "127.0.0.1:8300" --pd $pd_addr
Expand Down
2 changes: 1 addition & 1 deletion tests/cdc/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function prepare() {
cd $WORK_DIR

# record tso before we create tables to skip the system table DDLs
start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})

run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY

Expand Down
2 changes: 1 addition & 1 deletion tests/cdclog_file/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function prepare() {
cd $WORK_DIR

# record tso before we create tables to skip the system table DDLs
start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})

run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY

Expand Down
2 changes: 1 addition & 1 deletion tests/cdclog_s3/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function prepare() {
cd $WORK_DIR

# record tso before we create tables to skip the system table DDLs
start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})

run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY

Expand Down
2 changes: 1 addition & 1 deletion tests/changefeed_error/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function run() {

cd $WORK_DIR

start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})
run_sql "CREATE DATABASE changefeed_error;" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
go-ycsb load mysql -P $CUR/conf/workload -p mysql.host=${UP_TIDB_HOST} -p mysql.port=${UP_TIDB_PORT} -p mysql.user=root -p mysql.db=changefeed_error
export GO_FAILPOINTS='github.com/pingcap/ticdc/cdc/owner/NewChangefeedNoRetryError=1*return(true)'
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function run() {
pd_addr="http://$UP_PD_HOST_1:$UP_PD_PORT_1"

# record tso before we create tables to skip the system table DDLs
start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})
run_sql "CREATE table test.simple(id int primary key, val int);"
run_sql "CREATE table test.\`simple-dash\`(id int primary key, val int);"

Expand Down
2 changes: 1 addition & 1 deletion tests/common_1/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function run() {
fi

# record tso before we create tables to skip the system table DDLs
start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})

run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY

Expand Down
6 changes: 3 additions & 3 deletions tests/cyclic_ab/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ function run() {
}; done

# record tso after we create tables to not block on waiting mark tables DDLs.
start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})

# Echo y to ignore ineligible tables
echo "y" | run_cdc_cli changefeed create --start-ts=$start_ts \
--sink-uri="mysql://root@${DOWN_TIDB_HOST}:${DOWN_TIDB_PORT}/?safe-mode=false" \
--pd "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}" \
--cyclic-replica-id 1 \
--cyclic-filter-replica-ids 2 \
--cyclic-sync-ddl true
--cyclic-sync-ddl=true

run_cdc_cli changefeed create --start-ts=$start_ts \
--sink-uri="mysql://root@${UP_TIDB_HOST}:${UP_TIDB_PORT}/?safe-mode=false" \
--pd "http://${DOWN_PD_HOST}:${DOWN_PD_PORT}" \
--cyclic-replica-id 2 \
--cyclic-filter-replica-ids 1 \
--cyclic-sync-ddl false \
--cyclic-sync-ddl=false \
--config $CUR/conf/only_test_simple.toml

for i in $(seq 11 20); do {
Expand Down
Loading

0 comments on commit 722335a

Please sign in to comment.