Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -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.pipelines.fabric.pipeliner; |
| 18 | |
Carmelo Cascone | 4164436 | 2018-08-09 16:56:43 -0700 | [diff] [blame] | 19 | import org.junit.Test; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 20 | import org.onlab.packet.IpPrefix; |
| 21 | import org.onlab.packet.MacAddress; |
| 22 | import org.onlab.packet.MplsLabel; |
| 23 | import org.onlab.packet.VlanId; |
| 24 | import org.onosproject.TestApplicationId; |
| 25 | import org.onosproject.core.ApplicationId; |
| 26 | import org.onosproject.net.DeviceId; |
| 27 | import org.onosproject.net.PortNumber; |
Yi Tseng | 20f9e7b | 2018-05-24 23:27:39 +0800 | [diff] [blame] | 28 | import org.onosproject.net.flow.DefaultTrafficSelector; |
| 29 | import org.onosproject.net.flow.TrafficSelector; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 30 | import org.onosproject.net.flow.criteria.PiCriterion; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame^] | 31 | import org.onosproject.pipelines.fabric.FabricCapabilities; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 32 | import org.onosproject.pipelines.fabric.FabricConstants; |
| 33 | |
| 34 | import static org.easymock.EasyMock.createNiceMock; |
| 35 | import static org.easymock.EasyMock.expect; |
| 36 | import static org.easymock.EasyMock.replay; |
| 37 | |
Carmelo Cascone | 4164436 | 2018-08-09 16:56:43 -0700 | [diff] [blame] | 38 | public class FabricPipelinerTest { |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 39 | static final ApplicationId APP_ID = TestApplicationId.create("FabricPipelinerTest"); |
| 40 | static final DeviceId DEVICE_ID = DeviceId.deviceId("device:bmv2:11"); |
| 41 | static final int PRIORITY = 100; |
| 42 | static final PortNumber PORT_1 = PortNumber.portNumber(1); |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 43 | static final PortNumber PORT_2 = PortNumber.portNumber(2); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 44 | static final VlanId VLAN_100 = VlanId.vlanId("100"); |
| 45 | static final MacAddress HOST_MAC = MacAddress.valueOf("00:00:00:00:00:01"); |
| 46 | static final MacAddress ROUTER_MAC = MacAddress.valueOf("00:00:00:00:02:01"); |
| 47 | static final IpPrefix IPV4_UNICAST_ADDR = IpPrefix.valueOf("10.0.0.1/32"); |
| 48 | static final IpPrefix IPV4_MCAST_ADDR = IpPrefix.valueOf("224.0.0.1/32"); |
| 49 | static final IpPrefix IPV6_UNICAST_ADDR = IpPrefix.valueOf("2000::1/32"); |
| 50 | static final IpPrefix IPV6_MCAST_ADDR = IpPrefix.valueOf("ff00::1/32"); |
| 51 | static final MplsLabel MPLS_10 = MplsLabel.mplsLabel(10); |
| 52 | static final Integer NEXT_ID_1 = 1; |
Yi Tseng | 20f9e7b | 2018-05-24 23:27:39 +0800 | [diff] [blame] | 53 | static final TrafficSelector VLAN_META = DefaultTrafficSelector.builder() |
| 54 | .matchVlanId(VLAN_100) |
| 55 | .build(); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 56 | static final PiCriterion VLAN_VALID = PiCriterion.builder() |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame^] | 57 | .matchExact(FabricConstants.HDR_VLAN_IS_VALID, new byte[]{1}) |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 58 | .build(); |
| 59 | static final PiCriterion VLAN_INVALID = PiCriterion.builder() |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame^] | 60 | .matchExact(FabricConstants.HDR_VLAN_IS_VALID, new byte[]{0}) |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 61 | .build(); |
| 62 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame^] | 63 | FabricCapabilities capabilitiesHashed; |
| 64 | FabricCapabilities capabilitiesSimple; |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 65 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame^] | 66 | void doSetup() { |
| 67 | this.capabilitiesHashed = createNiceMock(FabricCapabilities.class); |
| 68 | this.capabilitiesSimple = createNiceMock(FabricCapabilities.class); |
| 69 | expect(capabilitiesHashed.hasHashedTable()).andReturn(true).anyTimes(); |
| 70 | expect(capabilitiesSimple.hasHashedTable()).andReturn(false).anyTimes(); |
| 71 | replay(capabilitiesHashed); |
| 72 | replay(capabilitiesSimple); |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 73 | } |
Carmelo Cascone | 4164436 | 2018-08-09 16:56:43 -0700 | [diff] [blame] | 74 | |
| 75 | @Test |
| 76 | public void fakeTest() { |
| 77 | // Needed otherwise Bazel complains about a test class without test cases. |
| 78 | assert true; |
| 79 | } |
Yi Tseng | 0b80972 | 2017-11-03 10:23:26 -0700 | [diff] [blame] | 80 | } |