Skip to content

Commit

Permalink
fix Yuce's PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kutluhanmetin committed Nov 3, 2023
1 parent f47341f commit e4a7c2c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 2 additions & 4 deletions base/commands/migration/estimate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ func (e EstimateCmd) Init(cc plug.InitContext) error {

func (e EstimateCmd) Exec(ctx context.Context, ec plug.ExecContext) error {
ec.PrintlnUnnecessary("")
ec.PrintlnUnnecessary(`Hazelcast Data Migration Tool v5.3.0
(c) 2023 Hazelcast, Inc.
ec.PrintlnUnnecessary(fmt.Sprintf(`%s
Estimation usually ends within 15 seconds.
`)
Estimation usually ends within 15 seconds.`, banner))
mID := MakeMigrationID()
stages, err := NewEstimateStages(ec.Logger(), mID, ec.GetStringArg(argDMTConfig))
if err != nil {
Expand Down
12 changes: 5 additions & 7 deletions base/commands/migration/estimate_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,28 @@ func TestEstimate(t *testing.T) {
wg.Add(1)
go func() {
defer wg.Done()
check.Must(tcx.CLC().Execute(ctx, "estimate", "dmt-config"))
check.Must(tcx.CLC().Execute(ctx, "estimate", "testdata/dmt-config"))
}()
c := make(chan string)
go findEstimationID(ctx, tcx, c)
mID := <-c
go estimateRunner(t, ctx, tcx, mID)
go estimateRunner(ctx, tcx, mID)
wg.Wait()
tcx.AssertStdoutContains("OK Estimation completed successfully")
})
}

func estimateRunner(t *testing.T, ctx context.Context, tcx it.TestContext, migrationID string) {
func estimateRunner(ctx context.Context, tcx it.TestContext, migrationID string) {
statusMap := check.MustValue(tcx.Client.GetMap(ctx, migration.StatusMapName))
b := check.MustValue(os.ReadFile("testdata/estimate/estimate_completed.json"))
it.Eventually(t, func() bool {
return statusMap.Set(ctx, migrationID, serialization.JSON(b)) == nil
})
check.Must(statusMap.Set(ctx, migrationID, serialization.JSON(b)))
}

func findEstimationID(ctx context.Context, tcx it.TestContext, c chan string) {
q := check.MustValue(tcx.Client.GetQueue(ctx, migration.EstimateQueueName))
var b migration.ConfigBundle
for {
v := check.MustValue(q.PollWithTimeout(ctx, time.Second))
v := check.MustValue(q.PollWithTimeout(ctx, 100*time.Millisecond))
if v != nil {
check.Must(json.Unmarshal(v.(serialization.JSON), &b))
c <- b.MigrationID
Expand Down
2 changes: 1 addition & 1 deletion base/commands/migration/start_stages_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "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)
Expand Down

0 comments on commit e4a7c2c

Please sign in to comment.