Search in sources :

Example 1 with IntentStoreDelegate

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

the class IntentCleanupTestMock method skipPoll.

/**
 * Only submit one of two intents because one is too new.
 */
@Test
public void skipPoll() {
    IntentStoreDelegate mockDelegate = new IntentStoreDelegate() {

        @Override
        public void process(IntentData intentData) {
            intentData.setState(CORRUPT);
            store.write(intentData);
        }

        @Override
        public void notify(IntentEvent event) {
        }
    };
    store.setDelegate(mockDelegate);
    Intent intent = new MockIntent(1L);
    IntentData data = new IntentData(intent, INSTALL_REQ, null);
    store.addPending(data);
    Intent intent2 = new MockIntent(2L);
    Timestamp version = new SystemClockTimestamp(1L);
    data = new IntentData(intent2, INSTALL_REQ, version);
    store.addPending(data);
    service.submit(intent);
    expectLastCall().once();
    service.submit(intent2);
    expectLastCall().once();
    replay(service);
    cleanup.run();
    verify(service);
    reset(service);
}
Also used : IntentStoreDelegate(org.onosproject.net.intent.IntentStoreDelegate) SystemClockTimestamp(org.onosproject.store.trivial.SystemClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) Intent(org.onosproject.net.intent.Intent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) SystemClockTimestamp(org.onosproject.store.trivial.SystemClockTimestamp) Timestamp(org.onosproject.store.Timestamp) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) IntentEvent(org.onosproject.net.intent.IntentEvent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 2 with IntentStoreDelegate

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

the class IntentCleanupTestMock method installingPoll.

/**
 * Trigger resubmit of intent in INSTALLING for too long.
 */
@Test
@Ignore("The implementation is dependent on the SimpleStore")
public void installingPoll() {
    IntentStoreDelegate mockDelegate = new IntentStoreDelegate() {

        @Override
        public void process(IntentData intentData) {
            intentData.setState(INSTALLING);
            store.write(intentData);
        }

        @Override
        public void notify(IntentEvent event) {
            cleanup.event(event);
        }
    };
    store.setDelegate(mockDelegate);
    Intent intent = new MockIntent(1L);
    Timestamp version = new SystemClockTimestamp(1L);
    IntentData data = new IntentData(intent, INSTALL_REQ, version);
    store.addPending(data);
    service.addPending(data);
    expectLastCall().once();
    replay(service);
    cleanup.run();
    verify(service);
    reset(service);
}
Also used : IntentStoreDelegate(org.onosproject.net.intent.IntentStoreDelegate) SystemClockTimestamp(org.onosproject.store.trivial.SystemClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) Intent(org.onosproject.net.intent.Intent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) SystemClockTimestamp(org.onosproject.store.trivial.SystemClockTimestamp) Timestamp(org.onosproject.store.Timestamp) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) IntentEvent(org.onosproject.net.intent.IntentEvent) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 3 with IntentStoreDelegate

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

the class IntentCleanupTestMock method corruptEvent.

/**
 * Verify resubmit in response to CORRUPT event.
 */
@Test
public void corruptEvent() {
    IntentStoreDelegate mockDelegate = new IntentStoreDelegate() {

        @Override
        public void process(IntentData intentData) {
            intentData.setState(CORRUPT);
            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);
    service.submit(intent);
    expectLastCall().once();
    replay(service);
    store.addPending(data);
    verify(service);
    reset(service);
}
Also used : IntentStoreDelegate(org.onosproject.net.intent.IntentStoreDelegate) IntentData(org.onosproject.net.intent.IntentData) Intent(org.onosproject.net.intent.Intent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) IntentEvent(org.onosproject.net.intent.IntentEvent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 4 with IntentStoreDelegate

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

the class IntentCleanupTest method pendingPoll.

/**
 * Trigger resubmit of intent in INSTALL_REQ for too long.
 */
@Test
public void pendingPoll() {
    IntentStoreDelegate mockDelegate = new IntentStoreDelegate() {

        @Override
        public void process(IntentData intentData) {
        }

        @Override
        public void notify(IntentEvent event) {
            cleanup.event(event);
        }
    };
    store.setDelegate(mockDelegate);
    Intent intent = new MockIntent(1L);
    Timestamp version = new SystemClockTimestamp(1L);
    IntentData data = new IntentData(intent, INSTALL_REQ, version);
    store.addPending(data);
    cleanup.run();
    assertEquals("Expect number of submits incorrect", 1, service.pendingCounter());
}
Also used : IntentStoreDelegate(org.onosproject.net.intent.IntentStoreDelegate) SystemClockTimestamp(org.onosproject.store.trivial.SystemClockTimestamp) IntentData(org.onosproject.net.intent.IntentData) Intent(org.onosproject.net.intent.Intent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) SystemClockTimestamp(org.onosproject.store.trivial.SystemClockTimestamp) Timestamp(org.onosproject.store.Timestamp) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) IntentEvent(org.onosproject.net.intent.IntentEvent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Example 5 with IntentStoreDelegate

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

the class IntentCleanupTest 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);
    store.addPending(data);
    assertEquals("Expect number of submits incorrect", 0, service.submitCounter());
}
Also used : IntentStoreDelegate(org.onosproject.net.intent.IntentStoreDelegate) IntentData(org.onosproject.net.intent.IntentData) Intent(org.onosproject.net.intent.Intent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) IntentEvent(org.onosproject.net.intent.IntentEvent) Test(org.junit.Test) AbstractIntentTest(org.onosproject.net.intent.AbstractIntentTest)

Aggregations

Test (org.junit.Test)12 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)12 Intent (org.onosproject.net.intent.Intent)12 IntentData (org.onosproject.net.intent.IntentData)12 IntentEvent (org.onosproject.net.intent.IntentEvent)12 IntentStoreDelegate (org.onosproject.net.intent.IntentStoreDelegate)12 MockIntent (org.onosproject.net.intent.IntentTestsMocks.MockIntent)12 Timestamp (org.onosproject.store.Timestamp)8 SystemClockTimestamp (org.onosproject.store.trivial.SystemClockTimestamp)8 Ignore (org.junit.Ignore)2