use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.
the class IntentCleanupTestMock method corruptEventThreshold.
/**
* Intent should not be retried because threshold is reached.
*/
@Test
public void corruptEventThreshold() {
IntentStoreDelegate mockDelegate = new IntentStoreDelegate() {
@Override
public void process(IntentData intentData) {
intentData.setState(CORRUPT);
intentData.setErrorCount(cleanup.retryThreshold);
store.write(intentData);
}
@Override
public void notify(IntentEvent event) {
cleanup.event(event);
}
};
store.setDelegate(mockDelegate);
Intent intent = new MockIntent(1L);
IntentData data = new IntentData(intent, INSTALL_REQ, null);
replay(service);
store.addPending(data);
verify(service);
reset(service);
}
use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.
the class IntentManagerTest method testFlowRemoval.
/**
* Tests that removing all intents results in no flows remaining.
*/
@Test
public void testFlowRemoval() {
List<Intent> intents;
flowRuleService.setFuture(true);
intents = Lists.newArrayList(service.getIntents());
assertThat(intents, hasSize(0));
final MockIntent intent1 = new MockIntent(MockIntent.nextId());
final MockIntent intent2 = new MockIntent(MockIntent.nextId());
listener.setLatch(1, Type.INSTALL_REQ);
listener.setLatch(1, Type.INSTALLED);
service.submit(intent1);
listener.await(Type.INSTALL_REQ);
listener.await(Type.INSTALLED);
listener.setLatch(1, Type.INSTALL_REQ);
listener.setLatch(1, Type.INSTALLED);
service.submit(intent2);
listener.await(Type.INSTALL_REQ);
listener.await(Type.INSTALLED);
assertThat(listener.getCounts(Type.INSTALLED), is(2));
assertThat(flowRuleService.getFlowRuleCount(), is(2));
listener.setLatch(1, Type.WITHDRAWN);
service.withdraw(intent1);
listener.await(Type.WITHDRAWN);
listener.setLatch(1, Type.WITHDRAWN);
service.withdraw(intent2);
listener.await(Type.WITHDRAWN);
assertThat(listener.getCounts(Type.WITHDRAWN), is(2));
assertThat(flowRuleService.getFlowRuleCount(), is(0));
}
use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.
the class IntentManagerTest method stressSubmitWithdrawSame.
@Test
public void stressSubmitWithdrawSame() {
flowRuleService.setFuture(true);
int count = 50;
Intent intent = new MockIntent(MockIntent.nextId());
for (int i = 0; i < count; i++) {
service.submit(intent);
service.withdraw(intent);
}
assertAfter(SUBMIT_TIMEOUT_MS, () -> {
assertEquals(1L, service.getIntentCount());
assertEquals(0L, flowRuleService.getFlowRuleCount());
});
verifyState();
}
use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.
the class IntentManagerTest method intentWithoutInstaller.
/**
* Tests an intent with no installer.
*/
@Test
public void intentWithoutInstaller() {
MockIntent intent = new MockIntent(MockIntent.nextId());
listener.setLatch(1, Type.INSTALL_REQ);
listener.setLatch(1, Type.CORRUPT);
service.submit(intent);
listener.await(Type.INSTALL_REQ);
listener.await(Type.CORRUPT);
verifyState();
}
use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.
the class IntentManagerTest method testFlowRemovalInstallError.
/**
* Tests that an intent that fails installation results in no flows remaining.
*/
@Test
// test works if run independently
@Ignore("MockFlowRule numbering issue")
public void testFlowRemovalInstallError() {
final TestIntentCompilerMultipleFlows errorCompiler = new TestIntentCompilerMultipleFlows();
extensionService.registerCompiler(MockIntent.class, errorCompiler);
List<Intent> intents;
flowRuleService.setFuture(true);
// FIXME relying on "3" is brittle
flowRuleService.setErrorFlow(3);
intents = Lists.newArrayList(service.getIntents());
assertThat(intents, hasSize(0));
final MockIntent intent1 = new MockIntent(MockIntent.nextId());
listener.setLatch(1, Type.INSTALL_REQ);
listener.setLatch(1, Type.CORRUPT);
service.submit(intent1);
listener.await(Type.INSTALL_REQ);
listener.await(Type.CORRUPT);
assertThat(listener.getCounts(Type.CORRUPT), is(1));
// in this test, there will still be flows abandoned on the data plane
// assertThat(flowRuleService.getFlowRuleCount(), is(0));
}
Aggregations