示例#1
0
 def testInitOneToOne(self):
     """Make sure that we are setting things up right."""
     self.ips_obj = iperf.IperfSet(self.fake_host_src[0],
                                   self.fake_host_dst[0],
                                   IperfSetTest.dst[0])
     self.assertEqual(len(self.ips_obj.client_list), 1)
     self.assertEqual(len(self.ips_obj.server_list), 1)
     for client in self.ips_obj.client_list:
         self.assertTrue(isinstance(client, iperf.IperfClient))
         self.assertIn('-c %s' % IperfSetTest.dst[0], client.args)
     for server in self.ips_obj.server_list:
         self.assertTrue(isinstance(server, iperf.IperfServer))
示例#2
0
 def testStop(self):
     """Make sure that all server and clients are stopped."""
     self.ips_obj = iperf.IperfSet(self.fake_host_src, self.fake_host_dst,
                                   IperfSetTest.dst)
     self.ips_obj.Start()
     for server in self.ips_obj.server_list:
         self.assertGreater(server.child_pid, 0)
     for client in self.ips_obj.client_list:
         self.assertGreater(client.child_pid, 0)
     self.ips_obj.Stop()
     for server in self.ips_obj.server_list:
         self.assertIsNone(server.child_pid)
     for client in self.ips_obj.client_list:
         self.assertIsNone(client.child_pid)
示例#3
0
    def testStart(self):
        """Make sure that all server and clients are started.

    Let's also make sure that they have the right hostnames.
    """
        self.ips_obj = iperf.IperfSet(self.fake_host_src, self.fake_host_dst,
                                      IperfSetTest.dst)
        for server in self.ips_obj.server_list:
            self.assertIsNone(server.child_pid)
        for client in self.ips_obj.client_list:
            self.assertIsNone(client.child_pid)
        self.ips_obj.Start()
        for server in self.ips_obj.server_list:
            self.assertGreater(server.child_pid, 0)
        for client in self.ips_obj.client_list:
            self.assertGreater(client.child_pid, 0)
示例#4
0
    def testResults(self):
        """Make sure that all server and clients are saving results.

    Let's also make sure that they have the right content.
    """
        self.ips_obj = iperf.IperfSet(self.fake_host_src, self.fake_host_dst,
                                      IperfSetTest.dst)
        self.ips_obj.Start(length=10)
        self.ips_obj.Stop()
        results = self.ips_obj.Results()
        self.assertEqual(len(results), 2)
        self.assertEqual(len(results[0]), len(self.fake_host_dst))
        self.assertEqual(len(results[1]), len(self.fake_host_src))
        for i in range(0, len(self.fake_host_dst)):
            self.assertIn('Server listening', results[0][i])
        for i in range(0, len(self.fake_host_src)):
            self.assertIn('Client connecting', results[1][i])
示例#5
0
 def testInitManyToOne(self):
     """Make sure that we are setting things up right."""
     self.ips_obj = iperf.IperfSet(self.fake_host_src,
                                   self.fake_host_dst[0],
                                   IperfSetTest.dst[0])
     self.assertEqual(len(self.ips_obj.client_list),
                      len(self.fake_host_src))
     self.assertEqual(len(self.ips_obj.server_list), 1)
     for i in range(0, len(self.ips_obj.client_list)):
         self.assertTrue(
             isinstance(self.ips_obj.client_list[i], iperf.IperfClient))
         self.assertIn('-c %s' % IperfSetTest.dst[0],
                       self.ips_obj.client_list[i].args)
         self.assertEqual(self.ips_obj.client_list[i].host.host,
                          IperfSetTest.target_src[i])
     for server in self.ips_obj.server_list:
         self.assertTrue(isinstance(server, iperf.IperfServer))