Ejemplo n.º 1
0
def my_funky_invariant_check(simulation):
  from sts.invariant_checker import InvariantChecker
  result = InvariantChecker.check_loops(simulation)
  if result:
    return result
  result = InvariantChecker.check_connectivity(simulation)
  if not result:
    print "Connectivity established - bailing out"
    import sys
    sys.exit(0)
  return []
Ejemplo n.º 2
0
def my_funky_invariant_check(simulation):
  from sts.invariant_checker import InvariantChecker
  result = InvariantChecker.check_loops(simulation)
  if result:
    return result
  result = InvariantChecker.check_connectivity(simulation)
  if not result:
    print "Connectivity established - bailing out"
    import sys
    sys.exit(0)
  return []
Ejemplo n.º 3
0
 def test_hassel_c_no_loop(self):
     if not hassel_c_loaded:
         return
     topo = self._create_loopy_network(cut_loop=True)
     (name_tf_pairs, TTF) = InvariantChecker._get_transfer_functions(topo.switches, topo.network_links)
     loops = hsa.check_loops_hassel_c(name_tf_pairs, TTF, topo.access_links)
     self.assertTrue(loops == [])
Ejemplo n.º 4
0
def check_everything(simulation):
    # Check liveness once at the beginning
    # If there are no more live controllers, stop
    violations = []
    down_controllers = InvariantChecker.check_liveness(simulation)
    violations = down_controllers
    # Check other invariants without checking liveness
    checks = [InvariantChecker.check_loops, InvariantChecker.python_check_blackholes]
    # InvariantChecker.check_connectivity ]
    for check in checks:
        violations += check(simulation, check_liveness_first=False)
    violations = list(set(violations))
    return violations
Ejemplo n.º 5
0
def check_everything(simulation):
    # Check liveness once at the beginning
    # If there are no more live controllers, stop
    violations = []
    down_controllers = InvariantChecker.check_liveness(simulation)
    violations = down_controllers
    # Check other invariants without checking liveness
    checks = [
        InvariantChecker.check_loops, InvariantChecker.python_check_blackholes
    ]
    #InvariantChecker.check_connectivity ]
    for check in checks:
        violations += check(simulation, check_liveness_first=False)
    violations = list(set(violations))
    return violations
Ejemplo n.º 6
0
    def invariant_check(self, kind):
        if kind == "omega" or kind == "o":
            self._log_input_event(
                CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_correspondence")
            )
            result = InvariantChecker.check_correspondence(self.simulation)
            message = "Controllers with miscorrepondence: "
        elif kind == "connectivity" or kind == "c":
            self._log_input_event(
                CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_connectivity")
            )
            result = InvariantChecker.check_connectivity(self.simulation)
            message = "Disconnected host pairs: "
        elif kind == "python_connectivity" or kind == "pc":
            self._log_input_event(
                CheckInvariants(
                    round=self.logical_time, invariant_check_name="InvariantChecker.python_check_connectivity"
                )
            )
            result = InvariantChecker.python_check_connectivity(self.simulation)
            message = "Disconnected host pairs: "
        elif kind == "loops" or kind == "lo":
            self._log_input_event(
                CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_loops")
            )
            result = InvariantChecker.python_check_loops(self.simulation)
            message = "Loops: "
        elif kind == "liveness" or kind == "li":
            self._log_input_event(
                CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_liveness")
            )
            result = InvariantChecker.check_liveness(self.simulation)
            message = "Crashed controllers: "
        elif kind == "blackholes" or kind == "bl":
            self._log_input_event(
                CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_blackholes")
            )
            result = InvariantChecker.python_check_blackholes(self.simulation)
            message = "Blackholes: "
        else:
            log.warn("Unknown invariant kind...")
            return
        self.simulation.violation_tracker.track(result, self.logical_time)
        persistent_violations = self.simulation.violation_tracker.persistent_violations
        transient_violations = list(set(result) - set(persistent_violations))

        msg.interactive(message + str(result))
        if transient_violations != []:
            self._log_input_event(InvariantViolation(transient_violations))
        if persistent_violations != []:
            msg.fail("Persistent violations detected!: %s" % str(persistent_violations))
            self._log_input_event(InvariantViolation(persistent_violations, persistent=True))
Ejemplo n.º 7
0
  def invariant_check(self, kind):
    if kind == "omega" or kind == "o":
      self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_correspondence"))
      result = InvariantChecker.check_correspondence(self.simulation)
      message = "Controllers with miscorrepondence: "
    elif kind == "connectivity" or kind == "c":
      self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_connectivity"))
      result = InvariantChecker.check_connectivity(self.simulation)
      message = "Disconnected host pairs: "
    elif kind == "python_connectivity" or kind == "pc":
      self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.python_check_connectivity"))
      result = InvariantChecker.python_check_connectivity(self.simulation)
      message = "Disconnected host pairs: "
    elif kind == "loops" or kind == "lo":
      self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_loops"))
      result = InvariantChecker.python_check_loops(self.simulation)
      message = "Loops: "
    elif kind == "liveness" or kind == "li":
      self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_liveness"))
      result = InvariantChecker.check_liveness(self.simulation)
      message = "Crashed controllers: "
    elif kind == "blackholes" or kind == "bl":
      self._log_input_event(CheckInvariants(round=self.logical_time, invariant_check_name="InvariantChecker.check_blackholes"))
      result = InvariantChecker.python_check_blackholes(self.simulation)
      message = "Blackholes: "
    else:
      log.warn("Unknown invariant kind...")
      return
    self.simulation.violation_tracker.track(result, self.logical_time)
    persistent_violations = self.simulation.violation_tracker.persistent_violations
    transient_violations = list(set(result) - set(persistent_violations))

    msg.interactive(message + str(result))
    if transient_violations != []:
      self._log_input_event(InvariantViolation(transient_violations))
    if persistent_violations != []:
      msg.fail("Persistent violations detected!: %s"
               % str(persistent_violations))
      self._log_input_event(InvariantViolation(persistent_violations, persistent=True))
Ejemplo n.º 8
0
def bail_on_connectivity(simulation):
  result = InvariantChecker.check_connectivity(simulation)
  if not result:
    print "Connectivity established - bailing out"
    sys.exit(0)
  return []
Ejemplo n.º 9
0
def my_funky_invariant_check(simulation):
  from sts.invariant_checker import InvariantChecker
  result = InvariantChecker.check_loops(simulation)
  if result:
    return result
  return []
Ejemplo n.º 10
0
def my_funky_invariant_check(simulation):
    from sts.invariant_checker import InvariantChecker
    result = InvariantChecker.check_loops(simulation)
    if result:
        return result
    return []
Ejemplo n.º 11
0
def check_for_loops_or_connectivity(simulation):
  result = InvariantChecker.check_loops(simulation)
  if result:
    return result
  return bail_on_connectivity(simulation)
Ejemplo n.º 12
0
def check_for_loops_or_connectivity(simulation):
    result = InvariantChecker.check_loops(simulation)
    if result:
        return result
    return bail_on_connectivity(simulation)