forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_stats_collector.go
52 lines (40 loc) · 1.11 KB
/
fake_stats_collector.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package fakes
import (
"errors"
"time"
boshstats "github.com/cloudfoundry/bosh-agent/platform/stats"
)
type FakeCollector struct {
StartCollectingCPUStats boshstats.CPUStats
CPULoad boshstats.CPULoad
cpuStats boshstats.CPUStats
MemStats boshstats.Usage
MemStatsErr error
SwapStats boshstats.Usage
DiskStats map[string]boshstats.DiskStats
}
func (c *FakeCollector) StartCollecting(collectionInterval time.Duration, latestGotUpdated chan struct{}) {
c.cpuStats = c.StartCollectingCPUStats
}
func (c *FakeCollector) GetCPULoad() (load boshstats.CPULoad, err error) {
load = c.CPULoad
return
}
func (c *FakeCollector) GetCPUStats() (stats boshstats.CPUStats, err error) {
stats = c.cpuStats
return
}
func (c *FakeCollector) GetMemStats() (boshstats.Usage, error) {
return c.MemStats, c.MemStatsErr
}
func (c *FakeCollector) GetSwapStats() (usage boshstats.Usage, err error) {
usage = c.SwapStats
return
}
func (c *FakeCollector) GetDiskStats(devicePath string) (stats boshstats.DiskStats, err error) {
stats, found := c.DiskStats[devicePath]
if !found {
err = errors.New("Disk not found")
}
return
}