Search in sources :

Example 1 with WriteRequest

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

the class P4RuntimeGroupTest method testInsertPiActionProfileGroup.

@Test
public void testInsertPiActionProfileGroup() throws Exception {
    CompletableFuture<Void> complete = p4RuntimeServerImpl.expectRequests(1);
    client.write(P4_DEVICE_ID, PIPECONF).insert(GROUP).submitSync();
    assertTrue(client.write(P4_DEVICE_ID, PIPECONF).insert(GROUP).submitSync().isSuccess());
    complete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS);
    WriteRequest result = p4RuntimeServerImpl.getWriteReqs().get(0);
    assertEquals(1, result.getDeviceId());
    assertEquals(1, result.getUpdatesCount());
    assertEquals(DEFAULT_ELECTION_ID, result.getElectionId());
    Update update = result.getUpdatesList().get(0);
    assertEquals(Update.Type.INSERT, update.getType());
    Entity entity = update.getEntity();
    ActionProfileGroup actionProfileGroup = entity.getActionProfileGroup();
    assertNotNull(actionProfileGroup);
    assertEquals(P4_INFO_ACT_PROF_ID, actionProfileGroup.getActionProfileId());
    assertEquals(3, actionProfileGroup.getMembersCount());
    List<ActionProfileGroup.Member> members = actionProfileGroup.getMembersList();
    for (ActionProfileGroup.Member member : members) {
        // XXX: We can't guarantee the order of member, just make sure we
        // have these member ids
        assertTrue(MEMBER_IDS.contains(member.getMemberId()));
        assertEquals(DEFAULT_MEMBER_WEIGHT, member.getWeight());
    }
}
Also used : Entity(p4.v1.P4RuntimeOuterClass.Entity) WriteRequest(p4.v1.P4RuntimeOuterClass.WriteRequest) ActionProfileGroup(p4.v1.P4RuntimeOuterClass.ActionProfileGroup) PiActionProfileGroup(org.onosproject.net.pi.runtime.PiActionProfileGroup) Update(p4.v1.P4RuntimeOuterClass.Update) ActionProfileMember(p4.v1.P4RuntimeOuterClass.ActionProfileMember) PiActionProfileMember(org.onosproject.net.pi.runtime.PiActionProfileMember) Test(org.junit.Test)

Example 2 with WriteRequest

use of p4.v1.P4RuntimeOuterClass.WriteRequest 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

Test (org.junit.Test)2 PiActionProfileMember (org.onosproject.net.pi.runtime.PiActionProfileMember)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 ByteString (com.google.protobuf.ByteString)1 PiAction (org.onosproject.net.pi.runtime.PiAction)1 PiActionProfileGroup (org.onosproject.net.pi.runtime.PiActionProfileGroup)1 Action (p4.v1.P4RuntimeOuterClass.Action)1 ActionProfileGroup (p4.v1.P4RuntimeOuterClass.ActionProfileGroup)1