Search in sources :

Example 16 with IntentEvent

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

the class IntentCleanupTestMock 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);
    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 17 with IntentEvent

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

the class IntentEventsListCommand method doExecute.

@Override
protected void doExecute() {
    IntentMetricsService service = get(IntentMetricsService.class);
    if (outputJson()) {
        print("%s", json(service.getEvents()));
    } else {
        for (IntentEvent event : service.getEvents()) {
            print(FORMAT_EVENT, event);
            // Extra empty line for clarity
            print("");
        }
    }
}
Also used : IntentMetricsService(org.onosproject.metrics.intent.IntentMetricsService) IntentEvent(org.onosproject.net.intent.IntentEvent)

Aggregations

IntentEvent (org.onosproject.net.intent.IntentEvent)17 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 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 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Ignore (org.junit.Ignore)2 IntentListener (org.onosproject.net.intent.IntentListener)2 Key (org.onosproject.net.intent.Key)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 MoreObjects (com.google.common.base.MoreObjects)1 ImmutableList (com.google.common.collect.ImmutableList)1