mirror of
https://github.com/opennetworkinglab/onos.git
synced 2026-05-05 04:06:49 +02:00
Added code to intent unit tests to pre-emptively unbind ID generator to avoid cascading failures.
Change-Id: I2e5aff44a90ceeaaad71d7154b79f20edab620a7
This commit is contained in:
parent
e538711b8d
commit
2323596967
@ -72,6 +72,7 @@ public class OpticalConnectivityTest {
|
||||
}
|
||||
};
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
}
|
||||
|
||||
|
||||
@ -248,6 +248,7 @@ public class OpticalPathProvisionerTest {
|
||||
return counter++;
|
||||
}
|
||||
};
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
}
|
||||
|
||||
|
||||
@ -54,6 +54,7 @@ public class PacketLinkRealizedByOpticalTest {
|
||||
}
|
||||
};
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
}
|
||||
|
||||
|
||||
@ -377,6 +377,7 @@ public class OpticalCircuitIntentCompilerTest {
|
||||
sut.intentService = new TestIntentService();
|
||||
sut.intentSetMultimap = new MockIntentSetMultimap();
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
intentExtensionService = createMock(IntentExtensionService.class);
|
||||
|
||||
@ -274,6 +274,7 @@ public class OpticalOduIntentCompilerTest {
|
||||
sut.resourceService = new MockResourceService();
|
||||
sut.topologyService = new MockTopologyService();
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
intentExtensionService = createMock(IntentExtensionService.class);
|
||||
|
||||
@ -81,6 +81,7 @@ public class OpticalPathIntentCompilerTest {
|
||||
.andReturn(appId);
|
||||
sut.coreService = coreService;
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
intent = OpticalPathIntent.builder()
|
||||
|
||||
@ -245,6 +245,7 @@ public class VplsTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
idGenerator = new TestIdGenerator();
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
applicationService = createMock(ApplicationService.class);
|
||||
|
||||
@ -55,6 +55,7 @@ public class IntentDataTest {
|
||||
@Before
|
||||
public void setUpTest() {
|
||||
idGenerator = new MockIdGenerator();
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
timestamp1 = new MockTimestamp(1);
|
||||
|
||||
@ -47,6 +47,7 @@ public class IntentServiceTest {
|
||||
public void setUp() {
|
||||
service = createIntentService();
|
||||
service.addListener(listener);
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
}
|
||||
|
||||
|
||||
@ -25,10 +25,13 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
public class MockIdGenerator implements IdGenerator {
|
||||
|
||||
private static boolean generatorIsBound = false;
|
||||
private static MockIdGenerator idGenerator;
|
||||
public static void bindNewGenerator() {
|
||||
if (!generatorIsBound) {
|
||||
generatorIsBound = true;
|
||||
Intent.bindIdGenerator(new MockIdGenerator());
|
||||
idGenerator = new MockIdGenerator();
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
}
|
||||
}
|
||||
private AtomicLong nextId = new AtomicLong(0);
|
||||
|
||||
@ -167,6 +167,7 @@ public class IntentManager
|
||||
batchExecutor = newSingleThreadExecutor(groupedThreads("onos/intent", "batch", log));
|
||||
workerExecutor = newFixedThreadPool(numThreads, groupedThreads("onos/intent", "worker-%d", log));
|
||||
idGenerator = coreService.getIdGenerator("intent-ids");
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
log.info("Started");
|
||||
}
|
||||
|
||||
@ -57,6 +57,7 @@ public class IntentAccumulatorTest {
|
||||
@Before
|
||||
public void localSetup() {
|
||||
mockGenerator = new MockIdGenerator();
|
||||
Intent.unbindIdGenerator(mockGenerator);
|
||||
Intent.bindIdGenerator(mockGenerator);
|
||||
|
||||
intent1 = new MockIntent(1L);
|
||||
|
||||
@ -89,13 +89,13 @@ public class IntentCleanupTest {
|
||||
assertTrue("store should be empty",
|
||||
Sets.newHashSet(cleanup.store.getIntents()).isEmpty());
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
cleanup.deactivate();
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
}
|
||||
|
||||
|
||||
@ -72,6 +72,7 @@ public class IntentCleanupTestMock {
|
||||
assertTrue("store should be empty",
|
||||
Sets.newHashSet(cleanup.store.getIntents()).isEmpty());
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
}
|
||||
|
||||
|
||||
@ -89,6 +89,7 @@ public class ObjectiveTrackerTest {
|
||||
deviceListener = TestUtils.getField(tracker, "deviceListener");
|
||||
resourceListener = TestUtils.getField(tracker, "resourceListener");
|
||||
mockGenerator = new MockIdGenerator();
|
||||
Intent.unbindIdGenerator(mockGenerator);
|
||||
Intent.bindIdGenerator(mockGenerator);
|
||||
}
|
||||
|
||||
|
||||
@ -65,6 +65,7 @@ public class LinkCollectionEncapIntentCompilerTest extends AbstractLinkCollectio
|
||||
expect(coreService.registerApplication("org.onosproject.net.intent")).andReturn(appId);
|
||||
sut.coreService = coreService;
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
intentExtensionService = createMock(IntentExtensionService.class);
|
||||
|
||||
@ -68,6 +68,7 @@ public class LinkCollectionIntentCompilerP2PTest extends AbstractLinkCollectionT
|
||||
.andReturn(appId);
|
||||
sut.coreService = coreService;
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
intentExtensionService = createMock(IntentExtensionService.class);
|
||||
|
||||
@ -80,6 +80,7 @@ public class LinkCollectionIntentCompilerTest extends AbstractLinkCollectionTest
|
||||
.andReturn(appId);
|
||||
sut.coreService = coreService;
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
intent = LinkCollectionIntent.builder()
|
||||
|
||||
@ -65,6 +65,7 @@ public class LinkCollectionOptimizationTest extends AbstractLinkCollectionTest {
|
||||
.andReturn(appId);
|
||||
sut.coreService = coreService;
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
intentExtensionService = createMock(IntentExtensionService.class);
|
||||
|
||||
@ -98,6 +98,7 @@ public class MplsPathIntentCompilerTest {
|
||||
sut.coreService = coreService;
|
||||
sut.resourceService = new MockResourceService();
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
intent = MplsPathIntent.builder()
|
||||
|
||||
@ -176,6 +176,7 @@ public class PathIntentCompilerTest {
|
||||
sut.coreService = coreService;
|
||||
sut.resourceService = new MockResourceService();
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
intent = PathIntent.builder()
|
||||
|
||||
@ -88,6 +88,7 @@ public class CompilingTest {
|
||||
|
||||
idGenerator = new MockIdGenerator();
|
||||
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
// Intent creation should be placed after binding an ID generator
|
||||
|
||||
@ -58,6 +58,7 @@ public class GossipIntentStoreTest {
|
||||
intentStore.partitionService = new WorkPartitionServiceAdapter();
|
||||
intentStore.clusterService = new ClusterServiceAdapter();
|
||||
idGenerator = new MockIdGenerator();
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
builder1 = HostToHostIntent
|
||||
.builder()
|
||||
|
||||
@ -92,6 +92,7 @@ public class VirtualNetworkManagerTest extends TestDeviceParams {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
virtualNetworkManagerStore = new DistributedVirtualNetworkStore();
|
||||
Intent.unbindIdGenerator(idGenerator);
|
||||
Intent.bindIdGenerator(idGenerator);
|
||||
|
||||
coreService = new TestCoreService();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user