-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAPREDUCE-7435. following chain through to validation
* validation also uses manifest entries (and so works!) * testing expects this * tests of IOStats * tests of new RemoteIterators Change-Id: I4cfb308d4b08f1f775cfdbe2df6f8ff07ac6bc54
- Loading branch information
1 parent
c96a769
commit 1358391
Showing
24 changed files
with
626 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
.../hadoop-common/src/test/java/org/apache/hadoop/fs/statistics/TestIOStatisticsSetters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
/* | ||
* 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.fs.statistics; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
|
||
import org.apache.hadoop.fs.statistics.impl.ForwardingIOStatisticsStore; | ||
import org.apache.hadoop.fs.statistics.impl.IOStatisticsStore; | ||
import org.apache.hadoop.test.AbstractHadoopTestBase; | ||
|
||
import static org.apache.hadoop.fs.statistics.IOStatisticAssertions.assertThatStatisticCounter; | ||
import static org.apache.hadoop.fs.statistics.IOStatisticAssertions.assertThatStatisticGauge; | ||
import static org.apache.hadoop.fs.statistics.IOStatisticAssertions.assertThatStatisticMaximum; | ||
import static org.apache.hadoop.fs.statistics.IOStatisticAssertions.assertThatStatisticMean; | ||
import static org.apache.hadoop.fs.statistics.IOStatisticAssertions.assertThatStatisticMinimum; | ||
import static org.apache.hadoop.fs.statistics.impl.IOStatisticsBinding.iostatisticsStore; | ||
|
||
/** | ||
* Test the {@link IOStatisticsSetters} interface implementations through | ||
* a parameterized run with each implementation. | ||
* For each of the setters, the value is set, verified, | ||
* updated, verified again. | ||
* An option known to be undefined in all created IOStatisticsStore instances | ||
* is set, to verify it is harmless. | ||
*/ | ||
|
||
@RunWith(Parameterized.class) | ||
|
||
public class TestIOStatisticsSetters extends AbstractHadoopTestBase { | ||
|
||
public static final String COUNTER = "counter"; | ||
|
||
public static final String GAUGE = "gauge"; | ||
|
||
public static final String MAXIMUM = "max"; | ||
|
||
public static final String MINIMUM = "min"; | ||
|
||
public static final String MEAN = "mean"; | ||
|
||
private final IOStatisticsSetters ioStatistics; | ||
|
||
@Parameterized.Parameters | ||
public static Collection<Object[]> params() { | ||
return Arrays.asList(new Object[][]{ | ||
{new IOStatisticsSnapshot()}, | ||
{createTestStore()}, | ||
{new ForwardingIOStatisticsStore(createTestStore())}, | ||
}); | ||
} | ||
|
||
/** | ||
* Create a test store with the stats used for testing set up. | ||
* @return a set up store | ||
*/ | ||
private static IOStatisticsStore createTestStore() { | ||
return iostatisticsStore() | ||
.withCounters(COUNTER) | ||
.withGauges(GAUGE) | ||
.withMaximums(MAXIMUM) | ||
.withMinimums(MINIMUM) | ||
.withMeanStatistics(MEAN) | ||
.build(); | ||
} | ||
|
||
public TestIOStatisticsSetters(IOStatisticsSetters ioStatisticsSetters) { | ||
this.ioStatistics = ioStatisticsSetters; | ||
} | ||
|
||
@Test | ||
public void testCounter() throws Throwable { | ||
// write | ||
ioStatistics.setCounter(COUNTER, 1); | ||
assertThatStatisticCounter(ioStatistics, COUNTER) | ||
.isEqualTo(1); | ||
|
||
// update | ||
ioStatistics.setCounter(COUNTER, 2); | ||
assertThatStatisticCounter(ioStatistics, COUNTER) | ||
.isEqualTo(2); | ||
|
||
// unknown value | ||
ioStatistics.setCounter("c2", 3); | ||
} | ||
|
||
@Test | ||
public void testMaximum() throws Throwable { | ||
// write | ||
ioStatistics.setMaximum(MAXIMUM, 1); | ||
assertThatStatisticMaximum(ioStatistics, MAXIMUM) | ||
.isEqualTo(1); | ||
|
||
// update | ||
ioStatistics.setMaximum(MAXIMUM, 2); | ||
assertThatStatisticMaximum(ioStatistics, MAXIMUM) | ||
.isEqualTo(2); | ||
|
||
// unknown value | ||
ioStatistics.setMaximum("mm2", 3); | ||
} | ||
|
||
@Test | ||
public void testMinimum() throws Throwable { | ||
// write | ||
ioStatistics.setMinimum(MINIMUM, 1); | ||
assertThatStatisticMinimum(ioStatistics, MINIMUM) | ||
.isEqualTo(1); | ||
|
||
// update | ||
ioStatistics.setMinimum(MINIMUM, 2); | ||
assertThatStatisticMinimum(ioStatistics, MINIMUM) | ||
.isEqualTo(2); | ||
|
||
// unknown value | ||
ioStatistics.setMinimum("c2", 3); | ||
} | ||
|
||
@Test | ||
public void testGauge() throws Throwable { | ||
// write | ||
ioStatistics.setGauge(GAUGE, 1); | ||
assertThatStatisticGauge(ioStatistics, GAUGE) | ||
.isEqualTo(1); | ||
|
||
// update | ||
ioStatistics.setGauge(GAUGE, 2); | ||
assertThatStatisticGauge(ioStatistics, GAUGE) | ||
.isEqualTo(2); | ||
|
||
// unknown value | ||
ioStatistics.setGauge("g2", 3); | ||
} | ||
|
||
@Test | ||
public void testMean() throws Throwable { | ||
// write | ||
final MeanStatistic mean11 = new MeanStatistic(1, 1); | ||
ioStatistics.setMeanStatistic(MEAN, mean11); | ||
assertThatStatisticMean(ioStatistics, MEAN) | ||
.isEqualTo(mean11); | ||
|
||
// update | ||
final MeanStatistic mean22 = new MeanStatistic(2, 2); | ||
ioStatistics.setMeanStatistic(MEAN, mean22); | ||
assertThatStatisticMean(ioStatistics, MEAN) | ||
.isEqualTo(mean22); | ||
|
||
// unknown value | ||
ioStatistics.setMeanStatistic("m2", mean11); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.