Sean Condon | 0e89bda | 2017-03-21 14:23:19 +0000 | [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 | package org.onosproject.incubator.net.l2monitoring.soam.loss; |
| 17 | |
Sean Condon | 0e89bda | 2017-03-21 14:23:19 +0000 | [diff] [blame] | 18 | import java.time.Duration; |
| 19 | |
| 20 | import org.junit.Before; |
| 21 | import org.junit.Test; |
| 22 | import org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority; |
| 23 | import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId; |
| 24 | import org.onosproject.incubator.net.l2monitoring.soam.MeasurementCreateBase.SessionType; |
| 25 | import org.onosproject.incubator.net.l2monitoring.soam.MilliPct; |
| 26 | import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException; |
| 27 | import org.onosproject.incubator.net.l2monitoring.soam.SoamId; |
| 28 | import org.onosproject.incubator.net.l2monitoring.soam.StartTime; |
| 29 | import org.onosproject.incubator.net.l2monitoring.soam.StopTime; |
| 30 | import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.DataPattern; |
| 31 | import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.TestTlvPattern; |
| 32 | import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version; |
| 33 | import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.CounterOption; |
| 34 | import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmCreateBuilder; |
| 35 | import org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementCreate.LmType; |
| 36 | |
Sean Condon | 3a1efef | 2018-02-24 13:16:03 +0000 | [diff] [blame] | 37 | import static org.junit.Assert.assertEquals; |
| 38 | |
Sean Condon | 0e89bda | 2017-03-21 14:23:19 +0000 | [diff] [blame] | 39 | public class LossMeasurementCreateTest { |
| 40 | |
| 41 | LossMeasurementCreate lmc1; |
| 42 | |
| 43 | @Before |
| 44 | public void setUp() throws SoamConfigException { |
| 45 | |
| 46 | LossMeasurementThreshold lmt1 = DefaultLmThreshold |
| 47 | .builder(SoamId.valueOf(4)).build(); |
| 48 | |
| 49 | |
| 50 | LmCreateBuilder builder = (LmCreateBuilder) DefaultLmCreate |
| 51 | .builder(Version.Y17312008, MepId.valueOf((short) 10), |
| 52 | Priority.PRIO3, LmType.LMLMM) |
| 53 | .addToCountersEnabled(CounterOption.AVAILABILITY_FORWARD_AVERAGE_FLR) |
| 54 | .addToCountersEnabled(CounterOption.AVAILABILITY_FORWARD_CONSECUTIVE_HIGH_LOSS) |
| 55 | .availabilityFlrThreshold(MilliPct.ofRatio(0.201f)) |
| 56 | .availabilityMeasurementInterval(Duration.ofSeconds(5)) |
| 57 | .availabilityNumberConsecutiveFlrMeasurements(6) |
| 58 | .availabilityNumberConsecutiveHighFlr((short) 7) |
| 59 | .availabilityNumberConsecutiveIntervals((short) 8) |
| 60 | .addToLossMeasurementThreshold(lmt1) |
| 61 | .frameSize((short) 100) |
| 62 | .dataPattern(DataPattern.ZEROES) |
| 63 | .testTlvIncluded(true) |
| 64 | .testTlvPattern(TestTlvPattern.NULL_SIGNAL_WITHOUT_CRC_32) |
| 65 | .messagePeriod(Duration.ofMinutes(9)) |
| 66 | .measurementInterval(Duration.ofMinutes(10)) |
| 67 | .numberIntervalsStored((short) 11) |
| 68 | .alignMeasurementIntervals(true) |
| 69 | .alignMeasurementOffset(Duration.ofSeconds(12)) |
| 70 | .startTime(StartTime.immediate()) |
| 71 | .stopTime(StopTime.none()) |
| 72 | .sessionType(SessionType.PROACTIVE); |
| 73 | |
| 74 | lmc1 = builder.build(); |
| 75 | } |
| 76 | |
| 77 | @Test |
| 78 | public void testLmCfgType() { |
| 79 | assertEquals(LmType.LMLMM, lmc1.lmCfgType()); |
| 80 | } |
| 81 | |
| 82 | @Test |
| 83 | public void testCountersEnabled() { |
| 84 | assertEquals(2, lmc1.countersEnabled().size()); |
| 85 | } |
| 86 | |
| 87 | @Test |
| 88 | public void testAvailabilityMeasurementInterval() { |
| 89 | assertEquals(5, lmc1.availabilityMeasurementInterval().getSeconds()); |
| 90 | } |
| 91 | |
| 92 | @Test |
| 93 | public void testAvailabilityNumberConsecutiveFlrMeasurements() { |
| 94 | assertEquals(6, lmc1.availabilityNumberConsecutiveFlrMeasurements().intValue()); |
| 95 | } |
| 96 | |
| 97 | @Test |
| 98 | public void testAvailabilityFlrThreshold() { |
| 99 | assertEquals(0.201f, lmc1.availabilityFlrThreshold().ratioValue(), 0.0001f); |
| 100 | } |
| 101 | |
| 102 | @Test |
| 103 | public void testAvailabilityNumberConsecutiveIntervals() { |
| 104 | assertEquals(8, lmc1.availabilityNumberConsecutiveIntervals().shortValue()); |
| 105 | } |
| 106 | |
| 107 | @Test |
| 108 | public void testAvailabilityNumberConsecutiveHighFlr() { |
| 109 | assertEquals(7, lmc1.availabilityNumberConsecutiveHighFlr().shortValue()); |
| 110 | } |
| 111 | |
| 112 | @Test |
| 113 | public void testLossMeasurementThreshold() { |
| 114 | assertEquals(1, lmc1.lossMeasurementThreshold().size()); |
| 115 | } |
| 116 | |
| 117 | @Test |
| 118 | public void testVersion() { |
| 119 | assertEquals(Version.Y17312008, lmc1.version()); |
| 120 | } |
| 121 | |
| 122 | @Test |
| 123 | public void testRemoteMepId() { |
| 124 | assertEquals(10, lmc1.remoteMepId().id().shortValue()); |
| 125 | } |
| 126 | |
| 127 | @Test |
| 128 | public void testMessagePeriod() { |
| 129 | assertEquals(9, lmc1.messagePeriod().toMinutes()); |
| 130 | } |
| 131 | |
| 132 | @Test |
| 133 | public void testPriority() { |
| 134 | assertEquals(Priority.PRIO3, lmc1.priority()); |
| 135 | } |
| 136 | |
| 137 | @Test |
| 138 | public void testFrameSize() { |
| 139 | assertEquals(100, lmc1.frameSize().shortValue()); |
| 140 | } |
| 141 | |
| 142 | @Test |
| 143 | public void testDataPattern() { |
| 144 | assertEquals(DataPattern.ZEROES, lmc1.dataPattern()); |
| 145 | } |
| 146 | |
| 147 | @Test |
| 148 | public void testTestTlvIncluded() { |
| 149 | assertEquals(true, lmc1.testTlvIncluded()); |
| 150 | } |
| 151 | |
| 152 | @Test |
| 153 | public void testTestTlvPattern() { |
| 154 | assertEquals(TestTlvPattern.NULL_SIGNAL_WITHOUT_CRC_32, lmc1.testTlvPattern()); |
| 155 | } |
| 156 | |
| 157 | @Test |
| 158 | public void testMeasurementInterval() { |
| 159 | assertEquals(10, lmc1.measurementInterval().toMinutes()); |
| 160 | } |
| 161 | |
| 162 | @Test |
| 163 | public void testNumberIntervalsStored() { |
| 164 | assertEquals(11, lmc1.numberIntervalsStored().shortValue()); |
| 165 | } |
| 166 | |
| 167 | @Test |
| 168 | public void testAlignMeasurementIntervals() { |
| 169 | assertEquals(true, lmc1.alignMeasurementIntervals()); |
| 170 | } |
| 171 | |
| 172 | @Test |
| 173 | public void testAlignMeasurementOffset() { |
| 174 | assertEquals(12, lmc1.alignMeasurementOffset().getSeconds()); |
| 175 | } |
| 176 | |
| 177 | @Test |
| 178 | public void testStartTime() { |
| 179 | assertEquals(StartTime.immediate().option(), |
| 180 | lmc1.startTime().option()); |
| 181 | } |
| 182 | |
| 183 | @Test |
| 184 | public void testStopTime() { |
| 185 | assertEquals(StopTime.none().option(), |
| 186 | lmc1.stopTime().option()); |
| 187 | } |
| 188 | |
| 189 | @Test |
| 190 | public void testSessionType() { |
| 191 | assertEquals(SessionType.PROACTIVE, lmc1.sessionType()); |
| 192 | } |
| 193 | |
| 194 | } |