Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.p4runtime.ctl; |
| 18 | |
| 19 | import com.google.common.collect.ImmutableList; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 20 | import com.google.common.collect.Lists; |
| 21 | import com.google.protobuf.ByteString; |
| 22 | import io.grpc.ManagedChannel; |
| 23 | import io.grpc.Server; |
| 24 | import io.grpc.inprocess.InProcessChannelBuilder; |
| 25 | import io.grpc.inprocess.InProcessServerBuilder; |
| 26 | import io.grpc.internal.AbstractServerImplBuilder; |
| 27 | import org.easymock.EasyMock; |
| 28 | import org.junit.AfterClass; |
| 29 | import org.junit.Before; |
| 30 | import org.junit.BeforeClass; |
| 31 | import org.junit.Test; |
| 32 | import org.onlab.util.ImmutableByteSequence; |
| 33 | import org.onosproject.net.DeviceId; |
| 34 | import org.onosproject.net.pi.model.DefaultPiPipeconf; |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame] | 35 | import org.onosproject.net.pi.model.PiActionId; |
| 36 | import org.onosproject.net.pi.model.PiActionParamId; |
| 37 | import org.onosproject.net.pi.model.PiActionProfileId; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 38 | import org.onosproject.net.pi.model.PiPipeconf; |
| 39 | import org.onosproject.net.pi.model.PiPipeconfId; |
| 40 | import org.onosproject.net.pi.model.PiPipelineModel; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 41 | import org.onosproject.net.pi.runtime.PiAction; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 42 | import org.onosproject.net.pi.runtime.PiActionParam; |
Carmelo Cascone | cb4327a | 2018-09-11 15:17:23 -0700 | [diff] [blame] | 43 | import org.onosproject.net.pi.runtime.PiActionProfileGroup; |
| 44 | import org.onosproject.net.pi.runtime.PiActionProfileGroupId; |
| 45 | import org.onosproject.net.pi.runtime.PiActionProfileMember; |
| 46 | import org.onosproject.net.pi.runtime.PiActionProfileMemberId; |
Yi Tseng | 2a340f7 | 2018-11-02 16:52:47 -0700 | [diff] [blame] | 47 | import org.onosproject.p4runtime.api.P4RuntimeClientKey; |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame^] | 48 | import org.onosproject.p4runtime.ctl.client.P4RuntimeClientImpl; |
| 49 | import org.onosproject.p4runtime.ctl.controller.P4RuntimeControllerImpl; |
Carmelo Cascone | 6af4e17 | 2018-06-15 16:01:30 +0200 | [diff] [blame] | 50 | import p4.v1.P4RuntimeOuterClass.ActionProfileGroup; |
| 51 | import p4.v1.P4RuntimeOuterClass.ActionProfileMember; |
| 52 | import p4.v1.P4RuntimeOuterClass.Entity; |
| 53 | import p4.v1.P4RuntimeOuterClass.Uint128; |
| 54 | import p4.v1.P4RuntimeOuterClass.Update; |
| 55 | import p4.v1.P4RuntimeOuterClass.WriteRequest; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 56 | |
| 57 | import java.io.IOException; |
| 58 | import java.net.URL; |
| 59 | import java.util.Collection; |
| 60 | import java.util.List; |
| 61 | import java.util.concurrent.CompletableFuture; |
| 62 | import java.util.concurrent.TimeUnit; |
Carmelo Cascone | 87b9b39 | 2017-10-02 18:33:20 +0200 | [diff] [blame] | 63 | import java.util.stream.Collectors; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 64 | |
Carmelo Cascone | 87b9b39 | 2017-10-02 18:33:20 +0200 | [diff] [blame] | 65 | import static org.easymock.EasyMock.niceMock; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 66 | import static org.junit.Assert.assertEquals; |
| 67 | import static org.junit.Assert.assertNotNull; |
| 68 | import static org.junit.Assert.assertTrue; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 69 | import static org.onosproject.net.pi.model.PiPipeconf.ExtensionType.P4_INFO_TEXT; |
Carmelo Cascone | 6af4e17 | 2018-06-15 16:01:30 +0200 | [diff] [blame] | 70 | import static p4.v1.P4RuntimeOuterClass.Action; |
| 71 | import static p4.v1.P4RuntimeOuterClass.ReadResponse; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * Tests for P4 Runtime Action Profile Group support. |
| 75 | */ |
| 76 | public class P4RuntimeGroupTest { |
| 77 | private static final String PIPECONF_ID = "p4runtime-mock-pipeconf"; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 78 | private static final String P4INFO_PATH = "/test.p4info"; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 79 | private static final PiPipeconf PIPECONF = buildPipeconf(); |
| 80 | private static final int P4_INFO_ACT_PROF_ID = 285227860; |
| 81 | private static final PiActionProfileId ACT_PROF_ID = PiActionProfileId.of("ecmp_selector"); |
Carmelo Cascone | cb4327a | 2018-09-11 15:17:23 -0700 | [diff] [blame] | 82 | private static final PiActionProfileGroupId GROUP_ID = PiActionProfileGroupId.of(1); |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 83 | private static final int DEFAULT_MEMBER_WEIGHT = 1; |
| 84 | private static final PiActionId EGRESS_PORT_ACTION_ID = PiActionId.of("set_egress_port"); |
| 85 | private static final PiActionParamId PORT_PARAM_ID = PiActionParamId.of("port"); |
| 86 | private static final int BASE_MEM_ID = 65535; |
| 87 | private static final List<Integer> MEMBER_IDS = ImmutableList.of(65536, 65537, 65538); |
Carmelo Cascone | 99c59db | 2019-01-17 15:39:35 -0800 | [diff] [blame] | 88 | private static final List<PiActionProfileMember> GROUP_MEMBER_INSTANCES = |
Carmelo Cascone | e44592f | 2018-09-12 02:24:47 -0700 | [diff] [blame] | 89 | Lists.newArrayList( |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 90 | outputMember((short) 1), |
| 91 | outputMember((short) 2), |
| 92 | outputMember((short) 3) |
| 93 | ); |
Carmelo Cascone | 99c59db | 2019-01-17 15:39:35 -0800 | [diff] [blame] | 94 | private static final List<PiActionProfileGroup.WeightedMember> GROUP_WEIGHTED_MEMBERS = |
| 95 | GROUP_MEMBER_INSTANCES.stream() |
| 96 | .map(m -> new PiActionProfileGroup.WeightedMember(m, DEFAULT_MEMBER_WEIGHT)) |
| 97 | .collect(Collectors.toList()); |
Carmelo Cascone | cb4327a | 2018-09-11 15:17:23 -0700 | [diff] [blame] | 98 | private static final PiActionProfileGroup GROUP = PiActionProfileGroup.builder() |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 99 | .withId(GROUP_ID) |
Carmelo Cascone | 99c59db | 2019-01-17 15:39:35 -0800 | [diff] [blame] | 100 | .addMembers(GROUP_MEMBER_INSTANCES) |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 101 | .withActionProfileId(ACT_PROF_ID) |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 102 | .build(); |
| 103 | private static final DeviceId DEVICE_ID = DeviceId.deviceId("device:p4runtime:1"); |
| 104 | private static final int P4_DEVICE_ID = 1; |
| 105 | private static final int SET_EGRESS_PORT_ID = 16794308; |
| 106 | private static final String GRPC_SERVER_NAME = "P4RuntimeGroupTest"; |
Carmelo Cascone | 87b9b39 | 2017-10-02 18:33:20 +0200 | [diff] [blame] | 107 | private static final long DEFAULT_TIMEOUT_TIME = 10; |
Yi Tseng | 3e7f145 | 2017-10-20 10:31:53 -0700 | [diff] [blame] | 108 | private static final Uint128 DEFAULT_ELECTION_ID = Uint128.newBuilder().setLow(1).build(); |
Yi Tseng | 2a340f7 | 2018-11-02 16:52:47 -0700 | [diff] [blame] | 109 | private static final String P4R_IP = "127.0.0.1"; |
| 110 | private static final int P4R_PORT = 50010; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 111 | |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame^] | 112 | private org.onosproject.p4runtime.ctl.client.P4RuntimeClientImpl client; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 113 | private P4RuntimeControllerImpl controller; |
| 114 | private static MockP4RuntimeServer p4RuntimeServerImpl = new MockP4RuntimeServer(); |
| 115 | private static Server grpcServer; |
| 116 | private static ManagedChannel grpcChannel; |
| 117 | |
Carmelo Cascone | cb4327a | 2018-09-11 15:17:23 -0700 | [diff] [blame] | 118 | private static PiActionProfileMember outputMember(short portNum) { |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 119 | PiActionParam param = new PiActionParam(PORT_PARAM_ID, |
| 120 | ImmutableByteSequence.copyFrom(portNum)); |
| 121 | PiAction piAction = PiAction.builder() |
| 122 | .withId(EGRESS_PORT_ACTION_ID) |
| 123 | .withParameter(param).build(); |
| 124 | |
Carmelo Cascone | cb4327a | 2018-09-11 15:17:23 -0700 | [diff] [blame] | 125 | return PiActionProfileMember.builder() |
Carmelo Cascone | e44592f | 2018-09-12 02:24:47 -0700 | [diff] [blame] | 126 | .forActionProfile(ACT_PROF_ID) |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 127 | .withAction(piAction) |
Carmelo Cascone | cb4327a | 2018-09-11 15:17:23 -0700 | [diff] [blame] | 128 | .withId(PiActionProfileMemberId.of(BASE_MEM_ID + portNum)) |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 129 | .build(); |
| 130 | } |
| 131 | |
| 132 | private static PiPipeconf buildPipeconf() { |
| 133 | final URL p4InfoUrl = P4RuntimeGroupTest.class.getResource(P4INFO_PATH); |
| 134 | return DefaultPiPipeconf.builder() |
| 135 | .withId(new PiPipeconfId(PIPECONF_ID)) |
| 136 | .withPipelineModel(EasyMock.niceMock(PiPipelineModel.class)) |
| 137 | .addExtension(P4_INFO_TEXT, p4InfoUrl) |
| 138 | .build(); |
| 139 | } |
| 140 | |
| 141 | @BeforeClass |
| 142 | public static void globalSetup() throws IOException { |
| 143 | AbstractServerImplBuilder builder = InProcessServerBuilder |
| 144 | .forName(GRPC_SERVER_NAME).directExecutor(); |
| 145 | builder.addService(p4RuntimeServerImpl); |
| 146 | grpcServer = builder.build().start(); |
| 147 | grpcChannel = InProcessChannelBuilder.forName(GRPC_SERVER_NAME) |
| 148 | .directExecutor() |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 149 | .build(); |
| 150 | } |
| 151 | |
| 152 | @AfterClass |
Carmelo Cascone | e5b2872 | 2018-06-22 17:28:28 +0200 | [diff] [blame] | 153 | public static void globalTearDown() { |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 154 | grpcServer.shutdown(); |
| 155 | grpcChannel.shutdown(); |
| 156 | } |
| 157 | |
| 158 | |
| 159 | @Before |
| 160 | public void setup() { |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame^] | 161 | controller = niceMock(org.onosproject.p4runtime.ctl.controller.P4RuntimeControllerImpl.class); |
Yi Tseng | 2a340f7 | 2018-11-02 16:52:47 -0700 | [diff] [blame] | 162 | P4RuntimeClientKey clientKey = new P4RuntimeClientKey(DEVICE_ID, P4R_IP, P4R_PORT, P4_DEVICE_ID); |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame^] | 163 | client = new P4RuntimeClientImpl(clientKey, grpcChannel, controller, new MockPipeconfService()); |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | @Test |
Carmelo Cascone | cb4327a | 2018-09-11 15:17:23 -0700 | [diff] [blame] | 167 | public void testInsertPiActionProfileGroup() throws Exception { |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 168 | CompletableFuture<Void> complete = p4RuntimeServerImpl.expectRequests(1); |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame^] | 169 | client.write(PIPECONF).insert(GROUP).submitSync(); |
| 170 | assertTrue(client.write(PIPECONF).insert(GROUP).submitSync().isSuccess()); |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 171 | complete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS); |
| 172 | WriteRequest result = p4RuntimeServerImpl.getWriteReqs().get(0); |
| 173 | assertEquals(1, result.getDeviceId()); |
| 174 | assertEquals(1, result.getUpdatesCount()); |
Yi Tseng | 3e7f145 | 2017-10-20 10:31:53 -0700 | [diff] [blame] | 175 | assertEquals(DEFAULT_ELECTION_ID, result.getElectionId()); |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 176 | |
| 177 | Update update = result.getUpdatesList().get(0); |
| 178 | assertEquals(Update.Type.INSERT, update.getType()); |
| 179 | |
| 180 | Entity entity = update.getEntity(); |
| 181 | ActionProfileGroup actionProfileGroup = entity.getActionProfileGroup(); |
| 182 | assertNotNull(actionProfileGroup); |
| 183 | |
| 184 | assertEquals(P4_INFO_ACT_PROF_ID, actionProfileGroup.getActionProfileId()); |
| 185 | assertEquals(3, actionProfileGroup.getMembersCount()); |
| 186 | List<ActionProfileGroup.Member> members = actionProfileGroup.getMembersList(); |
| 187 | |
| 188 | for (ActionProfileGroup.Member member : members) { |
| 189 | // XXX: We can't guarantee the order of member, just make sure we |
| 190 | // have these member ids |
| 191 | assertTrue(MEMBER_IDS.contains(member.getMemberId())); |
| 192 | assertEquals(DEFAULT_MEMBER_WEIGHT, member.getWeight()); |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | @Test |
| 197 | public void testInsertPiActionMembers() throws Exception { |
| 198 | CompletableFuture<Void> complete = p4RuntimeServerImpl.expectRequests(1); |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame^] | 199 | assertTrue(client.write(PIPECONF).insert(GROUP_MEMBER_INSTANCES) |
| 200 | .submitSync().isSuccess()); |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 201 | complete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS); |
| 202 | WriteRequest result = p4RuntimeServerImpl.getWriteReqs().get(0); |
| 203 | assertEquals(1, result.getDeviceId()); |
| 204 | assertEquals(3, result.getUpdatesCount()); |
Yi Tseng | 3e7f145 | 2017-10-20 10:31:53 -0700 | [diff] [blame] | 205 | assertEquals(DEFAULT_ELECTION_ID, result.getElectionId()); |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 206 | |
| 207 | List<Update> updates = result.getUpdatesList(); |
| 208 | for (Update update : updates) { |
| 209 | assertEquals(Update.Type.INSERT, update.getType()); |
| 210 | Entity entity = update.getEntity(); |
| 211 | ActionProfileMember member = entity.getActionProfileMember(); |
| 212 | assertNotNull(member); |
| 213 | assertEquals(P4_INFO_ACT_PROF_ID, member.getActionProfileId()); |
| 214 | assertTrue(MEMBER_IDS.contains(member.getMemberId())); |
| 215 | Action action = member.getAction(); |
| 216 | assertEquals(SET_EGRESS_PORT_ID, action.getActionId()); |
| 217 | assertEquals(1, action.getParamsCount()); |
| 218 | Action.Param param = action.getParamsList().get(0); |
| 219 | assertEquals(1, param.getParamId()); |
| 220 | byte outPort = (byte) (member.getMemberId() - BASE_MEM_ID); |
| 221 | ByteString bs = ByteString.copyFrom(new byte[]{0, outPort}); |
| 222 | assertEquals(bs, param.getValue()); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | @Test |
| 227 | public void testReadGroups() throws Exception { |
| 228 | ActionProfileGroup.Builder group = ActionProfileGroup.newBuilder() |
| 229 | .setGroupId(GROUP_ID.id()) |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 230 | .setActionProfileId(P4_INFO_ACT_PROF_ID); |
| 231 | |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 232 | MEMBER_IDS.forEach(id -> { |
| 233 | ActionProfileGroup.Member member = ActionProfileGroup.Member.newBuilder() |
| 234 | .setMemberId(id) |
| 235 | .setWeight(DEFAULT_MEMBER_WEIGHT) |
| 236 | .build(); |
| 237 | group.addMembers(member); |
Carmelo Cascone | 99c59db | 2019-01-17 15:39:35 -0800 | [diff] [blame] | 238 | }); |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 239 | |
Carmelo Cascone | 99c59db | 2019-01-17 15:39:35 -0800 | [diff] [blame] | 240 | List<ReadResponse> responses = Lists.newArrayList(); |
| 241 | responses.add(ReadResponse.newBuilder() |
| 242 | .addEntities(Entity.newBuilder().setActionProfileGroup(group)) |
| 243 | .build() |
| 244 | ); |
| 245 | |
| 246 | p4RuntimeServerImpl.willReturnReadResult(responses); |
| 247 | CompletableFuture<Void> complete = p4RuntimeServerImpl.expectRequests(1); |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame^] | 248 | Collection<PiActionProfileGroup> groups = client.read(PIPECONF) |
| 249 | .actionProfileGroups(ACT_PROF_ID) |
| 250 | .submitSync().all(PiActionProfileGroup.class); |
Carmelo Cascone | 99c59db | 2019-01-17 15:39:35 -0800 | [diff] [blame] | 251 | complete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS); |
Carmelo Cascone | 99c59db | 2019-01-17 15:39:35 -0800 | [diff] [blame] | 252 | assertEquals(1, groups.size()); |
| 253 | PiActionProfileGroup piActionGroup = groups.iterator().next(); |
| 254 | assertEquals(ACT_PROF_ID, piActionGroup.actionProfile()); |
| 255 | assertEquals(GROUP_ID, piActionGroup.id()); |
| 256 | assertEquals(3, piActionGroup.members().size()); |
| 257 | assertTrue(GROUP_WEIGHTED_MEMBERS.containsAll(piActionGroup.members())); |
| 258 | assertTrue(piActionGroup.members().containsAll(GROUP_WEIGHTED_MEMBERS)); |
| 259 | } |
| 260 | |
| 261 | @Test |
| 262 | public void testReadMembers() throws Exception { |
| 263 | List<ActionProfileMember> members = Lists.newArrayList(); |
| 264 | |
| 265 | MEMBER_IDS.forEach(id -> { |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 266 | byte outPort = (byte) (id - BASE_MEM_ID); |
| 267 | ByteString bs = ByteString.copyFrom(new byte[]{0, outPort}); |
| 268 | Action.Param param = Action.Param.newBuilder() |
| 269 | .setParamId(1) |
| 270 | .setValue(bs) |
| 271 | .build(); |
| 272 | |
| 273 | Action action = Action.newBuilder() |
| 274 | .setActionId(SET_EGRESS_PORT_ID) |
| 275 | .addParams(param) |
| 276 | .build(); |
| 277 | |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 278 | ActionProfileMember actProfMember = |
| 279 | ActionProfileMember.newBuilder() |
Carmelo Cascone | e44592f | 2018-09-12 02:24:47 -0700 | [diff] [blame] | 280 | .setActionProfileId(P4_INFO_ACT_PROF_ID) |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 281 | .setMemberId(id) |
| 282 | .setAction(action) |
| 283 | .build(); |
| 284 | members.add(actProfMember); |
| 285 | }); |
| 286 | |
| 287 | List<ReadResponse> responses = Lists.newArrayList(); |
| 288 | responses.add(ReadResponse.newBuilder() |
Carmelo Cascone | 87b9b39 | 2017-10-02 18:33:20 +0200 | [diff] [blame] | 289 | .addAllEntities(members.stream() |
Carmelo Cascone | e44592f | 2018-09-12 02:24:47 -0700 | [diff] [blame] | 290 | .map(m -> Entity.newBuilder() |
| 291 | .setActionProfileMember(m).build()) |
Carmelo Cascone | 87b9b39 | 2017-10-02 18:33:20 +0200 | [diff] [blame] | 292 | .collect(Collectors.toList())) |
| 293 | .build()); |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 294 | |
| 295 | p4RuntimeServerImpl.willReturnReadResult(responses); |
Carmelo Cascone | 99c59db | 2019-01-17 15:39:35 -0800 | [diff] [blame] | 296 | CompletableFuture<Void> complete = p4RuntimeServerImpl.expectRequests(1); |
Carmelo Cascone | 4c289b7 | 2019-01-22 15:30:45 -0800 | [diff] [blame^] | 297 | Collection<PiActionProfileMember> piMembers = client.read(PIPECONF) |
| 298 | .actionProfileMembers(ACT_PROF_ID).submitSync() |
| 299 | .all(PiActionProfileMember.class); |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 300 | complete.get(DEFAULT_TIMEOUT_TIME, TimeUnit.SECONDS); |
Carmelo Cascone | 99c59db | 2019-01-17 15:39:35 -0800 | [diff] [blame] | 301 | assertEquals(3, piMembers.size()); |
| 302 | assertTrue(GROUP_MEMBER_INSTANCES.containsAll(piMembers)); |
| 303 | assertTrue(piMembers.containsAll(GROUP_MEMBER_INSTANCES)); |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 304 | } |
| 305 | } |