Ejemplo n.º 1
0
    def test_VirshSession(self):
        """
        Unittest for VirshSession.

        This test use VirshSession over VirshPersistent with auto_close=True.
        """
        virsh_exec = self.virsh.Virsh()['virsh_exec']
        # Build a VirshSession object.
        session_1 = self.virsh.VirshSession(virsh_exec, auto_close=True)
        self.assertTrue(utils.process_is_alive(virsh_exec))
        del session_1
        self.assertFalse(utils.process_is_alive(virsh_exec))
Ejemplo n.º 2
0
    def test_VirshSession(self):
        """
        Unittest for VirshSession.

        This test use VirshSession over VirshPersistent with auto_close=True.
        """
        virsh_exec = self.virsh.Virsh()['virsh_exec']
        # Build a VirshSession object.
        session_1 = self.virsh.VirshSession(virsh_exec, auto_close=True)
        self.assertTrue(utils.process_is_alive(virsh_exec))
        del session_1
        self.assertFalse(utils.process_is_alive(virsh_exec))
Ejemplo n.º 3
0
    def test_del_VirshPersistent(self):
        """
        Unittest for __del__ of VirshPersistent.

        This test makes sure the __del__ method of VirshPersistent works
        well in `del vp_instance`.
        """
        vp = self.virsh.VirshPersistent()
        virsh_exec = vp.virsh_exec
        self.assertTrue(utils.process_is_alive(virsh_exec))
        del vp
        self.assertFalse(utils.process_is_alive(virsh_exec))
Ejemplo n.º 4
0
    def test_del_VirshPersistent(self):
        """
        Unittest for __del__ of VirshPersistent.

        This test makes sure the __del__ method of VirshPersistent works
        well in `del vp_instance`.
        """
        vp = self.virsh.VirshPersistent()
        virsh_exec = vp.virsh_exec
        self.assertTrue(utils.process_is_alive(virsh_exec))
        del vp
        self.assertFalse(utils.process_is_alive(virsh_exec))
Ejemplo n.º 5
0
 def setUp(self):
     logging.disable(logging.INFO)
     super(VirshPersistentClassHasHelpCommandTest, self).setUp()
     self.VirshPersistent = self.virsh.VirshPersistent
     self.assertEqual(self.VirshPersistent.SESSION_COUNTER, 0)
     self.virsh = self.VirshPersistent(debug=False)
     self.assertEqual(self.VirshPersistent.SESSION_COUNTER, 1)
     self.assertTrue(utils.process_is_alive(self.virsh.virsh_exec))
Ejemplo n.º 6
0
 def setUp(self):
     logging.disable(logging.INFO)
     super(VirshPersistentClassHasHelpCommandTest, self).setUp()
     self.VirshPersistent = self.virsh.VirshPersistent
     self.assertEqual(self.VirshPersistent.SESSION_COUNTER, 0)
     self.virsh = self.VirshPersistent(debug=False)
     self.assertEqual(self.VirshPersistent.SESSION_COUNTER, 1)
     self.assertTrue(utils.process_is_alive(self.virsh.virsh_exec))
Ejemplo n.º 7
0
    def test_VirshPersistent(self):
        """
        Unittest for session manager of VirshPersistent.
        """
        virsh_exec = self.virsh.Virsh()['virsh_exec']
        vp_1 = self.virsh.VirshPersistent()
        self.assertTrue(utils.process_is_alive(virsh_exec))
        # Init the vp_2 with same params of vp_1.
        vp_2 = self.virsh.VirshPersistent(**vp_1)
        # Make sure vp_1 and vp_2 are refer to the same session.
        self.assertEqual(vp_1.session_id, vp_2.session_id)

        del vp_1
        # Make sure the session is not closed when vp_2 still refer to it.
        self.assertTrue(utils.process_is_alive(virsh_exec))
        del vp_2
        # Session was closed since no other VirshPersistent refer to it.
        self.assertFalse(utils.process_is_alive(virsh_exec))
Ejemplo n.º 8
0
    def test_VirshPersistent(self):
        """
        Unittest for session manager of VirshPersistent.
        """
        virsh_exec = self.virsh.Virsh()['virsh_exec']
        vp_1 = self.virsh.VirshPersistent()
        self.assertTrue(utils.process_is_alive(virsh_exec))
        # Init the vp_2 with same params of vp_1.
        vp_2 = self.virsh.VirshPersistent(**vp_1)
        # Make sure vp_1 and vp_2 are refer to the same session.
        self.assertEqual(vp_1.session_id, vp_2.session_id)

        del vp_1
        # Make sure the session is not closed when vp_2 still refer to it.
        self.assertTrue(utils.process_is_alive(virsh_exec))
        del vp_2
        # Session was closed since no other VirshPersistent refer to it.
        self.assertFalse(utils.process_is_alive(virsh_exec))
