add aggression multiplier to mock collector

This commit is contained in:
Bradley Cicenas
2017-03-09 09:33:44 +11:00
parent 70790e88ae
commit 92cc7bc849
2 changed files with 29 additions and 18 deletions

View File

@@ -26,18 +26,26 @@ func NewMockContainerSource() *MockContainerSource {
// Create Mock containers
func (cs *MockContainerSource) Init() {
total := 20
rand.Seed(int64(time.Now().Nanosecond()))
for i := 0; i < total; i++ {
//time.Sleep(1 * time.Second)
collector := metrics.NewMock()
c := NewContainer(makeID(), collector)
c.SetMeta("name", makeName())
c.SetState(makeState())
cs.containers = append(cs.containers, c)
for i := 0; i < 4; i++ {
time.Sleep(500 * time.Millisecond)
cs.makeContainer(3)
}
for i := 0; i < 16; i++ {
time.Sleep(500 * time.Millisecond)
cs.makeContainer(1)
}
}
func (cs *MockContainerSource) makeContainer(aggression int64) {
collector := metrics.NewMock(aggression)
c := NewContainer(makeID(), collector)
c.SetMeta("name", makeName())
c.SetState(makeState())
cs.containers = append(cs.containers, c)
}
func (cs *MockContainerSource) Loop() {