Giuseppe Vallarelli has uploaded a new change for review.

Change subject: tests: WIP Adding functional tests for networking
......................................................................

tests: WIP Adding functional tests for networking

Functional tests for creation and deletion of virtual networks.

Change-Id: Ic3be71db9dc0b92c443b87e22fe06f920055c4d3
Signed-off-by: Giuseppe Vallarelli <gvall...@redhat.com>
---
M tests/functional/Makefile.am
A tests/functional/networkTests.py
2 files changed, 75 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/40/14840/1

diff --git a/tests/functional/Makefile.am b/tests/functional/Makefile.am
index 030242b..322dc67 100644
--- a/tests/functional/Makefile.am
+++ b/tests/functional/Makefile.am
@@ -22,6 +22,7 @@
 
 dist_vdsmfunctests_PYTHON = \
        momTests.py \
+       networkTests.py \
        sosPluginTests.py \
        xmlrpcTests.py \
        $(NULL)
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
new file mode 100644
index 0000000..4ffd30b
--- /dev/null
+++ b/tests/functional/networkTests.py
@@ -0,0 +1,74 @@
+#
+# Copyright 2012 Red Hat, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+from vdsm import netinfo
+from vdsm import vdscli
+
+from testrunner import VdsmTestCase as TestCaseBase
+
+
+NETWORK_NAME = 'test-network'
+SUCCESS = 0
+
+
+class VdsmNetUtil(object):
+
+    def __init__(self):
+        self.vdscli = vdscli.connect(useSSL=False)
+
+    def _get_net_args(self, vlan, bond, nics, opts):
+        if vlan is None:
+            vlan = ''
+        if bond is None:
+            bond = ''
+        if nics is None:
+            nics = ''
+        if opts is None:
+            opts = {}
+        return [vlan, bond, nics, opts]
+
+    def add_network(self, bridge, vlan=None, bond=None, nics=None, opts=None):
+        result = self.vdscli.addNetwork(bridge,
+                                        *self._get_net_args(vlan, bond, nics,
+                                                            opts))
+        return result['status']['code'], result['status']['message']
+
+    def del_network(self, bridge, vlan=None, bond=None, nics=None, opts=None):
+        result = self.vdscli.delNetwork(bridge,
+                                        *self._get_net_args(vlan, bond, nics,
+                                                            opts))
+        return result['status']['code'], result['status']['message']
+
+    def network_exists(self, network_name):
+        info = netinfo.NetInfo(self.vdscli.getVdsCapabilities()['info'])
+        return network_name in info.networks
+
+
+vdsm_net = VdsmNetUtil()
+
+
+class NetworkTest(TestCaseBase):
+
+    def test_add_delete_a_network(self):
+        status, msg = vdsm_net.add_network(NETWORK_NAME)
+        self.assertEqual(status, SUCCESS, msg)
+        self.assertTrue(vdsm_net.network_exists(NETWORK_NAME))
+
+        status, msg = vdsm_net.del_network(NETWORK_NAME)
+        self.assertEqual(status, SUCCESS, msg)
+        self.assertFalse(vdsm_net.network_exists(NETWORK_NAME))


--
To view, visit http://gerrit.ovirt.org/14840
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3be71db9dc0b92c443b87e22fe06f920055c4d3
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Giuseppe Vallarelli <gvall...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to