Ejemplo n.º 9
0
        muliticast_addr = params.get("muliticast_addr", "225.0.0.3")
        multicast_port = params.get("multicast_port", "5001")

        step_msg = "Start iperf server, bind host to multicast address %s "
        error.context(step_msg % muliticast_addr, logging.info)
        server_start_cmd = ("iperf -s -u -B %s -p %s " %
                            (muliticast_addr, multicast_port))

        default_flag = "%s port %s connected with %s"
        connected_flag = params.get("connected_flag", default_flag)
        catch_data = connected_flag % (muliticast_addr, multicast_port,
                                       client_ip)
        t = utils.InterruptedThread(server_start,
                                    (server_start_cmd, catch_data))
        t.start()
        if not utils.process_is_alive("iperf"):
            raise error.TestError("Start iperf server failed cmd: %s" %
                                  server_start_cmd)
        logging.info("Server start successfully")

        step_msg = "In client try to connect server and transfer file "
        step_msg += " through multicast address %s"
        error.context(step_msg % muliticast_addr, logging.info)
        if os_type == "linux":
            client_cmd = "iperf"
        else:
            client_cmd = guest_path
        start_cmd = params.get("start_client_cmd", "%s -c %s -u -p %s")
        start_client_cmd = start_cmd % (client_cmd, muliticast_addr,
                                        multicast_port)
        session.cmd(start_client_cmd)
Ejemplo n.º 10
0
        muliticast_addr = params.get("muliticast_addr", "225.0.0.3")
        multicast_port = params.get("multicast_port", "5001")

        step_msg = "Start iperf server, bind host to multicast address %s "
        error.context(step_msg % muliticast_addr, logging.info)
        server_start_cmd = ("iperf -s -u -B %s -p %s " %
                            (muliticast_addr, multicast_port))

        default_flag = "%s port %s connected with %s"
        connected_flag = params.get("connected_flag", default_flag)
        catch_data = connected_flag % (muliticast_addr, multicast_port,
                                       client_ip)
        t = utils.InterruptedThread(server_start, (server_start_cmd,
                                                   catch_data))
        t.start()
        if not utils.process_is_alive("iperf"):
            raise error.TestError("Start iperf server failed cmd: %s"
                                  % server_start_cmd)
        logging.info("Server start successfully")

        step_msg = "In client try to connect server and transfer file "
        step_msg += " through multicast address %s"
        error.context(step_msg % muliticast_addr, logging.info)
        if os_type == "linux":
            client_cmd = "iperf"
        else:
            client_cmd = guest_path
        start_cmd = params.get("start_client_cmd", "%s -c %s -u -p %s")
        start_client_cmd = start_cmd % (client_cmd, muliticast_addr,
                                        multicast_port)
        session.cmd(start_client_cmd)
Ejemplo n.º 11
0
 def tearDown(self):
     self.assertTrue(utils.process_is_alive(self.virsh.virsh_exec))
     self.virsh.close_session()
     self.assertFalse(utils.process_is_alive(self.virsh.virsh_exec))
Ejemplo n.º 12
0
 def tearDown(self):
     self.assertTrue(utils.process_is_alive(self.virsh.virsh_exec))
     self.virsh.close_session()
     self.assertFalse(utils.process_is_alive(self.virsh.virsh_exec))
Ejemplo n.º 13
0
 def tearDown(self):
     self.assertEqual(self.VirshPersistent.SESSION_COUNTER, 1)
     self.assertTrue(utils.process_is_alive(self.virsh.virsh_exec))
     self.virsh.close_session()
     self.assertEqual(self.VirshPersistent.SESSION_COUNTER, 0)
     self.assertFalse(utils.process_is_alive(self.virsh.virsh_exec))
Ejemplo n.º 14
0
 def tearDown(self):
     self.assertEqual(self.VirshPersistent.SESSION_COUNTER, 1)
     self.assertTrue(utils.process_is_alive(self.virsh.virsh_exec))
     self.virsh.close_session()
     self.assertEqual(self.VirshPersistent.SESSION_COUNTER, 0)
     self.assertFalse(utils.process_is_alive(self.virsh.virsh_exec))