Exemplo n.º 1
0
    def test_table_indirect_oneshot(self):
        te = sh.TableEntry("IndirectWS")
        te.match["header_test.field32"] = "10.0.0.0"
        a1 = sh.Action("actionA")
        a1["param"] = "aa:bb:cc:dd:ee:ff"
        a2 = sh.Action("actionB")
        a2["param"] = "10"
        te.oneshot.add(a1).add(a2, weight=2)

        expected_entry = """
table_id: 33586946
match {
  field_id: 1
  exact {
    value: "\\x0a\\x00\\x00\\x00"
  }
}
action {
  action_profile_action_set {
    action_profile_actions {
      action {
        action_id: 16783703
        params {
          param_id: 1
          value: "\\xaa\\xbb\\xcc\\xdd\\xee\\xff"
        }
      }
      weight: 1
      watch: 0
    }
    action_profile_actions {
      action {
        action_id: 16809468
        params {
          param_id: 1
          value: "\\x0a"
        }
      }
      weight: 2
      watch: 0
    }
  }
}
"""

        te.insert()

        expected_req = self.make_write_request(p4runtime_pb2.Update.INSERT,
                                               P4RuntimeEntity.table_entry,
                                               expected_entry)
        self.servicer.Write.assert_called_once_with(ProtoCmp(expected_req),
                                                    ANY)

        self.simple_read_check(expected_req.updates[0].entity, te,
                               P4RuntimeEntity.table_entry)
Exemplo n.º 2
0
    def test_table_indirect_with_direct_action(self):
        te = sh.TableEntry("IndirectWS")
        te.match["header_test.field32"] = "10.0.0.0"
        with self.assertRaisesRegex(UserError, "does not support direct actions"):
            te.action = sh.Action("actionA")

        with self.assertRaisesRegex(UserError, "does not support direct actions"):
            te = sh.TableEntry("IndirectWS")(action="actionA")