EdColeman commented on a change in pull request #1536: Improve master metrics 
rported via hadoop metrics
URL: https://github.com/apache/accumulo/pull/1536#discussion_r385875211
 
 

 ##########
 File path: 
test/src/main/java/org/apache/accumulo/test/functional/LegacyMetricsIT.java
 ##########
 @@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.accumulo.core.client.AccumuloException;
+import org.apache.accumulo.core.client.AccumuloSecurityException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.harness.AccumuloClusterHarness;
+import org.apache.accumulo.minicluster.impl.MiniAccumuloConfigImpl;
+import org.apache.accumulo.test.util.SlowOps;
+import org.apache.hadoop.conf.Configuration;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Basic functional test to verify enabling legacy metrics does not kill 
master.
+ */
+public class LegacyMetricsIT extends AccumuloClusterHarness {
+
+  private static final Logger log = 
LoggerFactory.getLogger(LegacyMetricsIT.class);
+
+  // number of tables / concurrent compactions used during testing.
+  private final int tableCount = 1;
+
+  private long maxWait = 15_000;
+
+  @Override
+  public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration 
hadoopCoreSite) {
+    cfg.setProperty(Property.GENERAL_LEGACY_METRICS, "true");
+  }
+
+  /**
+   * MANUAL TESTS ONLY - forces pause to allow jconsole connection
+   */
+  private final boolean PAUSE_FOR_MANUAL_TEST = false;
+
+  @Before
+  public void setup() {}
+
+  @Override
+  protected int defaultTimeoutSeconds() {
+    return 4 * 60;
+  }
+
+  /**
+   * Validates that the expected metrics are published - this excludes the 
dynamic metrics derived
+   * from operation types.
+   */
+  @Test
+  public void useMaster() {
+
+    boolean legacyMetricsEnabled =
+        
cluster.getSiteConfiguration().getBoolean(Property.GENERAL_LEGACY_METRICS);
+
+    assertTrue(legacyMetricsEnabled);
+
+    List<SlowOps> tables = new ArrayList<>();
+
+    for (int i = 0; i < tableCount; i++) {
+      String uniqueName = getUniqueNames(1)[0] + "_" + i;
+      SlowOps gen = new SlowOps(getConnector(), uniqueName, maxWait, 
tableCount);
+      tables.add(gen);
+      gen.startCompactTask();
+    }
+
+    // use calls that should need the master
+
+    try {
+
+      getConnector().instanceOperations().waitForBalance();
+
+      Map<String,String> configs = 
getConnector().instanceOperations().getSystemConfiguration();
+      assertTrue("master config should not be empty", !configs.isEmpty());
+
+    } catch (AccumuloException | AccumuloSecurityException ex) {
+      fail("Could not get config from master");
+    }
+
+    // clean-up cancel running compactions
+    for (SlowOps t : tables) {
+      try {
+        getConnector().tableOperations().cancelCompaction(t.getTableName());
+        // block if compaction still running
+        boolean cancelled = t.blockWhileCompactionRunning();
+        if (!cancelled) {
+          log.info("Failed to cancel compaction during multiple compaction 
test clean-up for {}",
+              t.getTableName());
+        }
+      } catch (AccumuloSecurityException | TableNotFoundException | 
AccumuloException ex) {
+        log.debug("Exception thrown during multiple table test clean-up", ex);
+      }
+    }
+  }
+
+  /**
+   * Pause for manual testing - allow time to connect with jconsole after 
launch.
+   *
+   * @param sleep_ms
+   *          sleep duration in milliseconds
+   */
+  private void manual_test_pause(int sleep_ms) {
 
 Review comment:
   Being that I must be the only one that finds these markers helpful for 
recalling a good place to put a pause for manual testing with jconsole, I've 
removed the code.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to