@Test
  public void invalidOperationTrackerScopeTest() {
    Properties props = new Properties();
    props.setProperty("router.hostname", "localhost");
    props.setProperty("router.datacenter.name", localDcName);
    props.setProperty("router.operation.tracker.metric.scope", "Invalid Scope");
    props.setProperty("router.get.success.target", Integer.toString(1));
    props.setProperty("router.get.request.parallelism", Integer.toString(1));
    RouterConfig routerConfig = null;
    try {
      routerConfig = new RouterConfig(new VerifiableProperties(props));
    } catch (IllegalArgumentException e) {
      //exception is expected and set valid metric scope to instantiate routerConfig for subsequent test.
      props.setProperty("router.operation.tracker.metric.scope", "Datacenter");
      routerConfig = new RouterConfig(new VerifiableProperties(props));
    }
    NonBlockingRouterMetrics routerMetrics = new NonBlockingRouterMetrics(mockClusterMap, routerConfig);
    AdaptiveOperationTracker tracker =
        new AdaptiveOperationTracker(routerConfig, routerMetrics, RouterOperation.GetBlobInfoOperation, mockPartition,
            null, time);
    // test that operation tracker works correctly with default Datacenter scope
    sendRequests(tracker, 1);
    assertFalse("Operation should not be done", tracker.isDone());
    tracker.onResponse(partitionAndInflightReplicas.get(mockPartition).poll(), TrackedRequestFinalState.SUCCESS);
    assertTrue("Operation should have succeeded", tracker.hasSucceeded());
    // test that no other resource-level metrics have been instantiated.
    assertTrue("Partition histogram in RouterMetrics should be empty",
        routerMetrics.getBlobInfoLocalDcResourceToLatency.isEmpty());
    assertTrue("Partition histogram in RouterMetrics should be empty",
        routerMetrics.getBlobInfoCrossDcResourceToLatency.isEmpty());
    assertTrue("Partition histogram in OperationTracker should be empty",
        tracker.getResourceToLatencyMap(RouterOperation.GetBlobInfoOperation, true).isEmpty());
    assertTrue("Partition histogram in OperationTracker should be empty",
        tracker.getResourceToLatencyMap(RouterOperation.GetBlobInfoOperation, false).isEmpty());
    // extra test: invalid router operation
    try {
      tracker.getResourceToLatencyMap(RouterOperation.TtlUpdateOperation, true);
      fail("should fail due to invalid router operation");
    } catch (IllegalArgumentException e) {
      //expected
    }
  }
Test that if metric scope in router config is invalid, the {@link IllegalArgumentException} is thrown explicitly.
ambry-router/src/test/java/com/github/ambry/router/AdaptiveOperationTrackerTest.java