From d83771aac53d5bc6f98e02538d21acf31fd17a0e Mon Sep 17 00:00:00 2001 From: ruperts Date: Tue, 19 Jun 2018 15:44:13 -0700 Subject: Be more generous with user time and system time bounds for execution statistics tests, and increase granularity of the waits. RELNOTES: None. PiperOrigin-RevId: 201254824 --- .../build/lib/exec/local/LocalSpawnRunnerTest.java | 14 +++++--------- .../build/lib/shell/CommandUsingProcessWrapperTest.java | 8 ++++---- .../build/lib/shell/ExecutionStatisticsTestUtil.java | 4 ++-- 3 files changed, 11 insertions(+), 15 deletions(-) (limited to 'src/test/java/com') diff --git a/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java b/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java index f503ddb547..63048fc108 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java @@ -815,14 +815,12 @@ public class LocalSpawnRunnerTest { options.collectLocalExecutionStatistics = true; Duration minimumWallTimeToSpend = Duration.ofSeconds(10); - // Because of e.g. interference, wall time taken may be much larger than CPU time used. - Duration maximumWallTimeToSpend = Duration.ofSeconds(40); Duration minimumUserTimeToSpend = minimumWallTimeToSpend; - Duration maximumUserTimeToSpend = minimumUserTimeToSpend.plus(Duration.ofSeconds(2)); + Duration maximumUserTimeToSpend = minimumUserTimeToSpend.plus(Duration.ofSeconds(5)); Duration minimumSystemTimeToSpend = Duration.ZERO; - Duration maximumSystemTimeToSpend = minimumSystemTimeToSpend.plus(Duration.ofSeconds(2)); + Duration maximumSystemTimeToSpend = minimumSystemTimeToSpend.plus(Duration.ofSeconds(5)); Path execRoot = getTemporaryExecRoot(fs); copyProcessWrapperIntoExecRoot(execRoot); @@ -856,7 +854,7 @@ public class LocalSpawnRunnerTest { assertThat(spawnResult.getWallTime()).isPresent(); assertThat(spawnResult.getWallTime().get()).isAtLeast(minimumWallTimeToSpend); - assertThat(spawnResult.getWallTime().get()).isAtMost(maximumWallTimeToSpend); + // Under heavy starvation, max wall time could be anything, so don't check it here. assertThat(spawnResult.getUserTime()).isPresent(); assertThat(spawnResult.getUserTime().get()).isAtLeast(minimumUserTimeToSpend); assertThat(spawnResult.getUserTime().get()).isAtMost(maximumUserTimeToSpend); @@ -878,9 +876,7 @@ public class LocalSpawnRunnerTest { LocalExecutionOptions options = Options.getDefaults(LocalExecutionOptions.class); options.collectLocalExecutionStatistics = false; - Duration minimumWallTimeToSpend = Duration.ofSeconds(10); - // Because of e.g. interference, wall time taken may be much larger than CPU time used. - Duration maximumWallTimeToSpend = Duration.ofSeconds(40); + Duration minimumWallTimeToSpend = Duration.ofSeconds(1); Duration minimumUserTimeToSpend = minimumWallTimeToSpend; Duration minimumSystemTimeToSpend = Duration.ZERO; @@ -917,7 +913,7 @@ public class LocalSpawnRunnerTest { assertThat(spawnResult.getWallTime()).isPresent(); assertThat(spawnResult.getWallTime().get()).isAtLeast(minimumWallTimeToSpend); - assertThat(spawnResult.getWallTime().get()).isAtMost(maximumWallTimeToSpend); + // Under heavy starvation, max wall time could be anything, so don't check it here. assertThat(spawnResult.getUserTime()).isEmpty(); assertThat(spawnResult.getSystemTime()).isEmpty(); assertThat(spawnResult.getNumBlockOutputOperations()).isEmpty(); diff --git a/src/test/java/com/google/devtools/build/lib/shell/CommandUsingProcessWrapperTest.java b/src/test/java/com/google/devtools/build/lib/shell/CommandUsingProcessWrapperTest.java index b6643914be..dbcbf48646 100644 --- a/src/test/java/com/google/devtools/build/lib/shell/CommandUsingProcessWrapperTest.java +++ b/src/test/java/com/google/devtools/build/lib/shell/CommandUsingProcessWrapperTest.java @@ -98,7 +98,7 @@ public final class CommandUsingProcessWrapperTest { @Test public void testProcessWrappedCommand_WithStatistics_SpendUserTime() throws CommandException, IOException { - Duration userTimeToSpend = Duration.ofSeconds(10); + Duration userTimeToSpend = Duration.ofSeconds(6); Duration systemTimeToSpend = Duration.ZERO; checkProcessWrapperStatistics(userTimeToSpend, systemTimeToSpend); @@ -108,7 +108,7 @@ public final class CommandUsingProcessWrapperTest { public void testProcessWrappedCommand_WithStatistics_SpendSystemTime() throws CommandException, IOException { Duration userTimeToSpend = Duration.ZERO; - Duration systemTimeToSpend = Duration.ofSeconds(10); + Duration systemTimeToSpend = Duration.ofSeconds(6); checkProcessWrapperStatistics(userTimeToSpend, systemTimeToSpend); } @@ -116,8 +116,8 @@ public final class CommandUsingProcessWrapperTest { @Test public void testProcessWrappedCommand_WithStatistics_SpendUserAndSystemTime() throws CommandException, IOException { - Duration userTimeToSpend = Duration.ofSeconds(10); - Duration systemTimeToSpend = Duration.ofSeconds(10); + Duration userTimeToSpend = Duration.ofSeconds(6); + Duration systemTimeToSpend = Duration.ofSeconds(6); checkProcessWrapperStatistics(userTimeToSpend, systemTimeToSpend); } diff --git a/src/test/java/com/google/devtools/build/lib/shell/ExecutionStatisticsTestUtil.java b/src/test/java/com/google/devtools/build/lib/shell/ExecutionStatisticsTestUtil.java index 221cac995c..612fbf6fbf 100644 --- a/src/test/java/com/google/devtools/build/lib/shell/ExecutionStatisticsTestUtil.java +++ b/src/test/java/com/google/devtools/build/lib/shell/ExecutionStatisticsTestUtil.java @@ -44,9 +44,9 @@ public class ExecutionStatisticsTestUtil { Path statisticsFilePath) throws CommandException, IOException { Duration userTimeLowerBound = userTimeToSpend; - Duration userTimeUpperBound = userTimeToSpend.plusSeconds(2); + Duration userTimeUpperBound = userTimeToSpend.plusSeconds(5); Duration systemTimeLowerBound = systemTimeToSpend; - Duration systemTimeUpperBound = systemTimeToSpend.plusSeconds(2); + Duration systemTimeUpperBound = systemTimeToSpend.plusSeconds(5); Command command = new Command(fullCommandLine.toArray(new String[0])); CommandResult commandResult = command.execute(); -- cgit v1.2.3