diff --git a/engine/pkg/cmd/cli/cli_job.go b/engine/pkg/cmd/cli/cli_job.go index e2152610aab..c59610f545e 100644 --- a/engine/pkg/cmd/cli/cli_job.go +++ b/engine/pkg/cmd/cli/cli_job.go @@ -22,11 +22,14 @@ import ( "github.com/pingcap/tiflow/engine/enginepb" "github.com/spf13/cobra" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "github.com/pingcap/tiflow/engine/pkg/tenant" - "github.com/pingcap/tiflow/pkg/errors" ) +// defaultMasterAddr is the default master address. +const defaultMasterAddr = "127.0.0.1:10240" + // jobGeneralOptions defines some general options of job management type jobGeneralOptions struct { projectID string @@ -61,12 +64,13 @@ func (o *jobGeneralOptions) addFlags(cmd *cobra.Command) { // validate checks that the provided job options are valid. func (o *jobGeneralOptions) validate(ctx context.Context, cmd *cobra.Command) error { if len(o.masterAddrs) == 0 { - return errors.ErrInvalidCliParameter.GenWithStack("master-addrs can't be nil") + o.masterAddrs = []string{defaultMasterAddr} + log.Warn("the master-addrs are not assigned, use default addr: " + defaultMasterAddr) } // TODO support https. dialURL := o.masterAddrs[0] - grpcConn, err := grpc.Dial(dialURL) + grpcConn, err := grpc.Dial(dialURL, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { return perrors.Trace(err) } diff --git a/engine/pkg/cmd/cli/cli_job_create.go b/engine/pkg/cmd/cli/cli_job_create.go index 25b087ed72a..d214398ebc2 100644 --- a/engine/pkg/cmd/cli/cli_job_create.go +++ b/engine/pkg/cmd/cli/cli_job_create.go @@ -34,6 +34,7 @@ type jobCreateOptions struct { jobTypeStr string jobConfigStr string + jobID string jobType engineModel.JobType jobConfig []byte } @@ -50,8 +51,9 @@ func (o *jobCreateOptions) addFlags(cmd *cobra.Command) { return } - cmd.Flags().StringVar(&o.jobTypeStr, "job-type", "", "job type") + cmd.Flags().StringVar(&o.jobTypeStr, "job-type", "", "job type, one of [FakeJob, CVSDemo, DM]") cmd.Flags().StringVar(&o.jobConfigStr, "job-config", "", "path of config file for the job") + cmd.Flags().StringVar(&o.jobID, "job-id", "", "job id") } // validate checks that the provided job options are valid. @@ -77,6 +79,10 @@ func (o *jobCreateOptions) validate(ctx context.Context, cmd *cobra.Command) err } func openFileAndReadString(path string) (content []byte, err error) { + if path == "" { + log.Warn("create job with empty config file") + return nil, nil + } fp, err := os.Open(path) if err != nil { return nil, err diff --git a/engine/test/integration_tests/run.sh b/engine/test/integration_tests/run.sh index e059ddd773c..5870bbba762 100755 --- a/engine/test/integration_tests/run.sh +++ b/engine/test/integration_tests/run.sh @@ -11,10 +11,11 @@ mkdir -p $OUT_DIR || true if [ "${1-}" = 'debug' ]; then shift - if [[ ${1} ]]; then + if [[ $# -lt 0 ]]; then cnf=$* else cnf="$DOCKER_COMPOSE_DIR/1m1e.yaml" + echo "got empty file, use default config: ${cnf}" fi trap "stop_engine_cluster $cnf" EXIT