YARN-8856. TestTimelineReaderWebServicesHBaseStorage tests failing with NoClassDefFoundError. Contributed by Sushil Ks.

This commit is contained in:
Inigo Goiri 2018-11-15 09:25:25 -08:00
parent d40912b1bd
commit eeaf8edaa7
4 changed files with 60 additions and 2 deletions

View File

@ -317,6 +317,13 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.24</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-testing-util</artifactId>

View File

@ -0,0 +1,39 @@
/**
* 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.hadoop.yarn.server.timelineservice.reader;
import org.apache.hadoop.yarn.server.timelineservice.metrics.TimelineReaderMetrics;
/**
* DummyTimelineReaderMetrics for mocking {@link TimelineReaderMetrics} calls.
*/
public class DummyTimelineReaderMetrics extends TimelineReaderMetrics {
@Override
public void addGetEntitiesLatency(
long durationMs, boolean succeeded) {
}
@Override
public void addGetEntityTypesLatency(
long durationMs, boolean succeeded) {
}
}

View File

@ -35,6 +35,8 @@ import java.util.Set;
import javax.ws.rs.core.MediaType;
import mockit.Mock;
import mockit.MockUp;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.yarn.api.records.ApplicationId;
@ -50,6 +52,7 @@ import org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric.Type;
import org.apache.hadoop.yarn.server.metrics.ApplicationMetricsConstants;
import org.apache.hadoop.yarn.server.timelineservice.collector.TimelineCollectorContext;
import org.apache.hadoop.yarn.server.timelineservice.metrics.TimelineReaderMetrics;
import org.apache.hadoop.yarn.server.timelineservice.storage.HBaseTimelineWriterImpl;
import org.apache.hadoop.yarn.server.timelineservice.storage.common.HBaseTimelineSchemaUtils;
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
@ -73,9 +76,17 @@ public class TestTimelineReaderWebServicesHBaseStorage
private static long dayTs =
HBaseTimelineSchemaUtils.getTopOfTheDayTimestamp(ts);
private static String doAsUser = "remoteuser";
private static final DummyTimelineReaderMetrics METRICS
= new DummyTimelineReaderMetrics();
@BeforeClass
public static void setupBeforeClass() throws Exception {
new MockUp<TimelineReaderMetrics>() {
@Mock
public TimelineReaderMetrics getInstance() {
return METRICS;
}
};
setup();
loadData();
initialize();

View File

@ -33,7 +33,7 @@ import static org.apache.hadoop.metrics2.lib.Interns.info;
* Metrics class for TimelineReader.
*/
@Metrics(about = "Metrics for timeline reader", context = "timelineservice")
final public class TimelineReaderMetrics {
public class TimelineReaderMetrics {
private final static MetricsInfo METRICS_INFO = info("TimelineReaderMetrics",
"Metrics for TimelineReader");
@ -50,7 +50,8 @@ final public class TimelineReaderMetrics {
@Metric(about = "GET entity types success latency", valueName = "latency")
private MutableQuantiles getEntityTypesSuccessLatency;
private TimelineReaderMetrics() {
@VisibleForTesting
protected TimelineReaderMetrics() {
}
public static TimelineReaderMetrics getInstance() {