Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 1 | package net.onrc.onos.api.rest; |
| 2 | |
| 3 | import com.codahale.metrics.Gauge; |
| 4 | import com.codahale.metrics.MetricFilter; |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 5 | import net.onrc.onos.core.metrics.OnosMetrics; |
| 6 | import org.json.JSONArray; |
| 7 | import org.json.JSONException; |
| 8 | import org.json.JSONObject; |
| 9 | import org.junit.After; |
| 10 | import org.junit.Before; |
| 11 | import org.junit.Test; |
| 12 | import org.junit.runner.RunWith; |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 13 | import org.powermock.modules.junit4.PowerMockRunner; |
| 14 | import org.restlet.resource.ClientResource; |
| 15 | |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 16 | import static org.hamcrest.MatcherAssert.assertThat; |
| 17 | import static org.hamcrest.Matchers.equalTo; |
| 18 | import static org.hamcrest.Matchers.is; |
| 19 | import static org.hamcrest.Matchers.notNullValue; |
| 20 | |
| 21 | /** |
| 22 | * Unit tests for filtering REST APIs for Timer Metrics. |
| 23 | */ |
| 24 | |
| 25 | @RunWith(PowerMockRunner.class) |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 26 | public class TestRestMetricsFilters extends TestRestMetrics { |
| 27 | |
| 28 | /** |
| 29 | * Create the web server and mocks required for |
| 30 | * all of the tests. |
| 31 | */ |
| 32 | @Before |
| 33 | @SuppressWarnings("ununsed") |
| 34 | public void beforeTest() { |
| 35 | setRestPort(generateRandomPort()); |
| 36 | setUp(); |
| 37 | // Make some test data |
| 38 | createMetrics(); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Remove anything that will interfere with the next test running correctly. |
| 43 | * Shuts down the test REST web server and removes the mocks. |
| 44 | */ |
| 45 | @After |
| 46 | @SuppressWarnings("unused") |
| 47 | public void afterTest() { |
| 48 | destroyMetrics(); |
| 49 | tearDown(); |
| 50 | } |
| 51 | |
| 52 | // Test data objects |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 53 | private static final OnosMetrics.MetricsComponent COMPONENT = |
| 54 | OnosMetrics.registerComponent("MetricsUnitTests"); |
| 55 | private static final OnosMetrics.MetricsFeature FEATURE = |
| 56 | COMPONENT.registerFeature("Filters"); |
| 57 | |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 58 | private static final String TIMER1_NAME = "timer1"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 59 | private static final String TIMER1_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 60 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 61 | "timer1"); |
| 62 | private static final String TIMER2_NAME = "timer2"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 63 | private static final String TIMER2_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 64 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 65 | "timer2"); |
| 66 | private static final String TIMER3_NAME = "timer3"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 67 | private static final String TIMER3_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 68 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 69 | "timer3"); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 70 | |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 71 | private static final String GAUGE1_NAME = "gauge1"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 72 | private static final String GAUGE1_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 73 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 74 | "gauge1"); |
| 75 | private static final String GAUGE2_NAME = "gauge2"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 76 | private static final String GAUGE2_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 77 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 78 | "gauge2"); |
| 79 | private static final String GAUGE3_NAME = "gauge3"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 80 | private static final String GAUGE3_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 81 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 82 | "gauge3"); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 83 | |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 84 | private static final String COUNTER1_NAME = "counter1"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 85 | private static final String COUNTER1_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 86 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 87 | "counter1"); |
| 88 | private static final String COUNTER2_NAME = "counter2"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 89 | private static final String COUNTER2_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 90 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 91 | "counter2"); |
| 92 | private static final String COUNTER3_NAME = "counter3"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 93 | private static final String COUNTER3_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 94 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 95 | "counter3"); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 96 | |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 97 | private static final String METER1_NAME = "meter1"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 98 | private static final String METER1_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 99 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 100 | "meter1"); |
| 101 | private static final String METER2_NAME = "meter2"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 102 | private static final String METER2_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 103 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 104 | "meter2"); |
| 105 | private static final String METER3_NAME = "meter3"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 106 | private static final String METER3_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 107 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 108 | "meter3"); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 109 | |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 110 | private static final String HISTOGRAM1_NAME = "histogram1"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 111 | private static final String HISTOGRAM1_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 112 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 113 | "histogram1"); |
| 114 | private static final String HISTOGRAM2_NAME = "histogram2"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 115 | private static final String HISTOGRAM2_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 116 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 117 | "histogram2"); |
| 118 | private static final String HISTOGRAM3_NAME = "histogram3"; |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 119 | private static final String HISTOGRAM3_FULL_NAME = OnosMetrics.generateName(COMPONENT, |
| 120 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 121 | "histogram3"); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 122 | |
Ray Milkey | 128651a | 2014-07-14 11:24:28 -0700 | [diff] [blame] | 123 | private final Gauge<Integer> testGauge = new Gauge<Integer>() { |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 124 | @Override |
| 125 | public Integer getValue() { |
| 126 | return 1; |
| 127 | } |
| 128 | }; |
| 129 | |
| 130 | /** |
| 131 | * Creates Metrics objects for test. |
| 132 | */ |
| 133 | private void createMetrics() { |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 134 | OnosMetrics.createTimer(COMPONENT, |
| 135 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 136 | TIMER1_NAME); |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 137 | OnosMetrics.createTimer(COMPONENT, |
| 138 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 139 | TIMER2_NAME); |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 140 | OnosMetrics.createTimer(COMPONENT, |
| 141 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 142 | TIMER3_NAME); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 143 | |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 144 | OnosMetrics.createCounter(COMPONENT, |
| 145 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 146 | COUNTER1_NAME); |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 147 | OnosMetrics.createCounter(COMPONENT, |
| 148 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 149 | COUNTER2_NAME); |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 150 | OnosMetrics.createCounter(COMPONENT, |
| 151 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 152 | COUNTER3_NAME); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 153 | |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 154 | OnosMetrics.createMeter(COMPONENT, |
| 155 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 156 | METER1_NAME); |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 157 | OnosMetrics.createMeter(COMPONENT, |
| 158 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 159 | METER2_NAME); |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 160 | OnosMetrics.createMeter(COMPONENT, |
| 161 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 162 | METER3_NAME); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 163 | |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 164 | OnosMetrics.createHistogram(COMPONENT, |
| 165 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 166 | HISTOGRAM1_NAME); |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 167 | OnosMetrics.createHistogram(COMPONENT, |
| 168 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 169 | HISTOGRAM2_NAME); |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 170 | OnosMetrics.createHistogram(COMPONENT, |
| 171 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 172 | HISTOGRAM3_NAME); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 173 | |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 174 | OnosMetrics.registerMetric(COMPONENT, |
| 175 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 176 | GAUGE1_NAME, |
| 177 | testGauge); |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 178 | OnosMetrics.registerMetric(COMPONENT, |
| 179 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 180 | GAUGE2_NAME, |
| 181 | testGauge); |
Ray Milkey | 71cd2c8 | 2014-07-16 15:02:33 -0700 | [diff] [blame] | 182 | OnosMetrics.registerMetric(COMPONENT, |
| 183 | FEATURE, |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 184 | GAUGE3_NAME, |
| 185 | testGauge); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Removes the Metrics to clean up for the next test run. |
| 190 | */ |
| 191 | private void destroyMetrics() { |
Ray Milkey | 128651a | 2014-07-14 11:24:28 -0700 | [diff] [blame] | 192 | OnosMetrics.removeMatching(MetricFilter.ALL); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Tests that query of non existant name returns nothing. |
| 197 | * |
| 198 | * @throws JSONException if any of the JSON processing fails. |
| 199 | */ |
| 200 | @Test |
| 201 | public void testFilterMatchesNothing() throws JSONException { |
| 202 | |
| 203 | // Read the metrics from the REST API for the test data |
| 204 | final ClientResource client = new ClientResource(getBaseRestMetricsUrl()); |
| 205 | client.addQueryParameter("ids", "xyzzy"); |
| 206 | |
| 207 | final JSONObject metrics = getJSONObject(client); |
| 208 | assertThat(metrics.length(), is(equalTo(5))); |
| 209 | |
| 210 | // There should be no timers, histograms, gauges, meters or counters |
| 211 | checkEmptyLists(metrics, "timers", "histograms", "gauges", "meters", "counters"); |
| 212 | |
| 213 | } |
| 214 | |
| 215 | /** |
| 216 | * Tests that query of multiple metrics of a single Metric type |
| 217 | * returns the proper data. |
| 218 | * |
| 219 | * @throws JSONException if any of the JSON processing fails. |
| 220 | */ |
| 221 | @Test |
| 222 | public void testMultipleFilterSingleType() throws JSONException { |
| 223 | |
| 224 | // Read the metrics from the REST API for the test data |
| 225 | final ClientResource client = new ClientResource(getBaseRestMetricsUrl()); |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 226 | client.addQueryParameter("ids", TIMER1_FULL_NAME + "," + TIMER2_FULL_NAME); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 227 | |
| 228 | final JSONObject metrics = getJSONObject(client); |
| 229 | assertThat(metrics.length(), is(equalTo(5))); |
| 230 | |
| 231 | // There should be 2 timer that match the filter |
| 232 | final JSONArray timers = metrics.getJSONArray("timers"); |
| 233 | assertThat(timers, is(notNullValue())); |
| 234 | assertThat(timers.length(), is(2)); |
| 235 | |
| 236 | final JSONObject jsonTimer1 = timers.getJSONObject(0); |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 237 | assertThat(jsonTimer1.getString("name"), is(equalTo(TIMER1_FULL_NAME))); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 238 | |
| 239 | final JSONObject jsonTimer2 = timers.getJSONObject(1); |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 240 | assertThat(jsonTimer2.getString("name"), is(equalTo(TIMER2_FULL_NAME))); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 241 | |
| 242 | // There should be no histograms, gauges, meters or counters |
| 243 | checkEmptyLists(metrics, "histograms", "gauges", "meters", "counters"); |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Tests that query of a single metric retunrs just that metric. |
| 248 | * |
| 249 | * @throws JSONException if any of the JSON processing fails. |
| 250 | */ |
| 251 | @Test |
| 252 | public void testSingleFilter() throws JSONException { |
| 253 | |
| 254 | // Read the metrics from the REST API for the test data |
| 255 | final ClientResource client = new ClientResource(getBaseRestMetricsUrl()); |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 256 | client.addQueryParameter("ids", TIMER1_FULL_NAME); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 257 | |
| 258 | final JSONObject metrics = getJSONObject(client); |
| 259 | assertThat(metrics.length(), is(equalTo(5))); |
| 260 | |
| 261 | // There should be 1 timer that matches the filter |
| 262 | final JSONArray timers = metrics.getJSONArray("timers"); |
| 263 | assertThat(timers, is(notNullValue())); |
| 264 | assertThat(timers.length(), is(1)); |
| 265 | |
| 266 | final JSONObject jsonTimer1 = timers.getJSONObject(0); |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 267 | assertThat(jsonTimer1.getString("name"), is(equalTo(TIMER1_FULL_NAME))); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 268 | |
| 269 | |
| 270 | // There should be no histograms, gauges, meters or counters |
| 271 | checkEmptyLists(metrics, "histograms", "gauges", "meters", "counters"); |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Tests that query of multiple metrics of multiple metric types returns |
| 276 | * the proper data. |
| 277 | * |
| 278 | * @throws JSONException if any of the JSON processing fails. |
| 279 | */ |
| 280 | @Test |
| 281 | public void testMultipleFiltersMultipleTypes() throws JSONException { |
| 282 | |
| 283 | // Read the metrics from the REST API for the test data |
| 284 | final ClientResource client = new ClientResource(getBaseRestMetricsUrl()); |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 285 | client.addQueryParameter("ids", |
| 286 | TIMER1_FULL_NAME + "," + |
| 287 | GAUGE2_FULL_NAME + "," + |
| 288 | HISTOGRAM3_FULL_NAME); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 289 | |
| 290 | final JSONObject metrics = getJSONObject(client); |
| 291 | assertThat(metrics.length(), is(equalTo(5))); |
| 292 | |
| 293 | // There should be 1 timer that matches the filter |
| 294 | final JSONArray timers = metrics.getJSONArray("timers"); |
| 295 | assertThat(timers, is(notNullValue())); |
| 296 | assertThat(timers.length(), is(1)); |
| 297 | |
| 298 | final JSONObject jsonTimer1 = timers.getJSONObject(0); |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 299 | assertThat(jsonTimer1.getString("name"), is(equalTo(TIMER1_FULL_NAME))); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 300 | |
| 301 | // There should be 1 gauge that matches the filter |
| 302 | final JSONArray gauges = metrics.getJSONArray("gauges"); |
| 303 | assertThat(gauges, is(notNullValue())); |
| 304 | assertThat(gauges.length(), is(1)); |
| 305 | |
| 306 | final JSONObject jsonGauge1 = gauges.getJSONObject(0); |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 307 | assertThat(jsonGauge1.getString("name"), is(equalTo(GAUGE2_FULL_NAME))); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 308 | |
| 309 | // There should be 1 histogram that matches the filter |
| 310 | final JSONArray histograms = metrics.getJSONArray("histograms"); |
| 311 | assertThat(histograms, is(notNullValue())); |
| 312 | assertThat(histograms.length(), is(1)); |
| 313 | |
| 314 | final JSONObject jsonHistogram1 = histograms.getJSONObject(0); |
Ray Milkey | 49d67be | 2014-07-10 13:47:01 -0700 | [diff] [blame] | 315 | assertThat(jsonHistogram1.getString("name"), is(equalTo(HISTOGRAM3_FULL_NAME))); |
Ray Milkey | 14c4651 | 2014-07-08 18:30:31 -0700 | [diff] [blame] | 316 | |
| 317 | // There should be no meters or counters |
| 318 | checkEmptyLists(metrics, "meters", "counters"); |
| 319 | } |
| 320 | |
| 321 | |
| 322 | } |