Example #1
0
    def play_forward(results_dir, subsequence_id):
      # TODO(cs): need to serialize the parameters to Replayer rather than
      # wrapping them in a closure... otherwise, can't use RemoteForker
      # TODO(aw): MCSFinder needs to configure Simulation to always let DataplaneEvents pass through
      create_clean_python_dir(results_dir)

      # Copy stdout and stderr to a file "replay.out"
      tee = Tee(open(os.path.join(results_dir, "replay.out"), "w"))
      tee.tee_stdout()
      tee.tee_stderr()

      # Set up replayer.
      input_logger = InputLogger()
      replayer = Replayer(self.simulation_cfg, new_dag,
                          wait_on_deterministic_values=self.wait_on_deterministic_values,
                          input_logger=input_logger,
                          allow_unexpected_messages=False,
                          pass_through_whitelisted_messages=True,
                          delay_flow_mods=self.delay_flow_mods,
                          **self.kwargs)
      replayer.init_results(results_dir)
      self._runtime_stats = RuntimeStats(subsequence_id)
      violations = []
      simulation = None
      try:
        simulation = replayer.simulate()
        self._track_new_internal_events(simulation, replayer)
        # Wait a bit in case the bug takes awhile to happen
        self.log("Sleeping %d seconds after run" % self.end_wait_seconds)
        time.sleep(self.end_wait_seconds)
        violations = self.invariant_check(simulation)
        if violations != []:
          input_logger.log_input_event(InvariantViolation(violations))
      except SystemExit:
        # One of the invariant checks bailed early. Oddly, this is not an
        # error for us, it just means that there were no violations...
        # [this logic is arguably broken]
        # Return no violations, and let Forker handle system exit for us.
        violations = []
      finally:
        input_logger.close(replayer, self.simulation_cfg, skip_mcs_cfg=True)
        if simulation is not None:
          simulation.clean_up()
        tee.close()
      if self.strict_assertion_checking:
        test_serialize_response(violations, self._runtime_stats.client_dict())
      timed_out_internal = [ e.label for e in new_dag.events if e.timed_out ]
      return (violations, self._runtime_stats.client_dict(), timed_out_internal)
def main(args):
  if args.dp_trace_path is None:
    args.dp_trace_path = os.path.dirname(args.input) + "/dataplane.trace"

  dp_trace = Trace(args.dp_trace_path).dataplane_trace

  event_logger = InputLogger()
  event_logger.open(results_dir="/tmp/events.trace")

  with open(args.input) as input_file:
    trace = parse(input_file)
    for event in trace:
      if type(event) == replay_events.TrafficInjection:
        event.dp_event = dp_trace.pop(0)
      event_logger.log_input_event(event)

    event_logger.output.close()
Example #3
0
    def play_forward(results_dir, subsequence_id):
      # TODO(cs): need to serialize the parameters to Replayer rather than
      # wrapping them in a closure... otherwise, can't use RemoteForker
      # TODO(aw): MCSFinder needs to configure Simulation to always let DataplaneEvents pass through
      create_clean_python_dir(results_dir)

      # Copy stdout and stderr to a file "replay.out"
      tee = Tee(open(os.path.join(results_dir, "replay.out"), "w"))
      tee.tee_stdout()
      tee.tee_stderr()

      # Set up replayer.
      input_logger = InputLogger()
      replayer = Replayer(self.simulation_cfg, new_dag,
                          input_logger=input_logger,
                          bug_signature=self.bug_signature,
                          invariant_check_name=self.invariant_check_name,
                          **self.kwargs)
      replayer.init_results(results_dir)
      self._runtime_stats = RuntimeStats(subsequence_id)
      simulation = None
      try:
        simulation = replayer.simulate()
        self._track_new_internal_events(simulation, replayer)
      except SystemExit:
        # One of the invariant checks bailed early. Oddly, this is not an
        # error for us, it just means that there were no violations...
        # [this logic is arguably broken]
        # Return no violations, and let Forker handle system exit for us.
        simulation.violation_found = False
      finally:
        input_logger.close(replayer, self.simulation_cfg, skip_mcs_cfg=True)
        if simulation is not None:
          simulation.clean_up()
        tee.close()
      if self.strict_assertion_checking:
        test_serialize_response(violations, self._runtime_stats.client_dict())
      timed_out_internal = [ e.label for e in new_dag.events if e.timed_out ]
      return (simulation.violation_found, self._runtime_stats.client_dict(), timed_out_internal)
