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.delay; |
| 17 | |
| 18 | import static org.junit.Assert.*; |
| 19 | |
| 20 | import java.time.Duration; |
| 21 | |
| 22 | import org.junit.Before; |
| 23 | import org.junit.Test; |
| 24 | import org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException; |
| 25 | import org.onosproject.incubator.net.l2monitoring.soam.SoamId; |
| 26 | import org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementThreshold.ThresholdOption; |
| 27 | |
| 28 | public class DelayMeasurementThresholdOptionTest { |
| 29 | |
| 30 | DelayMeasurementThreshold dmT1; |
| 31 | |
| 32 | @Before |
| 33 | public void setUp() throws Exception, SoamConfigException { |
| 34 | dmT1 = DefaultDelayMeasurementThreshold.builder(SoamId.valueOf(1)) |
| 35 | .averageFrameDelayBackward(Duration.ofMillis(101)) |
| 36 | .averageFrameDelayForward(Duration.ofMillis(102)) |
| 37 | .averageFrameDelayTwoWay(Duration.ofMillis(103)) |
| 38 | .averageFrameDelayRangeBackward(Duration.ofMillis(201)) |
| 39 | .averageFrameDelayRangeForward(Duration.ofMillis(202)) |
| 40 | .averageFrameDelayRangeTwoWay(Duration.ofMillis(203)) |
| 41 | .averageInterFrameDelayVariationBackward(Duration.ofMillis(301)) |
| 42 | .averageInterFrameDelayVariationForward(Duration.ofMillis(302)) |
| 43 | .averageInterFrameDelayVariationTwoWay(Duration.ofMillis(303)) |
| 44 | .maxFrameDelayBackward(Duration.ofMillis(401)) |
| 45 | .maxFrameDelayForward(Duration.ofMillis(402)) |
| 46 | .maxFrameDelayTwoWay(Duration.ofMillis(403)) |
| 47 | .maxFrameDelayRangeBackward(Duration.ofMillis(501)) |
| 48 | .maxFrameDelayRangeForward(Duration.ofMillis(502)) |
| 49 | .maxFrameDelayRangeTwoWay(Duration.ofMillis(503)) |
| 50 | .maxInterFrameDelayVariationBackward(Duration.ofMillis(601)) |
| 51 | .maxInterFrameDelayVariationForward(Duration.ofMillis(602)) |
| 52 | .maxInterFrameDelayVariationTwoWay(Duration.ofMillis(603)) |
| 53 | .measuredFrameDelayBackward(Duration.ofMillis(701)) |
| 54 | .measuredFrameDelayForward(Duration.ofMillis(702)) |
| 55 | .measuredFrameDelayTwoWay(Duration.ofMillis(703)) |
| 56 | .measuredInterFrameDelayVariationBackward(Duration.ofMillis(801)) |
| 57 | .measuredInterFrameDelayVariationForward(Duration.ofMillis(802)) |
| 58 | .measuredInterFrameDelayVariationTwoWay(Duration.ofMillis(803)) |
| 59 | .addToThresholdsEnabled(ThresholdOption.MEASURED_FRAME_DELAY_TWO_WAY) |
| 60 | .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_TWO_WAY) |
| 61 | .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_TWO_WAY) |
| 62 | .addToThresholdsEnabled(ThresholdOption.MEASURED_INTER_FRAME_DELAY_VARIATION_TWO_WAY) |
| 63 | .addToThresholdsEnabled(ThresholdOption.MAX_INTER_FRAME_DELAY_VARIATION_TWO_WAY) |
| 64 | .addToThresholdsEnabled(ThresholdOption.AVERAGE_INTER_FRAME_DELAY_VARIATION_TWO_WAY) |
| 65 | .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_RANGE_TWO_WAY) |
| 66 | .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_RANGE_TWO_WAY) |
| 67 | .addToThresholdsEnabled(ThresholdOption.MEASURED_FRAME_DELAY_FORWARD) |
| 68 | .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_FORWARD) |
| 69 | .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_FORWARD) |
| 70 | .addToThresholdsEnabled(ThresholdOption.MEASURED_INTER_FRAME_DELAY_VARIATION_FORWARD) |
| 71 | .addToThresholdsEnabled(ThresholdOption.MAX_INTER_FRAME_DELAY_VARIATION_FORWARD) |
| 72 | .addToThresholdsEnabled(ThresholdOption.AVERAGE_INTER_FRAME_DELAY_VARIATION_FORWARD) |
| 73 | .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_RANGE_FORWARD) |
| 74 | .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_RANGE_FORWARD) |
| 75 | .addToThresholdsEnabled(ThresholdOption.MEASURED_FRAME_DELAY_BACKWARD) |
| 76 | .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_BACKWARD) |
| 77 | .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_BACKWARD) |
| 78 | .addToThresholdsEnabled(ThresholdOption.MEASURED_INTER_FRAME_DELAY_VARIATION_BACKWARD) |
| 79 | .addToThresholdsEnabled(ThresholdOption.MAX_INTER_FRAME_DELAY_VARIATION_BACKWARD) |
| 80 | .addToThresholdsEnabled(ThresholdOption.AVERAGE_INTER_FRAME_DELAY_VARIATION_BACKWARD) |
| 81 | .addToThresholdsEnabled(ThresholdOption.MAX_FRAME_DELAY_RANGE_BACKWARD) |
| 82 | .addToThresholdsEnabled(ThresholdOption.AVERAGE_FRAME_DELAY_RANGE_BACKWARD) |
| 83 | .build(); |
| 84 | } |
| 85 | |
| 86 | @Test |
| 87 | public void testThreshId() { |
| 88 | assertEquals(1, dmT1.threshId().id().intValue()); |
| 89 | } |
| 90 | |
| 91 | @Test |
| 92 | public void testThresholdsEnabled() { |
| 93 | assertEquals(24, dmT1.thresholdsEnabled().size()); |
| 94 | } |
| 95 | |
| 96 | @Test |
| 97 | public void testMeasuredFrameDelayTwoWay() { |
| 98 | assertEquals(703, dmT1.measuredFrameDelayTwoWay().toMillis()); |
| 99 | } |
| 100 | |
| 101 | @Test |
| 102 | public void testMaxFrameDelayTwoWay() { |
| 103 | assertEquals(403, dmT1.maxFrameDelayTwoWay().toMillis()); |
| 104 | } |
| 105 | |
| 106 | @Test |
| 107 | public void testAverageFrameDelayTwoWay() { |
| 108 | assertEquals(103, dmT1.averageFrameDelayTwoWay().toMillis()); |
| 109 | } |
| 110 | |
| 111 | @Test |
| 112 | public void testMeasuredInterFrameDelayVariationTwoWay() { |
| 113 | assertEquals(803, dmT1.measuredInterFrameDelayVariationTwoWay().toMillis()); |
| 114 | } |
| 115 | |
| 116 | @Test |
| 117 | public void testMaxInterFrameDelayVariationTwoWay() { |
| 118 | assertEquals(603, dmT1.maxInterFrameDelayVariationTwoWay().toMillis()); |
| 119 | } |
| 120 | |
| 121 | @Test |
| 122 | public void testAverageInterFrameDelayVariationTwoWay() { |
| 123 | assertEquals(303, dmT1.averageInterFrameDelayVariationTwoWay().toMillis()); |
| 124 | } |
| 125 | |
| 126 | @Test |
| 127 | public void testMaxFrameDelayRangeTwoWay() { |
| 128 | assertEquals(503, dmT1.maxFrameDelayRangeTwoWay().toMillis()); |
| 129 | } |
| 130 | |
| 131 | @Test |
| 132 | public void testAverageFrameDelayRangeTwoWay() { |
| 133 | assertEquals(203, dmT1.averageFrameDelayRangeTwoWay().toMillis()); |
| 134 | } |
| 135 | |
| 136 | @Test |
| 137 | public void testMeasuredFrameDelayForward() { |
| 138 | assertEquals(702, dmT1.measuredFrameDelayForward().toMillis()); |
| 139 | } |
| 140 | |
| 141 | @Test |
| 142 | public void testMaxFrameDelayForward() { |
| 143 | assertEquals(402, dmT1.maxFrameDelayForward().toMillis()); |
| 144 | } |
| 145 | |
| 146 | @Test |
| 147 | public void testAverageFrameDelayForward() { |
| 148 | assertEquals(102, dmT1.averageFrameDelayForward().toMillis()); |
| 149 | } |
| 150 | |
| 151 | @Test |
| 152 | public void testMeasuredInterFrameDelayVariationForward() { |
| 153 | assertEquals(802, dmT1.measuredInterFrameDelayVariationForward().toMillis()); |
| 154 | } |
| 155 | |
| 156 | @Test |
| 157 | public void testMaxInterFrameDelayVariationForward() { |
| 158 | assertEquals(602, dmT1.maxInterFrameDelayVariationForward().toMillis()); |
| 159 | } |
| 160 | |
| 161 | @Test |
| 162 | public void testAverageInterFrameDelayVariationForward() { |
| 163 | assertEquals(302, dmT1.averageInterFrameDelayVariationForward().toMillis()); |
| 164 | } |
| 165 | |
| 166 | @Test |
| 167 | public void testMaxFrameDelayRangeForward() { |
| 168 | assertEquals(502, dmT1.maxFrameDelayRangeForward().toMillis()); |
| 169 | } |
| 170 | |
| 171 | @Test |
| 172 | public void testAverageFrameDelayRangeForward() { |
| 173 | assertEquals(202, dmT1.averageFrameDelayRangeForward().toMillis()); |
| 174 | } |
| 175 | |
| 176 | @Test |
| 177 | public void testMeasuredFrameDelayBackward() { |
| 178 | assertEquals(701, dmT1.measuredFrameDelayBackward().toMillis()); |
| 179 | } |
| 180 | |
| 181 | @Test |
| 182 | public void testMaxFrameDelayBackward() { |
| 183 | assertEquals(401, dmT1.maxFrameDelayBackward().toMillis()); |
| 184 | } |
| 185 | |
| 186 | @Test |
| 187 | public void testAverageFrameDelayBackward() { |
| 188 | assertEquals(101, dmT1.averageFrameDelayBackward().toMillis()); |
| 189 | } |
| 190 | |
| 191 | @Test |
| 192 | public void testMeasuredInterFrameDelayVariationBackward() { |
| 193 | assertEquals(801, dmT1.measuredInterFrameDelayVariationBackward().toMillis()); |
| 194 | } |
| 195 | |
| 196 | @Test |
| 197 | public void testMaxInterFrameDelayVariationBackward() { |
| 198 | assertEquals(601, dmT1.maxInterFrameDelayVariationBackward().toMillis()); |
| 199 | } |
| 200 | |
| 201 | @Test |
| 202 | public void testAverageInterFrameDelayVariationBackward() { |
| 203 | assertEquals(301, dmT1.averageInterFrameDelayVariationBackward().toMillis()); |
| 204 | } |
| 205 | |
| 206 | @Test |
| 207 | public void testMaxFrameDelayRangeBackward() { |
| 208 | assertEquals(501, dmT1.maxFrameDelayRangeBackward().toMillis()); |
| 209 | } |
| 210 | |
| 211 | @Test |
| 212 | public void testAverageFrameDelayRangeBackward() { |
| 213 | assertEquals(201, dmT1.averageFrameDelayRangeBackward().toMillis()); |
| 214 | } |
| 215 | |
| 216 | } |