Skip to content

Commit

Permalink
fix Yuce's comments 2
Browse files Browse the repository at this point in the history
  • Loading branch information
kmetin committed Oct 19, 2023
1 parent 0c7028c commit f50a1de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
18 changes: 3 additions & 15 deletions base/commands/migration/start_stages_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,20 @@ func startMigrationTest(t *testing.T, expectedErr error, statusMapStateFiles []s
defer wg.Done()
execErr = tcx.CLC().Execute(ctx, "start", "dmt-config", "--yes")
})
c := make(chan string, 1)
wg.Add(1)
c := make(chan string)
go findMigrationID(ctx, tcx, c)
mID := <-c
wg.Done()
wg.Add(1)
go migrationRunner(ctx, tcx, mID, &wg, statusMapStateFiles)
wg.Wait()
if expectedErr == nil {
require.Equal(t, nil, execErr)
}
if expectedErr != nil {
} else {
require.Contains(t, execErr.Error(), expectedErr.Error())
}
tcx.WithReset(func() {
f := fmt.Sprintf("migration_report_%s.txt", mID)
require.Equal(t, true, fileExists(f))
require.Equal(t, true, paths.Exists(f))
Must(os.Remove(f))
b := MustValue(os.ReadFile(paths.ResolveLogPath("test")))
for _, m := range ci.OrderedMembers() {
Expand Down Expand Up @@ -122,12 +119,3 @@ func findMigrationID(ctx context.Context, tcx it.TestContext, c chan string) {
}
}
}

func fileExists(filename string) bool {
MustValue(os.Getwd())
_, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
return true
}
17 changes: 8 additions & 9 deletions base/commands/migration/status_stages_it_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
_ "github.com/hazelcast/hazelcast-commandline-client/base"
_ "github.com/hazelcast/hazelcast-commandline-client/base/commands"
"github.com/hazelcast/hazelcast-commandline-client/base/commands/migration"
"github.com/hazelcast/hazelcast-commandline-client/clc/paths"
. "github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/it"
hz "github.com/hazelcast/hazelcast-go-client"
Expand Down Expand Up @@ -70,16 +71,14 @@ func statusTest(t *testing.T) {
tcx.AssertStdoutContains("Connected to the migration cluster")
tcx.WithReset(func() {
f := fmt.Sprintf("migration_report_%s.txt", mID)
require.Equal(t, true, fileExists(f))
require.Equal(t, true, paths.Exists(f))
Must(os.Remove(f))
/*
b := MustValue(os.ReadFile(paths.DefaultLogPath(time.Now())))
for _, m := range ci.OrderedMembers() {
require.Contains(t, string(b), fmt.Sprintf("[%s_%s] log1", mID, m.UUID.String()))
require.Contains(t, string(b), fmt.Sprintf("[%s_%s] log2", mID, m.UUID.String()))
require.Contains(t, string(b), fmt.Sprintf("[%s_%s] log3", mID, m.UUID.String()))
}
*/
b := MustValue(os.ReadFile(paths.ResolveLogPath("test")))
for _, m := range ci.OrderedMembers() {
require.Contains(t, string(b), fmt.Sprintf("[%s_%s] log1", mID, m.UUID.String()))
require.Contains(t, string(b), fmt.Sprintf("[%s_%s] log2", mID, m.UUID.String()))
require.Contains(t, string(b), fmt.Sprintf("[%s_%s] log3", mID, m.UUID.String()))
}
})
})
}
Expand Down

0 comments on commit f50a1de

Please sign in to comment.