예제 #1
0
 def test_add_get_remove_applications(self):
     for v in self.topo.nodes_iter():
         self.assertEqual([], fnss.get_application_names(self.topo, v))
     fnss.add_application(self.topo, 10, self.app_1_name, self.app_1_props)
     self.assertEqual([self.app_1_name],
                      fnss.get_application_names(self.topo, 10))
     self.assertEqual(self.app_1_props,
                      fnss.get_application_properties(self.topo, 10, 
                                                 self.app_1_name))
     fnss.add_application(self.topo, 10, self.app_1_name, self.app_2_props)
     self.assertEqual([self.app_1_name],
                      fnss.get_application_names(self.topo, 10))
     self.assertEqual(self.app_2_props,
                      fnss.get_application_properties(self.topo, 10,
                                                 self.app_1_name))
     fnss.add_application(self.topo, 10, self.app_2_name, self.app_2_props)
     self.assertEqual(set([self.app_1_name, self.app_2_name]),
                      set(fnss.get_application_names(self.topo, 10)))
     self.assertEqual(self.app_2_props,
                      fnss.get_application_properties(self.topo, 10,
                                                 self.app_1_name))
     self.assertEqual(self.app_2_props,
                      fnss.get_application_properties(self.topo, 10,
                                                 self.app_2_name))
     fnss.remove_application(self.topo, 10, self.app_2_name)
     self.assertEqual([self.app_1_name],
                      fnss.get_application_names(self.topo, 10))
     fnss.remove_application(self.topo, 10, self.app_1_name)
     self.assertEqual([], fnss.get_application_names(self.topo, 10))
     fnss.add_application(self.topo, 10, self.app_1_name, self.app_1_props)
     fnss.add_application(self.topo, 10, self.app_2_name, self.app_1_props)
     fnss.remove_application(self.topo, 10)
     self.assertEqual([], fnss.get_application_names(self.topo, 10))
예제 #2
0
 def test_add_get_remove_applications(self):
     for v in self.topo.nodes():
         self.assertEqual([], fnss.get_application_names(self.topo, v))
     fnss.add_application(self.topo, 10, self.app_1_name, self.app_1_props)
     self.assertEqual([self.app_1_name],
                      fnss.get_application_names(self.topo, 10))
     self.assertEqual(self.app_1_props,
                      fnss.get_application_properties(self.topo, 10,
                                                 self.app_1_name))
     fnss.add_application(self.topo, 10, self.app_1_name, self.app_2_props)
     self.assertEqual([self.app_1_name],
                      fnss.get_application_names(self.topo, 10))
     self.assertEqual(self.app_2_props,
                      fnss.get_application_properties(self.topo, 10,
                                                 self.app_1_name))
     fnss.add_application(self.topo, 10, self.app_2_name, self.app_2_props)
     self.assertEqual(set([self.app_1_name, self.app_2_name]),
                      set(fnss.get_application_names(self.topo, 10)))
     self.assertEqual(self.app_2_props,
                      fnss.get_application_properties(self.topo, 10,
                                                 self.app_1_name))
     self.assertEqual(self.app_2_props,
                      fnss.get_application_properties(self.topo, 10,
                                                 self.app_2_name))
     fnss.remove_application(self.topo, 10, self.app_2_name)
     self.assertEqual([self.app_1_name],
                      fnss.get_application_names(self.topo, 10))
     fnss.remove_application(self.topo, 10, self.app_1_name)
     self.assertEqual([], fnss.get_application_names(self.topo, 10))
     fnss.add_application(self.topo, 10, self.app_1_name, self.app_1_props)
     fnss.add_application(self.topo, 10, self.app_2_name, self.app_1_props)
     fnss.remove_application(self.topo, 10)
     self.assertEqual([], fnss.get_application_names(self.topo, 10))
예제 #3
0
 def test_read_write_topology(self):
     tmp_topo_file = path.join(TMP_DIR, 'toporw.xml')
     fnss.write_topology(self.G, tmp_topo_file)
     self.assertTrue(path.exists(tmp_topo_file))
     read_topo = fnss.read_topology(tmp_topo_file)
     self.assertEqual(len(self.G), len(read_topo))
     self.assertEqual(self.G.number_of_edges(), read_topo.number_of_edges())
     self.assertEqual('tcp', fnss.get_stack(read_topo, 2)[0])
     self.assertEqual(1024, fnss.get_stack(read_topo, 2)[1]['rcvwnd'])
     self.assertEqual('cubic', fnss.get_stack(read_topo, 2)[1]['protocol'])
     self.assertEqual(len(fnss.get_application_names(self.G, 2)),
                      len(fnss.get_application_names(read_topo, 2)))
     self.assertEqual(
         'fnss',
         fnss.get_application_properties(read_topo, 2,
                                         'server')['user-agent'])
     self.assertEqual([2, 4, 6], [
         v for v in read_topo.nodes()
         if fnss.get_stack(read_topo, v) is not None
         and fnss.get_stack(read_topo, v)[0] == 'tcp'
     ])
     self.assertEqual([2, 4], [
         v for v in read_topo.nodes()
         if 'client' in fnss.get_application_names(read_topo, v)
     ])
     self.assertEqual([2], [
         v for v in read_topo.nodes()
         if 'server' in fnss.get_application_names(read_topo, v)
     ])
예제 #4
0
 def test_read_write_topology(self):
     tmp_topo_file = path.join(TMP_DIR, 'toporw.xml')
     fnss.write_topology(self.G, tmp_topo_file)
     self.assertTrue(path.exists(tmp_topo_file))
     read_topo = fnss.read_topology(tmp_topo_file)
     self.assertEquals(len(self.G), len(read_topo))
     self.assertEquals(self.G.number_of_edges(),
                       read_topo.number_of_edges())
     self.assertEquals('tcp', fnss.get_stack(read_topo, 2)[0])
     self.assertEquals(1024, fnss.get_stack(read_topo, 2)[1]['rcvwnd'])
     self.assertEquals('cubic', fnss.get_stack(read_topo, 2)[1]['protocol'])
     self.assertEquals(len(fnss.get_application_names(self.G, 2)), 
                   len(fnss.get_application_names(read_topo, 2)))
     self.assertEquals('fnss', fnss.get_application_properties(read_topo, 2, 'server')['user-agent'])
     self.assertEquals([2, 4, 6], [ v for v in read_topo.nodes_iter()
                                   if fnss.get_stack(read_topo, v) is not None
                                   and fnss.get_stack(read_topo, v)[0] == 'tcp'])
     self.assertEquals([2, 4], [ v for v in read_topo.nodes_iter()
                                if 'client' in fnss.get_application_names(read_topo, v)])
     self.assertEquals([2], [ v for v in read_topo.nodes_iter()
                             if 'server' in fnss.get_application_names(read_topo, v)])