forked from cloudfoundry/gosigar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sigar_windows_test.go
150 lines (130 loc) · 3.4 KB
/
sigar_windows_test.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package sigar_test
import (
. "github.com/scalingdata/ginkgo"
. "github.com/scalingdata/gomega"
"os"
sigar "github.com/scalingdata/gosigar"
)
var _ = Describe("SigarWindows", func() {
Describe("Memory", func() {
It("gets the total memory", func() {
mem := sigar.Mem{}
err := mem.Get()
Ω(err).ShouldNot(HaveOccurred())
Ω(mem.Total).Should(BeNumerically(">", 0))
})
})
Describe("Memory", func() {
It("gets the total swap", func() {
swap := sigar.Swap{}
err := swap.Get()
Ω(err).ShouldNot(HaveOccurred())
Ω(swap.Total).Should(BeNumerically(">", 0))
})
})
Describe("FileSystemList", func() {
It("gets volumes", func() {
fsList := sigar.FileSystemList{}
err := fsList.Get()
Ω(err).ShouldNot(HaveOccurred())
Ω(len(fsList.List)).Should(BeNumerically(">", 0))
})
It("doesn't expand needlessly", func() {
fsList := sigar.FileSystemList{}
for i := 0; i < 100; i++ {
err := fsList.Get()
Ω(err).ShouldNot(HaveOccurred())
}
Ω(len(fsList.List)).Should(BeNumerically("<", 100))
})
})
Describe("Disk", func() {
It("gets the total disk space", func() {
usage := sigar.FileSystemUsage{}
err := usage.Get(os.TempDir())
Ω(err).ShouldNot(HaveOccurred())
Ω(usage.Total).Should(BeNumerically(">", 0))
})
})
Describe("DiskList", func() {
It("gets the list of attached disks", func() {
diskList := sigar.DiskList{}
err := diskList.Get()
Ω(err).ShouldNot(HaveOccurred())
Ω(len(diskList.List)).Should(BeNumerically(">", 0))
})
})
Describe("Cpu", func() {
It("gets CPU stats", func() {
cpu := sigar.Cpu{}
err := cpu.Get()
Ω(err).ShouldNot(HaveOccurred())
Ω(cpu.Total()).Should(BeNumerically(">", 0))
})
})
Describe("CpuList", func() {
It("gets CPU stats", func() {
cpuList := sigar.CpuList{}
err := cpuList.Get()
Ω(err).ShouldNot(HaveOccurred())
Ω(cpuList.List[0].Total()).Should(BeNumerically(">", 0))
})
})
Describe("NetIface", func() {
It("gets interface stats", func() {
netList := sigar.NetIfaceList{}
err := netList.Get()
Ω(err).ShouldNot(HaveOccurred())
})
})
Describe("NetConnList", func() {
It("gets TCP IPv4 conns", func() {
connList := sigar.NetTcpConnList{}
err := connList.Get()
Ω(err).ShouldNot(HaveOccurred())
})
It("gets UDP IPv4 conns", func() {
connList := sigar.NetUdpConnList{}
err := connList.Get()
Ω(err).ShouldNot(HaveOccurred())
})
It("gets TCP IPv6 conns", func() {
connList := sigar.NetTcpV6ConnList{}
err := connList.Get()
Ω(err).ShouldNot(HaveOccurred())
})
It("gets UDP IPv6 conns", func() {
connList := sigar.NetUdpV6ConnList{}
err := connList.Get()
Ω(err).ShouldNot(HaveOccurred())
})
})
Describe("NetProtoStats", func() {
It("gets IPv4", func() {
stats := sigar.NetProtoV4Stats{}
err := stats.Get()
Ω(err).ShouldNot(HaveOccurred())
})
It("gets IPv6", func() {
stats := sigar.NetProtoV6Stats{}
err := stats.Get()
Ω(err).ShouldNot(HaveOccurred())
})
})
Describe("SystemInfo", func() {
It("gets system info", func() {
si := sigar.SystemInfo{}
err := si.Get()
Ω(err).ShouldNot(HaveOccurred())
Ω(si.Sysname).Should(Equal("Windows"))
})
})
Describe("SystemDistribution", func() {
It("gets system distribution", func() {
sd := sigar.SystemDistribution{}
err := sd.Get()
Ω(err).ShouldNot(HaveOccurred())
Ω(sd.Description).Should(Equal("Windows"))
})
})
})