Refined the methods waiting for BGP routes in the BgpSessionManagerTest
unit test. This reduces the typical run time for the unit tests from 2-3 seconds to 0.6-0.7 seconds. Change-Id: I7a31f837da5838c20d2b43de23de77d378e9f900
Showing
1 changed file
with
6 additions
and
6 deletions
| ... | @@ -146,7 +146,7 @@ public class BgpSessionManagerTest { | ... | @@ -146,7 +146,7 @@ public class BgpSessionManagerTest { |
| 146 | /** | 146 | /** |
| 147 | * Gets BGP RIB-IN routes by waiting until they are received. | 147 | * Gets BGP RIB-IN routes by waiting until they are received. |
| 148 | * <p/> | 148 | * <p/> |
| 149 | - * NOTE: We keep checking once a second the number of received routes, | 149 | + * NOTE: We keep checking once every 10ms the number of received routes, |
| 150 | * up to 5 seconds. | 150 | * up to 5 seconds. |
| 151 | * | 151 | * |
| 152 | * @param bgpSession the BGP session that is expected to receive the | 152 | * @param bgpSession the BGP session that is expected to receive the |
| ... | @@ -160,12 +160,12 @@ public class BgpSessionManagerTest { | ... | @@ -160,12 +160,12 @@ public class BgpSessionManagerTest { |
| 160 | throws InterruptedException { | 160 | throws InterruptedException { |
| 161 | Collection<BgpRouteEntry> bgpRibIn = bgpSession.getBgpRibIn(); | 161 | Collection<BgpRouteEntry> bgpRibIn = bgpSession.getBgpRibIn(); |
| 162 | 162 | ||
| 163 | - final int maxChecks = 5; // Max wait of 5 seconds | 163 | + final int maxChecks = 500; // Max wait of 5 seconds |
| 164 | for (int i = 0; i < maxChecks; i++) { | 164 | for (int i = 0; i < maxChecks; i++) { |
| 165 | if (bgpRibIn.size() == expectedRoutes) { | 165 | if (bgpRibIn.size() == expectedRoutes) { |
| 166 | break; | 166 | break; |
| 167 | } | 167 | } |
| 168 | - Thread.sleep(1000); | 168 | + Thread.sleep(10); |
| 169 | bgpRibIn = bgpSession.getBgpRibIn(); | 169 | bgpRibIn = bgpSession.getBgpRibIn(); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| ... | @@ -175,7 +175,7 @@ public class BgpSessionManagerTest { | ... | @@ -175,7 +175,7 @@ public class BgpSessionManagerTest { |
| 175 | /** | 175 | /** |
| 176 | * Gets BGP merged routes by waiting until they are received. | 176 | * Gets BGP merged routes by waiting until they are received. |
| 177 | * <p/> | 177 | * <p/> |
| 178 | - * NOTE: We keep checking once a second the number of received routes, | 178 | + * NOTE: We keep checking once every 10ms the number of received routes, |
| 179 | * up to 5 seconds. | 179 | * up to 5 seconds. |
| 180 | * | 180 | * |
| 181 | * @param expectedRoutes the expected number of routes | 181 | * @param expectedRoutes the expected number of routes |
| ... | @@ -186,12 +186,12 @@ public class BgpSessionManagerTest { | ... | @@ -186,12 +186,12 @@ public class BgpSessionManagerTest { |
| 186 | throws InterruptedException { | 186 | throws InterruptedException { |
| 187 | Collection<BgpRouteEntry> bgpRoutes = bgpSessionManager.getBgpRoutes(); | 187 | Collection<BgpRouteEntry> bgpRoutes = bgpSessionManager.getBgpRoutes(); |
| 188 | 188 | ||
| 189 | - final int maxChecks = 5; // Max wait of 5 seconds | 189 | + final int maxChecks = 500; // Max wait of 5 seconds |
| 190 | for (int i = 0; i < maxChecks; i++) { | 190 | for (int i = 0; i < maxChecks; i++) { |
| 191 | if (bgpRoutes.size() == expectedRoutes) { | 191 | if (bgpRoutes.size() == expectedRoutes) { |
| 192 | break; | 192 | break; |
| 193 | } | 193 | } |
| 194 | - Thread.sleep(1000); | 194 | + Thread.sleep(10); |
| 195 | bgpRoutes = bgpSessionManager.getBgpRoutes(); | 195 | bgpRoutes = bgpSessionManager.getBgpRoutes(); |
| 196 | } | 196 | } |
| 197 | 197 | ... | ... |
-
Please register or login to post a comment