Пример #1
0
 def test_endpoint_check(self):
     """
     Check the endpoints of the VM
     """
     self.log.info("Check the endpoints of the VM")
     # install nmap
     if "command not found" in self.vm_test01.get_output("nmap", timeout=5):
         self.vm_test01.get_output("rpm -ivh /root/RHEL*.rpm")
         self.vm_test01.get_output("yum -y install nmap")
     # Set postfix, listen to 0.0.0.0
     self.vm_test01.get_output("sed -i -e \'/inet_interfaces = localhost/s/^/#/g\' "
                               "-e \'/inet_interfaces = all/s/^#//g\' "
                               "/etc/postfix/main.cf")
     self.vm_test01.get_output("service postfix restart")
     self.assertIn("0.0.0.0:25", self.vm_test01.get_output("netstat -antp"),
                   "Fail to start postfix and listen to 0.0.0.0")
     # Check endpoint
     import re
     inside = re.sub(r'\s+', ' ', self.vm_test01.get_output("nmap 127.0.0.1"))
     self.assertIn("22/tcp open ssh", inside,
                   "port 22 is not opened inside")
     self.assertIn("25/tcp open smtp", inside,
                   "port 25 is not opened inside")
     self.assertIn("open", azure_cli_common.host_command("tcping %s %d" % (self.vm_params["DNSName"],
                                                                           self.vm_params["PublicPort"]),
                                                         ignore_status=True),
                   "ssh port should be opened outside")
     self.assertIn("closed", azure_cli_common.host_command("tcping %s 25" % self.vm_params["DNSName"],
                                                           ignore_status=True),
                   "port 25 shouldn't be opened outside")
Пример #2
0
 def test_02_convert_image(self):
     """
     Convert qcow2 image to vhd format
     """
     realpath = os.path.split(os.path.realpath(__file__))[0]
     cmd = "/usr/bin/python %s/../tools/azure_image_prepare/azure_image_prepare.py -convert" % realpath
     self.assertEqual(azure_cli_common.host_command(cmd, ret='exit_status'), 0,
                      "Fail to check image")
Пример #3
0
 def test_01_prepare_image(self):
     """
     Install an image from iso
     """
     realpath = os.path.split(os.path.realpath(__file__))[0]
     cmd = "/usr/bin/python %s/../tools/azure_image_prepare/azure_image_prepare.py -setup" % realpath
     self.assertEqual(azure_cli_common.host_command(cmd, ret='exit_status'), 0,
                      "Fail to setup environment")
     self.log.info("Begin to install image")
     cmd = "/usr/bin/python %s/../tools/azure_image_prepare/azure_image_prepare.py -check" % realpath
     self.assertEqual(azure_cli_common.host_command(cmd, ret='exit_status'), 0,
                      "Fail to check environment")
     cmd = "/usr/bin/python %s/../tools/azure_image_prepare/azure_image_prepare.py -download" % realpath
     self.assertEqual(azure_cli_common.host_command(cmd, ret='exit_status', timeout=12*3600), 0,
                      "Fail to download iso")
     cmd = "/usr/bin/python %s/../tools/azure_image_prepare/azure_image_prepare.py -install" % realpath
     self.assertEqual(azure_cli_common.host_command(cmd, ret='exit_status', timeout=12*3600), 0,
                      "Fail to install image")