示例#1
0
  /**
   * Returns mutable map of default testing shell environment. By itself it is incomplete and is
   * modified further by the specific test strategy implementations (mostly due to the fact that
   * environments used locally and remotely are different).
   */
  protected Map<String, String> getDefaultTestEnvironment(TestRunnerAction action) {
    Map<String, String> env = new HashMap<>();

    env.putAll(action.getConfiguration().getLocalShellEnvironment());
    env.remove("LANG");
    env.put("TZ", "UTC");
    env.put("TEST_SIZE", action.getTestProperties().getSize().toString());
    env.put("TEST_TIMEOUT", Integer.toString(getTimeout(action)));

    if (action.isSharded()) {
      env.put("TEST_SHARD_INDEX", Integer.toString(action.getShardNum()));
      env.put(
          "TEST_TOTAL_SHARDS", Integer.toString(action.getExecutionSettings().getTotalShards()));
    }

    // When we run test multiple times, set different TEST_RANDOM_SEED values for each run.
    if (action.getConfiguration().getRunsPerTestForLabel(action.getOwner().getLabel()) > 1) {
      env.put("TEST_RANDOM_SEED", Integer.toString(action.getRunNumber() + 1));
    }

    String testFilter = action.getExecutionSettings().getTestFilter();
    if (testFilter != null) {
      env.put(TEST_BRIDGE_TEST_FILTER_ENV, testFilter);
    }

    return env;
  }
示例#2
0
 /**
  * Returns the number of attempts specific test action can be retried.
  *
  * <p>For rules with "flaky = 1" attribute, this method will return 3 unless --flaky_test_attempts
  * option is given and specifies another value.
  */
 @VisibleForTesting /* protected */
 public int getTestAttempts(TestRunnerAction action) {
   if (executionOptions.testAttempts == -1) {
     return action.getTestProperties().isFlaky() ? 3 : 1;
   } else {
     return executionOptions.testAttempts;
   }
 }
示例#3
0
 /**
  * Returns timeout value in seconds that should be used for the given test action. We always use
  * the "categorical timeouts" which are based on the --test_timeout flag. A rule picks its timeout
  * but ends up with the same effective value as all other rules in that bucket.
  */
 protected final int getTimeout(TestRunnerAction testAction) {
   return executionOptions.testTimeout.get(testAction.getTestProperties().getTimeout());
 }