16 package org.openkilda.wfm.topology.islstats.bolts;
18 import static org.hamcrest.CoreMatchers.containsString;
19 import static org.hamcrest.CoreMatchers.instanceOf;
20 import static org.hamcrest.CoreMatchers.is;
21 import static org.junit.Assert.assertEquals;
22 import static org.junit.Assert.assertThat;
35 import org.junit.Rule;
36 import org.junit.Test;
37 import org.junit.rules.ExpectedException;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
41 import java.util.List;
45 private static final SwitchId SWITCH1_ID =
new SwitchId(
"00:00:b0:d2:f5:b0:09:34");
46 private static final String SWITCH1_ID_OTSD_FORMAT = SWITCH1_ID.
toOtsdFormat();
47 private static final int SWITCH1_PORT = 1;
48 private static final int PATH1_SEQID = 1;
49 private static final long PATH1_LATENCY = 10L;
50 private static final PathNode NODE1 =
new PathNode(SWITCH1_ID, SWITCH1_PORT, PATH1_SEQID, PATH1_LATENCY);
52 private static final SwitchId SWITCH2_ID =
new SwitchId(
"00:00:b0:d2:f5:00:5e:18");
53 private static final String SWITCH2_ID_OTSD_FORMAT = SWITCH2_ID.
toOtsdFormat();
54 private static final int SWITCH2_PORT = 5;
55 private static final int PATH2_SEQID = 2;
56 private static final long PATH2_LATENCY = 15L;
57 private static final PathNode NODE2 =
new PathNode(SWITCH2_ID, SWITCH2_PORT, PATH2_SEQID, PATH2_LATENCY);
59 private static final int LATENCY = 1000;
60 private static final List<PathNode> PATH = java.util.Arrays.asList(NODE1, NODE2);
61 private static final long SPEED = 400L;
63 private static final long AVAILABLE_BANDWIDTH = 500L;
64 private static final IslInfoData ISL_INFO_DATA =
new IslInfoData(LATENCY, PATH, SPEED, STATE, AVAILABLE_BANDWIDTH);
65 private static final long TIMESTAMP = 1507433872L;
69 private static final String CORRELATION_ID =
"system";
70 private static final Destination DESTINATION = null;
71 private static final InfoMessage MESSAGE =
new InfoMessage(ISL_INFO_DATA, TIMESTAMP, CORRELATION_ID, DESTINATION);
73 private static Logger logger = LoggerFactory.getLogger(
IslStatsBolt.class);
76 public ExpectedException
thrown = ExpectedException.none();
80 List<Object> tsdbTuple = statsBolt.
buildTsdbTuple(ISL_INFO_DATA, TIMESTAMP);
81 assertThat(tsdbTuple.size(), is(1));
84 assertEquals(
"pen.isl.latency", datapoint.getMetric());
85 assertEquals((Long) TIMESTAMP, datapoint.getTime());
86 assertEquals(LATENCY, datapoint.getValue());
88 Map<String, String> pathNode = datapoint.getTags();
89 assertEquals(SWITCH1_ID_OTSD_FORMAT, pathNode.get(
"src_switch"));
90 assertEquals(SWITCH2_ID_OTSD_FORMAT, pathNode.get(
"dst_switch"));
91 assertEquals(SWITCH1_PORT, Integer.parseInt(pathNode.get(
"src_port")));
92 assertEquals(SWITCH2_PORT, Integer.parseInt(pathNode.get(
"dst_port")));
105 assertEquals(ISL_INFO_DATA,
data);
107 thrown.expect(Exception.class);
108 thrown.expectMessage(containsString(
"is not an IslInfoData"));
static final ObjectMapper MAPPER
IslInfoData getIslInfoData(InfoData data)
List< Object > buildTsdbTuple(IslInfoData data, long timestamp)
InfoData getInfoData(Message message)