use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.
the class IntentManagerTest method testIntentFetching.
/**
* Tests that the intent fetching methods are correct.
*/
@Test
public void testIntentFetching() {
List<Intent> intents;
flowRuleService.setFuture(true);
intents = Lists.newArrayList(service.getIntents());
assertThat(intents, hasSize(0));
final MockIntent intent1 = new MockIntent(MockIntent.nextId(), NetTestTools.APP_ID);
final MockIntent intent2 = new MockIntent(MockIntent.nextId(), NetTestTools.APP_ID_2);
listener.setLatch(2, Type.INSTALL_REQ);
listener.setLatch(2, Type.INSTALLED);
service.submit(intent1);
service.submit(intent2);
listener.await(Type.INSTALL_REQ);
listener.await(Type.INSTALL_REQ);
listener.await(Type.INSTALLED);
listener.await(Type.INSTALLED);
intents = Lists.newArrayList(service.getIntents());
assertThat(intents, hasSize(2));
assertThat(intents, hasIntentWithId(intent1.id()));
assertThat(intents, hasIntentWithId(intent2.id()));
verifyState();
List<Intent> intentsAppId = Lists.newArrayList(service.getIntentsByAppId(NetTestTools.APP_ID));
assertThat(intentsAppId, hasSize(1));
assertThat(intentsAppId, hasIntentWithId(intent1.id()));
List<Intent> intentsAppId2 = Lists.newArrayList(service.getIntentsByAppId(NetTestTools.APP_ID_2));
assertThat(intentsAppId2, hasSize(1));
assertThat(intentsAppId2, hasIntentWithId(intent2.id()));
verifyState();
}
use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.
the class IntentManagerTest method testCorruptCleanup.
/**
* Test failure to install an intent, then succeed on retry via IntentCleanup.
*/
@Test
public void testCorruptCleanup() {
IntentCleanup cleanup = new IntentCleanup();
cleanup.service = manager;
cleanup.store = manager.store;
cleanup.cfgService = new ComponentConfigAdapter();
try {
cleanup.activate();
final TestIntentCompilerMultipleFlows errorCompiler = new TestIntentCompilerMultipleFlows();
extensionService.registerCompiler(MockIntent.class, errorCompiler);
List<Intent> intents;
flowRuleService.setFuture(false);
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);
listener.setLatch(1, Type.INSTALLED);
service.submit(intent1);
listener.await(Type.INSTALL_REQ);
listener.await(Type.CORRUPT);
flowRuleService.setFuture(true);
listener.await(Type.INSTALLED);
assertThat(listener.getCounts(Type.CORRUPT), is(1));
assertThat(listener.getCounts(Type.INSTALLED), is(1));
assertEquals(INSTALLED, manager.getIntentState(intent1.key()));
assertThat(flowRuleService.getFlowRuleCount(), is(5));
} finally {
cleanup.deactivate();
}
}
use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.
the class IntentManagerTest method errorIntentInstallNeverTrue.
/**
* Tests handling a future that contains an unresolvable error as a result of
* installing an intent.
*/
@Test
public void errorIntentInstallNeverTrue() {
final Long id = MockIntent.nextId();
flowRuleService.setFuture(false);
MockIntent intent = new MockIntent(id);
listener.setLatch(1, Type.CORRUPT);
listener.setLatch(1, Type.INSTALL_REQ);
service.submit(intent);
listener.await(Type.INSTALL_REQ);
// The delay here forces the retry loop in the intent manager to time out
delay(100);
flowRuleService.setFuture(false);
service.withdraw(intent);
listener.await(Type.CORRUPT);
verifyState();
}
use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.
the class IntentManagerTest method stressSubmitWithdrawUnique.
@Test
@Ignore("This is disabled because we are seeing intermittent failures on Jenkins")
public void stressSubmitWithdrawUnique() {
flowRuleService.setFuture(true);
int count = 500;
Intent[] intents = new Intent[count];
listener.setLatch(count, Type.WITHDRAWN);
for (int i = 0; i < count; i++) {
intents[i] = new MockIntent(MockIntent.nextId());
service.submit(intents[i]);
}
for (int i = 0; i < count; i++) {
service.withdraw(intents[i]);
}
listener.await(Type.WITHDRAWN);
assertEquals(0L, flowRuleService.getFlowRuleCount());
verifyState();
}
use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.
the class IntentManagerTest method withdrawIntent.
@Test
public void withdrawIntent() {
flowRuleService.setFuture(true);
listener.setLatch(1, Type.INSTALLED);
Intent intent = new MockIntent(MockIntent.nextId());
service.submit(intent);
listener.await(Type.INSTALLED);
assertEquals(1L, service.getIntentCount());
assertEquals(1L, flowRuleService.getFlowRuleCount());
listener.setLatch(1, Type.WITHDRAWN);
service.withdraw(intent);
listener.await(Type.WITHDRAWN);
assertEquals(0L, flowRuleService.getFlowRuleCount());
verifyState();
}
Aggregations