use of org.onosproject.net.intent.TestInstallableIntent in project onos by opennetworkinglab.
the class InstallCoordinatorTest method testUninstallAndInstallIntent.
/**
* Do both uninstall and install test Intents.
*/
@Test
public void testUninstallAndInstallIntent() {
IntentData toUninstall = new IntentData(createTestIntent(), IntentState.INSTALLED, new WallClockTimestamp());
IntentData toInstall = new IntentData(createTestIntent(), IntentState.INSTALLING, new WallClockTimestamp());
List<Intent> intentsToUninstall = Lists.newArrayList();
List<Intent> intentsToInstall = Lists.newArrayList();
IntStream.range(0, 10).forEach(val -> {
intentsToUninstall.add(new TestInstallableIntent(val));
});
IntStream.range(10, 20).forEach(val -> {
intentsToInstall.add(new TestInstallableIntent(val));
});
toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
toInstall = IntentData.compiled(toInstall, intentsToInstall);
installCoordinator.installIntents(Optional.of(toUninstall), Optional.of(toInstall));
Intent toInstallIntent = toInstall.intent();
TestTools.assertAfter(INSTALL_DELAY, INSTALL_DURATION, () -> {
IntentData newData = intentStore.newData;
assertEquals(toInstallIntent, newData.intent());
assertEquals(IntentState.INSTALLED, newData.state());
assertEquals(intentsToInstall, newData.installables());
});
}
use of org.onosproject.net.intent.TestInstallableIntent in project onos by opennetworkinglab.
the class InstallCoordinatorTest method testInstallFailed.
/**
* Test Intent install failed.
*/
@Test
public void testInstallFailed() {
installerRegistry.unregisterInstaller(TestInstallableIntent.class);
installerRegistry.registerInstaller(TestInstallableIntent.class, new TestFailedIntentInstaller());
IntentData toUninstall = new IntentData(createTestIntent(), IntentState.INSTALLED, new WallClockTimestamp());
IntentData toInstall = new IntentData(createTestIntent(), IntentState.INSTALLING, new WallClockTimestamp());
List<Intent> intentsToUninstall = Lists.newArrayList();
List<Intent> intentsToInstall = Lists.newArrayList();
IntStream.range(0, 10).forEach(val -> {
intentsToUninstall.add(new TestInstallableIntent(val));
});
IntStream.range(10, 20).forEach(val -> {
intentsToInstall.add(new TestInstallableIntent(val));
});
toUninstall = IntentData.compiled(toUninstall, intentsToUninstall);
toInstall = IntentData.compiled(toInstall, intentsToInstall);
installCoordinator.installIntents(Optional.of(toUninstall), Optional.of(toInstall));
Intent toUninstallIntent = toUninstall.intent();
TestTools.assertAfter(INSTALL_DELAY, INSTALL_DURATION, () -> {
IntentData newData = intentStore.newData;
assertEquals(toUninstallIntent, newData.intent());
assertEquals(IntentState.CORRUPT, newData.state());
assertEquals(intentsToUninstall, newData.installables());
});
}
use of org.onosproject.net.intent.TestInstallableIntent in project onos by opennetworkinglab.
the class InstallCoordinatorTest method testInstallIntent.
/**
* Installs test Intents.
*/
@Test
public void testInstallIntent() {
IntentData toInstall = new IntentData(createTestIntent(), IntentState.INSTALLING, new WallClockTimestamp());
List<Intent> intents = Lists.newArrayList();
IntStream.range(0, 10).forEach(val -> {
intents.add(new TestInstallableIntent(val));
});
toInstall = IntentData.compiled(toInstall, intents);
installCoordinator.installIntents(Optional.empty(), Optional.of(toInstall));
Intent toInstallIntent = toInstall.intent();
TestTools.assertAfter(INSTALL_DELAY, INSTALL_DURATION, () -> {
IntentData newData = intentStore.newData;
assertEquals(toInstallIntent, newData.intent());
assertEquals(IntentState.INSTALLED, newData.state());
assertEquals(intents, newData.installables());
});
}
use of org.onosproject.net.intent.TestInstallableIntent in project onos by opennetworkinglab.
the class InstallCoordinatorTest method testUninstallIntent.
/**
* Uninstalls test Intents.
*/
@Test
public void testUninstallIntent() {
IntentData toUninstall = new IntentData(createTestIntent(), IntentState.WITHDRAWING, new WallClockTimestamp());
List<Intent> intents = Lists.newArrayList();
IntStream.range(0, 10).forEach(val -> {
intents.add(new TestInstallableIntent(val));
});
toUninstall = IntentData.compiled(toUninstall, intents);
installCoordinator.installIntents(Optional.of(toUninstall), Optional.empty());
Intent toUninstallIntent = toUninstall.intent();
TestTools.assertAfter(INSTALL_DELAY, INSTALL_DURATION, () -> {
IntentData newData = intentStore.newData;
assertEquals(toUninstallIntent, newData.intent());
assertEquals(IntentState.WITHDRAWN, newData.state());
assertEquals(ImmutableList.of(), newData.installables());
});
}
Aggregations