~ubuntu-branches/ubuntu/utopic/python-quantumclient/utopic

« back to all changes in this revision

Viewing changes to quantum_test.sh

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-08-16 12:45:43 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120816124543-5m96n37eik89sr2j
Tags: 1:2.0-0ubuntu1
* New upstream version.
* debian/control: Update build dependencies.
* debian/rules: Enable testsuite.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
set -x
 
3
function die() {
 
4
    local exitcode=$?
 
5
    set +o xtrace
 
6
    echo $@
 
7
    exit $exitcode
 
8
}
 
9
 
 
10
noauth_tenant_id=me
 
11
if [ $1 == 'noauth' ]; then
 
12
    NOAUTH="--tenant_id $noauth_tenant_id"
 
13
else
 
14
    NOAUTH=
 
15
fi
 
16
 
 
17
 
 
18
# test the CRUD of network
 
19
network=mynet1
 
20
quantum net-create $NOAUTH $network || die "fail to create network $network"
 
21
temp=`quantum net-list -- --name $network --fields id | wc -l`
 
22
echo $temp
 
23
if [ $temp -ne 5 ]; then
 
24
   die "networks with name $network is not unique or found"
 
25
fi
 
26
network_id=`quantum net-list -- --name $network --fields id | tail -n 2 | head -n 1 |  cut -d' ' -f 2`
 
27
echo "ID of network with name $network is $network_id"
 
28
 
 
29
quantum net-show $network ||  die "fail to show network $network"
 
30
quantum net-show $network_id ||  die "fail to show network $network_id"
 
31
 
 
32
quantum  net-update $network --admin_state_up False  ||  die "fail to update network $network"
 
33
quantum  net-update $network_id --admin_state_up True  ||  die "fail to update network $network_id"
 
34
 
 
35
quantum net-list -c id -- --id fakeid  || die "fail to list networks with column selection on empty list"
 
36
 
 
37
# test the CRUD of subnet
 
38
subnet=mysubnet1
 
39
cidr=10.0.1.3/24
 
40
quantum subnet-create $NOAUTH $network $cidr --name $subnet  || die "fail to create subnet $subnet"
 
41
tempsubnet=`quantum subnet-list -- --name $subnet --fields id | wc -l`
 
42
echo $tempsubnet
 
43
if [ $tempsubnet -ne 5 ]; then
 
44
   die "subnets with name $subnet is not unique or found"
 
45
fi
 
46
subnet_id=`quantum subnet-list -- --name $subnet --fields id | tail -n 2 | head -n 1 |  cut -d' ' -f 2`
 
47
echo "ID of subnet with name $subnet is $subnet_id"
 
48
quantum subnet-show $subnet ||  die "fail to show subnet $subnet"
 
49
quantum subnet-show $subnet_id ||  die "fail to show subnet $subnet_id"
 
50
 
 
51
quantum  subnet-update $subnet --dns_namesevers host1  ||  die "fail to update subnet $subnet"
 
52
quantum  subnet-update $subnet_id --dns_namesevers host2  ||  die "fail to update subnet $subnet_id"
 
53
 
 
54
# test the crud of ports
 
55
port=myport1
 
56
quantum port-create $NOAUTH $network --name $port  || die "fail to create port $port"
 
57
tempport=`quantum port-list -- --name $port --fields id | wc -l`
 
58
echo $tempport
 
59
if [ $tempport -ne 5 ]; then
 
60
   die "ports with name $port is not unique or found"
 
61
fi
 
62
port_id=`quantum port-list -- --name $port --fields id | tail -n 2 | head -n 1 |  cut -d' ' -f 2`
 
63
echo "ID of port with name $port is $port_id"
 
64
quantum port-show $port ||  die "fail to show port $port"
 
65
quantum port-show $port_id ||  die "fail to show port $port_id"
 
66
 
 
67
quantum  port-update $port --device_id deviceid1  ||  die "fail to update port $port"
 
68
quantum  port-update $port_id --device_id deviceid2  ||  die "fail to update port $port_id"
 
69
 
 
70
# test quota commands RUD
 
71
DEFAULT_NETWORKS=10
 
72
DEFAULT_PORTS=50
 
73
tenant_id=tenant_a
 
74
tenant_id_b=tenant_b
 
75
quantum quota-update --tenant_id $tenant_id --network 30 || die "fail to update quota for tenant $tenant_id"
 
76
quantum quota-update --tenant_id $tenant_id_b --network 20 || die "fail to update quota for tenant $tenant_id"
 
77
networks=`quantum quota-list | grep $tenant_id | awk '{print $2}'`
 
78
if [ $networks -ne 30 ]; then
 
79
   die "networks quota should be 30"
 
80
fi
 
81
networks=`quantum quota-list | grep $tenant_id_b | awk '{print $2}'`
 
82
if [ $networks -ne 20 ]; then
 
83
   die "networks quota should be 20"
 
84
fi
 
85
networks=`quantum quota-show --tenant_id $tenant_id | grep network | awk -F'|'  '{print $3}'`
 
86
if [ $networks -ne 30 ]; then
 
87
   die "networks quota should be 30"
 
88
fi
 
89
quantum quota-delete --tenant_id $tenant_id || die "fail to delete quota for tenant $tenant_id"
 
90
networks=`quantum quota-show --tenant_id $tenant_id | grep network | awk -F'|'  '{print $3}'`
 
91
if [ $networks -ne $DEFAULT_NETWORKS ]; then
 
92
   die "networks quota should be $DEFAULT_NETWORKS"
 
93
fi
 
94
# update self
 
95
if [ "t$NOAUTH" = "t" ]; then
 
96
    # with auth
 
97
    quantum quota-update --port 99 || die "fail to update quota for self"
 
98
    ports=`quantum quota-show | grep port | awk -F'|'  '{print $3}'`
 
99
    if [ $ports -ne 99 ]; then
 
100
       die "ports quota should be 99"
 
101
    fi
 
102
    
 
103
    ports=`quantum quota-list | grep 99 | awk '{print $4}'`
 
104
    if [ $ports -ne 99 ]; then
 
105
       die "ports quota should be 99"
 
106
    fi
 
107
    quantum quota-delete || die "fail to delete quota for tenant self"
 
108
    ports=`quantum quota-show | grep port | awk -F'|'  '{print $3}'`
 
109
    if [ $ports -ne $DEFAULT_PORTS ]; then
 
110
       die "ports quota should be $DEFAULT_PORTS"
 
111
    fi
 
112
else
 
113
    # without auth
 
114
    quantum quota-update --port 100
 
115
    if [ $? -eq 0 ]; then
 
116
        die "without valid context on server, quota update command should fail."
 
117
    fi
 
118
    quantum quota-show
 
119
    if [ $? -eq 0 ]; then
 
120
        die "without valid context on server, quota show command should fail."
 
121
    fi
 
122
    quantum quota-delete
 
123
    if [ $? -eq 0 ]; then
 
124
        die "without valid context on server, quota delete command should fail."
 
125
    fi
 
126
    quantum quota-list || die "fail to update quota for self"
 
127
fi