Skip to content

Commit

Permalink
MAPREDUCE-7435. Mehakmeet review
Browse files Browse the repository at this point in the history
Change-Id: Ica813c6068eca18d83bf2f5f94fac4a1e1996c36
  • Loading branch information
steveloughran committed Jun 1, 2023
1 parent b289707 commit 355fa35
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* {@link IOStatisticsSnapshot} to also support it.
* These are the simple setters, they don't provide for increments,
* decrements, calculation of min/max/mean etc.
* @since The interface and IOStatisticsSnapshot support was added after Hadoop 3.3.5
* @since The interface and IOStatisticsSnapshot support was added <i>after</i> Hadoop 3.3.5
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Arrays;
import java.util.Collection;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
Expand Down Expand Up @@ -61,12 +62,14 @@ public class TestIOStatisticsSetters extends AbstractHadoopTestBase {

private final IOStatisticsSetters ioStatistics;

@Parameterized.Parameters
private final boolean createsNewEntries;

@Parameterized.Parameters(name="{0}")
public static Collection<Object[]> params() {
return Arrays.asList(new Object[][]{
{new IOStatisticsSnapshot()},
{createTestStore()},
{new ForwardingIOStatisticsStore(createTestStore())},
{"IOStatisticsSnapshot", new IOStatisticsSnapshot(), true},
{"IOStatisticsStore", createTestStore(), false},
{"ForwardingIOStatisticsStore", new ForwardingIOStatisticsStore(createTestStore()), false},
});
}

Expand All @@ -84,8 +87,13 @@ private static IOStatisticsStore createTestStore() {
.build();
}

public TestIOStatisticsSetters(IOStatisticsSetters ioStatisticsSetters) {
public TestIOStatisticsSetters(
String source,
IOStatisticsSetters ioStatisticsSetters,
boolean createsNewEntries) {
this.ioStatistics = ioStatisticsSetters;

this.createsNewEntries = createsNewEntries;
}

@Test
Expand All @@ -101,7 +109,16 @@ public void testCounter() throws Throwable {
.isEqualTo(2);

// unknown value
ioStatistics.setCounter("c2", 3);
final String unknown = "unknown";
ioStatistics.setCounter(unknown, 3);
if (createsNewEntries) {
assertThatStatisticCounter(ioStatistics, unknown)
.isEqualTo(3);
} else {
Assertions.assertThat(ioStatistics.counters())
.describedAs("Counter map in {}", ioStatistics)
.doesNotContainKey(unknown);
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,4 @@ private InternalConstants() {
/** Schemas of filesystems we know to not work with this committer. */
public static final Set<String> UNSUPPORTED_FS_SCHEMAS =
ImmutableSet.of("s3a", "wasb");

}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public class TestJobThroughManifestCommitter

/**
* Loaded manifest data, set in job commit and used in validation.
* This is static so it can be passed from where it is loaded
* {@link #test_0400_loadManifests()} to subsequent tests.
*/
private static LoadedManifestData
loadedManifestData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ public class TestRenameStageFailure extends AbstractManifestCommitterTest {
/** resilient commit expected? */
private boolean resilientCommit;

/**
* Entry file IO.
*/
private EntryFileIO entryFileIO;

protected boolean isResilientCommit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public void testCreateEmptyFile() throws Throwable {
// now use the iterator to access it.
List<FileEntry> files = new ArrayList<>();
Assertions.assertThat(foreach(iterateOverEntryFile(), files::add))
.describedAs("Count of iterations over entries in an entry file with no entries")
.isEqualTo(0);
}

Expand Down

0 comments on commit 355fa35

Please sign in to comment.