Search in sources :

Example 11 with MockIntent

use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.

the class IntentManagerTest method errorIntentCompile.

/**
 * Tests for proper behavior of installation of an intent that triggers
 * a compilation error.
 */
@Test
public void errorIntentCompile() {
    final TestIntentCompilerError errorCompiler = new TestIntentCompilerError();
    extensionService.registerCompiler(MockIntent.class, errorCompiler);
    MockIntent intent = new MockIntent(MockIntent.nextId());
    listener.setLatch(1, Type.INSTALL_REQ);
    listener.setLatch(1, Type.FAILED);
    service.submit(intent);
    listener.await(Type.INSTALL_REQ);
    listener.await(Type.FAILED);
    verifyState();
}
Also used : MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) Test(org.junit.Test)

Example 12 with MockIntent

use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.

the class IntentManagerTest method errorIntentInstallFromFlows.

/**
 * Tests handling a future that contains an error as a result of
 * installing an intent.
 */
@Ignore("skipping until we fix update ordering problem")
@Test
public void errorIntentInstallFromFlows() {
    final Long id = MockIntent.nextId();
    flowRuleService.setFuture(false);
    MockIntent intent = new MockIntent(id);
    listener.setLatch(1, Type.FAILED);
    listener.setLatch(1, Type.INSTALL_REQ);
    service.submit(intent);
    listener.await(Type.INSTALL_REQ);
    listener.await(Type.FAILED);
    // FIXME the intent will be moved into INSTALLED immediately which overrides FAILED
    // ... the updates come out of order
    verifyState();
}
Also used : MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with MockIntent

use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.

the class IntentManagerTest method intentSubclassCompile.

/**
 * Tests that a compiler for a subclass of an intent that already has a
 * compiler is automatically added.
 */
@Test
public void intentSubclassCompile() {
    class MockIntentSubclass extends MockIntent {

        public MockIntentSubclass(Long number) {
            super(number);
        }
    }
    flowRuleService.setFuture(true);
    listener.setLatch(1, Type.INSTALL_REQ);
    listener.setLatch(1, Type.INSTALLED);
    Intent intent = new MockIntentSubclass(MockIntent.nextId());
    service.submit(intent);
    listener.await(Type.INSTALL_REQ);
    listener.await(Type.INSTALLED);
    assertEquals(1L, service.getIntentCount());
    assertEquals(1L, flowRuleService.getFlowRuleCount());
    final Map<Class<? extends Intent>, IntentCompiler<? extends Intent>> compilers = extensionService.getCompilers();
    assertEquals(2, compilers.size());
    assertNotNull(compilers.get(MockIntentSubclass.class));
    assertNotNull(compilers.get(MockIntent.class));
    verifyState();
}
Also used : IntentCompiler(org.onosproject.net.intent.IntentCompiler) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) Test(org.junit.Test)

Example 14 with MockIntent

use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.

the class IntentManagerTest method submitIntent.

@Test
public void submitIntent() {
    flowRuleService.setFuture(true);
    listener.setLatch(1, Type.INSTALL_REQ);
    listener.setLatch(1, Type.INSTALLED);
    Intent intent = new MockIntent(MockIntent.nextId());
    service.submit(intent);
    listener.await(Type.INSTALL_REQ);
    listener.await(Type.INSTALLED);
    assertEquals(1L, service.getIntentCount());
    assertEquals(1L, flowRuleService.getFlowRuleCount());
    verifyState();
}
Also used : FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) Test(org.junit.Test)

Example 15 with MockIntent

use of org.onosproject.net.intent.IntentTestsMocks.MockIntent in project onos by opennetworkinglab.

the class IntentAccumulatorTest method setUp.

/**
 * Creates mock intents used by the test.
 */
@Before
public void setUp() {
    super.setUp();
    intent1 = new MockIntent(1L);
    intent2 = new MockIntent(2L);
    intent3 = new MockIntent(3L);
}
Also used : MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) Before(org.junit.Before)

Aggregations

MockIntent (org.onosproject.net.intent.IntentTestsMocks.MockIntent)34 Test (org.junit.Test)32 Intent (org.onosproject.net.intent.Intent)28 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)16 PathIntent (org.onosproject.net.intent.PathIntent)16 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)12 IntentData (org.onosproject.net.intent.IntentData)12 IntentEvent (org.onosproject.net.intent.IntentEvent)12 IntentStoreDelegate (org.onosproject.net.intent.IntentStoreDelegate)12 Timestamp (org.onosproject.store.Timestamp)8 SystemClockTimestamp (org.onosproject.store.trivial.SystemClockTimestamp)8 WebTarget (javax.ws.rs.client.WebTarget)6 NetworkResource (org.onosproject.net.NetworkResource)6 ConnectivityIntent (org.onosproject.net.intent.ConnectivityIntent)6 HostToHostIntent (org.onosproject.net.intent.HostToHostIntent)6 PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)6 JsonObject (com.eclipsesource.json.JsonObject)5 HashSet (java.util.HashSet)5 Ignore (org.junit.Ignore)5 Before (org.junit.Before)2