本文整理汇总了Golang中github.com/cockroachdb/cockroach/util/leaktest.AfterTest函数的典型用法代码示例。如果您正苦于以下问题:Golang AfterTest函数的具体用法?Golang AfterTest怎么用?Golang AfterTest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AfterTest函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestTxnCoordSenderBeginTransactionMinPriority
// TestTxnCoordSenderBeginTransactionMinPriority verifies that when starting
// a new transaction, a non-zero priority is treated as a minimum value.
func TestTxnCoordSenderBeginTransactionMinPriority(t *testing.T) {
defer leaktest.AfterTest(t)
s := createTestDB(t)
defer s.Stop()
defer teardownHeartbeats(s.Sender)
reply := &proto.PutResponse{}
s.Sender.Send(context.Background(), proto.Call{
Args: &proto.PutRequest{
RequestHeader: proto.RequestHeader{
Key: proto.Key("key"),
User: security.RootUser,
UserPriority: gogoproto.Int32(-10), // negative user priority is translated into positive priority
Txn: &proto.Transaction{
Name: "test txn",
Isolation: proto.SNAPSHOT,
Priority: 11,
},
},
},
Reply: reply,
})
if reply.Error != nil {
t.Fatal(reply.GoError())
}
if reply.Txn.Priority != 11 {
t.Errorf("expected txn priority 11; got %d", reply.Txn.Priority)
}
}
开发者ID:routhcr,项目名称:cockroach,代码行数:31,代码来源:txn_coord_sender_test.go
示例2: TestKeyAddress
func TestKeyAddress(t *testing.T) {
defer leaktest.AfterTest(t)()
testCases := []struct {
key roachpb.Key
}{
{MakeNameMetadataKey(0, "BAR")},
{MakeNameMetadataKey(1, "BAR")},
{MakeNameMetadataKey(1, "foo")},
{MakeNameMetadataKey(2, "foo")},
{MakeDescMetadataKey(123)},
{MakeDescMetadataKey(124)},
}
var lastKey roachpb.Key
for i, test := range testCases {
resultAddr, err := keys.Addr(test.key)
if err != nil {
t.Fatal(err)
}
result := resultAddr.AsRawKey()
if result.Compare(lastKey) <= 0 {
t.Errorf("%d: key address %q is <= %q", i, result, lastKey)
}
lastKey = result
}
}
开发者ID:yangxuanjia,项目名称:cockroach,代码行数:25,代码来源:keys_test.go
示例3: TestRetryResolveQNames
// Test that we can resolve the qnames in an expression that has already been
// resolved.
func TestRetryResolveQNames(t *testing.T) {
defer leaktest.AfterTest(t)()
expr, err := parser.ParseExprTraditional(`COUNT(a)`)
if err != nil {
t.Fatal(err)
}
for i := 0; i < 2; i++ {
desc := testTableDesc()
s := testInitDummySelectNode(desc)
if err := desc.AllocateIDs(); err != nil {
t.Fatal(err)
}
_, err := s.resolveQNames(expr)
if err != nil {
t.Fatal(err)
}
if len(s.qvals) != 1 {
t.Fatalf("%d: expected 1 qvalue, but found %d", i, len(s.qvals))
}
if _, ok := s.qvals[columnRef{&s.source.info, 0}]; !ok {
t.Fatalf("%d: unable to find qvalue for column 0 (a)", i)
}
}
}
开发者ID:JKhawaja,项目名称:cockroach,代码行数:29,代码来源:select_qvalue_test.go
示例4: TestInfoStoreMostDistant
// TestInfoStoreMostDistant verifies selection of most distant node &
// associated hops.
func TestInfoStoreMostDistant(t *testing.T) {
defer leaktest.AfterTest(t)()
nodes := []roachpb.NodeID{
roachpb.NodeID(1),
roachpb.NodeID(2),
roachpb.NodeID(3),
}
stopper := stop.NewStopper()
defer stopper.Stop()
is := newInfoStore(context.TODO(), 1, emptyAddr, stopper)
// Add info from each address, with hop count equal to index+1.
for i := 0; i < len(nodes); i++ {
inf := is.newInfo(nil, time.Second)
inf.Hops = uint32(i + 1)
inf.NodeID = nodes[i]
if err := is.addInfo(fmt.Sprintf("b.%d", i), inf); err != nil {
t.Fatal(err)
}
nodeID, hops := is.mostDistant()
if nodeID != inf.NodeID {
t.Errorf("%d: expected node %d; got %d", i, inf.NodeID, nodeID)
}
if hops != inf.Hops {
t.Errorf("%d: expected node %d; got %d", i, inf.Hops, hops)
}
}
}
开发者ID:yaojingguo,项目名称:cockroach,代码行数:29,代码来源:infostore_test.go
示例5: TestRangeLookupOptionOnReverseScan
// TestRangeLookupOptionOnReverseScan verifies that a lookup triggered by a
// ReverseScan request has the useReverseScan specified.
func TestRangeLookupOptionOnReverseScan(t *testing.T) {
defer leaktest.AfterTest(t)
g, s := makeTestGossip(t)
defer s()
var testFn rpcSendFn = func(_ rpc.Options, method string, addrs []net.Addr, getArgs func(addr net.Addr) proto.Message, _ func() proto.Message, _ *rpc.Context) ([]proto.Message, error) {
return []proto.Message{getArgs(nil).(*roachpb.BatchRequest).CreateReply()}, nil
}
ctx := &DistSenderContext{
RPCSend: testFn,
RangeDescriptorDB: mockRangeDescriptorDB(func(k roachpb.RKey, considerIntents, useReverseScan bool) ([]roachpb.RangeDescriptor, *roachpb.Error) {
if len(k) > 0 && !useReverseScan {
t.Fatalf("expected UseReverseScan to be set")
}
return []roachpb.RangeDescriptor{testRangeDescriptor}, nil
}),
}
ds := NewDistSender(ctx, g)
rScan := &roachpb.ReverseScanRequest{
Span: roachpb.Span{Key: roachpb.Key("a"), EndKey: roachpb.Key("b")},
}
if _, err := client.SendWrapped(ds, nil, rScan); err != nil {
t.Fatal(err)
}
}
开发者ID:welfeng2016,项目名称:cockroach,代码行数:28,代码来源:dist_sender_test.go
示例6: TestRejectFutureCommand
// TestRejectFutureCommand verifies that lease holders reject commands that
// would cause a large time jump.
func TestRejectFutureCommand(t *testing.T) {
defer leaktest.AfterTest(t)()
const maxOffset = 100 * time.Millisecond
manual := hlc.NewManualClock(0)
clock := hlc.NewClock(manual.UnixNano)
clock.SetMaxOffset(maxOffset)
mtc := multiTestContext{
clock: clock,
}
mtc.Start(t, 1)
defer mtc.Stop()
// First do a write. The first write will advance the clock by MaxOffset
// because of the read cache's low water mark.
getArgs := putArgs([]byte("b"), []byte("b"))
if _, err := client.SendWrapped(rg1(mtc.stores[0]), nil, &getArgs); err != nil {
t.Fatal(err)
}
if now := clock.Now(); now.WallTime != int64(maxOffset) {
t.Fatalf("expected clock to advance to 100ms; got %s", now)
}
// The logical clock has advanced past the physical clock; increment
// the "physical" clock to catch up.
manual.Increment(int64(maxOffset))
startTime := manual.UnixNano()
// Commands with a future timestamp that is within the MaxOffset
// bound will be accepted and will cause the clock to advance.
for i := int64(0); i < 3; i++ {
incArgs := incrementArgs([]byte("a"), 5)
ts := hlc.ZeroTimestamp.Add(startTime+((i+1)*30)*int64(time.Millisecond), 0)
if _, err := client.SendWrappedWith(rg1(mtc.stores[0]), nil, roachpb.Header{Timestamp: ts}, &incArgs); err != nil {
t.Fatal(err)
}
}
if now := clock.Now(); now.WallTime != int64(190*time.Millisecond) {
t.Fatalf("expected clock to advance to 190ms; got %s", now)
}
// Once the accumulated offset reaches MaxOffset, commands will be rejected.
incArgs := incrementArgs([]byte("a"), 11)
ts := hlc.ZeroTimestamp.Add(int64((time.Duration(startTime)+maxOffset+1)*time.Millisecond), 0)
if _, err := client.SendWrappedWith(rg1(mtc.stores[0]), nil, roachpb.Header{Timestamp: ts}, &incArgs); err == nil {
t.Fatalf("expected clock offset error but got nil")
}
// The clock remained at 190ms and the final command was not executed.
if now := clock.Now(); now.WallTime != int64(190*time.Millisecond) {
t.Errorf("expected clock to advance to 190ms; got %s", now)
}
val, _, err := engine.MVCCGet(context.Background(), mtc.engines[0], roachpb.Key("a"), clock.Now(), true, nil)
if err != nil {
t.Fatal(err)
}
if v := mustGetInt(val); v != 15 {
t.Errorf("expected 15, got %v", v)
}
}
开发者ID:yangxuanjia,项目名称:cockroach,代码行数:62,代码来源:client_replica_test.go
示例7: TestStoreRangeUpReplicate
// TestStoreRangeUpReplicate verifies that the replication queue will notice
// under-replicated ranges and replicate them.
func TestStoreRangeUpReplicate(t *testing.T) {
defer leaktest.AfterTest(t)
mtc := startMultiTestContext(t, 3)
defer mtc.Stop()
// Initialize the gossip network.
var wg sync.WaitGroup
wg.Add(len(mtc.stores))
key := gossip.MakePrefixPattern(gossip.KeyStorePrefix)
mtc.stores[0].Gossip().RegisterCallback(key, func(_ string, _ roachpb.Value) { wg.Done() })
for _, s := range mtc.stores {
s.GossipStore()
}
wg.Wait()
// Once we know our peers, trigger a scan.
mtc.stores[0].ForceReplicationScanAndProcess()
// The range should become available on every node.
if err := util.IsTrueWithin(func() bool {
for _, s := range mtc.stores {
r := s.LookupReplica(roachpb.RKey("a"), roachpb.RKey("b"))
if r == nil {
return false
}
}
return true
}, replicationTimeout); err != nil {
t.Fatal(err)
}
}
开发者ID:harryge00,项目名称:cockroach,代码行数:33,代码来源:client_raft_test.go
示例8: TestBuildEndpointListRemoveStagnantClocks
// TestBuildEndpointListRemoveStagnantClocks tests the side effect of removing
// older offsets when we build an endpoint list.
func TestBuildEndpointListRemoveStagnantClocks(t *testing.T) {
defer leaktest.AfterTest(t)()
offsets := map[string]RemoteOffset{
"0": {Offset: 0, Uncertainty: 10, MeasuredAt: 11},
"stagnant0": {Offset: 1, Uncertainty: 10, MeasuredAt: 0},
"1": {Offset: 2, Uncertainty: 10, MeasuredAt: 20},
"stagnant1": {Offset: 3, Uncertainty: 10, MeasuredAt: 9},
}
manual := hlc.NewManualClock(0)
clock := hlc.NewClock(manual.UnixNano)
clock.SetMaxOffset(5 * time.Nanosecond)
remoteClocks := newRemoteClockMonitor(clock)
// The stagnant offsets older than this will be removed.
remoteClocks.monitorInterval = 10 * time.Nanosecond
remoteClocks.mu.offsets = offsets
remoteClocks.mu.lastMonitoredAt = time.Unix(0, 10) // offsets measured before this will be removed.
remoteClocks.buildEndpointList()
_, ok0 := offsets["stagnant0"]
_, ok1 := offsets["stagnant1"]
if ok0 || ok1 {
t.Errorf("expected stagant offsets removed, instead offsets: %v", offsets)
}
}
开发者ID:cuongdo,项目名称:cockroach,代码行数:29,代码来源:clock_offset_test.go
示例9: TestFindOffsetWithLargeError
// TestFindOffsetWithLargeError tests a case where offset errors are
// bigger than the max offset (e.g., a case where heartbeat messages
// to the node are having high latency).
func TestFindOffsetWithLargeError(t *testing.T) {
defer leaktest.AfterTest(t)()
maxOffset := 100 * time.Nanosecond
manual := hlc.NewManualClock(0)
clock := hlc.NewClock(manual.UnixNano)
clock.SetMaxOffset(maxOffset)
offsets := map[string]RemoteOffset{}
// Offsets are bigger than maxOffset, but Errors are also bigger than Offset.
offsets["0"] = RemoteOffset{Offset: 110, Uncertainty: 300}
offsets["1"] = RemoteOffset{Offset: 120, Uncertainty: 300}
offsets["2"] = RemoteOffset{Offset: 130, Uncertainty: 300}
remoteClocks := newRemoteClockMonitor(clock)
remoteClocks.mu.offsets = offsets
interval, err := remoteClocks.findOffsetInterval()
if err != nil {
t.Fatal(err)
}
expectedInterval := clusterOffsetInterval{lowerbound: -270, upperbound: 510}
if interval != expectedInterval {
t.Errorf("expected interval %v, instead %v", expectedInterval, interval)
}
// The interval is still considered healthy.
assertIntervalHealth(true, interval, maxOffset, t)
}
开发者ID:cuongdo,项目名称:cockroach,代码行数:30,代码来源:clock_offset_test.go
示例10: TestExactPrefix
func TestExactPrefix(t *testing.T) {
defer leaktest.AfterTest(t)
testData := []struct {
expr string
columns []string
expected int
}{
{`a = 1`, []string{"a"}, 1},
{`a != 1`, []string{"a"}, 0},
{`a IN (1)`, []string{"a"}, 1},
{`a = 1 AND b = 1`, []string{"a", "b"}, 2},
{`(a, b) IN ((1, 2))`, []string{"a", "b"}, 2},
{`(a, b) IN ((1, 2))`, []string{"a"}, 1},
{`(a, b) IN ((1, 2))`, []string{"b"}, 1},
{`(a, b) IN ((1, 2)) AND c = true`, []string{"a", "b", "c"}, 3},
{`a = 1 AND (b, c) IN ((2, true))`, []string{"a", "b", "c"}, 3},
}
for _, d := range testData {
desc, index := makeTestIndex(t, d.columns)
constraints := makeConstraints(t, d.expr, desc, index)
prefix := exactPrefix(constraints)
if d.expected != prefix {
t.Errorf("%s: expected %d, but found %d", d.expr, d.expected, prefix)
}
}
}
开发者ID:rohanahata,项目名称:cockroach,代码行数:27,代码来源:select_test.go
示例11: TestColumnTypeSQLString
func TestColumnTypeSQLString(t *testing.T) {
defer leaktest.AfterTest(t)
testData := []struct {
colType sql.ColumnType
expectedSQL string
}{
{sql.ColumnType{Kind: sql.ColumnType_INT}, "INT"},
{sql.ColumnType{Kind: sql.ColumnType_INT, Width: 2}, "INT(2)"},
{sql.ColumnType{Kind: sql.ColumnType_FLOAT}, "FLOAT"},
{sql.ColumnType{Kind: sql.ColumnType_FLOAT, Precision: 3}, "FLOAT(3)"},
{sql.ColumnType{Kind: sql.ColumnType_DECIMAL}, "DECIMAL"},
{sql.ColumnType{Kind: sql.ColumnType_DECIMAL, Precision: 6}, "DECIMAL(6)"},
{sql.ColumnType{Kind: sql.ColumnType_DECIMAL, Precision: 7, Width: 8}, "DECIMAL(7,8)"},
{sql.ColumnType{Kind: sql.ColumnType_DATE}, "DATE"},
{sql.ColumnType{Kind: sql.ColumnType_TIMESTAMP}, "TIMESTAMP"},
{sql.ColumnType{Kind: sql.ColumnType_INTERVAL}, "INTERVAL"},
{sql.ColumnType{Kind: sql.ColumnType_STRING}, "STRING"},
{sql.ColumnType{Kind: sql.ColumnType_STRING, Width: 10}, "STRING(10)"},
{sql.ColumnType{Kind: sql.ColumnType_BYTES}, "BYTES"},
}
for i, d := range testData {
sql := d.colType.SQLString()
if d.expectedSQL != sql {
t.Errorf("%d: expected %s, but got %s", i, d.expectedSQL, sql)
}
}
}
开发者ID:kaustubhkurve,项目名称:cockroach,代码行数:28,代码来源:structured_test.go
示例12: TestTxnCoordSenderGC
// TestTxnCoordSenderGC verifies that the coordinator cleans up extant
// transactions after the lastUpdateNanos exceeds the timeout.
func TestTxnCoordSenderGC(t *testing.T) {
defer leaktest.AfterTest(t)
s := createTestDB(t)
defer s.Stop()
// Set heartbeat interval to 1ms for testing.
s.Sender.heartbeatInterval = 1 * time.Millisecond
txn := newTxn(s.Clock, proto.Key("a"))
call := proto.Call{
Args: createPutRequest(proto.Key("a"), []byte("value"), txn),
Reply: &proto.PutResponse{},
}
if err := sendCall(s.Sender, call); err != nil {
t.Fatal(err)
}
// Now, advance clock past the default client timeout.
// Locking the TxnCoordSender to prevent a data race.
s.Sender.Lock()
s.Manual.Set(defaultClientTimeout.Nanoseconds() + 1)
s.Sender.Unlock()
if err := util.IsTrueWithin(func() bool {
// Locking the TxnCoordSender to prevent a data race.
s.Sender.Lock()
_, ok := s.Sender.txns[string(txn.ID)]
s.Sender.Unlock()
return !ok
}, 50*time.Millisecond); err != nil {
t.Error("expected garbage collection")
}
}
开发者ID:routhcr,项目名称:cockroach,代码行数:35,代码来源:txn_coord_sender_test.go
示例13: TestTxnCoordSenderEndTxn
// TestTxnCoordSenderEndTxn verifies that ending a transaction
// sends resolve write intent requests and removes the transaction
// from the txns map.
func TestTxnCoordSenderEndTxn(t *testing.T) {
defer leaktest.AfterTest(t)
s := createTestDB(t)
defer s.Stop()
txn := newTxn(s.Clock, proto.Key("a"))
pReply := &proto.PutResponse{}
key := proto.Key("a")
call := proto.Call{
Args: createPutRequest(key, []byte("value"), txn),
Reply: pReply,
}
if err := sendCall(s.Sender, call); err != nil {
t.Fatal(err)
}
if pReply.GoError() != nil {
t.Fatal(pReply.GoError())
}
etReply := &proto.EndTransactionResponse{}
s.Sender.Send(context.Background(), proto.Call{
Args: &proto.EndTransactionRequest{
RequestHeader: proto.RequestHeader{
Key: txn.Key,
Timestamp: txn.Timestamp,
Txn: txn,
},
Commit: true,
},
Reply: etReply,
})
if etReply.Error != nil {
t.Fatal(etReply.GoError())
}
verifyCleanup(key, s.Sender, s.Eng, t)
}
开发者ID:routhcr,项目名称:cockroach,代码行数:38,代码来源:txn_coord_sender_test.go
示例14: TestTxnCoordSenderMultipleTxns
// TestTxnCoordSenderMultipleTxns verifies correct operation with
// multiple outstanding transactions.
func TestTxnCoordSenderMultipleTxns(t *testing.T) {
defer leaktest.AfterTest(t)
s := createTestDB(t)
defer s.Stop()
defer teardownHeartbeats(s.Sender)
txn1 := newTxn(s.Clock, proto.Key("a"))
txn2 := newTxn(s.Clock, proto.Key("b"))
call := proto.Call{
Args: createPutRequest(proto.Key("a"), []byte("value"), txn1),
Reply: &proto.PutResponse{}}
if err := sendCall(s.Sender, call); err != nil {
t.Fatal(err)
}
call = proto.Call{
Args: createPutRequest(proto.Key("b"), []byte("value"), txn2),
Reply: &proto.PutResponse{}}
if err := sendCall(s.Sender, call); err != nil {
t.Fatal(err)
}
if len(s.Sender.txns) != 2 {
t.Errorf("expected length of transactions map to be 2; got %d", len(s.Sender.txns))
}
}
开发者ID:routhcr,项目名称:cockroach,代码行数:27,代码来源:txn_coord_sender_test.go
示例15: TestBatchDefer
func TestBatchDefer(t *testing.T) {
defer leaktest.AfterTest(t)
stopper := stop.NewStopper()
defer stopper.Stop()
e := NewInMem(roachpb.Attributes{}, 1<<20, stopper)
b := e.NewBatch()
defer b.Close()
list := []string{}
b.Defer(func() {
list = append(list, "one")
})
b.Defer(func() {
list = append(list, "two")
})
if err := b.Commit(); err != nil {
t.Fatal(err)
}
// Order was reversed when the defers were run.
if !reflect.DeepEqual(list, []string{"two", "one"}) {
t.Errorf("expected [two, one]; got %v", list)
}
}
开发者ID:mbertschler,项目名称:cockroach,代码行数:28,代码来源:batch_test.go
示例16: TestIsHealthyOffsetInterval
// TestIsHealthyOffsetInterval tests if we correctly determine if
// a clusterOffsetInterval is healthy or not i.e. if it indicates that the
// local clock has too great an offset or not.
func TestIsHealthyOffsetInterval(t *testing.T) {
defer leaktest.AfterTest(t)()
maxOffset := 10 * time.Nanosecond
interval := clusterOffsetInterval{
lowerbound: 0,
upperbound: 0,
}
assertIntervalHealth(true, interval, maxOffset, t)
interval = clusterOffsetInterval{
lowerbound: -11,
upperbound: 11,
}
assertIntervalHealth(true, interval, maxOffset, t)
interval = clusterOffsetInterval{
lowerbound: -20,
upperbound: -11,
}
assertIntervalHealth(false, interval, maxOffset, t)
interval = clusterOffsetInterval{
lowerbound: 11,
upperbound: 20,
}
assertIntervalHealth(false, interval, maxOffset, t)
interval = clusterOffsetInterval{
lowerbound: math.MaxInt64,
upperbound: math.MaxInt64,
}
assertIntervalHealth(false, interval, maxOffset, t)
}
开发者ID:cuongdo,项目名称:cockroach,代码行数:37,代码来源:clock_offset_test.go
示例17: TestHeartbeatResponseFanout
// TestHeartbeatResponseFanout check 2 raft groups on the same node distribution,
// but each group has different Term, heartbeat response from each group should
// not disturb other group's Term or Leadership
func TestHeartbeatResponseFanout(t *testing.T) {
defer leaktest.AfterTest(t)
stopper := stop.NewStopper()
defer stopper.Stop()
cluster := newTestCluster(nil, 3, stopper, t)
groupID1 := roachpb.RangeID(1)
cluster.createGroup(groupID1, 0, 3 /* replicas */)
groupID2 := roachpb.RangeID(2)
cluster.createGroup(groupID2, 0, 3 /* replicas */)
leaderIndex := 0
cluster.elect(leaderIndex, groupID1)
// GroupID2 will have 3 round of election, so it will have different
// term with groupID1, but both leader on the same node.
for i := 2; i >= 0; i-- {
leaderIndex = i
cluster.elect(leaderIndex, groupID2)
}
// Send a coalesced heartbeat.
// Heartbeat response from groupID2 will have a big term than which from groupID1.
cluster.nodes[0].coalescedHeartbeat()
// Start submit a command to see if groupID1's leader changed?
cluster.nodes[0].SubmitCommand(groupID1, makeCommandID(), []byte("command"))
select {
case _ = <-cluster.events[0].CommandCommitted:
log.Infof("SubmitCommand succeed after Heartbeat Response fanout")
case <-time.After(500 * time.Millisecond):
t.Fatalf("No leader after Heartbeat Response fanout")
}
}
开发者ID:mbertschler,项目名称:cockroach,代码行数:37,代码来源:heartbeat_test.go
示例18: TestEndpointListSort
// TestEndpointListSort tests the sort interface for endpointLists.
func TestEndpointListSort(t *testing.T) {
defer leaktest.AfterTest(t)()
list := endpointList{
endpoint{offset: 5, endType: +1},
endpoint{offset: 3, endType: -1},
endpoint{offset: 3, endType: +1},
endpoint{offset: 1, endType: -1},
endpoint{offset: 4, endType: +1},
}
sortedList := endpointList{
endpoint{offset: 1, endType: -1},
endpoint{offset: 3, endType: -1},
endpoint{offset: 3, endType: +1},
endpoint{offset: 4, endType: +1},
endpoint{offset: 5, endType: +1},
}
sort.Sort(list)
for i := range sortedList {
if list[i] != sortedList[i] {
t.Errorf("expected index %d of sorted list to be %v, instead %v",
i, sortedList[i], list[i])
}
}
if len(list) != len(sortedList) {
t.Errorf("exptected endpoint list to be size %d, instead %d",
len(sortedList), len(list))
}
}
开发者ID:cuongdo,项目名称:cockroach,代码行数:32,代码来源:clock_offset_test.go
示例19: TestLeaderRemoveSelf
// TestLeaderRemoveSelf verifies that a leader can remove itself
// without panicking and future access to the range returns a
// RangeNotFoundError (not RaftGroupDeletedError, and even before
// the ReplicaGCQueue has run).
func TestLeaderRemoveSelf(t *testing.T) {
defer leaktest.AfterTest(t)
mtc := startMultiTestContext(t, 2)
defer mtc.Stop()
// Disable the replica GC queue. This verifies that the replica is
// considered removed even before the gc queue has run, and also
// helps avoid a deadlock at shutdown.
mtc.stores[0].DisableReplicaGCQueue(true)
raftID := roachpb.RangeID(1)
mtc.replicateRange(raftID, 1)
// Remove the replica from first store.
mtc.unreplicateRange(raftID, 0)
getArgs := getArgs([]byte("a"))
// Force the read command request a new lease.
clock := mtc.clocks[0]
header := roachpb.Header{}
header.Timestamp = clock.Update(clock.Now().Add(int64(storage.DefaultLeaderLeaseDuration), 0))
// Expect get a RangeNotFoundError.
_, pErr := client.SendWrappedWith(rg1(mtc.stores[0]), nil, header, &getArgs)
if _, ok := pErr.GoError().(*roachpb.RangeNotFoundError); !ok {
t.Fatalf("expect get RangeNotFoundError, actual get %v ", pErr)
}
}
开发者ID:harryge00,项目名称:cockroach,代码行数:30,代码来源:client_raft_test.go
示例20: TestPGWireMetrics
func TestPGWireMetrics(t *testing.T) {
defer leaktest.AfterTest(t)
s := server.StartTestServer(t)
defer s.Stop()
// Setup pgwire client.
pgUrl, cleanupFn := sqlutils.PGUrl(t, s, security.RootUser, "TestPGWireMetrics")
defer cleanupFn()
const minbytes = 20
// Make sure we're starting at 0.
if _, _, err := checkPGWireMetrics(s, 0, 0, 0, 0); err != nil {
t.Fatal(err)
}
// A single query should give us some I/O.
if err := trivialQuery(pgUrl); err != nil {
t.Fatal(err)
}
bytesIn, bytesOut, err := checkPGWireMetrics(s, minbytes, minbytes, 300, 300)
if err != nil {
t.Fatal(err)
}
if err := trivialQuery(pgUrl); err != nil {
t.Fatal(err)
}
// A second query should give us more I/O.
_, _, err = checkPGWireMetrics(s, bytesIn+minbytes, bytesOut+minbytes, 300, 300)
if err != nil {
t.Fatal(err)
}
}
开发者ID:steelglove,项目名称:cockroach,代码行数:35,代码来源:pgwire_test.go
注:本文中的github.com/cockroachdb/cockroach/util/leaktest.AfterTest函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论