File: metric.bats

package info (click to toggle)
golang-github-vmware-govmomi 0.24.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,848 kB
  • sloc: sh: 2,285; lisp: 1,560; ruby: 948; xml: 139; makefile: 54
file content (102 lines) | stat: -rwxr-xr-x 1,886 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env bats

load test_helper

@test "metric.ls" {
  esx_env

  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)

  run govc metric.ls "$host"
  assert_success

  run govc metric.ls -json "$host"
  assert_success

  run govc metric.ls "$pool"
  assert_success
}

@test "metric.sample" {
  esx_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=$(new_ttylinux_vm)

  run govc metric.ls "$vm"
  assert_output ""

  run govc vm.power -on "$vm"
  assert_success

  run govc vm.ip "$vm"
  assert_success

  metrics=($(govc metric.ls "$vm"))

  run govc metric.sample "$vm" "${metrics[@]}"
  assert_success

  run govc metric.sample -json "$vm" "${metrics[@]}"
  assert_success

  run govc metric.sample "govc-test-*" "${metrics[@]}"
  assert_success
}

@test "metric.info" {
  esx_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 .
}