Search in sources :

Example 26 with Timestamp

use of org.onosproject.store.Timestamp in project onos by opennetworkinglab.

the class IntentCleanupTestMock method corruptPoll.

/**
 * Trigger resubmit of intent in CORRUPT during periodic poll.
 */
@Test
public void corruptPoll() {
    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);
    Timestamp version = new SystemClockTimestamp(1L);
    IntentData data = new IntentData(intent, INSTALL_REQ, version);
    store.addPending(data);
    service.submit(intent);
    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 27 with Timestamp

use of org.onosproject.store.Timestamp in project onos by opennetworkinglab.

the class IntentCleanupTestMock 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);
    service.addPending(isA(IntentData.class));
    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 28 with Timestamp

use of org.onosproject.store.Timestamp in project onos by opennetworkinglab.

the class EventuallyConsistentMapImplTest method generatePutMessage.

private List<UpdateEntry<String, String>> generatePutMessage(String key1, String value1, String key2, String value2) {
    List<UpdateEntry<String, String>> list = new ArrayList<>();
    Timestamp timestamp1 = clockService.peek(1);
    Timestamp timestamp2 = clockService.peek(2);
    list.add(generatePutMessage(key1, value1, timestamp1));
    list.add(generatePutMessage(key2, value2, timestamp2));
    return list;
}
Also used : ArrayList(java.util.ArrayList) Timestamp(org.onosproject.store.Timestamp)

Example 29 with Timestamp

use of org.onosproject.store.Timestamp in project onos by opennetworkinglab.

the class MapValueTest method testComparison.

@SuppressWarnings("SelfComparison")
@Test
public void testComparison() {
    Timestamp ts1 = new LogicalTimestamp(9);
    Timestamp ts2 = new LogicalTimestamp(10);
    Timestamp ts3 = new LogicalTimestamp(11);
    MapValue<String> mv1 = new MapValue<>("foo", ts1);
    MapValue<String> mv2 = new MapValue<>("foo", ts2);
    MapValue<String> mv3 = new MapValue<>("foo", ts3);
    assertTrue(mv2.isNewerThan(mv1));
    assertFalse(mv1.isNewerThan(mv3));
    assertTrue(mv3.isNewerThan(ts2));
    assertFalse(mv1.isNewerThan(ts2));
    assertTrue(mv1.compareTo(mv2) < 0);
    assertTrue(mv1.compareTo(mv1) == 0);
    assertTrue(mv3.compareTo(mv2) > 0);
}
Also used : LogicalTimestamp(org.onosproject.store.LogicalTimestamp) Timestamp(org.onosproject.store.Timestamp) LogicalTimestamp(org.onosproject.store.LogicalTimestamp) Test(org.junit.Test)

Example 30 with Timestamp

use of org.onosproject.store.Timestamp in project onos by opennetworkinglab.

the class MapValueTest method testTombstone.

@Test
public void testTombstone() {
    Timestamp ts1 = new LogicalTimestamp(9);
    MapValue<String> mv = MapValue.tombstone(ts1);
    assertTrue(mv.isTombstone());
    assertFalse(mv.isAlive());
    assertNull(mv.get());
    assertEquals(ts1, mv.timestamp());
}
Also used : LogicalTimestamp(org.onosproject.store.LogicalTimestamp) Timestamp(org.onosproject.store.Timestamp) LogicalTimestamp(org.onosproject.store.LogicalTimestamp) Test(org.junit.Test)

Aggregations

Timestamp (org.onosproject.store.Timestamp)32 Test (org.junit.Test)15 WallClockTimestamp (org.onosproject.store.service.WallClockTimestamp)14 MastershipBasedTimestamp (org.onosproject.store.impl.MastershipBasedTimestamp)13 MultiValuedTimestamp (org.onosproject.store.service.MultiValuedTimestamp)13 ProviderId (org.onosproject.net.provider.ProviderId)9 DeviceEvent (org.onosproject.net.device.DeviceEvent)8 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)8 Intent (org.onosproject.net.intent.Intent)8 IntentData (org.onosproject.net.intent.IntentData)8 IntentEvent (org.onosproject.net.intent.IntentEvent)8 IntentStoreDelegate (org.onosproject.net.intent.IntentStoreDelegate)8 MockIntent (org.onosproject.net.intent.IntentTestsMocks.MockIntent)8 SystemClockTimestamp (org.onosproject.store.trivial.SystemClockTimestamp)8 DeviceId (org.onosproject.net.DeviceId)6 ArrayList (java.util.ArrayList)5 ControllerNodeToNodeId.toNodeId (org.onosproject.cluster.ControllerNodeToNodeId.toNodeId)5 NodeId (org.onosproject.cluster.NodeId)5 DefaultDevice (org.onosproject.net.DefaultDevice)5 Device (org.onosproject.net.Device)5