Increase priority of rerun testing tasks

This should ensure rerun tasks don't block other more time-critical
tasks.

Bug: 39904
Change-Id: I18f7e1cdf803326c1da202c05b188da083e0f4f9
diff --git a/recipe_modules/testing/api.py b/recipe_modules/testing/api.py
index 94cf0e5..3e794ad 100644
--- a/recipe_modules/testing/api.py
+++ b/recipe_modules/testing/api.py
@@ -564,11 +564,15 @@
                              for tag in shard_request.task_request.tags)
       targets_fuchsia = shard_request.task_request[0].dimensions.get(
           'os', '').lower() not in ('linux', 'mac')
+      task_request = shard_request.task_request
+      if rerun_budget_secs:
+        # Rerun tasks should not block other tasks.
+        task_request = task_request.with_priority(task_request.priority + 1)
       self.tasks.append(
           Task(
               api=self._api,
               name=shard_request.task_request.name,
-              request=shard_request.task_request,
+              request=task_request,
               symbolize_tool=symbolize_tool,
               llvm_symbolizer=llvm_symbolizer,
               tests=shard_request.shard.tests,
diff --git a/recipe_modules/testing/examples/full.expected/rerun.json b/recipe_modules/testing/examples/full.expected/rerun.json
index 772017b..ba2f9a2 100644
--- a/recipe_modules/testing/examples/full.expected/rerun.json
+++ b/recipe_modules/testing/examples/full.expected/rerun.json
@@ -1464,7 +1464,7 @@
       "-server",
       "https://example.swarmingserver.appspot.com",
       "-json-input",
-      "{\"requests\": [{\"name\": \"fuchsia-0000\", \"priority\": \"200\", \"service_account\": \"default_service_account\", \"tags\": [\"test_environment_name:QEMU-arm64\"], \"task_slices\": [{\"expiration_secs\": \"0\", \"properties\": {\"cipd_input\": {\"packages\": [{\"package_name\": \"infra/tools/luci-auth/${platform}\", \"path\": \".\", \"version\": \"latest\"}, {\"package_name\": \"fuchsia/infra/catalyst/${platform}\", \"path\": \".\", \"version\": \"git_revision:12ba48e4eea05053e01e834502042a8c710bdc99\"}, {\"package_name\": \"fuchsia/third_party/qemu/${platform}\", \"path\": \"qemu\", \"version\": \"git_revision:533bf2563d0213a7e002d9fcde75519d30ffa70f\"}]}, \"command\": [\"./luci-auth\", \"context\", \"--\", \"./catalyst\", \"-images\", \"gs://fuchsia-artifacts/8945511751514863184/images/images.json\", \"-bootserver\", \"./bootserver_new\", \"./botanist\", \"-level\", \"debug\", \"run\", \"-images\", \"gs://fuchsia-artifacts/8945511751514863184/images/images.json\", \"-timeout\", \"0s\", \"-syslog\", \"syslog.txt\", \"-ssh\", \"private_key\", \"-config\", \"./qemu.json\", \"./testrunner\", \"-archive\", \"out.tar\", \"tests.json\"], \"containment\": {\"containment_type\": \"NONE\", \"limit_processes\": \"0\", \"limit_total_committed_memory\": \"0\", \"lower_priority\": false}, \"dimensions\": [{\"key\": \"kvm\", \"value\": \"1\"}, {\"key\": \"os\", \"value\": \"Debian\"}, {\"key\": \"cpu\", \"value\": \"arm64\"}, {\"key\": \"pool\", \"value\": \"fuchsia.tests\"}], \"env\": [{\"key\": \"BUILD_PRODUCT\", \"value\": \"//products/foo.gni\"}, {\"key\": \"FUCHSIA_TEST_OUTDIR\", \"value\": \"${ISOLATED_OUTDIR}\"}, {\"key\": \"INPUT_COMMIT_HOST\", \"value\": \"fuchsia.googlesource.com\"}, {\"key\": \"LSAN_SYMBOLIZER_PATH\", \"value\": \"llvm-symbolizer\"}, {\"key\": \"BUILDBUCKET_BUCKET\", \"value\": \"ci\"}, {\"key\": \"BUILD_TARGET\", \"value\": \"arm64\"}, {\"key\": \"ASAN_SYMBOLIZER_PATH\", \"value\": \"llvm-symbolizer\"}, {\"key\": \"UBSAN_SYMBOLIZER_PATH\", \"value\": \"llvm-symbolizer\"}, {\"key\": \"INPUT_COMMIT_PROJECT\", \"value\": \"fuchsia\"}, {\"key\": \"BUILDER_NAME\", \"value\": \"builder\"}, {\"key\": \"INPUT_COMMIT_REF\", \"value\": \"refs/heads/master\"}, {\"key\": \"FUCHSIA_DEVICE_TYPE\", \"value\": \"QEMU\"}, {\"key\": \"BUILDBUCKET_ID\", \"value\": \"8945511751514863184\"}, {\"key\": \"BUILD_BOARD\", \"value\": \"//boards/foo.gni\"}, {\"key\": \"BUILD_CREATE_TIME\", \"value\": \"1527292217\"}, {\"key\": \"BUILD_TYPE\", \"value\": \"build-type\"}], \"env_prefixes\": [], \"execution_timeout_secs\": \"0\", \"grace_period_secs\": \"30\", \"idempotent\": false, \"inputs_ref\": {\"isolated\": \"[dummy hash]\", \"isolatedserver\": \"https://example.isolateserver.appspot.com\", \"namespace\": \"default-gzip\"}, \"io_timeout_secs\": \"0\", \"outputs\": [\"syslog.txt\", \"out.tar\"]}}]}]}",
+      "{\"requests\": [{\"name\": \"fuchsia-0000\", \"priority\": \"201\", \"service_account\": \"default_service_account\", \"tags\": [\"test_environment_name:QEMU-arm64\"], \"task_slices\": [{\"expiration_secs\": \"0\", \"properties\": {\"cipd_input\": {\"packages\": [{\"package_name\": \"infra/tools/luci-auth/${platform}\", \"path\": \".\", \"version\": \"latest\"}, {\"package_name\": \"fuchsia/infra/catalyst/${platform}\", \"path\": \".\", \"version\": \"git_revision:12ba48e4eea05053e01e834502042a8c710bdc99\"}, {\"package_name\": \"fuchsia/third_party/qemu/${platform}\", \"path\": \"qemu\", \"version\": \"git_revision:533bf2563d0213a7e002d9fcde75519d30ffa70f\"}]}, \"command\": [\"./luci-auth\", \"context\", \"--\", \"./catalyst\", \"-images\", \"gs://fuchsia-artifacts/8945511751514863184/images/images.json\", \"-bootserver\", \"./bootserver_new\", \"./botanist\", \"-level\", \"debug\", \"run\", \"-images\", \"gs://fuchsia-artifacts/8945511751514863184/images/images.json\", \"-timeout\", \"0s\", \"-syslog\", \"syslog.txt\", \"-ssh\", \"private_key\", \"-config\", \"./qemu.json\", \"./testrunner\", \"-archive\", \"out.tar\", \"tests.json\"], \"containment\": {\"containment_type\": \"NONE\", \"limit_processes\": \"0\", \"limit_total_committed_memory\": \"0\", \"lower_priority\": false}, \"dimensions\": [{\"key\": \"kvm\", \"value\": \"1\"}, {\"key\": \"os\", \"value\": \"Debian\"}, {\"key\": \"cpu\", \"value\": \"arm64\"}, {\"key\": \"pool\", \"value\": \"fuchsia.tests\"}], \"env\": [{\"key\": \"BUILD_PRODUCT\", \"value\": \"//products/foo.gni\"}, {\"key\": \"FUCHSIA_TEST_OUTDIR\", \"value\": \"${ISOLATED_OUTDIR}\"}, {\"key\": \"INPUT_COMMIT_HOST\", \"value\": \"fuchsia.googlesource.com\"}, {\"key\": \"LSAN_SYMBOLIZER_PATH\", \"value\": \"llvm-symbolizer\"}, {\"key\": \"BUILDBUCKET_BUCKET\", \"value\": \"ci\"}, {\"key\": \"BUILD_TARGET\", \"value\": \"arm64\"}, {\"key\": \"ASAN_SYMBOLIZER_PATH\", \"value\": \"llvm-symbolizer\"}, {\"key\": \"UBSAN_SYMBOLIZER_PATH\", \"value\": \"llvm-symbolizer\"}, {\"key\": \"INPUT_COMMIT_PROJECT\", \"value\": \"fuchsia\"}, {\"key\": \"BUILDER_NAME\", \"value\": \"builder\"}, {\"key\": \"INPUT_COMMIT_REF\", \"value\": \"refs/heads/master\"}, {\"key\": \"FUCHSIA_DEVICE_TYPE\", \"value\": \"QEMU\"}, {\"key\": \"BUILDBUCKET_ID\", \"value\": \"8945511751514863184\"}, {\"key\": \"BUILD_BOARD\", \"value\": \"//boards/foo.gni\"}, {\"key\": \"BUILD_CREATE_TIME\", \"value\": \"1527292217\"}, {\"key\": \"BUILD_TYPE\", \"value\": \"build-type\"}], \"env_prefixes\": [], \"execution_timeout_secs\": \"0\", \"grace_period_secs\": \"30\", \"idempotent\": false, \"inputs_ref\": {\"isolated\": \"[dummy hash]\", \"isolatedserver\": \"https://example.isolateserver.appspot.com\", \"namespace\": \"default-gzip\"}, \"io_timeout_secs\": \"0\", \"outputs\": [\"syslog.txt\", \"out.tar\"]}}]}]}",
       "-json-output",
       "/path/to/tmp/json"
     ],