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