blob: c2137534d6ce4d682883c16fb753eb4db7822ec2 [file] [log] [blame]
Carmelo Cascone8d99b172017-07-18 17:26:31 -04001/*
Carmelo Cascone4c289b72019-01-22 15:30:45 -08002 * Copyright 2019-present Open Networking Foundation
Carmelo Cascone8d99b172017-07-18 17:26:31 -04003 *
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
Carmelo Cascone4c289b72019-01-22 15:30:45 -080017package org.onosproject.p4runtime.ctl.codec;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040018
Carmelo Cascone8d99b172017-07-18 17:26:31 -040019import com.google.common.testing.EqualsTester;
Yi Tseng82512da2017-08-16 19:46:36 -070020import org.easymock.EasyMock;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040021import org.junit.Test;
22import org.onlab.util.ImmutableByteSequence;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040023import org.onosproject.net.pi.model.DefaultPiPipeconf;
Carmelo Cascone87892e22017-11-13 16:01:29 -080024import org.onosproject.net.pi.model.PiActionId;
25import org.onosproject.net.pi.model.PiActionParamId;
26import org.onosproject.net.pi.model.PiMatchFieldId;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040027import org.onosproject.net.pi.model.PiPipeconf;
28import org.onosproject.net.pi.model.PiPipeconfId;
Yi Tseng82512da2017-08-16 19:46:36 -070029import org.onosproject.net.pi.model.PiPipelineModel;
Carmelo Cascone87892e22017-11-13 16:01:29 -080030import org.onosproject.net.pi.model.PiTableId;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040031import org.onosproject.net.pi.runtime.PiAction;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040032import org.onosproject.net.pi.runtime.PiActionParam;
Carmelo Casconecb4327a2018-09-11 15:17:23 -070033import org.onosproject.net.pi.runtime.PiActionProfileGroupId;
steven308017632e152018-10-20 00:51:08 +080034import org.onosproject.net.pi.runtime.PiCounterCellData;
Yi Tseng95390822018-01-22 17:57:22 -080035import org.onosproject.net.pi.runtime.PiExactFieldMatch;
Carmelo Cascone0e896a02017-07-31 07:22:27 +020036import org.onosproject.net.pi.runtime.PiMatchKey;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040037import org.onosproject.net.pi.runtime.PiTableEntry;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040038import org.onosproject.net.pi.runtime.PiTernaryFieldMatch;
Carmelo Cascone4c289b72019-01-22 15:30:45 -080039import org.onosproject.p4runtime.ctl.utils.P4InfoBrowser;
40import org.onosproject.p4runtime.ctl.utils.PipeconfHelper;
Carmelo Cascone6af4e172018-06-15 16:01:30 +020041import p4.v1.P4RuntimeOuterClass.Action;
steven308017632e152018-10-20 00:51:08 +080042import p4.v1.P4RuntimeOuterClass.CounterData;
Carmelo Cascone6af4e172018-06-15 16:01:30 +020043import p4.v1.P4RuntimeOuterClass.TableEntry;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040044
45import java.net.URL;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040046import java.util.Random;
47
48import static org.hamcrest.MatcherAssert.assertThat;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040049import static org.hamcrest.Matchers.is;
Carmelo Casconeca94bcf2017-10-27 14:16:59 -070050import static org.onlab.util.ImmutableByteSequence.copyFrom;
Carmelo Casconeca94bcf2017-10-27 14:16:59 -070051import static org.onlab.util.ImmutableByteSequence.ofOnes;
Carmelo Cascone8d99b172017-07-18 17:26:31 -040052import static org.onosproject.net.pi.model.PiPipeconf.ExtensionType.P4_INFO_TEXT;
Andrea Campanellafc1d34c2017-07-18 17:01:41 +020053
Yi Tseng82512da2017-08-16 19:46:36 -070054/**
55 * Test for P4 runtime table entry encoder.
56 */
Carmelo Cascone8d99b172017-07-18 17:26:31 -040057public class TableEntryEncoderTest {
Carmelo Cascone87892e22017-11-13 16:01:29 -080058 private static final String DOT = ".";
Carmelo Cascone8d99b172017-07-18 17:26:31 -040059 private static final String TABLE_0 = "table0";
Yi Tseng95390822018-01-22 17:57:22 -080060 private static final String TABLE_ECMP = "ecmp";
Carmelo Cascone8d99b172017-07-18 17:26:31 -040061 private static final String SET_EGRESS_PORT = "set_egress_port";
62 private static final String PORT = "port";
Carmelo Cascone87892e22017-11-13 16:01:29 -080063 private static final String HDR = "hdr";
Yi Tseng95390822018-01-22 17:57:22 -080064 private static final String META = "meta";
Carmelo Cascone8d99b172017-07-18 17:26:31 -040065 private static final String ETHERNET = "ethernet";
66 private static final String DST_ADDR = "dstAddr";
67 private static final String SRC_ADDR = "srcAddr";
68 private static final String STANDARD_METADATA = "standard_metadata";
Daniele Morof178b0a2020-12-15 14:13:51 +010069 private static final String LOCAL_METADATA = "local_metadata";
Yi Tseng95390822018-01-22 17:57:22 -080070 private static final String ECMP_METADATA = "ecmp_metadata";
Carmelo Cascone8d99b172017-07-18 17:26:31 -040071 private static final String INGRESS_PORT = "ingress_port";
72 private static final String ETHER_TYPE = "etherType";
Yi Tseng95390822018-01-22 17:57:22 -080073 private static final String ECMP_GROUP_ID = "ecmp_group_id";
Carmelo Cascone8d99b172017-07-18 17:26:31 -040074
steven308017632e152018-10-20 00:51:08 +080075 private static final long PACKETS = 10;
76 private static final long BYTES = 100;
77
Carmelo Cascone8d99b172017-07-18 17:26:31 -040078 private final Random rand = new Random();
Carmelo Casconeca94bcf2017-10-27 14:16:59 -070079 private final URL p4InfoUrl = this.getClass().getResource("/test.p4info");
Daniele Morof178b0a2020-12-15 14:13:51 +010080 private final URL p4InfoUrl2 = this.getClass().getResource("/test_p4runtime_translation_p4info.txt");
Carmelo Cascone8d99b172017-07-18 17:26:31 -040081
82 private final PiPipeconf defaultPipeconf = DefaultPiPipeconf.builder()
83 .withId(new PiPipeconfId("mock"))
Yi Tseng82512da2017-08-16 19:46:36 -070084 .withPipelineModel(EasyMock.niceMock(PiPipelineModel.class))
Carmelo Cascone8d99b172017-07-18 17:26:31 -040085 .addExtension(P4_INFO_TEXT, p4InfoUrl)
Carmelo Cascone8d99b172017-07-18 17:26:31 -040086 .build();
87
Daniele Morof178b0a2020-12-15 14:13:51 +010088 private final PiPipeconf defaultPipeconf2 = DefaultPiPipeconf.builder()
89 .withId(new PiPipeconfId("mock"))
90 .withPipelineModel(EasyMock.niceMock(PiPipelineModel.class))
91 .addExtension(P4_INFO_TEXT, p4InfoUrl2)
92 .build();
93
Carmelo Cascone8d99b172017-07-18 17:26:31 -040094 private final P4InfoBrowser browser = PipeconfHelper.getP4InfoBrowser(defaultPipeconf);
Carmelo Cascone8a571af2018-04-06 23:17:04 -070095 private final ImmutableByteSequence ethAddr = copyFrom(rand.nextInt()).fit(48);
Daniele Morof178b0a2020-12-15 14:13:51 +010096 private final ImmutableByteSequence ethAddrString = ImmutableByteSequence.copyFrom(
97 "00:11:22:33:44:55:66".getBytes());
Carmelo Cascone8d99b172017-07-18 17:26:31 -040098 private final ImmutableByteSequence portValue = copyFrom((short) rand.nextInt());
Daniele Morof178b0a2020-12-15 14:13:51 +010099 private final ImmutableByteSequence portValueString = ImmutableByteSequence.copyFrom(
100 String.format("Ethernet%d", rand.nextInt()).getBytes());
101 private final ImmutableByteSequence portValue32Bit = copyFrom((short) rand.nextInt()).fit(32);
Carmelo Cascone87892e22017-11-13 16:01:29 -0800102 private final PiMatchFieldId ethDstAddrFieldId = PiMatchFieldId.of(HDR + DOT + ETHERNET + DOT + DST_ADDR);
103 private final PiMatchFieldId ethSrcAddrFieldId = PiMatchFieldId.of(HDR + DOT + ETHERNET + DOT + SRC_ADDR);
104 private final PiMatchFieldId inPortFieldId = PiMatchFieldId.of(STANDARD_METADATA + DOT + INGRESS_PORT);
Daniele Morof178b0a2020-12-15 14:13:51 +0100105 private final PiMatchFieldId inPortFieldId2 = PiMatchFieldId.of(LOCAL_METADATA + DOT + INGRESS_PORT);
Carmelo Cascone87892e22017-11-13 16:01:29 -0800106 private final PiMatchFieldId ethTypeFieldId = PiMatchFieldId.of(HDR + DOT + ETHERNET + DOT + ETHER_TYPE);
Yi Tseng95390822018-01-22 17:57:22 -0800107 private final PiMatchFieldId ecmpGroupFieldId =
108 PiMatchFieldId.of(META + DOT + ECMP_METADATA + DOT + ECMP_GROUP_ID);
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400109 private final PiActionParamId portParamId = PiActionParamId.of(PORT);
110 private final PiActionId outActionId = PiActionId.of(SET_EGRESS_PORT);
Daniele Morof178b0a2020-12-15 14:13:51 +0100111 private final PiActionId outActionId2 = PiActionId.of(SET_EGRESS_PORT + "2");
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400112 private final PiTableId tableId = PiTableId.of(TABLE_0);
Yi Tseng95390822018-01-22 17:57:22 -0800113 private final PiTableId ecmpTableId = PiTableId.of(TABLE_ECMP);
steven308017632e152018-10-20 00:51:08 +0800114 private final PiCounterCellData counterCellData = new PiCounterCellData(PACKETS, BYTES);
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400115
116 private final PiTableEntry piTableEntry = PiTableEntry
117 .builder()
118 .forTable(tableId)
Carmelo Cascone0e896a02017-07-31 07:22:27 +0200119 .withMatchKey(PiMatchKey.builder()
120 .addFieldMatch(new PiTernaryFieldMatch(ethDstAddrFieldId, ethAddr, ofOnes(6)))
121 .addFieldMatch(new PiTernaryFieldMatch(ethSrcAddrFieldId, ethAddr, ofOnes(6)))
122 .addFieldMatch(new PiTernaryFieldMatch(inPortFieldId, portValue, ofOnes(2)))
123 .addFieldMatch(new PiTernaryFieldMatch(ethTypeFieldId, portValue, ofOnes(2)))
124 .build())
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400125 .withAction(PiAction
Carmelo Cascone0e896a02017-07-31 07:22:27 +0200126 .builder()
127 .withId(outActionId)
128 .withParameter(new PiActionParam(portParamId, portValue))
129 .build())
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400130 .withPriority(1)
131 .withCookie(2)
steven308017632e152018-10-20 00:51:08 +0800132 .withCounterCellData(counterCellData)
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400133 .build();
134
Daniele Morof178b0a2020-12-15 14:13:51 +0100135 private final PiTableEntry piTableEntry2 = PiTableEntry
136 .builder()
137 .forTable(tableId)
138 .withMatchKey(PiMatchKey.builder()
139 .addFieldMatch(new PiExactFieldMatch(inPortFieldId2, portValue32Bit))
140 .addFieldMatch(new PiExactFieldMatch(ethDstAddrFieldId, ethAddrString))
141 .addFieldMatch(new PiExactFieldMatch(ethSrcAddrFieldId, ethAddrString))
142 .addFieldMatch(new PiExactFieldMatch(ethTypeFieldId, portValue))
143 .build())
144 .withAction(PiAction
145 .builder()
146 .withId(outActionId)
147 .withParameter(new PiActionParam(portParamId, portValueString))
148 .build())
149 .withPriority(1)
150 .withCookie(2)
151 .build();
152
153 private final PiTableEntry piTableEntry3 = PiTableEntry
154 .builder()
155 .forTable(tableId)
156 .withMatchKey(PiMatchKey.builder()
157 .addFieldMatch(new PiExactFieldMatch(inPortFieldId2, portValue32Bit))
158 .addFieldMatch(new PiExactFieldMatch(ethDstAddrFieldId, ethAddrString))
159 .addFieldMatch(new PiExactFieldMatch(ethSrcAddrFieldId, ethAddrString))
160 .addFieldMatch(new PiExactFieldMatch(ethTypeFieldId, portValue))
161 .build())
162 .withAction(PiAction
163 .builder()
164 .withId(outActionId2)
165 .withParameter(new PiActionParam(portParamId, portValue32Bit))
166 .build())
167 .withPriority(1)
168 .withCookie(2)
169 .build();
170
Yi Tsengd28936e2018-02-23 22:11:11 +0100171 private final PiTableEntry piTableEntryWithoutAction = PiTableEntry
172 .builder()
173 .forTable(tableId)
174 .withMatchKey(PiMatchKey.builder()
175 .addFieldMatch(new PiTernaryFieldMatch(ethDstAddrFieldId, ethAddr, ofOnes(6)))
176 .addFieldMatch(new PiTernaryFieldMatch(ethSrcAddrFieldId, ethAddr, ofOnes(6)))
177 .addFieldMatch(new PiTernaryFieldMatch(inPortFieldId, portValue, ofOnes(2)))
178 .addFieldMatch(new PiTernaryFieldMatch(ethTypeFieldId, portValue, ofOnes(2)))
179 .build())
180 .withPriority(1)
181 .withCookie(2)
steven308017632e152018-10-20 00:51:08 +0800182 .withCounterCellData(counterCellData)
Yi Tsengd28936e2018-02-23 22:11:11 +0100183 .build();
184
Yi Tseng95390822018-01-22 17:57:22 -0800185 private final PiTableEntry piTableEntryWithGroupAction = PiTableEntry
186 .builder()
187 .forTable(ecmpTableId)
188 .withMatchKey(PiMatchKey.builder()
189 .addFieldMatch(new PiExactFieldMatch(ecmpGroupFieldId, ofOnes(1)))
190 .build())
Carmelo Casconecb4327a2018-09-11 15:17:23 -0700191 .withAction(PiActionProfileGroupId.of(1))
Yi Tseng95390822018-01-22 17:57:22 -0800192 .withPriority(1)
193 .withCookie(2)
steven308017632e152018-10-20 00:51:08 +0800194 .withCounterCellData(counterCellData)
Yi Tseng95390822018-01-22 17:57:22 -0800195 .build();
196
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400197 public TableEntryEncoderTest() throws ImmutableByteSequence.ByteSequenceTrimException {
198 }
199
200 @Test
201 public void testP4InfoBrowser() throws Exception {
202
203 P4InfoBrowser browser = PipeconfHelper.getP4InfoBrowser(defaultPipeconf);
204
205 assertThat(browser.tables().hasName(TABLE_0), is(true));
206 assertThat(browser.actions().hasName(SET_EGRESS_PORT), is(true));
207
Carmelo Casconecb0a49c2017-10-03 14:32:23 +0200208 int tableId = browser.tables().getByName(TABLE_0).getPreamble().getId();
209 int actionId = browser.actions().getByName(SET_EGRESS_PORT).getPreamble().getId();
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400210
Carmelo Cascone87892e22017-11-13 16:01:29 -0800211 assertThat(browser.matchFields(tableId).hasName(STANDARD_METADATA + DOT + INGRESS_PORT), is(true));
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400212 assertThat(browser.actionParams(actionId).hasName(PORT), is(true));
213
214 // TODO: improve, assert browsing other entities (counters, meters, etc.)
215 }
216
217 @Test
Carmelo Cascone5bc7e102018-02-18 18:27:55 -0800218 public void testTableEntryEncoder() throws Exception {
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400219
Carmelo Cascone4c289b72019-01-22 15:30:45 -0800220 TableEntry tableEntryMsg = Codecs.CODECS.tableEntry().encode(
221 piTableEntry, null, defaultPipeconf);
222 PiTableEntry decodedPiTableEntry = Codecs.CODECS.tableEntry().decode(
223 tableEntryMsg, null, defaultPipeconf);
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400224
225 // Test equality for decoded entry.
226 new EqualsTester()
227 .addEqualityGroup(piTableEntry, decodedPiTableEntry)
228 .testEquals();
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400229 // Table ID.
Carmelo Casconecb0a49c2017-10-03 14:32:23 +0200230 int p4InfoTableId = browser.tables().getByName(tableId.id()).getPreamble().getId();
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400231 int encodedTableId = tableEntryMsg.getTableId();
232 assertThat(encodedTableId, is(p4InfoTableId));
233
234 // Ternary match.
235 byte[] encodedTernaryMatchValue = tableEntryMsg.getMatch(0).getTernary().getValue().toByteArray();
236 assertThat(encodedTernaryMatchValue, is(ethAddr.asArray()));
237
238 Action actionMsg = tableEntryMsg.getAction().getAction();
239
240 // Action ID.
Carmelo Cascone87892e22017-11-13 16:01:29 -0800241 int p4InfoActionId = browser.actions().getByName(outActionId.toString()).getPreamble().getId();
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400242 int encodedActionId = actionMsg.getActionId();
243 assertThat(encodedActionId, is(p4InfoActionId));
244
245 // Action param ID.
Carmelo Cascone87892e22017-11-13 16:01:29 -0800246 int p4InfoActionParamId = browser.actionParams(p4InfoActionId).getByName(portParamId.toString()).getId();
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400247 int encodedActionParamId = actionMsg.getParams(0).getParamId();
248 assertThat(encodedActionParamId, is(p4InfoActionParamId));
249
250 // Action param value.
251 byte[] encodedActionParam = actionMsg.getParams(0).getValue().toByteArray();
252 assertThat(encodedActionParam, is(portValue.asArray()));
253
steven308017632e152018-10-20 00:51:08 +0800254 // Counter
255 CounterData counterData = tableEntryMsg.getCounterData();
256 PiCounterCellData encodedCounterData = new PiCounterCellData(counterData.getPacketCount(),
257 counterData.getByteCount());
258 assertThat(encodedCounterData, is(counterCellData));
259
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400260 // TODO: improve, assert other field match types (ternary, LPM)
261 }
Yi Tseng95390822018-01-22 17:57:22 -0800262
263 @Test
Daniele Morof178b0a2020-12-15 14:13:51 +0100264 public void testTableEntryEncoderWithTranslations() throws Exception {
265 TableEntry tableEntryMsg = Codecs.CODECS.tableEntry().encode(
266 piTableEntry2, null, defaultPipeconf2);
267 PiTableEntry decodedPiTableEntry = Codecs.CODECS.tableEntry().decode(
268 tableEntryMsg, null, defaultPipeconf2);
269
270 // Test equality for decoded entry.
271 new EqualsTester()
272 .addEqualityGroup(piTableEntry2, decodedPiTableEntry)
273 .testEquals();
274
275 // Check the exact match with string
276 byte[] encodedExactMatchValueString = tableEntryMsg.getMatch(1).getExact().getValue().toByteArray();
277 assertThat(encodedExactMatchValueString, is(ethAddrString.asArray()));
278
279 Action actionMsg = tableEntryMsg.getAction().getAction();
280
281 // Check action param value with string
282 byte[] encodedActionParamString = actionMsg.getParams(0).getValue().toByteArray();
283 assertThat(encodedActionParamString, is(portValueString.asArray()));
284
285 TableEntry tableEntryMsg1 = Codecs.CODECS.tableEntry().encode(
286 piTableEntry3, null, defaultPipeconf2);
287 PiTableEntry decodedPiTableEntry1 = Codecs.CODECS.tableEntry().decode(
288 tableEntryMsg1, null, defaultPipeconf2);
289
290 // Test equality for decoded entry.
291 new EqualsTester()
292 .addEqualityGroup(piTableEntry3, decodedPiTableEntry1)
293 .testEquals();
294 }
295
296 @Test
Carmelo Cascone5bc7e102018-02-18 18:27:55 -0800297 public void testActopProfileGroup() throws Exception {
Carmelo Cascone4c289b72019-01-22 15:30:45 -0800298 TableEntry tableEntryMsg = Codecs.CODECS.tableEntry().encode(
299 piTableEntryWithGroupAction, null, defaultPipeconf);
300 PiTableEntry decodedPiTableEntry = Codecs.CODECS.tableEntry().decode(
301 tableEntryMsg, null, defaultPipeconf);
Yi Tseng95390822018-01-22 17:57:22 -0800302
303 // Test equality for decoded entry.
304 new EqualsTester()
305 .addEqualityGroup(piTableEntryWithGroupAction, decodedPiTableEntry)
306 .testEquals();
307
308 // Table ID.
309 int p4InfoTableId = browser.tables().getByName(ecmpTableId.id()).getPreamble().getId();
310 int encodedTableId = tableEntryMsg.getTableId();
311 assertThat(encodedTableId, is(p4InfoTableId));
312
313 // Exact match.
314 byte[] encodedTernaryMatchValue = tableEntryMsg.getMatch(0).getExact().getValue().toByteArray();
315 assertThat(encodedTernaryMatchValue, is(new byte[]{(byte) 0xff}));
316
317 // Action profile group id
318 int actionProfileGroupId = tableEntryMsg.getAction().getActionProfileGroupId();
319 assertThat(actionProfileGroupId, is(1));
320 }
Yi Tsengd28936e2018-02-23 22:11:11 +0100321
322 @Test
323 public void testEncodeWithNoAction() throws Exception {
Carmelo Cascone4c289b72019-01-22 15:30:45 -0800324 TableEntry tableEntryMsg = Codecs.CODECS.tableEntry().encode(
325 piTableEntryWithoutAction, null, defaultPipeconf);
326 PiTableEntry decodedPiTableEntry = Codecs.CODECS.tableEntry().decode(
327 tableEntryMsg, null, defaultPipeconf);
Yi Tsengd28936e2018-02-23 22:11:11 +0100328
329 // Test equality for decoded entry.
330 new EqualsTester()
331 .addEqualityGroup(piTableEntryWithoutAction, decodedPiTableEntry)
332 .testEquals();
333
334 // Table ID.
335 int p4InfoTableId = browser.tables().getByName(tableId.id()).getPreamble().getId();
336 int encodedTableId = tableEntryMsg.getTableId();
337 assertThat(encodedTableId, is(p4InfoTableId));
338
339 // Ternary match.
340 byte[] encodedTernaryMatchValue = tableEntryMsg.getMatch(0).getTernary().getValue().toByteArray();
341 assertThat(encodedTernaryMatchValue, is(ethAddr.asArray()));
342
343 // no action
344 assertThat(tableEntryMsg.hasAction(), is(false));
345
steven308017632e152018-10-20 00:51:08 +0800346 // Counter
347 CounterData counterData = tableEntryMsg.getCounterData();
348 PiCounterCellData encodedCounterData = new PiCounterCellData(counterData.getPacketCount(),
349 counterData.getByteCount());
350 assertThat(encodedCounterData, is(counterCellData));
351
Yi Tsengd28936e2018-02-23 22:11:11 +0100352 // TODO: improve, assert other field match types (ternary, LPM)
353 }
Carmelo Cascone8d99b172017-07-18 17:26:31 -0400354}