X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fstatistics-manager%2Fsrc%2Ftest%2Fjava%2Ftest%2Fmock%2FFlowStatisticsTest.java;fp=opendaylight%2Fmd-sal%2Fstatistics-manager%2Fsrc%2Ftest%2Fjava%2Ftest%2Fmock%2FFlowStatisticsTest.java;h=0000000000000000000000000000000000000000;hp=7fc171c49bdbc3b849a6c182ed8ac028ec93e7a0;hb=d6f88909ce1dd271c43b5f415a99a46350888f84;hpb=47ad11bd477096d9ffcf568e071ba68baabdbe6e diff --git a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/FlowStatisticsTest.java b/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/FlowStatisticsTest.java deleted file mode 100644 index 7fc171c49b..0000000000 --- a/opendaylight/md-sal/statistics-manager/src/test/java/test/mock/FlowStatisticsTest.java +++ /dev/null @@ -1,159 +0,0 @@ -package test.mock; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.Collections; -import java.util.concurrent.ExecutionException; - -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.statistics.manager.StatisticsManagerActivator; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowFeatureCapabilityFlowStats; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowStatisticsData; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes; -import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -import test.mock.util.StatisticsManagerTest; - -import com.google.common.base.Optional; - -public class FlowStatisticsTest extends StatisticsManagerTest { - private final Object waitObject = new Object(); - -// @Test(timeout = 5000) - public void addedFlowOnDemandStatsTest() throws ExecutionException, InterruptedException, ReadFailedException { - final StatisticsManagerActivator activator = new StatisticsManagerActivator(); - activator.onSessionInitiated(providerContext); - - addFlowCapableNode(s1Key); - - final Flow flow = getFlow(); - - final InstanceIdentifier flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key) - .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())) - .child(Flow.class, flow.getKey()); - final InstanceIdentifier tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key) - .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())); - final Table table = new TableBuilder().setKey(new TableKey(flow.getTableId())).setFlow(Collections.emptyList()).build(); - - final WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table); - writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow); - writeTx.put(LogicalDatastoreType.OPERATIONAL, tableII, table); - writeTx.put(LogicalDatastoreType.OPERATIONAL, flowII, flow); - assertCommit(writeTx.submit()); - - getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, - flowII.augmentation(FlowStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE); - - synchronized (waitObject) { - waitObject.wait(); - } - - final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction(); - final Optional flowStatDataOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, flowII.augmentation(FlowStatisticsData.class)) - .checkedGet(); - assertTrue(flowStatDataOptional.isPresent()); - assertEquals(COUNTER_64_TEST_VALUE, flowStatDataOptional.get().getFlowStatistics().getByteCount()); - - } - -// @Test(timeout = 5000) - public void deletedFlowStatsRemovalTest() throws ExecutionException, InterruptedException, ReadFailedException { - final StatisticsManagerActivator activator = new StatisticsManagerActivator(); - activator.onSessionInitiated(providerContext); - - addFlowCapableNode(s1Key); - - final Flow flow = getFlow(); - - final InstanceIdentifier flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key) - .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())) - .child(Flow.class, flow.getKey()); - final InstanceIdentifier
tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key) - .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())); - final Table table = new TableBuilder().setKey(new TableKey(flow.getTableId())).setFlow(Collections.emptyList()).build(); - - WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table); - writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow); - writeTx.put(LogicalDatastoreType.OPERATIONAL, tableII, table); - writeTx.put(LogicalDatastoreType.OPERATIONAL, flowII, flow); - - getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, - flowII.augmentation(FlowStatisticsData.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE); - - assertCommit(writeTx.submit()); - - synchronized (waitObject) { - waitObject.wait(); - } - - ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction(); - Optional flowStatDataOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, flowII).checkedGet(); - assertTrue(flowStatDataOptional.isPresent()); -// assertEquals(COUNTER_64_TEST_VALUE, flowStatDataOptional.get().getFlowStatistics().getByteCount()); - - writeTx = getDataBroker().newWriteOnlyTransaction(); - writeTx.delete(LogicalDatastoreType.CONFIGURATION, flowII); - assertCommit(writeTx.submit()); - - readTx = getDataBroker().newReadOnlyTransaction(); - flowStatDataOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, flowII).checkedGet(); - assertFalse(flowStatDataOptional.isPresent()); - } - -// @Test(timeout = 23000) - public void getAllStatsWhenNodeIsConnectedTest() throws ExecutionException, InterruptedException, ReadFailedException { - final StatisticsManagerActivator activator = new StatisticsManagerActivator(); - activator.onSessionInitiated(providerContext); - - addFlowCapableNodeWithFeatures(s1Key, false, FlowFeatureCapabilityFlowStats.class); - - final Flow flow = getFlow(); - - final InstanceIdentifier
tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key) - .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())); - - getDataBroker().registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, - tableII.child(Flow.class), new ChangeListener(), AsyncDataBroker.DataChangeScope.BASE); - - synchronized (waitObject) { - waitObject.wait(); - } - - final ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction(); - final Optional
tableOptional = readTx.read(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Nodes.class) - .child(Node.class, s1Key).augmentation(FlowCapableNode.class) - .child(Table.class, new TableKey(flow.getTableId()))).checkedGet(); - assertTrue(tableOptional.isPresent()); - final FlowStatisticsData flowStats = tableOptional.get().getFlow().get(0).getAugmentation(FlowStatisticsData.class); - assertTrue(flowStats != null); - assertEquals(COUNTER_64_TEST_VALUE, flowStats.getFlowStatistics().getByteCount()); - } - - public class ChangeListener implements DataChangeListener { - - @Override - public void onDataChanged(final AsyncDataChangeEvent, DataObject> change) { - synchronized (waitObject) { - waitObject.notify(); - } - } - } -} -