Search in sources :

Example 1 with PolicerConfigurable

use of org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable in project onos by opennetworkinglab.

the class OpenFlowPolicerConfigurableTest method testAllocateId.

/**
 * Test allocate policer id.
 */
@Test
public void testAllocateId() {
    // Get device handler
    DriverHandler driverHandler = driverService.createHandler(ofDid);
    // Get policer config behavior
    PolicerConfigurable policerConfigurable = driverHandler.behaviour(PolicerConfigurable.class);
    // Get policer id
    PolicerId policerId = policerConfigurable.allocatePolicerId();
    // Assert that scheme is equal to OF
    assertThat(policerId.uri().getScheme(), is(OF_SCHEME));
    // Convert in hex the id
    String hexId = Long.toHexString((mid1.id()));
    // Assert that specific part contains hex of meter id
    assertThat(policerId.uri().getSchemeSpecificPart(), is(hexId));
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) PolicerId(org.onosproject.net.behaviour.trafficcontrol.PolicerId) PolicerConfigurable(org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable) Test(org.junit.Test)

Example 2 with PolicerConfigurable

use of org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable in project onos by opennetworkinglab.

the class OpenFlowPolicerConfigurableTest method testWrongDevice.

/**
 * Test no corresponding device.
 */
@Test
public void testWrongDevice() {
    // Get device handler
    DriverHandler driverHandler = driverService.createHandler(fooDid);
    // Get policer config behavior
    PolicerConfigurable policerConfigurable = driverHandler.behaviour(PolicerConfigurable.class);
    // Get policer id
    PolicerId policerId = policerConfigurable.allocatePolicerId();
    // Assert that is none
    assertThat(policerId, is(PolicerId.NONE));
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) PolicerId(org.onosproject.net.behaviour.trafficcontrol.PolicerId) PolicerConfigurable(org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable) Test(org.junit.Test)

Example 3 with PolicerConfigurable

use of org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable in project onos by opennetworkinglab.

the class OpenFlowPolicerConfigurableTest method testWrongId.

/**
 * Test wrong policer id.
 */
@Test
public void testWrongId() {
    // Get device handler
    DriverHandler driverHandler = driverService.createHandler(ofDid);
    // Get policer config behavior
    PolicerConfigurable policerConfigurable = driverHandler.behaviour(PolicerConfigurable.class);
    // Get policer id
    PolicerId policerId = policerConfigurable.allocatePolicerId();
    // this works
    assertThat(policerId.uri().getScheme(), is(OF_SCHEME));
    String hexId = Long.toHexString((mid1.id()));
    assertThat(policerId.uri().getSchemeSpecificPart(), is(hexId));
    // Verify the allocation before free
    assertThat(meterService.availableIds.size(), is(2));
    // Update the pid with a wrong id (same id but wrong schema)
    policerId = fooPid;
    // Let's free the policer id
    policerConfigurable.freePolicerId(policerId);
    // Free does not end correctly
    assertThat(meterService.availableIds.size(), is(2));
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) PolicerId(org.onosproject.net.behaviour.trafficcontrol.PolicerId) PolicerConfigurable(org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable) Test(org.junit.Test)

Example 4 with PolicerConfigurable

use of org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable in project onos by opennetworkinglab.

the class OpenFlowPolicerConfigurableTest method testMeterNull.

/**
 * Test meter problems.
 */
@Test
public void testMeterNull() {
    // Get device handler
    DriverHandler driverHandler = driverService.createHandler(ofDid);
    // Get policer config behavior
    PolicerConfigurable policerConfigurable = driverHandler.behaviour(PolicerConfigurable.class);
    // Get policer id
    PolicerId policerId = policerConfigurable.allocatePolicerId();
    // this works
    assertThat(policerId.uri().getScheme(), is(OF_SCHEME));
    String hexId = Long.toHexString((mid1.id()));
    assertThat(policerId.uri().getSchemeSpecificPart(), is(hexId));
    // Get another policer id
    policerId = policerConfigurable.allocatePolicerId();
    assertThat(policerId.uri().getScheme(), is(OF_SCHEME));
    hexId = Long.toHexString((mid10.id()));
    assertThat(policerId.uri().getSchemeSpecificPart(), is(hexId));
    // Get the last policer id
    policerId = policerConfigurable.allocatePolicerId();
    assertThat(policerId.uri().getScheme(), is(OF_SCHEME));
    hexId = Long.toHexString((mid100.id()));
    assertThat(policerId.uri().getSchemeSpecificPart(), is(hexId));
    // this does not work
    policerId = policerConfigurable.allocatePolicerId();
    // Assert that is none
    assertThat(policerId, is(PolicerId.NONE));
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) PolicerId(org.onosproject.net.behaviour.trafficcontrol.PolicerId) PolicerConfigurable(org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable) Test(org.junit.Test)

Example 5 with PolicerConfigurable

use of org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable in project onos by opennetworkinglab.

the class OpenFlowPolicerConfigurableTest method testFreeId.

/**
 * Test free policer id.
 */
@Test
public void testFreeId() {
    // Get device handler
    DriverHandler driverHandler = driverService.createHandler(ofDid);
    // Get policer config behavior
    PolicerConfigurable policerConfigurable = driverHandler.behaviour(PolicerConfigurable.class);
    // Get policer id
    PolicerId policerId = policerConfigurable.allocatePolicerId();
    // this works
    assertThat(policerId.uri().getScheme(), is(OF_SCHEME));
    String hexId = Long.toHexString((mid1.id()));
    assertThat(policerId.uri().getSchemeSpecificPart(), is(hexId));
    // Verify the allocation before free
    assertThat(meterService.availableIds.size(), is(2));
    // Let's free the policer id
    policerConfigurable.freePolicerId(policerId);
    // Verify the availability after free
    assertThat(meterService.availableIds.size(), is(3));
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) PolicerId(org.onosproject.net.behaviour.trafficcontrol.PolicerId) PolicerConfigurable(org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 PolicerConfigurable (org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable)5 PolicerId (org.onosproject.net.behaviour.trafficcontrol.PolicerId)5 DriverHandler (org.onosproject.net.driver.DriverHandler)5