diff --git a/base/commands/migration/estimate.go b/base/commands/migration/estimate.go index ecd4a5a0..8dde2888 100644 --- a/base/commands/migration/estimate.go +++ b/base/commands/migration/estimate.go @@ -6,6 +6,7 @@ import ( "context" "fmt" + "github.com/hazelcast/hazelcast-commandline-client/clc/paths" "github.com/hazelcast/hazelcast-commandline-client/clc/ux/stage" "github.com/hazelcast/hazelcast-commandline-client/internal/check" "github.com/hazelcast/hazelcast-commandline-client/internal/plug" @@ -27,8 +28,12 @@ func (e EstimateCmd) Exec(ctx context.Context, ec plug.ExecContext) error { ec.PrintlnUnnecessary(fmt.Sprintf(`%s Estimation usually ends within 15 seconds.`, banner)) + conf := ec.GetStringArg(argDMTConfig) + if !paths.Exists(conf) { + return fmt.Errorf("migration config does not exist: %s", conf) + } mID := MakeMigrationID() - stages, err := NewEstimateStages(ec.Logger(), mID, ec.GetStringArg(argDMTConfig)) + stages, err := NewEstimateStages(ec.Logger(), mID, conf) if err != nil { return err } diff --git a/base/commands/migration/estimate_it_test.go b/base/commands/migration/estimate_it_test.go index b21da4fc..5779197d 100644 --- a/base/commands/migration/estimate_it_test.go +++ b/base/commands/migration/estimate_it_test.go @@ -25,7 +25,7 @@ func TestEstimate(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - check.Must(tcx.CLC().Execute(ctx, "estimate", "testdata/dmt-config")) + check.Must(tcx.CLC().Execute(ctx, "estimate", "testdata/dmt_config")) }() c := make(chan string) go findEstimationID(ctx, tcx, c) diff --git a/base/commands/migration/migration_start.go b/base/commands/migration/migration_start.go index 84368199..499b1eae 100644 --- a/base/commands/migration/migration_start.go +++ b/base/commands/migration/migration_start.go @@ -4,8 +4,10 @@ package migration import ( "context" + "fmt" "github.com/hazelcast/hazelcast-commandline-client/clc" + "github.com/hazelcast/hazelcast-commandline-client/clc/paths" "github.com/hazelcast/hazelcast-commandline-client/clc/ux/stage" clcerrors "github.com/hazelcast/hazelcast-commandline-client/errors" "github.com/hazelcast/hazelcast-commandline-client/internal/check" @@ -41,6 +43,10 @@ func (StartCmd) Exec(ctx context.Context, ec plug.ExecContext) (err error) { Selected data structures in the source cluster will be migrated to the target cluster. `) + conf := ec.GetStringArg(argDMTConfig) + if !paths.Exists(conf) { + return fmt.Errorf("migration config does not exist: %s", conf) + } if !ec.Props().GetBool(clc.FlagAutoYes) { p := prompt.New(ec.Stdin(), ec.Stdout()) yes, err := p.YesNo("Proceed?") @@ -59,7 +65,7 @@ Selected data structures in the source cluster will be migrated to the target cl err = finalizeErr } }() - sts, err := NewStartStages(ec.Logger(), mID, ec.GetStringArg(argDMTConfig)) + sts, err := NewStartStages(ec.Logger(), mID, conf) if err != nil { return err } diff --git a/base/commands/migration/start_stages_it_test.go b/base/commands/migration/start_stages_it_test.go index a1634de4..07334100 100644 --- a/base/commands/migration/start_stages_it_test.go +++ b/base/commands/migration/start_stages_it_test.go @@ -67,7 +67,7 @@ func startMigrationTest(t *testing.T, expectedErr error, statusMapStateFiles []s var execErr error go tcx.WithReset(func() { defer wg.Done() - execErr = tcx.CLC().Execute(ctx, "start", "testdata/dmt-config", "--yes", "-o", outDir) + execErr = tcx.CLC().Execute(ctx, "start", "testdata/dmt_config", "--yes", "-o", outDir) }) c := make(chan string) go findMigrationID(ctx, tcx, c)