diff --git a/cmd/executor/main.go b/cmd/executor/main.go index ccd216aa667..2be2e3bd788 100644 --- a/cmd/executor/main.go +++ b/cmd/executor/main.go @@ -9,9 +9,6 @@ import ( "syscall" "github.com/hanfei1991/microcosm/executor" - _ "github.com/hanfei1991/microcosm/executor/cvsTask" - _ "github.com/hanfei1991/microcosm/jobmaster/cvsJob" - "github.com/hanfei1991/microcosm/lib/registry" "github.com/pingcap/errors" "github.com/pingcap/tiflow/dm/pkg/log" "go.uber.org/zap" @@ -60,8 +57,6 @@ func main() { } }() - registry.LoadFake(registry.GlobalWorkerRegistry()) - // 4. run executor server server := executor.NewServer(cfg, nil) if err != nil { diff --git a/cmd/master-client/main.go b/cmd/master-client/main.go index 218e8a56335..afe4033b491 100644 --- a/cmd/master-client/main.go +++ b/cmd/master-client/main.go @@ -2,24 +2,15 @@ package main import ( "context" - "encoding/json" - "flag" "fmt" "os" - "strconv" - "github.com/hanfei1991/microcosm/client" "github.com/hanfei1991/microcosm/ctl" - "github.com/hanfei1991/microcosm/jobmaster/benchmark" - "github.com/hanfei1991/microcosm/pb" "github.com/pingcap/tiflow/dm/pkg/log" - "github.com/pkg/errors" ) func main() { - cmd := os.Args[1] ctx := context.Background() - addr := "" err := log.InitLogger(&log.Config{ Level: "info", }) @@ -27,80 +18,5 @@ func main() { fmt.Printf("err: %v", err) os.Exit(1) } - switch cmd { - case "submit-job", "cancel-job": - flag1 := os.Args[2] - if flag1 != "--master-addr" { - fmt.Printf("no master address found") - os.Exit(1) - } - addr = os.Args[3] - case "run-fake": - ctl.MainStart(ctx, os.Args[1:]) - os.Exit(0) - default: - fmt.Printf("submit-job --config configFile") - os.Exit(0) - } - clt, err := client.NewMasterClient(ctx, []string{addr}) - if err != nil { - fmt.Printf("err: %v", err) - os.Exit(1) - } - - if cmd == "submit-job" { - args := os.Args[4:] - cfg := benchmark.NewConfig() - err = cfg.Parse(args) - switch errors.Cause(err) { - case nil: - case flag.ErrHelp: - os.Exit(0) - default: - fmt.Printf("err1: %v", err) - os.Exit(2) - } - - configJSON, err := json.Marshal(cfg) - if err != nil { - fmt.Printf("err2: %v", err) - } - - req := &pb.SubmitJobRequest{ - Tp: pb.JobType_Benchmark, - Config: configJSON, - User: "hanfei", - } - resp, err := clt.SubmitJob(context.Background(), req) - if err != nil { - fmt.Printf("err: %v", err) - return - } - if resp.Err != nil { - fmt.Printf("err: %v", resp.Err.Message) - return - } - fmt.Printf("submit job successful JobID:%d JobIDStr:%s\n", resp.JobId, resp.JobIdStr) - } - if cmd == "cancel-job" { - flag1 := os.Args[4] - jobID, err := strconv.ParseInt(flag1, 10, 32) - if err != nil { - fmt.Print(err.Error()) - os.Exit(1) - } - req := &pb.CancelJobRequest{ - JobId: int32(jobID), - } - resp, err := clt.CancelJob(context.Background(), req) - if err != nil { - fmt.Printf("err: %v", err) - return - } - if resp.Err != nil { - fmt.Printf("err: %v", resp.Err.Message) - return - } - fmt.Print("cancel job successful") - } + ctl.MainStart(ctx, os.Args[1:]) } diff --git a/ctl/cmd.go b/ctl/cmd.go index 218742bcfbd..09873904dca 100644 --- a/ctl/cmd.go +++ b/ctl/cmd.go @@ -6,10 +6,6 @@ import ( "io/ioutil" "os" - "github.com/google/uuid" - "github.com/hanfei1991/microcosm/client" - "github.com/hanfei1991/microcosm/lib" - "github.com/hanfei1991/microcosm/model" "github.com/hanfei1991/microcosm/pb" "github.com/pingcap/tiflow/dm/pkg/log" "github.com/spf13/cobra" @@ -18,7 +14,7 @@ import ( func NewRunFake() *cobra.Command { cmd := &cobra.Command{ - Use: "run-fake [--executor-addr addr] [--executor-id id]", + Use: "submit-job", Short: "Run a fake workload to a specific executor", RunE: runFakeFunc, } @@ -38,16 +34,6 @@ func openFileAndReadString(path string) (content []byte, err error) { } func runFakeFunc(cmd *cobra.Command, _ []string) error { - execAddr, err := cmd.Flags().GetString("executor-addr") - if err != nil { - fmt.Print("error in parse `--executor-addr`") - return err - } - execID, err := cmd.Flags().GetString("executor-id") - if err != nil { - fmt.Print("error in parse `--executor-id`") - return err - } path, err := cmd.Flags().GetString("job-config") if err != nil { fmt.Print("error in parse `--job-config`") @@ -58,25 +44,16 @@ func runFakeFunc(cmd *cobra.Command, _ []string) error { fmt.Print("error in parse job-config") return err } - err = cltManager.AddExecutor(model.ExecutorID(execID), execAddr) - if err != nil { - return err - } ctx, cancel := context.WithTimeout(context.Background(), rpcTimeout) defer cancel() - log.L().Info("sending request to executor", zap.String("address", execAddr)) - resp, err := cltManager.ExecutorClient(model.ExecutorID(execID)).Send(ctx, &client.ExecutorRequest{ - Cmd: client.CmdDispatchTask, - Req: &pb.DispatchTaskRequest{ - TaskTypeId: int64(lib.CvsJobMaster), - TaskConfig: jobConfig, - MasterId: uuid.New().String(), // use a unique ID to force Init the master each time, - WorkerId: uuid.New().String(), - }, + resp, err := cltManager.MasterClient().SubmitJob(ctx, &pb.SubmitJobRequest{ + Tp: pb.JobType_CVSDemo, // TODO: Support different job types. + Config: jobConfig, + User: "hanfei", }) if err != nil { - log.L().Error("failed to dispatch master", zap.Error(err)) + log.L().Error("failed to submit job", zap.Error(err)) os.Exit(1) } log.L().Info("resp", zap.Any("resp", resp)) diff --git a/executor/cvsTask/cvstask.go b/executor/cvsTask/cvstask.go index 82202512381..bdf225194a8 100644 --- a/executor/cvsTask/cvstask.go +++ b/executor/cvsTask/cvstask.go @@ -46,7 +46,7 @@ type cvsTask struct { isEOF bool } -func init() { +func RegisterWorker() { constructor := func(ctx *dcontext.Context, id lib.WorkerID, masterID lib.MasterID, config lib.WorkerConfig) lib.Worker { return NewCvsTask(ctx, id, masterID, config) } diff --git a/executor/init.go b/executor/init.go index ebcbce8ad73..64ba9ac96ab 100644 --- a/executor/init.go +++ b/executor/init.go @@ -1,14 +1,11 @@ package executor import ( - "github.com/hanfei1991/microcosm/executor/runtime" - "github.com/hanfei1991/microcosm/executor/runtime/benchmark" - "github.com/hanfei1991/microcosm/executor/runtime/jobmaster" + cvstask "github.com/hanfei1991/microcosm/executor/cvsTask" + cvs "github.com/hanfei1991/microcosm/jobmaster/cvsJob" ) func init() { - // register operator builder for runtime - runtime.InitOpBuilders() - benchmark.RegisterBuilder() - jobmaster.RegisterBuilder() + cvstask.RegisterWorker() + cvs.RegisterWorker() } diff --git a/jobmaster/cvsJob/cvsJobMaster.go b/jobmaster/cvsJob/cvsJobMaster.go index aa930edd75b..f197d6d3586 100644 --- a/jobmaster/cvsJob/cvsJobMaster.go +++ b/jobmaster/cvsJob/cvsJobMaster.go @@ -46,7 +46,7 @@ type JobMaster struct { workerID lib.WorkerID } -func init() { +func RegisterWorker() { constructor := func(ctx *dcontext.Context, id lib.WorkerID, masterID lib.MasterID, config lib.WorkerConfig) lib.Worker { return NewCVSJobMaster(ctx, id, masterID, config) } @@ -113,10 +113,10 @@ func (jm *JobMaster) Tick(ctx context.Context) error { } status := worker.handle.Status() if status.Code == lib.WorkerStatusNormal { - num := status.Ext.(int64) - worker.curLoc = num - jm.counter += num - log.L().Info("cvs job tmp num ", zap.Any("id :", worker.handle.ID()), zap.Int64("counter: ", num)) + num := status.Ext.(*int64) + worker.curLoc = *num + jm.counter += *num + log.L().Debug("cvs job tmp num ", zap.Any("id :", worker.handle.ID()), zap.Int64("counter: ", *num)) // todo : store the sync progress into the meta store for each file } else if status.Code == lib.WorkerStatusFinished { // todo : handle error case here diff --git a/lib/common.go b/lib/common.go index b49b9581695..27f01b037d9 100644 --- a/lib/common.go +++ b/lib/common.go @@ -35,9 +35,11 @@ const ( const ( JobManager = WorkerType(iota + 1) + // job master CvsJobMaster DmJobMaster CdcJobMaster + // task CvsTask DmTask CdcTask diff --git a/lib/registry/load_fake.go b/lib/registry/register_fake.go similarity index 92% rename from lib/registry/load_fake.go rename to lib/registry/register_fake.go index 774c04ca318..e562573a291 100644 --- a/lib/registry/load_fake.go +++ b/lib/registry/register_fake.go @@ -13,7 +13,8 @@ const ( type FakeConfig struct{} -func LoadFake(registry Registry) { +// only for test. +func RegisterFake(registry Registry) { fakeMasterFactory := NewSimpleWorkerFactory(func(ctx *dcontext.Context, id lib.WorkerID, masterID lib.MasterID, config WorkerConfig) lib.Worker { return fake.NewFakeMaster(ctx, id, masterID, config) }, &FakeConfig{}) diff --git a/lib/registry/registry.go b/lib/registry/registry.go index 63512b5a277..c02042195a7 100644 --- a/lib/registry/registry.go +++ b/lib/registry/registry.go @@ -40,6 +40,7 @@ func (r *registryImpl) MustRegisterWorkerType(tp lib.WorkerType, factory WorkerF if ok := r.RegisterWorkerType(tp, factory); !ok { log.L().Panic("duplicate worker type", zap.Int64("worker-type", int64(tp))) } + log.L().Info("register worker", zap.Int64("worker-type", int64(tp))) } func (r *registryImpl) RegisterWorkerType(tp lib.WorkerType, factory WorkerFactory) (ok bool) { diff --git a/lib/registry/registry_test.go b/lib/registry/registry_test.go index f8db9eb18b8..1ed6e30a931 100644 --- a/lib/registry/registry_test.go +++ b/lib/registry/registry_test.go @@ -55,6 +55,6 @@ func TestRegistryWorkerTypeNotFound(t *testing.T) { func TestLoadFake(t *testing.T) { registry := NewRegistry() require.NotPanics(t, func() { - LoadFake(registry) + RegisterFake(registry) }) } diff --git a/pb/master.pb.go b/pb/master.pb.go index 015cd3f21d7..452751aa2eb 100644 --- a/pb/master.pb.go +++ b/pb/master.pb.go @@ -30,21 +30,21 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type JobType int32 const ( - JobType_Benchmark JobType = 0 - JobType_DM JobType = 1 - JobType_CDC JobType = 2 + JobType_CVSDemo JobType = 0 + JobType_DM JobType = 1 + JobType_CDC JobType = 2 ) var JobType_name = map[int32]string{ - 0: "Benchmark", + 0: "CVSDemo", 1: "DM", 2: "CDC", } var JobType_value = map[string]int32{ - "Benchmark": 0, - "DM": 1, - "CDC": 2, + "CVSDemo": 0, + "DM": 1, + "CDC": 2, } func (x JobType) String() string { @@ -235,7 +235,7 @@ func (m *SubmitJobRequest) GetTp() JobType { if m != nil { return m.Tp } - return JobType_Benchmark + return JobType_CVSDemo } func (m *SubmitJobRequest) GetConfig() []byte { @@ -876,7 +876,7 @@ func (m *ExecWorkload) GetTp() JobType { if m != nil { return m.Tp } - return JobType_Benchmark + return JobType_CVSDemo } func (m *ExecWorkload) GetUsage() int32 { @@ -1007,66 +1007,66 @@ func init() { func init() { proto.RegisterFile("master.proto", fileDescriptor_f9c348dec43a6705) } var fileDescriptor_f9c348dec43a6705 = []byte{ - // 931 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xdf, 0x6e, 0xe3, 0x44, - 0x17, 0x8f, 0xed, 0x24, 0x6d, 0x4e, 0xda, 0xd4, 0x99, 0xcd, 0xee, 0x7a, 0xd3, 0x7e, 0xf9, 0x2a, - 0x23, 0x20, 0x20, 0x51, 0x50, 0xf7, 0x02, 0xb4, 0x17, 0x48, 0xb4, 0x1b, 0x89, 0x16, 0xaa, 0x85, - 0xe9, 0x22, 0x90, 0x90, 0xa8, 0xc6, 0xc9, 0x69, 0x37, 0x1b, 0x27, 0x36, 0x33, 0xe3, 0x42, 0xde, - 0x82, 0x67, 0xe0, 0x69, 0x10, 0x57, 0x7b, 0xc9, 0x25, 0x6a, 0x1f, 0x83, 0x1b, 0x34, 0x63, 0x8f, - 0xe3, 0x38, 0xed, 0x2a, 0x17, 0xdc, 0xcd, 0xf9, 0x1d, 0x9f, 0xdf, 0xf9, 0x37, 0xe7, 0x8c, 0x61, - 0x6b, 0xca, 0x84, 0x44, 0x7e, 0x10, 0xf3, 0x48, 0x46, 0xc4, 0x8e, 0x83, 0x6e, 0x13, 0x39, 0x8f, - 0x32, 0xa0, 0xdb, 0xc2, 0x5f, 0x71, 0x98, 0xc8, 0x5c, 0xde, 0x99, 0xa2, 0x64, 0x42, 0x46, 0x1c, - 0x53, 0xc0, 0xff, 0xdd, 0x02, 0xf7, 0x4b, 0x64, 0x5c, 0x06, 0xc8, 0x24, 0xc5, 0x9f, 0x13, 0x14, - 0x92, 0xfc, 0x1f, 0x9a,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0x43, 0x0c, 0x0b, 0xe4, 0x4f, - 0xa0, 0xfe, 0x3a, 0x0a, 0x4c, 0x6d, 0x6b, 0x47, 0xb6, 0x67, 0xd1, 0xda, 0xeb, 0x28, 0x38, 0x19, - 0x91, 0x3d, 0x80, 0x54, 0x75, 0x21, 0xa4, 0x89, 0x7e, 0x53, 0xab, 0xce, 0x25, 0xf7, 0x4f, 0x61, - 0xe7, 0x1b, 0x96, 0x08, 0xfc, 0x2f, 0xb8, 0xc6, 0xd0, 0x2e, 0x64, 0xbd, 0x4e, 0x55, 0x17, 0xae, - 0xec, 0xb7, 0xbb, 0x72, 0x4a, 0xae, 0x3e, 0x06, 0x77, 0x11, 0xf6, 0x1a, 0x9e, 0xfc, 0x4f, 0xa0, - 0x5d, 0x28, 0xda, 0x3a, 0x16, 0x53, 0x78, 0x4c, 0xf1, 0x6a, 0xac, 0x86, 0x61, 0x90, 0x5d, 0x54, - 0x53, 0x21, 0x0f, 0x36, 0x54, 0x9f, 0x51, 0x88, 0xec, 0x2a, 0x1b, 0x51, 0x69, 0xae, 0x91, 0x8b, - 0x71, 0x34, 0xcb, 0xaa, 0x63, 0x44, 0xd2, 0x03, 0x18, 0xb2, 0x98, 0x05, 0xe3, 0x70, 0x2c, 0xe7, - 0x3a, 0x1f, 0x87, 0x16, 0x10, 0xff, 0x07, 0xf0, 0x56, 0xdd, 0xad, 0x53, 0xc3, 0xd2, 0x6c, 0xd9, - 0xe5, 0xd9, 0xf2, 0xaf, 0x61, 0xeb, 0x7c, 0xf8, 0x0a, 0x47, 0x49, 0x88, 0x2f, 0x99, 0x98, 0x90, - 0x77, 0xa0, 0x2a, 0x99, 0x98, 0x64, 0x74, 0x3b, 0x8a, 0x4e, 0xe1, 0x59, 0x72, 0x54, 0x2b, 0xd5, - 0xc5, 0x1b, 0x46, 0x42, 0x6a, 0x3a, 0x87, 0xea, 0x33, 0xf9, 0x08, 0x48, 0xcc, 0xf1, 0x12, 0x39, - 0xc7, 0xd1, 0x45, 0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- 0x67, 0x84, 0xde, 0xaa, 0xc2, 0xd0, 0x1d, 0x79, 0x7f, 0xdc, 0xf4, 0xac, 0x37, 0x37, 0x3d, 0xeb, - 0xef, 0x9b, 0x9e, 0xf5, 0xdb, 0x6d, 0xaf, 0xf2, 0xe6, 0xb6, 0x57, 0xf9, 0xeb, 0xb6, 0x57, 0x09, - 0xea, 0xfa, 0x3f, 0xe8, 0xe9, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4e, 0x9d, 0x1b, 0x29, 0x49, - 0x09, 0x00, 0x00, + // 929 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0x8f, 0xed, 0xa4, 0x6d, 0x5e, 0xba, 0xa9, 0x33, 0x9b, 0xdd, 0xf5, 0xa6, 0x25, 0x54, 0x46, + 0xb0, 0x11, 0x12, 0x05, 0x75, 0x0f, 0xa0, 0x3d, 0x20, 0xb1, 0x69, 0x24, 0x5a, 0xa8, 0x16, 0x26, + 0xcb, 0x1f, 0x09, 0x89, 0x6a, 0x9c, 0xbc, 0x96, 0x6c, 0x9d, 0xd8, 0xcc, 0x8c, 0x0b, 0xf9, 0x16, + 0x7c, 0x06, 0x3e, 0x0d, 0xe2, 0xb4, 0x47, 0x8e, 0xa8, 0xfd, 0x18, 0x5c, 0xd0, 0x8c, 0x3d, 0x8e, + 0xe3, 0xb4, 0xab, 0x1c, 0xf6, 0x36, 0xef, 0xf7, 0xfc, 0x7e, 0xef, 0xdf, 0xbc, 0x37, 0x86, 0xed, + 0x29, 0x13, 0x12, 0xf9, 0x41, 0xcc, 0x23, 0x19, 0x11, 0x3b, 0x0e, 0x3a, 0x0d, 0xe4, 0x3c, 0xca, + 0x80, 0x4e, 0x13, 0x7f, 0xc7, 0x51, 0x22, 0x73, 0x79, 0x67, 0x8a, 0x92, 0x09, 0x19, 0x71, 0x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4, 0x21, 0x2c, 0x63, 0x86, 0xad, 0x73, 0x9b, 0x2a, 0xa7, 0x3a, + 0x85, 0x87, 0x14, 0xe3, 0x88, 0x4b, 0xd3, 0xee, 0x7c, 0x82, 0x1e, 0xad, 0xdc, 0xe1, 0x8c, 0xd0, + 0x5b, 0x55, 0x18, 0xba, 0xe7, 0xde, 0x5f, 0xd7, 0x5d, 0xeb, 0xf5, 0x75, 0xd7, 0xfa, 0xf7, 0xba, + 0x6b, 0xfd, 0x71, 0xd3, 0xad, 0xbc, 0xbe, 0xe9, 0x56, 0xfe, 0xb9, 0xe9, 0x56, 0x82, 0x0d, 0xfd, + 0x17, 0xf4, 0xf4, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x90, 0x5f, 0x05, 0x47, 0x09, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/master.proto b/proto/master.proto index 5fb145a4e26..0fb5d8e5fe2 100644 --- a/proto/master.proto +++ b/proto/master.proto @@ -66,7 +66,7 @@ message HeartbeatResponse { } enum JobType { - Benchmark = 0; + CVSDemo = 0; DM = 1; CDC = 2; } diff --git a/sample/README.md b/sample/README.md index afcfe19cdf4..21a05c7e5ef 100644 --- a/sample/README.md +++ b/sample/README.md @@ -20,4 +20,4 @@ docker-compose -f ./3m3e.yaml -f ./demo.yaml up ## Use Master Client to Run Demo workload -./client.sh run-fake --master-addr server-master-0:10240 --job-config ./sample/config/demo.json --executor-id="random" --executor-addr="server-executor-0:10241" +./client.sh --master-addr server-master-0:10240 submit-job --job-config ./sample/config/demo.json diff --git a/servermaster/jobmanager.go b/servermaster/jobmanager.go index 866e27e4fe6..49a60670460 100644 --- a/servermaster/jobmanager.go +++ b/servermaster/jobmanager.go @@ -2,12 +2,12 @@ package servermaster import ( "context" + "encoding/json" "sync" "github.com/hanfei1991/microcosm/client" + cvs "github.com/hanfei1991/microcosm/jobmaster/cvsJob" "github.com/hanfei1991/microcosm/lib" - "github.com/hanfei1991/microcosm/lib/registry" - "github.com/hanfei1991/microcosm/model" "github.com/hanfei1991/microcosm/pb" dcontext "github.com/hanfei1991/microcosm/pkg/context" "github.com/hanfei1991/microcosm/pkg/errors" @@ -57,29 +57,32 @@ func (jm *JobManagerImplV2) CancelJob(ctx context.Context, req *pb.CancelJobRequ func (jm *JobManagerImplV2) SubmitJob(ctx context.Context, req *pb.SubmitJobRequest) *pb.SubmitJobResponse { log.L().Logger.Info("submit job", zap.String("config", string(req.Config))) resp := &pb.SubmitJobResponse{} - var masterConfig *model.JobMaster + var ( + id lib.WorkerID + err error + ) + // CreateWorker here is to create job master actually + // TODO: use correct worker cost switch req.Tp { - case pb.JobType_Benchmark: - masterConfig = &model.JobMaster{ - Tp: model.Benchmark, - Config: req.Config, + case pb.JobType_CVSDemo: + config := &cvs.Config{} + err = json.Unmarshal(req.Config, config) + if err != nil { + break } + id, err = jm.BaseMaster.CreateWorker( + lib.CvsJobMaster, config, defaultJobMasterCost) default: err := errors.ErrBuildJobFailed.GenWithStack("unknown job type", req.Tp) resp.Err = errors.ToPBError(err) return resp } - // CreateWorker here is to create job master actually - // TODO: use correct worker type and worker cost - id, err := jm.BaseMaster.CreateWorker( - registry.WorkerTypeFakeMaster, masterConfig, defaultJobMasterCost) if err != nil { log.L().Error("create job master met error", zap.Error(err)) resp.Err = errors.ToPBError(err) return resp } resp.JobIdStr = id - return resp } diff --git a/servermaster/jobmanager_test.go b/servermaster/jobmanager_test.go index a846004116b..d385cee11c3 100644 --- a/servermaster/jobmanager_test.go +++ b/servermaster/jobmanager_test.go @@ -32,8 +32,8 @@ func TestJobManagerSubmitJob(t *testing.T) { err := mockMaster.Init(ctx) require.Nil(t, err) req := &pb.SubmitJobRequest{ - Tp: pb.JobType_Benchmark, - Config: []byte(""), + Tp: pb.JobType_CVSDemo, + Config: []byte("{\"srcHost\":\"0.0.0.0:1234\", \"dstHost\":\"0.0.0.0:1234\", \"srcDir\":\"data\", \"dstDir\":\"data1\"}"), } resp := mgr.SubmitJob(ctx, req) require.Nil(t, resp.Err) diff --git a/test/job_test.go b/test/job_test.go index 87e1f8f48af..241b6a0f323 100644 --- a/test/job_test.go +++ b/test/job_test.go @@ -40,7 +40,7 @@ func (t *testJobSuite) testSubmit(c *C) { configBytes, err := json.Marshal(testJobConfig) c.Assert(err, IsNil) req := &pb.SubmitJobRequest{ - Tp: pb.JobType_Benchmark, + Tp: pb.JobType_CVSDemo, Config: configBytes, } resp, err := client.SubmitJob(context.Background(), req) @@ -99,7 +99,7 @@ func (t *testJobSuite) testPause(c *C) { configBytes, err := json.Marshal(testJobConfig) c.Assert(err, IsNil) req := &pb.SubmitJobRequest{ - Tp: pb.JobType_Benchmark, + Tp: pb.JobType_CVSDemo, Config: configBytes, } resp, err := client.SubmitJob(context.Background(), req)