Search in sources :

Example 1 with TestInstallableIntent

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());
    });
}
Also used : TestInstallableIntent(org.onosproject.net.intent.TestInstallableIntent) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) TestInstallableIntent(org.onosproject.net.intent.TestInstallableIntent) Intent(org.onosproject.net.intent.Intent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 2 with TestInstallableIntent

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());
    });
}
Also used : TestInstallableIntent(org.onosproject.net.intent.TestInstallableIntent) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) TestInstallableIntent(org.onosproject.net.intent.TestInstallableIntent) Intent(org.onosproject.net.intent.Intent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 3 with TestInstallableIntent

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());
    });
}
Also used : TestInstallableIntent(org.onosproject.net.intent.TestInstallableIntent) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) TestInstallableIntent(org.onosproject.net.intent.TestInstallableIntent) Intent(org.onosproject.net.intent.Intent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 4 with TestInstallableIntent

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());
    });
}
Also used : TestInstallableIntent(org.onosproject.net.intent.TestInstallableIntent) WallClockTimestamp(org.onosproject.store.service.WallClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) TestInstallableIntent(org.onosproject.net.intent.TestInstallableIntent) Intent(org.onosproject.net.intent.Intent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Aggregations

Test (org.junit.Test)4 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)4 Intent (org.onosproject.net.intent.Intent)4 IntentData (org.onosproject.net.intent.IntentData)4 PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)4 TestInstallableIntent (org.onosproject.net.intent.TestInstallableIntent)4 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)4