~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/govmomi/govc/test/datacenter.bats

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env bats
 
2
 
 
3
load test_helper
 
4
 
 
5
@test "create and destroy datacenters" {
 
6
  vcsim_env
 
7
  dcs=(`uuidgen` `uuidgen`)
 
8
  run govc datacenter.create ${dcs[0]} ${dcs[1]}
 
9
  assert_success
 
10
 
 
11
  for dc in ${dcs[*]}; do
 
12
    run govc ls /$dc
 
13
    assert_success
 
14
    # /<datacenter>/{vm,network,host,datastore}
 
15
    [ ${#lines[@]} -eq 4 ]
 
16
  done
 
17
 
 
18
  run govc datacenter.destroy ${dcs[0]} ${dcs[1]}
 
19
  assert_success
 
20
 
 
21
  for dc in ${dcs[*]}; do
 
22
    run govc ls /$dc
 
23
    assert_success
 
24
    [ ${#lines[@]} -eq 0 ]
 
25
  done
 
26
}
 
27
 
 
28
@test "destroy datacenter using glob" {
 
29
  vcsim_env
 
30
  prefix=test-dc
 
31
  dcs=(${prefix}-`uuidgen` ${prefix}-`uuidgen`)
 
32
  run govc datacenter.create ${dcs[0]} ${dcs[1]}
 
33
  assert_success
 
34
 
 
35
  run govc datacenter.destroy ${prefix}-*
 
36
  assert_success
 
37
 
 
38
  for dc in ${dcs[*]}; do
 
39
    run govc ls /$dc
 
40
    assert_success
 
41
    [ ${#lines[@]} -eq 0 ]
 
42
  done
 
43
}
 
44
 
 
45
@test "destroy datacenter that doesn't exist" {
 
46
  vcsim_env
 
47
  dc=$(uuidgen)
 
48
 
 
49
  run govc datacenter.destroy $dc
 
50
  assert_success
 
51
}
 
52
 
 
53
@test "create datacenter that already exists" {
 
54
  vcsim_env
 
55
  dc=$(uuidgen)
 
56
 
 
57
  run govc datacenter.create $dc
 
58
  assert_success
 
59
 
 
60
  run govc datacenter.create $dc
 
61
  assert_success
 
62
 
 
63
  run govc datacenter.destroy $dc
 
64
  assert_success
 
65
}
 
66
 
 
67
@test "fails when datacenter name not specified" {
 
68
  run govc datacenter.create
 
69
  assert_failure
 
70
 
 
71
  run govc datacenter.destroy
 
72
  assert_failure
 
73
}
 
74
 
 
75
@test "fails when operation attempted on standalone ESX host" {
 
76
  run govc datacenter.create something
 
77
  assert_failure
 
78
  assert_output "Error: ServerFaultCode: The operation is not supported on the object."
 
79
}
 
80
 
 
81
@test "fails when attempting to destroy ha-datacenter" {
 
82
  run govc datacenter.destroy ha-datacenter
 
83
  assert_failure
 
84
  assert_output "Error: The operation is not supported on the object."
 
85
}