Esempio n. 1
0
  def basic_test(self):
    simulation = None
    try:
      start_cmd = ('''./pox.py --verbose '''
                   '''openflow.discovery forwarding.l2_multi '''
                   '''sts.util.socket_mux.pox_monkeypatcher --snapshot_address=../snapshot_socket '''
                   '''openflow.of_01 --address=__address__ --port=__port__''')

      IPAddressSpace._claimed_addresses.clear()
      ControllerConfig._controller_labels.clear()
      controllers = [ControllerConfig(start_cmd, cwd="pox", snapshot_address="./snapshot_socket")]
      topology_class = MeshTopology
      topology_params = "num_switches=2"

      simulation_config = SimulationConfig(controller_configs=controllers,
                                           topology_class=topology_class,
                                           topology_params=topology_params,
                                           multiplex_sockets=True)
      simulation = simulation_config.bootstrap(RecordingSyncCallback(None))
      simulation.connect_to_controllers()

      c1 = simulation.controller_manager.controllers[0]
      c1_pid = c1.pid

      snapshotter = Snapshotter(simulation, c1)
      snapshotter.snapshot_controller()
      # TODO(cs): time.sleep() is a broken way to synchronize
      time.sleep(1)
      kill_procs([c1.process])
      snapshotter.snapshot_proceed()

      self.assertEqual(1, len(simulation.controller_manager.controllers))
      c2 = simulation.controller_manager.controllers[0]
      c2_pid = c2.pid
      self.assertTrue(c1_pid != c2_pid)
      # Controller object itself should not have changed
      self.assertTrue(c1 == c2)

      # snapshotting should work multiple times
      snapshotter = Snapshotter(simulation, c2)
      snapshotter.snapshot_controller()
      # TODO(cs): time.sleep() is a broken way to synchronize
      time.sleep(1)
      kill_procs([c2.process])
      snapshotter.snapshot_proceed()

      self.assertEqual(1, len(simulation.controller_manager.controllers))
      c3 = simulation.controller_manager.controllers[0]
      self.assertTrue(c2_pid != c3.pid)
    finally:
      try:
        if simulation is not None:
          simulation.clean_up()
      except Exception as e:
        print "SnapshotTest.test_basic: exception encountered in finally clause: %s" % e
  def basic_test(self):
    start_cmd = ('''./pox.py --verbose '''
                 '''openflow.discovery forwarding.l2_multi '''
                 '''sts.util.socket_mux.pox_monkeypatcher '''
                 '''openflow.of_01 --address=__address__ --port=__port__''')

    IPAddressSpace._claimed_addresses.clear()
    ControllerConfig._controller_labels.clear()
    controllers = [ControllerConfig(start_cmd, cwd="pox")]
    topology_class = MeshTopology
    topology_params = "num_switches=2"

    simulation_config = SimulationConfig(controller_configs=controllers,
                                         topology_class=topology_class,
                                         topology_params=topology_params,
                                         multiplex_sockets=True)
    simulation = simulation_config.bootstrap(RecordingSyncCallback(None))
    simulation.set_pass_through()
    simulation.connect_to_controllers()
    time.sleep(1)
    observed_events = simulation.unset_pass_through()
    print "Observed events: %s" % str(observed_events)
    self.assertTrue(observed_events != [])
Esempio n. 3
0
    def basic_test(self):
        start_cmd = (
            '''./pox.py --verbose '''
            '''openflow.discovery forwarding.l2_multi '''
            '''sts.util.socket_mux.pox_monkeypatcher '''
            '''openflow.of_01 --address=__address__ --port=__port__''')

        IPAddressSpace._claimed_addresses.clear()
        ControllerConfig._controller_labels.clear()
        controllers = [ControllerConfig(start_cmd, cwd="pox")]
        topology_class = MeshTopology
        topology_params = "num_switches=2"

        simulation_config = SimulationConfig(controller_configs=controllers,
                                             topology_class=topology_class,
                                             topology_params=topology_params,
                                             multiplex_sockets=True)
        simulation = simulation_config.bootstrap(RecordingSyncCallback(None))
        simulation.set_pass_through()
        simulation.connect_to_controllers()
        time.sleep(1)
        observed_events = simulation.unset_pass_through()
        print "Observed events: %s" % str(observed_events)
        self.assertTrue(observed_events != [])
Esempio n. 4
0
    def basic_test(self):
        simulation = None
        try:
            start_cmd = (
                '''./pox.py --verbose '''
                '''openflow.discovery forwarding.l2_multi '''
                '''sts.util.socket_mux.pox_monkeypatcher --snapshot_address=../snapshot_socket '''
                '''openflow.of_01 --address=__address__ --port=__port__''')

            IPAddressSpace._claimed_addresses.clear()
            ControllerConfig._controller_labels.clear()
            controllers = [
                ControllerConfig(start_cmd,
                                 cwd="pox",
                                 snapshot_address="./snapshot_socket")
            ]
            topology_class = MeshTopology
            topology_params = "num_switches=2"

            simulation_config = SimulationConfig(
                controller_configs=controllers,
                topology_class=topology_class,
                topology_params=topology_params,
                multiplex_sockets=True)
            simulation = simulation_config.bootstrap(
                RecordingSyncCallback(None))
            simulation.connect_to_controllers()

            c1 = simulation.controller_manager.controllers[0]
            c1_pid = c1.pid

            snapshotter = Snapshotter(simulation, c1)
            snapshotter.snapshot_controller()
            # TODO(cs): time.sleep() is a broken way to synchronize
            time.sleep(1)
            kill_procs([c1.process])
            snapshotter.snapshot_proceed()

            self.assertEqual(1, len(simulation.controller_manager.controllers))
            c2 = simulation.controller_manager.controllers[0]
            c2_pid = c2.pid
            self.assertTrue(c1_pid != c2_pid)
            # Controller object itself should not have changed
            self.assertTrue(c1 == c2)

            # snapshotting should work multiple times
            snapshotter = Snapshotter(simulation, c2)
            snapshotter.snapshot_controller()
            # TODO(cs): time.sleep() is a broken way to synchronize
            time.sleep(1)
            kill_procs([c2.process])
            snapshotter.snapshot_proceed()

            self.assertEqual(1, len(simulation.controller_manager.controllers))
            c3 = simulation.controller_manager.controllers[0]
            self.assertTrue(c2_pid != c3.pid)
        finally:
            try:
                if simulation is not None:
                    simulation.clean_up()
            except Exception as e:
                print "SnapshotTest.test_basic: exception encountered in finally clause: %s" % e