Пример #1
0
func (s *MemberlistTestSuite) SetupTest() {
	s.incarnation = util.TimeNowMS()
	s.node = NewNode("test", "127.0.0.1:3001", nil, nil)
	s.m = s.node.memberlist
	s.m.MakeAlive(s.node.Address(), s.incarnation)

	s.changes = []Change{
		Change{
			Address:     "127.0.0.1:3002",
			Status:      Alive,
			Incarnation: s.incarnation,
		},
		Change{
			Address:     "127.0.0.1:3003",
			Status:      Suspect,
			Incarnation: s.incarnation,
		},
		Change{
			Address:     "127.0.0.1:3004",
			Status:      Faulty,
			Incarnation: s.incarnation,
		},
		Change{
			Address:     "127.0.0.1:3005",
			Status:      Leave,
			Incarnation: s.incarnation,
		},
	}
}
Пример #2
0
func (s *MemberlistIterTestSuite) SetupTest() {
	s.incarnation = util.TimeNowMS()
	s.node = NewNode("test", "127.0.0.1:3001", nil, nil)
	s.m = s.node.memberlist
	s.i = s.m.Iter()

	s.m.MakeAlive(s.node.Address(), s.incarnation)
}
Пример #3
0
func (s *DisseminatorTestSuite) SetupTest() {
	s.incarnation = util.TimeNowMS()

	fakeAddress := fakeHostPorts(1, 1, 1, 1)[0]
	s.node = NewNode("test", fakeAddress, nil, nil)

	s.node.memberlist.MakeAlive(s.node.Address(), s.incarnation)
	s.d = s.node.disseminator
	s.m = s.node.memberlist
}
Пример #4
0
func (s *RollupTestSuite) SetupTest() {
	s.node = NewNode("test", "127.0.0.1:3001", nil, &Options{
		RollupFlushInterval: 10000 * time.Second,
		RollupMaxUpdates:    10000,
	})
	s.r = s.node.rollup
	s.incarnation = util.TimeNowMS()
	s.updates = []Change{
		Change{Address: "one"},
		Change{Address: "two"},
	}
}
Пример #5
0
func (s *SuspicionTestSuite) SetupTest() {
	s.incarnation = util.TimeNowMS()
	s.node = NewNode("test", "127.0.0.1:3001", nil, &Options{
		SuspicionTimeout: 1000 * time.Second,
	})
	s.s = s.node.suspicion
	s.m = s.node.memberlist

	s.m.MakeAlive(s.node.Address(), s.incarnation)

	s.suspect = Change{
		Address:     "127.0.0.1:3002",
		Incarnation: s.incarnation,
	}
}
Пример #6
0
func (s *MemberTestSuite) SetupTest() {
	s.localAddr = "local address"
	s.nonLocalAddr = "non-local address"

	incNumStart := util.TimeNowMS()
	statuses := []string{Alive, Suspect, Faulty, Leave}

	// Add incNo, status combinations of ever increasing precedence.
	s.states = nil
	for i := int64(0); i < 4; i++ {
		for _, status := range statuses {
			s.states = append(s.states, state{incNumStart + i, status})
		}
	}
}
Пример #7
0
// makes a change to the member list
func (m *memberlist) MakeChange(address string, incarnation int64, status string) []Change {
	if m.local == nil {
		m.local = &Member{
			Address:     m.node.Address(),
			Incarnation: util.TimeNowMS(),
			Status:      Alive,
		}
	}

	return m.Update([]Change{Change{
		Source:            m.local.Address,
		SourceIncarnation: m.local.Incarnation,
		Address:           address,
		Incarnation:       incarnation,
		Status:            status,
		Timestamp:         util.Timestamp(time.Now()),
	}})
}
Пример #8
0
import (
	"errors"
	"fmt"
	"testing"
	"time"

	"github.com/benbjohnson/clock"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"github.com/uber/ringpop-go/shared"
	"github.com/uber/ringpop-go/util"
	"github.com/uber/tchannel-go"
)

var testNow = time.Now()
var testInc = util.TimeNowMS()

var testSuspect = Change{
	Address:           "127.0.0.1:3002",
	Incarnation:       testInc,
	Source:            "127.0.0.1:3001",
	SourceIncarnation: testInc,
	Status:            Suspect,
	Timestamp:         util.Timestamp(testNow),
}

type dummyIter struct{}

func (dummyIter) Next() (*Member, bool) {
	return &Member{
		Address:     "127.0.0.1:3010",
Пример #9
0
func (s *PingRequestTestSuite) SetupTest() {
	s.incarnation = util.TimeNowMS()
	s.tnode = newChannelNode(s.T())
	s.node = s.tnode.node
	s.peers = genChannelNodes(s.T(), 2)
}