Statistics
| Branch: | Tag: | Revision:

root / qa / qa_network.py @ cf62af3a

History | View | Annotate | Download (2.5 kB)

1 ea7693c1 Helga Velroyen
#
2 ea7693c1 Helga Velroyen
#
3 ea7693c1 Helga Velroyen
4 ea7693c1 Helga Velroyen
# Copyright (C) 2013 Google Inc.
5 ea7693c1 Helga Velroyen
#
6 ea7693c1 Helga Velroyen
# This program is free software; you can redistribute it and/or modify
7 ea7693c1 Helga Velroyen
# it under the terms of the GNU General Public License as published by
8 ea7693c1 Helga Velroyen
# the Free Software Foundation; either version 2 of the License, or
9 ea7693c1 Helga Velroyen
# (at your option) any later version.
10 ea7693c1 Helga Velroyen
#
11 ea7693c1 Helga Velroyen
# This program is distributed in the hope that it will be useful, but
12 ea7693c1 Helga Velroyen
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 ea7693c1 Helga Velroyen
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 ea7693c1 Helga Velroyen
# General Public License for more details.
15 ea7693c1 Helga Velroyen
#
16 ea7693c1 Helga Velroyen
# You should have received a copy of the GNU General Public License
17 ea7693c1 Helga Velroyen
# along with this program; if not, write to the Free Software
18 ea7693c1 Helga Velroyen
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 ea7693c1 Helga Velroyen
# 02110-1301, USA.
20 ea7693c1 Helga Velroyen
21 ea7693c1 Helga Velroyen
22 ea7693c1 Helga Velroyen
"""QA tests for networks.
23 ea7693c1 Helga Velroyen

24 ea7693c1 Helga Velroyen
"""
25 ea7693c1 Helga Velroyen
26 ea7693c1 Helga Velroyen
import qa_config
27 ea7693c1 Helga Velroyen
import qa_utils
28 ea7693c1 Helga Velroyen
29 ea7693c1 Helga Velroyen
from qa_utils import AssertCommand
30 ea7693c1 Helga Velroyen
31 ea7693c1 Helga Velroyen
32 ea7693c1 Helga Velroyen
def GetNonexistentNetworks(count):
33 ea7693c1 Helga Velroyen
  """Gets network names which shouldn't exist on the cluster.
34 ea7693c1 Helga Velroyen

35 ea7693c1 Helga Velroyen
  @param count: Number of networks to get
36 ea7693c1 Helga Velroyen
  @rtype: integer
37 ea7693c1 Helga Velroyen

38 ea7693c1 Helga Velroyen
  """
39 ea7693c1 Helga Velroyen
  return qa_utils.GetNonexistentEntityNames(count, "networks", "network")
40 ea7693c1 Helga Velroyen
41 ea7693c1 Helga Velroyen
42 ea7693c1 Helga Velroyen
def TestNetworkAddRemove():
43 ea7693c1 Helga Velroyen
  """gnt-network add/remove"""
44 ea7693c1 Helga Velroyen
  (network1, network2) = GetNonexistentNetworks(2)
45 ea7693c1 Helga Velroyen
46 ea7693c1 Helga Velroyen
  # Add some networks of different sizes.
47 ea7693c1 Helga Velroyen
  # Note: Using RFC5737 addresses.
48 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-network", "add", "--network", "192.0.2.0/30", network1])
49 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-network", "add", "--network", "198.51.100.0/24",
50 ea7693c1 Helga Velroyen
                 network2])
51 ea7693c1 Helga Velroyen
  # Try to add a network with an existing name.
52 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-network", "add", "--network", "203.0.133.0/24", network2],
53 ea7693c1 Helga Velroyen
                fail=True)
54 ea7693c1 Helga Velroyen
55 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-network", "remove", network1])
56 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-network", "remove", network2])
57 ea7693c1 Helga Velroyen
58 ea7693c1 Helga Velroyen
59 ea7693c1 Helga Velroyen
def TestNetworkConnect():
60 ea7693c1 Helga Velroyen
  """gnt-network connect/disconnect"""
61 ea7693c1 Helga Velroyen
  (group1, ) = qa_utils.GetNonexistentGroups(1)
62 ea7693c1 Helga Velroyen
  (network1, ) = GetNonexistentNetworks(1)
63 ea7693c1 Helga Velroyen
64 ea7693c1 Helga Velroyen
  default_mode = "bridged"
65 ea7693c1 Helga Velroyen
  default_link = "xen-br0"
66 ea7693c1 Helga Velroyen
  nicparams = qa_config.get("default-nicparams")
67 ea7693c1 Helga Velroyen
  if nicparams:
68 ea7693c1 Helga Velroyen
    mode = nicparams.get("mode", default_mode)
69 ea7693c1 Helga Velroyen
    link = nicparams.get("link", default_link)
70 ea7693c1 Helga Velroyen
  else:
71 ea7693c1 Helga Velroyen
    mode = default_mode
72 ea7693c1 Helga Velroyen
    link = default_link
73 ea7693c1 Helga Velroyen
74 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-group", "add", group1])
75 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-network", "add", "--network", "192.0.2.0/24", network1])
76 ea7693c1 Helga Velroyen
77 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-network", "connect", network1, mode, link, group1])
78 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-network", "disconnect", network1, group1])
79 ea7693c1 Helga Velroyen
80 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-group", "remove", group1])
81 ea7693c1 Helga Velroyen
  AssertCommand(["gnt-network", "remove", network1])