-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is not correct to use WithPrefix. Range end will change in every batch.
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package mirror | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"testing" | ||
|
||
"github.com/coreos/etcd/integration" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
func TestSyncBase(t *testing.T) { | ||
cluster := integration.NewClusterV3(nil, &integration.ClusterConfig{Size: 1, UseGRPC: true}) | ||
defer cluster.Terminate(nil) | ||
|
||
cli := cluster.Client(0) | ||
ctx := context.TODO() | ||
|
||
for i := 0; i < 2000; i++ { | ||
if _, err := cli.Put(ctx, fmt.Sprint("test%d", i), "test"); err != nil { | ||
log.Panic(err) | ||
} | ||
} | ||
|
||
syncer := NewSyncer(cli, "test", 0) | ||
respCh, _ := syncer.SyncBase(ctx) | ||
|
||
count := 0 | ||
|
||
for resp := range respCh { | ||
count = count + len(resp.Kvs) | ||
if !resp.More { | ||
break | ||
} | ||
} | ||
|
||
if count != 2000 { | ||
t.Fatalf("unexpected kv count: %d", count) | ||
} | ||
} |