forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_stats_collector.go
59 lines (45 loc) · 1.26 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
53
54
55
56
57
58
59
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
UptimeStats boshstats.UptimeStats
}
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
}
func (c *FakeCollector) GetUptimeStats() (stats boshstats.UptimeStats, err error) {
stats = c.UptimeStats
return
}