예제 #1
0
파일: fsm_test.go 프로젝트: FoxComm/vulcan
func newWeights(weights ...int) []SuggestedWeight {
	out := make([]SuggestedWeight, len(weights))
	for i, w := range weights {
		out[i] = &EndpointWeight{
			Weight:   w,
			Endpoint: &WeightedEndpoint{endpoint: endpoint.MustParseUrl(fmt.Sprintf("http://localhost:500%d", i))},
		}
	}
	return out
}
예제 #2
0
파일: fsm_test.go 프로젝트: FoxComm/vulcan
func (s *FSMSuite) TestMetricsAreNotReady(c *C) {
	endpoints := []*WeightedEndpoint{
		&WeightedEndpoint{
			meter:           &metrics.TestMeter{Rate: 0.5, NotReady: true},
			endpoint:        endpoint.MustParseUrl("http://localhost:5000"),
			weight:          1,
			effectiveWeight: 1,
		},
		&WeightedEndpoint{
			meter:           &metrics.TestMeter{Rate: 0, NotReady: true},
			endpoint:        endpoint.MustParseUrl("http://localhost:5001"),
			weight:          1,
			effectiveWeight: 1,
		},
	}
	adjusted, err := s.newF(endpoints).AdjustWeights()
	c.Assert(err, IsNil)
	c.Assert(getWeights(adjusted), DeepEquals, []int{1, 1})
}
예제 #3
0
파일: fsm_test.go 프로젝트: FoxComm/vulcan
func newW(failRates ...float64) []*WeightedEndpoint {
	out := make([]*WeightedEndpoint, len(failRates))
	for i, r := range failRates {
		out[i] = &WeightedEndpoint{
			meter:           &metrics.TestMeter{Rate: r, WindowSize: time.Second * 10},
			endpoint:        endpoint.MustParseUrl(fmt.Sprintf("http://localhost:500%d", i)),
			weight:          1,
			effectiveWeight: 1,
		}
	}
	return out
}