Example #4
0
 def _dump_mcs_trace(self, dag=None, mcs_trace_path=None):
   if dag is None:
     dag = self.dag
   if mcs_trace_path is None:
     mcs_trace_path = self.mcs_trace_path
   # Dump the mcs trace
   input_logger = InputLogger(output_path=mcs_trace_path)
   input_logger.open(os.path.dirname(mcs_trace_path))
   for e in dag.events:
     input_logger.log_input_event(e)
   input_logger.close(self, self.simulation_cfg, skip_mcs_cfg=True)
Example #5
0
 def dump_mcs_trace(self, dag, control_flow, mcs_trace_path=None):
   if mcs_trace_path is None:
     mcs_trace_path = self.mcs_trace_path
   for extension in ["", ".notimeouts"]:
     output_path = mcs_trace_path + extension
     input_logger = InputLogger()
     input_logger.open(os.path.dirname(output_path),
                       output_filename="mcs.trace" + extension)
     for e in dag.events:
       if extension == ".notimeouts" and e.timed_out:
         continue
       input_logger.log_input_event(e)
     input_logger.close(control_flow, self.simulation_cfg, skip_mcs_cfg=True)
Example #6
0
from sts.topology import *
from sts.control_flow import Replayer
from sts.simulation_state import SimulationConfig
from sts.input_traces.input_logger import InputLogger

simulation_config = SimulationConfig(controller_configs=[
    ControllerConfig(
        start_cmd=
        './pox.py --verbose --unthreaded-sh misc.ip_loadbalancer --ip=123.123.1.3 --servers=123.123.2.3,123.123.1.3 sts.util.socket_mux.pox_monkeypatcher   openflow.discovery openflow.of_01 --address=__address__ --port=__port__',
        label='c1',
        address='127.0.0.1',
        cwd='dart_pox')
],
                                     topology_class=MeshTopology,
                                     topology_params="num_switches=3",
                                     patch_panel_class=BufferedPatchPanel,
                                     multiplex_sockets=True,
                                     kill_controllers_on_exit=True)

control_flow = Replayer(
    simulation_config,
    "experiments/load_balancer_fuzzer_mcs/interreplay_82_l_4/events.trace",
    input_logger=InputLogger(),
    wait_on_deterministic_values=False,
    allow_unexpected_messages=False,
    delay_flow_mods=False,
    default_dp_permit=False,
    pass_through_whitelisted_messages=False,
    invariant_check_name='check_for_ofp_error',
    bug_signature="ERROR_SENT")
Example #7
0
controllers = [
    ControllerConfig(start_cmd,
                     address="192.168.56.11",
                     port=6633,
                     kill_cmd=kill_cmd % "onosdev1",
                     restart_cmd=restart_cmd % "onosdev1",
                     controller_type="onos",
                     cwd="/home/rcs/vagrant_onosdev"),
    ControllerConfig(dummy_cmd,
                     address="192.168.56.12",
                     port=6633,
                     kill_cmd=kill_cmd % "onosdev2",
                     restart_cmd=restart_cmd % "onosdev2",
                     controller_type="onos",
                     cwd="/home/rcs/vagrant_onosdev")
]
topology_class = MeshTopology
topology_params = "num_switches=2"

simulation_config = SimulationConfig(controller_configs=controllers,
                                     topology_class=topology_class,
                                     topology_params=topology_params,
                                     kill_controllers_on_exit=False)

#control_flow = Fuzzer(simulation_config, check_interval=20,
#                      halt_on_violation=True,
#                      input_logger=InputLogger(),
#                      invariant_check_name="InvariantChecker.check_loops")
control_flow = Interactive(simulation_config, input_logger=InputLogger())
Example #8
0
from experiment_config_lib import ControllerConfig
from sts.control_flow import Fuzzer
from sts.input_traces.input_logger import InputLogger
from sts.invariant_checker import InvariantChecker
from sts.simulation_state import SimulationConfig

# Use NOX as our controller
command_line = "./nox_core -i ptcp:6633 routing"
controllers = [ControllerConfig(command_line, cwd="nox_classic/build/src", address="127.0.0.1", port=6633)]

dataplane_trace = "dataplane_traces/ping_pong_fat_tree.trace"

simulation_config = SimulationConfig(controller_configs=controllers,
                                     dataplane_trace=dataplane_trace)

# Use a Fuzzer (already the default)
control_flow = Fuzzer(simulation_config, input_logger=InputLogger(),
                      check_interval=80,
                      invariant_check=InvariantChecker.check_connectivity)

Example #9
0
 def _dump_mcs_trace(self):
   # Dump the mcs trace
   input_logger = InputLogger(output_path=self.mcs_trace_path)
   for e in self.dag.events:
     input_logger.log_input_event(e)
   input_logger.close(self.simulation_cfg, skip_mcs_cfg=True)