This repository has been archived by the owner on Dec 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix several issues (partially close #42)
* RouterCallImpl: fix decoding responce from storage_ref * RouterCallImpl: fix decoding responce from storage_map * BucketDiscovery: check res for nil * BucketStat: decode bsInfo by ptr * Add tnt tests for disvoery logic * Add tnt tests for RouterCallImpl * Add tnt tests for RouterMapCallRWImpl
- Loading branch information
1 parent
7938584
commit 0035bcc
Showing
10 changed files
with
229 additions
and
44 deletions.
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
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
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
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,65 @@ | ||
package tnt_test | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"testing" | ||
"time" | ||
|
||
vshardrouter "github.com/KaymeKaydex/go-vshard-router" | ||
"github.com/KaymeKaydex/go-vshard-router/providers/static" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestBucketDiscovery(t *testing.T) { | ||
if !isCorrectRun() { | ||
log.Printf("Incorrect run of tnt-test framework") | ||
return | ||
} | ||
|
||
t.Parallel() | ||
|
||
ctx := context.Background() | ||
|
||
cfg := getCfg() | ||
|
||
router, err := vshardrouter.NewRouter(ctx, vshardrouter.Config{ | ||
TopologyProvider: static.NewProvider(cfg), | ||
DiscoveryTimeout: 5 * time.Second, | ||
DiscoveryMode: vshardrouter.DiscoveryModeOn, | ||
TotalBucketCount: totalBucketCount, | ||
User: defaultTntUser, | ||
Password: defaultTntPassword, | ||
}) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// pick some random bucket | ||
bucketID := randBucketID(totalBucketCount) | ||
|
||
// clean everything | ||
router.RouteMapClean() | ||
|
||
// resolve it | ||
rs, err := router.BucketResolve(ctx, bucketID) | ||
require.Nil(t, err, "BucketResolve ok") | ||
|
||
// reset it again | ||
router.BucketReset(bucketID) | ||
|
||
// call RouterRouteAll, because: | ||
// 1. increase coverage | ||
// 2. we cannot get replicaset uuid by rs instance (lack of interface) | ||
rsMap := router.RouterRouteAll() | ||
for k, v := range rsMap { | ||
if v == rs { | ||
// set it again | ||
res, err := router.BucketSet(bucketID, k) | ||
require.Nil(t, err, nil, "BucketSet ok") | ||
require.Equal(t, res, rs, "BucketSet res ok") | ||
break | ||
} | ||
} | ||
} |
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
Oops, something went wrong.