diff --git a/.github/ci/partition.sh b/.github/ci/partition.sh index 2f24380adf..b685393b01 100755 --- a/.github/ci/partition.sh +++ b/.github/ci/partition.sh @@ -16,6 +16,7 @@ not force minutes of Docker work onto the same shard. Deterministic: sorted inputs, greedy least-loaded bin-packing, no RNG/timestamps. Exit 2 on bad arguments or an unreadable input file. """ +import json import os import re import sys @@ -23,12 +24,10 @@ import sys AUGMENTATION_WEIGHT = 10 # one augmentation ~ 5.4s ~ 10 average test classes # Classes that take far longer than the suite's average, keyed by class name so package renames -# retain their weight. The EMR runner took 651s on GitHub's runners on 2026-11-12; at its old -# 280s weight, its shard ran into Surefire's 1500s while others finished in 16 to 20 minutes. -# Hive steps now run only in nightly checks and no longer need a routine-shard weight. -SLOW_CLASSES = { - 'EmrDockerRunnerDockerIntegrationTest': 650, -} +# retain their weight, as {"ClassName": seconds}. None today: the EMR runner (651s on GitHub's +# runners on 2026-11-12) and the Hive steps now run only in the nightly checks. The tests pass +# their own through PARTITION_SLOW_CLASSES, a JSON object of the same shape. +SLOW_CLASSES = json.loads(os.environ.get('PARTITION_SLOW_CLASSES', '{}')) SECONDS_PER_CLASS = 1.2 # the suite's mean: 4212s over 3451 classes on 2026-11-09 def weight(cls): diff --git a/.github/ci/prefetch-images.sh b/.github/ci/prefetch-images.sh index c2c157e7b0..f9f2c1a0e0 100755 --- a/.github/ci/prefetch-images.sh +++ b/.github/ci/prefetch-images.sh @@ -111,23 +111,23 @@ grep -qE '/apigateway/|/apigatewayv2/|/lambda/' "$SHARD_FILE" && ecr public.ecr. grep -qE '/lambdaweb/' "$SHARD_FILE" && ecr public.ecr.aws/lambda/nodejs:24 starts SwfLambdaIntegrationTest && ecr public.ecr.aws/lambda/python:3.12 starts ElbV2LambdaTargetDataPlaneIntegrationTest && ecr public.ecr.aws/lambda/python:3.14 -# EmrDockerRunnerDockerIntegrationTest runs EMR steps and EMR Serverless job runs in the emr-7.5.0 image the runner's +# EmrDockerRunnerNightlyIntegrationTest runs EMR steps and EMR Serverless job runs in the emr-7.5.0 image the runner's # default template names (EmrServerlessSparkRunner), 3.5 GB, so it is queued last, behind the Lambda runtimes; # Of the nightly checks, EmrHiveStepsNightlyIntegrationTest runs a cluster's other steps in it, # EmrServerlessCustomImageNightlyIntegrationTest builds its custom image on it, # EmrFlociContainerNightlyIntegrationTest runs a cluster's steps in it from Floci in a container, # EmrPigStepsNightlyIntegrationTest a cluster's Pig steps, EmrAppUiNightlyIntegrationTest a MapReduce step, # and EmrClusterShrinkNightlyIntegrationTest a cluster shrink. -starts EmrDockerRunnerDockerIntegrationTest EmrHiveStepsNightlyIntegrationTest EmrServerlessCustomImageNightlyIntegrationTest \ +starts EmrDockerRunnerNightlyIntegrationTest EmrHiveStepsNightlyIntegrationTest EmrServerlessCustomImageNightlyIntegrationTest \ EmrFlociContainerNightlyIntegrationTest EmrPigStepsNightlyIntegrationTest EmrNotebookExecutionNightlyIntegrationTest \ EmrAppUiNightlyIntegrationTest EmrClusterShrinkNightlyIntegrationTest \ && ecr public.ecr.aws/emr-serverless/spark/emr-7.5.0:latest # EmrServerlessHiveDockerIntegrationTest runs EMR Serverless Hive job runs, and EmrHiveStepsNightlyIntegrationTest EMR # Hive steps, in the emr-7.5.0 Hive image the runner's default Hive template names, 2.7 GB; every EMR cluster runs its -# HDFS in it, EmrDockerRunnerDockerIntegrationTest's and the nightly EmrFlociContainerNightlyIntegrationTest's, +# HDFS in it, EmrDockerRunnerNightlyIntegrationTest's and the nightly EmrFlociContainerNightlyIntegrationTest's, # EmrPigStepsNightlyIntegrationTest's and EmrSessionServerNightlyIntegrationTest's included (an emr-spark-* cluster's # Hadoop comes from it too). -starts EmrServerlessHiveDockerIntegrationTest EmrHiveStepsNightlyIntegrationTest EmrDockerRunnerDockerIntegrationTest \ +starts EmrServerlessHiveDockerIntegrationTest EmrHiveStepsNightlyIntegrationTest EmrDockerRunnerNightlyIntegrationTest \ EmrFlociContainerNightlyIntegrationTest EmrPigStepsNightlyIntegrationTest EmrSessionServerNightlyIntegrationTest \ EmrNotebookExecutionNightlyIntegrationTest EmrAppUiNightlyIntegrationTest EmrClusterShrinkNightlyIntegrationTest \ && ecr public.ecr.aws/emr-serverless/hive/emr-7.5.0:latest diff --git a/.github/ci/test_partition.py b/.github/ci/test_partition.py index 5181afc92f..fc7ab3e63b 100644 --- a/.github/ci/test_partition.py +++ b/.github/ci/test_partition.py @@ -1,5 +1,6 @@ """Run with python3 -m unittest discover -s .github/ci -p 'test_partition.py'.""" from pathlib import Path +import os import subprocess import sys import tempfile @@ -21,8 +22,10 @@ class PartitionTest(unittest.TestCase): path.write_text(annotation + '\nclass Fixture {}\n') def invoke(self, total, index): + # One slow class, as SLOW_CLASSES weighed the EMR runner before it moved to the nightly checks. + env = dict(os.environ, PARTITION_SLOW_CLASSES='{"SlowDockerIntegrationTest": 650}') return subprocess.run([sys.executable, str(PATH), str(self.classes), str(total), str(index)], - cwd=self.root, capture_output=True, text=True) + cwd=self.root, capture_output=True, text=True, env=env) def shards(self, classes, total): self.classes.write_text('\n'.join(classes) + '\n') @@ -92,34 +95,34 @@ class PartitionTest(unittest.TestCase): self.shards(['third/C', 'second/B', 'first/A'], 2)) def test_a_slow_class_in_a_profile_keeps_other_classes_off_its_shard(self): - self.source('p/EmrDockerRunnerDockerIntegrationTest', '@TestProfile(Docker.class)') + self.source('p/SlowDockerIntegrationTest', '@TestProfile(Docker.class)') plain = ['p/C%03d' % n for n in range(40)] - shards = self.shards(['p/EmrDockerRunnerDockerIntegrationTest'] + plain, 2) - self.assertEqual([['p/EmrDockerRunnerDockerIntegrationTest'], plain], shards) + shards = self.shards(['p/SlowDockerIntegrationTest'] + plain, 2) + self.assertEqual([['p/SlowDockerIntegrationTest'], plain], shards) def test_a_group_holding_a_slow_class_is_placed_before_a_larger_group(self): - self.source('p/EmrDockerRunnerDockerIntegrationTest', '@TestProfile(Docker.class)') + self.source('p/SlowDockerIntegrationTest', '@TestProfile(Docker.class)') for name in ('p/A', 'p/B', 'p/C', 'p/D'): self.source(name, '@TestProfile(Zeta.class)') - shards = self.shards(['p/A', 'p/B', 'p/C', 'p/D', 'p/EmrDockerRunnerDockerIntegrationTest'], 2) - self.assertEqual(['p/EmrDockerRunnerDockerIntegrationTest'], shards[0]) + shards = self.shards(['p/A', 'p/B', 'p/C', 'p/D', 'p/SlowDockerIntegrationTest'], 2) + self.assertEqual(['p/SlowDockerIntegrationTest'], shards[0]) def test_a_slow_class_without_a_profile_is_placed_before_the_others(self): plain = ['p/A', 'p/B', 'p/C'] - shards = self.shards(plain + ['p/EmrDockerRunnerDockerIntegrationTest'], 2) - self.assertEqual([['p/EmrDockerRunnerDockerIntegrationTest'], plain], shards) + shards = self.shards(plain + ['p/SlowDockerIntegrationTest'], 2) + self.assertEqual([['p/SlowDockerIntegrationTest'], plain], shards) def test_a_slow_class_is_known_by_its_name_whatever_its_package(self): plain = ['some/other/C%03d' % n for n in range(40)] - shards = self.shards(['some/where/EmrDockerRunnerDockerIntegrationTest'] + plain, 2) - self.assertEqual(['some/where/EmrDockerRunnerDockerIntegrationTest'], shards[0]) + shards = self.shards(['some/where/SlowDockerIntegrationTest'] + plain, 2) + self.assertEqual(['some/where/SlowDockerIntegrationTest'], shards[0]) def test_a_slow_class_is_separate_from_ordinary_members_of_its_profile(self): - self.source('p/EmrDockerRunnerDockerIntegrationTest', '@TestProfile(Docker.class)') + self.source('p/SlowDockerIntegrationTest', '@TestProfile(Docker.class)') self.source('p/A', '@TestProfile(Docker.class)') self.source('p/B', '@TestProfile(Docker.class)') - classes = ['p/EmrDockerRunnerDockerIntegrationTest', 'p/A', 'p/B'] - self.assertEqual([['p/EmrDockerRunnerDockerIntegrationTest'], ['p/A', 'p/B']], + classes = ['p/SlowDockerIntegrationTest', 'p/A', 'p/B'] + self.assertEqual([['p/SlowDockerIntegrationTest'], ['p/A', 'p/B']], self.shards(classes, 2)) def test_a_slow_class_that_no_longer_exists_is_named_and_changes_nothing(self): @@ -128,7 +131,7 @@ class PartitionTest(unittest.TestCase): self.assertEqual(0, result.returncode, result.stderr) self.assertEqual('p/A\n', result.stdout) self.assertIn('::warning title=partition.sh::stale SLOW_CLASSES key: no test class named ' - 'EmrDockerRunnerDockerIntegrationTest', result.stderr) + 'SlowDockerIntegrationTest', result.stderr) def test_invalid_shard_arguments_fail_without_emitting_assignments(self): self.classes.write_text('p/A\np/B\n') diff --git a/.github/workflows/nightly-checks.yml b/.github/workflows/nightly-checks.yml index a63038d67d..60faf7a83f 100644 --- a/.github/workflows/nightly-checks.yml +++ b/.github/workflows/nightly-checks.yml @@ -28,17 +28,20 @@ jobs: checks: name: Nightly checks (${{ matrix.group }}) runs-on: ubuntu-latest - # The existing checks keep their 339-minute total plus twenty minutes for setup. The shrink check runs - # separately: its sixteen-minute method and two-minute setup plus twenty minutes for compilation/prefetch. - # Combining them would exceed the hosted runner's 360-minute job limit. + # Each group runs its checks one after another, within their own @Timeout bounds, plus about twenty minutes for + # compilation, the image and the prefetch; together they would exceed the 360 minutes a hosted runner gives one + # job. standard holds every check but the EMR Docker runner's, 339 minutes. docker-runner holds + # EmrDockerRunnerNightlyIntegrationTest's eleven two-minute tests and two-minute setup, and + # EmrClusterShrinkNightlyIntegrationTest's sixteen-minute method and two-minute setup, 42 minutes. A check added, + # or a bound raised, raises its group's timeout with it, so a slow check fails with its own message. strategy: fail-fast: false matrix: include: - group: standard timeout: 359 - - group: cluster-shrink - timeout: 38 + - group: docker-runner + timeout: 62 timeout-minutes: ${{ matrix.timeout }} # A fork's schedule would spend its owner's minutes on checks it never asked for; a draft waits until it is # ready for review, as the CI shards do. @@ -49,17 +52,32 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # Every test is a top-level class in src/test/java, so the file name is the class name, as ci.yml relies on. + # On a pull request, only the checks it adds or changes run, or all of them when it changes this workflow. - name: List the nightly checks id: list + env: + GH_TOKEN: ${{ github.token }} + PR: ${{ github.event.pull_request.number }} + GROUP: ${{ matrix.group }} run: | + set -euo pipefail cd src/test/java find . -name '*NightlyIntegrationTest.java' | sed 's|^\./||; s|\.java$||' | LC_ALL=C sort \ > "$GITHUB_WORKSPACE/all-nightly.txt" cd "$GITHUB_WORKSPACE" - if [ "${{ matrix.group }}" = "cluster-shrink" ]; then - grep '/EmrClusterShrinkNightlyIntegrationTest$' all-nightly.txt > nightly.txt + if [ -n "$PR" ]; then + gh pr diff "$PR" --repo "$GITHUB_REPOSITORY" --name-only > changed.txt + if ! grep -qx '.github/workflows/nightly-checks.yml' changed.txt; then + sed -n 's|^src/test/java/\(.*NightlyIntegrationTest\)\.java$|\1|p' changed.txt | LC_ALL=C sort \ + | comm -12 all-nightly.txt - > selected.txt + mv selected.txt all-nightly.txt + fi + fi + runner='/(EmrDockerRunner|EmrClusterShrink)NightlyIntegrationTest$' + if [ "$GROUP" = "docker-runner" ]; then + grep -E "$runner" all-nightly.txt > nightly.txt || true else - grep -v '/EmrClusterShrinkNightlyIntegrationTest$' all-nightly.txt > nightly.txt + grep -vE "$runner" all-nightly.txt > nightly.txt || true fi count=$(wc -l < nightly.txt | tr -d ' ') echo "count=$count" >> "$GITHUB_OUTPUT" diff --git a/src/test/java/io/floci/aws/services/emr/EmrDockerRunnerDockerIntegrationTest.java b/src/test/java/io/floci/aws/services/emr/EmrDockerRunnerNightlyIntegrationTest.java similarity index 98% rename from src/test/java/io/floci/aws/services/emr/EmrDockerRunnerDockerIntegrationTest.java rename to src/test/java/io/floci/aws/services/emr/EmrDockerRunnerNightlyIntegrationTest.java index d38f633741..3e8d1c89cb 100644 --- a/src/test/java/io/floci/aws/services/emr/EmrDockerRunnerDockerIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/emr/EmrDockerRunnerNightlyIntegrationTest.java @@ -24,6 +24,7 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import org.junit.jupiter.api.extension.RegisterExtension; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.regions.Region; @@ -60,10 +61,14 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue; * runner mode runs each step, and an application each job run, in a container of the release's EMR Serverless image, * which reaches Floci's S3 and Glue from there, a job run's executors each in a container of their own, as the profile sets. The cached {@code emr-7.5.0} image keeps a local run from pulling; * CI pulls it (3.5 GB) the first time. + * + *

A nightly check: it pulls a 3.5 GB image and runs for over ten minutes, about half of a pull request shard, so + * it runs with {@code -Dnightly.checks.enabled=true}. */ @QuarkusTest @TestProfile(CloudFormationSettingsProfile.class) -class EmrDockerRunnerDockerIntegrationTest { +@EnabledIfSystemProperty(named = "nightly.checks.enabled", matches = "true") +class EmrDockerRunnerNightlyIntegrationTest { private static final ObjectMapper JSON = new ObjectMapper(); private static final String REGION = "us-east-1"; diff --git a/src/test/java/io/floci/aws/services/emr/EmrHiveStepsNightlyIntegrationTest.java b/src/test/java/io/floci/aws/services/emr/EmrHiveStepsNightlyIntegrationTest.java index 78ce77af1d..499a07e418 100644 --- a/src/test/java/io/floci/aws/services/emr/EmrHiveStepsNightlyIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/emr/EmrHiveStepsNightlyIntegrationTest.java @@ -149,7 +149,7 @@ class EmrHiveStepsNightlyIntegrationTest { // A query that groups its rows through a shuffle, its tasks giving the hosts they ran on: the primary node, // whose NodeManager runs them on a cluster without core nodes, not the step's container. Core and task nodes - // running a job's containers are EmrDockerRunnerDockerIntegrationTest's, as a cluster with Hive starts slower. + // running a job's containers are EmrDockerRunnerNightlyIntegrationTest's, as a cluster with Hive starts slower. assertEquals("COMPLETED", hiveStep("-e", "create external table kv (k string, v int) row format delimited" + " fields terminated by ',' location '" + s3Uri("data/rows/") + "';" + " insert overwrite directory '" + s3Uri("out/tez/") + "' row format delimited fields terminated" diff --git a/src/test/java/io/floci/aws/testing/CloudFormationSettingsProfile.java b/src/test/java/io/floci/aws/testing/CloudFormationSettingsProfile.java index 699f43a1a1..361838e9ae 100644 --- a/src/test/java/io/floci/aws/testing/CloudFormationSettingsProfile.java +++ b/src/test/java/io/floci/aws/testing/CloudFormationSettingsProfile.java @@ -35,7 +35,7 @@ import java.util.Map; * {@code floci.services.emrserverless.runner-mode=docker} run a cluster's steps and an EMR * Serverless application's job runs in containers of the release's image, and * {@code floci.services.emrserverless.executor-containers=2} a Spark job run's executors each in a - * container of its own. {@code EmrDockerRunnerDockerIntegrationTest}, + * container of its own. {@code EmrDockerRunnerNightlyIntegrationTest}, * {@code EmrServerlessHiveDockerIntegrationTest} and the EMR nightly checks rely on them. *

  • {@code floci.services.cloudfront.enabled=false} turns CloudFront off. * {@code CloudFrontDisabledServingTest} relies on it.