Search in sources :

Example 6 with Entity

use of p4.v1.P4RuntimeOuterClass.Entity in project onos by opennetworkinglab.

the class P4RuntimeGroupTest method testInsertPiActionMembers.

@Test
public void testInsertPiActionMembers() throws Exception {
    CompletableFuture<Void> complete = p4RuntimeServerImpl.expectRequests(1);
    assertTrue(client.write(P4_DEVICE_ID, PIPECONF).insert(GROUP_MEMBER_INSTANCES).submitSync().isSuccess());
    complete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS);
    WriteRequest result = p4RuntimeServerImpl.getWriteReqs().get(0);
    assertEquals(1, result.getDeviceId());
    assertEquals(3, result.getUpdatesCount());
    assertEquals(DEFAULT_ELECTION_ID, result.getElectionId());
    List<Update> updates = result.getUpdatesList();
    for (Update update : updates) {
        assertEquals(Update.Type.INSERT, update.getType());
        Entity entity = update.getEntity();
        ActionProfileMember member = entity.getActionProfileMember();
        assertNotNull(member);
        assertEquals(P4_INFO_ACT_PROF_ID, member.getActionProfileId());
        assertTrue(MEMBER_IDS.contains(member.getMemberId()));
        Action action = member.getAction();
        assertEquals(SET_EGRESS_PORT_ID, action.getActionId());
        assertEquals(1, action.getParamsCount());
        Action.Param param = action.getParamsList().get(0);
        assertEquals(1, param.getParamId());
        byte outPort = (byte) (member.getMemberId() - BASE_MEM_ID);
        ByteString bs = ByteString.copyFrom(new byte[] { 0, outPort });
        assertEquals(bs, param.getValue());
    }
}
Also used : Entity(p4.v1.P4RuntimeOuterClass.Entity) Action(p4.v1.P4RuntimeOuterClass.Action) PiAction(org.onosproject.net.pi.runtime.PiAction) WriteRequest(p4.v1.P4RuntimeOuterClass.WriteRequest) ByteString(com.google.protobuf.ByteString) Update(p4.v1.P4RuntimeOuterClass.Update) ActionProfileMember(p4.v1.P4RuntimeOuterClass.ActionProfileMember) PiActionProfileMember(org.onosproject.net.pi.runtime.PiActionProfileMember) Test(org.junit.Test)

Aggregations

CodecException (org.onosproject.p4runtime.ctl.codec.CodecException)3 P4RuntimeOuterClass (p4.v1.P4RuntimeOuterClass)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 PiActionProfileMember (org.onosproject.net.pi.runtime.PiActionProfileMember)2 PiCounterCell (org.onosproject.net.pi.runtime.PiCounterCell)2 ActionProfileMember (p4.v1.P4RuntimeOuterClass.ActionProfileMember)2 Entity (p4.v1.P4RuntimeOuterClass.Entity)2 Update (p4.v1.P4RuntimeOuterClass.Update)2 WriteRequest (p4.v1.P4RuntimeOuterClass.WriteRequest)2 Preconditions (com.google.common.base.Preconditions)1 Strings (com.google.common.base.Strings)1 ByteString (com.google.protobuf.ByteString)1 LocalDateTime (java.time.LocalDateTime)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1