summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Howard <ben@prongs>2015-07-17 14:24:20 -0600
committerusd-importer <ubuntu-server@lists.ubuntu.com>2015-07-17 21:23:35 +0000
commit0afc048f2a6ff3638ecfa33e7ded5dc8dddf041a (patch)
treebe55edf0ceacac21db4872fe335019fdb8b71623 /tests
parent7cb11e70e6c639cefc143e8df243b3e88f5fe232 (diff)
downloadvyos-walinuxagent-0afc048f2a6ff3638ecfa33e7ded5dc8dddf041a.tar.gz
vyos-walinuxagent-0afc048f2a6ff3638ecfa33e7ded5dc8dddf041a.zip
Import patches-unapplied version 2.0.14-0ubuntu1 to ubuntu/wily-proposed
Imported using git-ubuntu import. Changelog parent: 7cb11e70e6c639cefc143e8df243b3e88f5fe232 New changelog entries: * New upstream release. - Rebased patches for 2.0.13 onto 2.0.14. - Fix rdma config - Fix page blob uploading for python 2.6 . Fix http request error handling
Diffstat (limited to 'tests')
-rw-r--r--tests/test_shared_config.py69
-rw-r--r--tests/upload_status_blob.py8
2 files changed, 69 insertions, 8 deletions
diff --git a/tests/test_shared_config.py b/tests/test_shared_config.py
index ede2766..8252b3b 100644
--- a/tests/test_shared_config.py
+++ b/tests/test_shared_config.py
@@ -13,6 +13,8 @@
# limitations under the License.
#
+import os
+import re
import unittest
from env import waagent
@@ -24,6 +26,16 @@ class MockDistro(object):
pass
class TestSharedConfig(unittest.TestCase):
+
+ def test_reg(self):
+ mac = "00:15:5D:34:00:08"
+ output = Ifconfig_Out
+ output = output.replace('\n', '')
+ reg = r"(eth\d).*(HWaddr|ether) {0}".format(mac)
+ match = re.search(reg, output, re.IGNORECASE)
+ output = match.group(0)
+ eths = re.findall(r"eth\d", output)
+ self.assertNotEquals(0, len(eths))
def test_parse_shared_config(self):
conf = waagent.SharedConfig().Parse(SharedConfigText)
@@ -34,15 +46,32 @@ class TestSharedConfig(unittest.TestCase):
return conf
def test_config_rdma(self):
- #waagent.LoggerInit("/dev/stdout", "/dev/null", verbose=True)
waagent.MyDistro= MockDistro()
- testDev = "/tmp/hvnd_rdma"
- waagent.SetFileContents(testDev, "")
+ waagent.LibDir="/tmp"
+
+ test_dev = "/tmp/hvnd_rdma"
+ test_dat_conf_files = ["/tmp/dat.conf"]
+ if os.path.isfile("/tmp/rdmaconfiged"):
+ os.remove("/tmp/rdmaconfiged")
+ waagent.SetFileContents(test_dev, "")
+ old = ("ofa-v2-ib0 u2.0 nonthreadsafe default libdaplofa.so.2 "
+ "dapl.2.0 \"oldip 0\"")
+ waagent.SetFileContents(test_dat_conf_files[0], old)
conf = self.test_parse_shared_config()
- conf.ConfigRdma(dev=testDev)
- rdmaConf = waagent.GetFileContents(testDev)
- self.assertNotEquals(None, rdmaConf)
- self.assertNotEquals("", rdmaConf)
+ handler = waagent.RdmaHandler(conf.RdmaMacAddress, conf.RdmaIPv4Address,
+ test_dev, test_dat_conf_files)
+ handler.set_dat_conf()
+ handler.set_rdma_dev()
+
+ rdma_conf = waagent.GetFileContents(test_dev)
+ self.assertNotEquals(None, rdma_conf)
+ self.assertNotEquals(0, rdma_conf.count(conf.RdmaIPv4Address))
+ self.assertNotEquals(0, rdma_conf.count(conf.RdmaMacAddress))
+
+ dat_conf = waagent.GetFileContents(test_dat_conf_files[0])
+ self.assertNotEquals(None, dat_conf)
+ self.assertNotEquals(0, dat_conf.count(conf.RdmaIPv4Address))
+ self.assertEquals(0, dat_conf.count("oldip"))
SharedConfigText="""\
<?xml version="1.0" encoding="utf-8"?>
@@ -88,6 +117,32 @@ SharedConfigText="""\
</Instances>
</SharedConfig>
"""
+Ifconfig_Out="""\
+eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
+inet 100.74.52.8 netmask 255.255.255.0 broadcast 100.74.52.255
+inet6 fe80::20d:3aff:fe10:672f prefixlen 64 scopeid 0x20<link>
+ether 00:0d:3a:10:67:2f txqueuelen 1000 (Ethernet)
+RX packets 9911 bytes 4451278 (4.2 MiB)
+RX errors 0 dropped 0 overruns 0 frame 0
+TX packets 10505 bytes 1643251 (1.5 MiB)
+TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
+
+eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
+inet6 fe80::215:5dff:fe34:8 prefixlen 64 scopeid 0x20<link>
+ether 00:15:5d:34:00:08 txqueuelen 1000 (Ethernet)
+RX packets 16 bytes 672 (672.0 B)
+RX errors 0 dropped 0 overruns 0 frame 0
+TX packets 16 bytes 2544 (2.4 KiB)
+TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
+
+lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
+inet 127.0.0.1 netmask 255.0.0.0
+inet6 ::1 prefixlen 128 scopeid 0x10<host>
+loop txqueuelen 0 (Local Loopback)
+RX packets 0 bytes 0 (0.0 B)
+RX errors 0 dropped 0 overruns 0 frame 0
+TX packets 0 bytes 0 (0.0 B)
+"""
if __name__ == '__main__':
unittest.main()
diff --git a/tests/upload_status_blob.py b/tests/upload_status_blob.py
index af8c580..59cb732 100644
--- a/tests/upload_status_blob.py
+++ b/tests/upload_status_blob.py
@@ -30,8 +30,14 @@ and defined the following 2 variables like:
"""
from status_blob_url import blockBlobUrl, pageBlobUrl
+class MockConfig(object):
+ def get(self, keyName):
+ return None
+
+waagent.Config = MockConfig()
+
if __name__ == '__main__':
waagent.LoggerInit('/dev/stdout', '/dev/null', verbose=True)
status = "a" * 512
waagent.UploadStatusBlob(blockBlobUrl, status.encode("utf-8"))
- waagent.UploadStatusBlob(pageBlobUrl, status.encode("utf-8"))
+ #waagent.UploadStatusBlob(pageBlobUrl, status.encode("utf-8"))