-
Notifications
You must be signed in to change notification settings - Fork 911
/
metric.bats
executable file
·97 lines (65 loc) · 1.81 KB
/
metric.bats
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
#!/usr/bin/env bats
load test_helper
@test "metric.ls" {
vcsim_env -esx
run govc metric.ls
assert_failure
run govc metric.ls enoent
assert_failure
host=$(govc ls -t HostSystem ./... | head -n 1)
pool=$(govc ls -t ResourcePool ./... | head -n 1)
vm=$(govc ls -t VirtualMachine ./... | head -n 1)
run govc metric.ls "$host"
assert_success
run govc metric.ls -json "$host"
assert_success
run govc metric.ls "$pool"
assert_success
run govc metric.ls "$vm"
assert_success
}
@test "metric.sample" {
vcsim_env
host=$(govc ls -t HostSystem ./... | head -n 1)
metrics=($(govc metric.ls "$host"))
run govc metric.sample "$host" enoent
assert_failure
run govc metric.sample "$host" "${metrics[@]}"
assert_success
run govc metric.sample -instance - "$host" "${metrics[@]}"
assert_success
run govc metric.sample -json "$host" "${metrics[@]}"
assert_success
vm=vm/DC0_H0_VM0
metrics=($(govc metric.ls "$vm"))
run govc metric.sample -i day "$vm" "${metrics[@]}"
assert_success
run govc metric.sample -i 300 -json "$vm" "${metrics[@]}"
assert_success
run govc metric.sample $vm "${metrics[@]}"
assert_success
}
@test "metric.info" {
vcsim_env
host=$(govc ls -t HostSystem ./... | head -n 1)
metrics=($(govc metric.ls "$host"))
run govc metric.info "$host" enoent
assert_failure
run govc metric.info "$host"
assert_success
run govc metric.info -json "$host"
assert_success
run govc metric.info -dump "$host"
assert_success
run govc metric.sample "$host" "${metrics[@]}"
assert_success
run govc metric.info "$host" "${metrics[@]}"
assert_success
run govc metric.info - "${metrics[@]}"
assert_success
}
@test "metric manager" {
vcsim_env
moid=$(govc object.collect -s - content.perfManager)
govc object.collect -json "$moid" | jq .
}