From b06f5522829057e916f9f7d34d0faae0a98f9533 Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Mon, 28 Oct 2024 08:49:32 +0000 Subject: [PATCH 1/8] Add uuid-runtime to builder image --- scripts/cli/builder/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/cli/builder/Dockerfile b/scripts/cli/builder/Dockerfile index 10445731a1..f4a77dc52e 100644 --- a/scripts/cli/builder/Dockerfile +++ b/scripts/cli/builder/Dockerfile @@ -23,6 +23,7 @@ RUN apt-get update && apt-get install -y \ python3-venv \ zip \ jq \ + uuid-runtime \ sudo \ gcc g++ cmake make \ pkg-config libssl-dev \ From 2e6a1fa59eca443664ef381c14a8eaf30b590627 Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:01:23 +0000 Subject: [PATCH 2/8] Use randomness to avoid naming conflicts between nightly system test runs --- scripts/test/nightly/runTests.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/test/nightly/runTests.sh b/scripts/test/nightly/runTests.sh index 41f8ff39c2..0f9407069d 100755 --- a/scripts/test/nightly/runTests.sh +++ b/scripts/test/nightly/runTests.sh @@ -59,7 +59,10 @@ source "$SCRIPTS_DIR/functions/timeUtils.sh" source "$SCRIPTS_DIR/functions/systemTestUtils.sh" START_TIMESTAMP=$(record_time) START_TIME=$(recorded_time_str "$START_TIMESTAMP" "%Y%m%d-%H%M%S") -START_TIME_SHORT=$(recorded_time_str "$START_TIMESTAMP" "%m%d%H%M") +START_DAY=$(recorded_time_str "$START_TIMESTAMP" "%m%d") +# Use randomness to avoid naming conflicts between test runs +DAY_RUN_ID=$(uuidgen -r | head -c 4) +TEST_RUN_ID="$START_DAY$DAY_RUN_ID" OUTPUT_DIR="/tmp/sleeper/${MAIN_SUITE_NAME}Tests/$START_TIME" mkdir -p "$OUTPUT_DIR" @@ -109,8 +112,8 @@ runMavenSystemTests() { echo -n "$TEST_EXIT_CODE $SHORT_ID" > "$OUTPUT_DIR/$TEST_NAME.status" } -runMavenSystemTests "mvn-$START_TIME_SHORT" $MAIN_SUITE_NAME "${MAIN_SUITE_PARAMS[@]}" -runMavenSystemTests "dyn-$START_TIME_SHORT" $SECONDARY_SUITE_NAME "${SECONDARY_SUITE_PARAMS[@]}" +runMavenSystemTests "mvn-$TEST_RUN_ID" $MAIN_SUITE_NAME "${MAIN_SUITE_PARAMS[@]}" +runMavenSystemTests "dyn-$TEST_RUN_ID" $SECONDARY_SUITE_NAME "${SECONDARY_SUITE_PARAMS[@]}" echo "[$(time_str)] Uploading test output" java -cp "${SYSTEM_TEST_JAR}" \ From 36f083da498cd80a20d4d24ea2efb76e8ca9931b Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Mon, 28 Oct 2024 09:06:38 +0000 Subject: [PATCH 3/8] Add hyphen before randomness --- scripts/test/nightly/runTests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test/nightly/runTests.sh b/scripts/test/nightly/runTests.sh index 0f9407069d..f5573f0802 100755 --- a/scripts/test/nightly/runTests.sh +++ b/scripts/test/nightly/runTests.sh @@ -62,7 +62,7 @@ START_TIME=$(recorded_time_str "$START_TIMESTAMP" "%Y%m%d-%H%M%S") START_DAY=$(recorded_time_str "$START_TIMESTAMP" "%m%d") # Use randomness to avoid naming conflicts between test runs DAY_RUN_ID=$(uuidgen -r | head -c 4) -TEST_RUN_ID="$START_DAY$DAY_RUN_ID" +TEST_RUN_ID="$START_DAY-$DAY_RUN_ID" OUTPUT_DIR="/tmp/sleeper/${MAIN_SUITE_NAME}Tests/$START_TIME" mkdir -p "$OUTPUT_DIR" From e4a650192b1486953b0de7fff8f32520bb60b0ba Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:08:29 +0000 Subject: [PATCH 4/8] Set nightly test deploy ID --- .../cdk/buildec2/BuildEC2Parameters.java | 9 +++++ .../environment/cdk/config/AppParameters.java | 1 + .../main/resources/nightlyTestSettings.json | 1 + .../cdk/buildec2/BuildEC2ParametersTest.java | 35 +++++++++++++++++++ .../cdk/buildec2/LoadUserDataUtilTest.java | 5 +++ scripts/test/nightly/README.md | 2 +- scripts/test/nightly/nightlyTestSettings.json | 1 + scripts/test/nightly/runTests.sh | 24 ++++++------- scripts/test/nightly/updateAndRunTests.sh | 3 +- 9 files changed, 66 insertions(+), 15 deletions(-) diff --git a/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Parameters.java b/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Parameters.java index 360aba6620..6acd6be084 100644 --- a/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Parameters.java +++ b/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Parameters.java @@ -27,6 +27,7 @@ import static java.util.stream.Collectors.toUnmodifiableList; import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_BUCKET; +import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_DEPLOY_ID; import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_RUN_ENABLED; import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_RUN_HOUR_UTC; import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_SUBNETS; @@ -43,6 +44,7 @@ public class BuildEC2Parameters { private final String branch; private final BuildEC2Image image; private final boolean nightlyTestEnabled; + private final String nightlyTestDeployId; private final String testHour; private final String testBucket; private final String vpc; @@ -56,6 +58,11 @@ private BuildEC2Parameters(Builder builder) { image = BuildEC2Image.from(context); nightlyTestEnabled = context.get(NIGHTLY_TEST_RUN_ENABLED); if (nightlyTestEnabled) { + nightlyTestDeployId = context.get(NIGHTLY_TEST_DEPLOY_ID) + .orElseThrow(() -> new IllegalArgumentException("Nightly test deploy ID must be set (up to 2 characters)")); + if (nightlyTestDeployId.length() > 2) { + throw new IllegalArgumentException("Nightly test deploy ID must be at most 2 characters long"); + } testHour = "" + context.get(NIGHTLY_TEST_RUN_HOUR_UTC); testBucket = context.get(NIGHTLY_TEST_BUCKET) .orElseGet(() -> Objects.requireNonNull(builder.testBucket, "testBucket must not be null")); @@ -66,6 +73,7 @@ private BuildEC2Parameters(Builder builder) { } subnets = String.join(",", subnetsList); } else { + nightlyTestDeployId = null; testHour = null; testBucket = null; vpc = null; @@ -95,6 +103,7 @@ String fillUserDataTemplate(String template) { return noNightlyTests; } return noNightlyTests + .replace("${deployId}", nightlyTestDeployId) .replace("${testHour}", testHour) .replace("${testBucket}", testBucket) .replace("${vpc}", vpc) diff --git a/java/cdk-environment/src/main/java/sleeper/environment/cdk/config/AppParameters.java b/java/cdk-environment/src/main/java/sleeper/environment/cdk/config/AppParameters.java index 71baa2d9b6..4e7d4b6f1a 100644 --- a/java/cdk-environment/src/main/java/sleeper/environment/cdk/config/AppParameters.java +++ b/java/cdk-environment/src/main/java/sleeper/environment/cdk/config/AppParameters.java @@ -39,6 +39,7 @@ private AppParameters() { public static final StringListParameter AUTO_SHUTDOWN_EXISTING_EC2_IDS = StringListParameter.key("autoShutdownExistingEc2Ids"); public static final IntParameter AUTO_SHUTDOWN_HOUR_UTC = IntParameter.keyAndDefault("autoShutdownHourUtc", 19); public static final BooleanParameter NIGHTLY_TEST_RUN_ENABLED = BooleanParameter.keyAndDefault("nightlyTestsEnabled", false); + public static final OptionalStringParameter NIGHTLY_TEST_DEPLOY_ID = OptionalStringParameter.key("nightlyTestDeployId"); public static final IntParameter NIGHTLY_TEST_RUN_HOUR_UTC = IntParameter.keyAndDefault("nightlyTestHourUtc", 3); public static final OptionalStringParameter NIGHTLY_TEST_BUCKET = OptionalStringParameter.key("nightlyTestBucket"); public static final StringListParameter NIGHTLY_TEST_SUBNETS = StringListParameter.key("subnetIds"); diff --git a/java/cdk-environment/src/main/resources/nightlyTestSettings.json b/java/cdk-environment/src/main/resources/nightlyTestSettings.json index 444c280a0d..a11ba14252 100644 --- a/java/cdk-environment/src/main/resources/nightlyTestSettings.json +++ b/java/cdk-environment/src/main/resources/nightlyTestSettings.json @@ -1,4 +1,5 @@ { + "deployId": "${deployId}", "vpc": "${vpc}", "subnets": "${subnets}", "resultsBucket": "${testBucket}", diff --git a/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/BuildEC2ParametersTest.java b/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/BuildEC2ParametersTest.java index 21e5b91a33..907ec039fb 100644 --- a/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/BuildEC2ParametersTest.java +++ b/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/BuildEC2ParametersTest.java @@ -20,10 +20,12 @@ import sleeper.environment.cdk.config.AppContext; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static sleeper.environment.cdk.buildec2.BuildEC2Image.LOGIN_USER; import static sleeper.environment.cdk.buildec2.BuildEC2Parameters.BRANCH; import static sleeper.environment.cdk.buildec2.BuildEC2Parameters.FORK; import static sleeper.environment.cdk.buildec2.BuildEC2Parameters.REPOSITORY; +import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_DEPLOY_ID; import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_RUN_ENABLED; import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_SUBNETS; import static sleeper.environment.cdk.config.AppParameters.VPC_ID; @@ -73,17 +75,20 @@ void shouldFillNightlyTestSettings() { assertThat(BuildEC2Parameters.builder() .context(AppContext.of( NIGHTLY_TEST_RUN_ENABLED.value(true), + NIGHTLY_TEST_DEPLOY_ID.value("mt"), VPC_ID.value("my-vpc"), NIGHTLY_TEST_SUBNETS.value("subnet-1,subnet-2"), FORK.value("my-fork"), REPOSITORY.value("my-repo"))) .testBucket("nightly-test-results") .build().fillUserDataTemplate("{" + + "\"deployId\": \"${deployId}\"," + "\"vpc\":\"${vpc}\"," + "\"subnets\":\"${subnets}\"," + "\"resultsBucket\":\"${testBucket}\"," + "\"repoPath\":\"${fork}/${repository}\"}")) .isEqualTo("{" + + "\"deployId\": \"mt\"," + "\"vpc\":\"my-vpc\"," + "\"subnets\":\"subnet-1,subnet-2\"," + "\"resultsBucket\":\"nightly-test-results\"," + @@ -96,15 +101,45 @@ void shouldFillNoNightlyTestSettings() { .context(AppContext.empty()) .testBucket(null) .build().fillUserDataTemplate("{" + + "\"deployId\": \"${deployId}\"," + "\"vpc\":\"${vpc}\"," + "\"subnets\":\"${subnets}\"," + "\"resultsBucket\":\"${testBucket}\"," + "\"repoPath\":\"${fork}/${repository}\"}")) .isEqualTo("{" + + "\"deployId\": \"${deployId}\"," + "\"vpc\":\"${vpc}\"," + "\"subnets\":\"${subnets}\"," + "\"resultsBucket\":\"${testBucket}\"," + "\"repoPath\":\"gchq/sleeper\"}"); } + @Test + void shouldRefuseTooLongNightlyTestDeployId() { + AppContext context = AppContext.of( + NIGHTLY_TEST_RUN_ENABLED.value(true), + NIGHTLY_TEST_DEPLOY_ID.value("abc"), + VPC_ID.value("my-vpc"), + NIGHTLY_TEST_SUBNETS.value("subnet-1,subnet-2"), + FORK.value("my-fork"), + REPOSITORY.value("my-repo")); + + assertThatThrownBy(() -> BuildEC2Parameters.from(context)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Nightly test deploy ID must be at most 2 characters long"); + } + + @Test + void shouldRefuseNoNightlyTestDeployId() { + AppContext context = AppContext.of( + NIGHTLY_TEST_RUN_ENABLED.value(true), + VPC_ID.value("my-vpc"), + NIGHTLY_TEST_SUBNETS.value("subnet-1,subnet-2"), + FORK.value("my-fork"), + REPOSITORY.value("my-repo")); + + assertThatThrownBy(() -> BuildEC2Parameters.from(context)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("Nightly test deploy ID must be set (up to 2 characters)"); + } } diff --git a/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/LoadUserDataUtilTest.java b/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/LoadUserDataUtilTest.java index 42428e2ee1..127891b96c 100644 --- a/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/LoadUserDataUtilTest.java +++ b/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/LoadUserDataUtilTest.java @@ -25,6 +25,7 @@ import static sleeper.environment.cdk.buildec2.BuildEC2Parameters.FORK; import static sleeper.environment.cdk.buildec2.BuildEC2Parameters.REPOSITORY; import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_BUCKET; +import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_DEPLOY_ID; import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_RUN_ENABLED; import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_RUN_HOUR_UTC; import static sleeper.environment.cdk.config.AppParameters.NIGHTLY_TEST_SUBNETS; @@ -55,6 +56,7 @@ void shouldLoadUserDataWithNightlyTests() { FORK.value("a-fork"), BRANCH.value("feature/something"), NIGHTLY_TEST_RUN_ENABLED.value(true), + NIGHTLY_TEST_DEPLOY_ID.value("mt"), VPC_ID.value("my-vpc"), NIGHTLY_TEST_SUBNETS.value("subnet-1", "subnet-2"), NIGHTLY_TEST_BUCKET.value("my-bucket"))))) @@ -70,11 +72,13 @@ void shouldLoadUserDataWithNightlyTests() { void shouldLoadNightlyTestSettings() { assertThat(LoadUserDataUtil.nightlyTestSettingsJson(BuildEC2Parameters.from(AppContext.of( NIGHTLY_TEST_RUN_ENABLED.value(true), + NIGHTLY_TEST_DEPLOY_ID.value("mt"), VPC_ID.value("my-vpc"), NIGHTLY_TEST_SUBNETS.value("subnet-1", "subnet-2"), NIGHTLY_TEST_BUCKET.value("my-bucket"), FORK.value("my-fork"), REPOSITORY.value("my-repo"))))) + .contains("\"deployId\": \"mt\"") .contains("\"vpc\": \"my-vpc\"") .contains("\"subnets\": \"subnet-1,subnet-2\"") .contains("\"repoPath\": \"my-fork/my-repo\"") @@ -85,6 +89,7 @@ void shouldLoadNightlyTestSettings() { void shouldLoadCrontab() { assertThat(LoadUserDataUtil.crontab(BuildEC2Parameters.from(AppContext.of( NIGHTLY_TEST_RUN_ENABLED.value(true), + NIGHTLY_TEST_DEPLOY_ID.value("mt"), NIGHTLY_TEST_RUN_HOUR_UTC.value(3), LOGIN_USER.value("my-user"), VPC_ID.value("my-vpc"), diff --git a/scripts/test/nightly/README.md b/scripts/test/nightly/README.md index 927e2288dd..b116ccb31f 100644 --- a/scripts/test/nightly/README.md +++ b/scripts/test/nightly/README.md @@ -29,7 +29,7 @@ cp /sleeper-builder/sleeper/scripts/test/nightly/nightlyTestSettings.json /sleep vim nightlyTestSettings.json ``` -You'll need to set a VPC, subnets, results S3 bucket and a path to your fork in GitHub. +You'll need to set a deployment ID, a VPC, subnets, a results S3 bucket and a path to your fork in GitHub. #### Automatic merge to main diff --git a/scripts/test/nightly/nightlyTestSettings.json b/scripts/test/nightly/nightlyTestSettings.json index 1f971d8dc1..8cbd20b2f1 100644 --- a/scripts/test/nightly/nightlyTestSettings.json +++ b/scripts/test/nightly/nightlyTestSettings.json @@ -1,4 +1,5 @@ { + "deployId": "my deployment ID (up to 2 characters to distinguish these tests from others running simultaneously)", "vpc": "my VPC ID", "subnets": "comma separated list of my subnet IDs", "resultsBucket": "S3 bucket name", diff --git a/scripts/test/nightly/runTests.sh b/scripts/test/nightly/runTests.sh index f5573f0802..5406eb30da 100755 --- a/scripts/test/nightly/runTests.sh +++ b/scripts/test/nightly/runTests.sh @@ -22,17 +22,18 @@ MAVEN_DIR=$(cd "$SCRIPTS_DIR" && cd ../java && pwd) pushd "$SCRIPTS_DIR/test" -if [ "$#" -lt 3 ]; then - echo "Usage: $0 " +if [ "$#" -lt 4 ]; then + echo "Usage: $0 " echo "Valid test types are: performance, functional" exit 1 fi -VPC=$1 -SUBNETS=$2 -RESULTS_BUCKET=$3 -MAIN_SUITE_NAME=$4 -shift 3 +DEPLOY_ID=$1 +VPC=$2 +SUBNETS=$3 +RESULTS_BUCKET=$4 +MAIN_SUITE_NAME=$5 +shift 4 if [ "$MAIN_SUITE_NAME" == "performance" ]; then shift MAIN_SUITE_PARAMS=(-Dsleeper.system.test.cluster.enabled=true -DrunIT=NightlyPerformanceSystemTestSuite "$@") @@ -59,10 +60,7 @@ source "$SCRIPTS_DIR/functions/timeUtils.sh" source "$SCRIPTS_DIR/functions/systemTestUtils.sh" START_TIMESTAMP=$(record_time) START_TIME=$(recorded_time_str "$START_TIMESTAMP" "%Y%m%d-%H%M%S") -START_DAY=$(recorded_time_str "$START_TIMESTAMP" "%m%d") -# Use randomness to avoid naming conflicts between test runs -DAY_RUN_ID=$(uuidgen -r | head -c 4) -TEST_RUN_ID="$START_DAY-$DAY_RUN_ID" +START_TIME_SHORT=$(recorded_time_str "$START_TIMESTAMP" "%m%d%H%M") OUTPUT_DIR="/tmp/sleeper/${MAIN_SUITE_NAME}Tests/$START_TIME" mkdir -p "$OUTPUT_DIR" @@ -112,8 +110,8 @@ runMavenSystemTests() { echo -n "$TEST_EXIT_CODE $SHORT_ID" > "$OUTPUT_DIR/$TEST_NAME.status" } -runMavenSystemTests "mvn-$TEST_RUN_ID" $MAIN_SUITE_NAME "${MAIN_SUITE_PARAMS[@]}" -runMavenSystemTests "dyn-$TEST_RUN_ID" $SECONDARY_SUITE_NAME "${SECONDARY_SUITE_PARAMS[@]}" +runMavenSystemTests "${DEPLOY_ID}mvn${START_TIME_SHORT}" $MAIN_SUITE_NAME "${MAIN_SUITE_PARAMS[@]}" +runMavenSystemTests "${DEPLOY_ID}dyn${START_TIME_SHORT}" $SECONDARY_SUITE_NAME "${SECONDARY_SUITE_PARAMS[@]}" echo "[$(time_str)] Uploading test output" java -cp "${SYSTEM_TEST_JAR}" \ diff --git a/scripts/test/nightly/updateAndRunTests.sh b/scripts/test/nightly/updateAndRunTests.sh index ef696cfe66..17f8a8f8b4 100755 --- a/scripts/test/nightly/updateAndRunTests.sh +++ b/scripts/test/nightly/updateAndRunTests.sh @@ -28,6 +28,7 @@ fi SETTINGS_FILE=$1 TEST_TYPE=$2 +DEPLOY_ID=$(jq ".deployId" "$SETTINGS_FILE" --raw-output) VPC=$(jq ".vpc" "$SETTINGS_FILE" --raw-output) SUBNETS=$(jq ".subnets" "$SETTINGS_FILE" --raw-output) RESULTS_BUCKET=$(jq ".resultsBucket" "$SETTINGS_FILE" --raw-output) @@ -41,7 +42,7 @@ git fetch git switch --discard-changes -C develop origin/develop set +e -./runTests.sh "$VPC" "$SUBNETS" "$RESULTS_BUCKET" "$TEST_TYPE" +./runTests.sh "$DEPLOY_ID" "$VPC" "$SUBNETS" "$RESULTS_BUCKET" "$TEST_TYPE" EXIT_CODE=$? set -e From c0d55489fa9de9dd3d6a61f8352fcc6ade235eff Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:14:18 +0000 Subject: [PATCH 5/8] Include parameter name in error message --- .../sleeper/environment/cdk/buildec2/BuildEC2Parameters.java | 4 ++-- .../environment/cdk/buildec2/BuildEC2ParametersTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Parameters.java b/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Parameters.java index 6acd6be084..03a4fa616e 100644 --- a/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Parameters.java +++ b/java/cdk-environment/src/main/java/sleeper/environment/cdk/buildec2/BuildEC2Parameters.java @@ -59,9 +59,9 @@ private BuildEC2Parameters(Builder builder) { nightlyTestEnabled = context.get(NIGHTLY_TEST_RUN_ENABLED); if (nightlyTestEnabled) { nightlyTestDeployId = context.get(NIGHTLY_TEST_DEPLOY_ID) - .orElseThrow(() -> new IllegalArgumentException("Nightly test deploy ID must be set (up to 2 characters)")); + .orElseThrow(() -> new IllegalArgumentException("nightlyTestDeployId must be set (up to 2 characters)")); if (nightlyTestDeployId.length() > 2) { - throw new IllegalArgumentException("Nightly test deploy ID must be at most 2 characters long"); + throw new IllegalArgumentException("nightlyTestDeployId must be at most 2 characters long"); } testHour = "" + context.get(NIGHTLY_TEST_RUN_HOUR_UTC); testBucket = context.get(NIGHTLY_TEST_BUCKET) diff --git a/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/BuildEC2ParametersTest.java b/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/BuildEC2ParametersTest.java index 907ec039fb..fafd69e5cc 100644 --- a/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/BuildEC2ParametersTest.java +++ b/java/cdk-environment/src/test/java/sleeper/environment/cdk/buildec2/BuildEC2ParametersTest.java @@ -126,7 +126,7 @@ void shouldRefuseTooLongNightlyTestDeployId() { assertThatThrownBy(() -> BuildEC2Parameters.from(context)) .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Nightly test deploy ID must be at most 2 characters long"); + .hasMessage("nightlyTestDeployId must be at most 2 characters long"); } @Test @@ -140,6 +140,6 @@ void shouldRefuseNoNightlyTestDeployId() { assertThatThrownBy(() -> BuildEC2Parameters.from(context)) .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Nightly test deploy ID must be set (up to 2 characters)"); + .hasMessage("nightlyTestDeployId must be set (up to 2 characters)"); } } From f25f9879cda8c07ae7e480168fa22de1bd270536 Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:26:04 +0000 Subject: [PATCH 6/8] Validate short test ID in SystemTestParameters --- .../sleeper/systemtest/dsl/instance/SystemTestParameters.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestParameters.java b/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestParameters.java index cc857ce565..80e20d4908 100644 --- a/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestParameters.java +++ b/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestParameters.java @@ -78,6 +78,9 @@ private SystemTestParameters(Builder builder) { forceStateStoreClassname = builder.forceStateStoreClassname; standalonePropertiesTemplate = Objects.requireNonNull(builder.standalonePropertiesTemplate, "standalonePropertiesTemplate must not be null"); instancePropertiesOverrides = Objects.requireNonNull(builder.instancePropertiesOverrides, "instancePropertiesOverrides must not be null"); + if (shortTestId.length() > 13) { + throw new IllegalArgumentException("shortTestId is too long, must be at most 13 characters: " + shortTestId); + } } public static Builder builder() { From 96297259c60ad242da9f2e80ec573bd4c68d0d07 Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:27:30 +0000 Subject: [PATCH 7/8] Comment explaining instance ID validation --- .../systemtest/dsl/instance/SystemTestInstanceConfiguration.java | 1 + .../sleeper/systemtest/dsl/instance/SystemTestParameters.java | 1 + 2 files changed, 2 insertions(+) diff --git a/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestInstanceConfiguration.java b/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestInstanceConfiguration.java index a9e9d12183..8d17579d78 100644 --- a/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestInstanceConfiguration.java +++ b/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestInstanceConfiguration.java @@ -34,6 +34,7 @@ private SystemTestInstanceConfiguration(Builder builder) { deployConfig = builder.deployConfig; useSystemTestIngestSourceBucket = builder.useSystemTestIngestSourceBucket; disableTransactionLogSnapshots = builder.disableTransactionLogSnapshots; + // Combines with SystemTestParameters.shortTestId to create an instance ID within maximum length if (shortName.length() > 7) { throw new IllegalArgumentException("Instance shortName must not be longer than 7 characters"); } diff --git a/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestParameters.java b/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestParameters.java index 80e20d4908..a0c72d7841 100644 --- a/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestParameters.java +++ b/java/system-test/system-test-dsl/src/main/java/sleeper/systemtest/dsl/instance/SystemTestParameters.java @@ -78,6 +78,7 @@ private SystemTestParameters(Builder builder) { forceStateStoreClassname = builder.forceStateStoreClassname; standalonePropertiesTemplate = Objects.requireNonNull(builder.standalonePropertiesTemplate, "standalonePropertiesTemplate must not be null"); instancePropertiesOverrides = Objects.requireNonNull(builder.instancePropertiesOverrides, "instancePropertiesOverrides must not be null"); + // Combines with SystemTestInstanceConfiguration.shortName to create an instance ID within maximum length if (shortTestId.length() > 13) { throw new IllegalArgumentException("shortTestId is too long, must be at most 13 characters: " + shortTestId); } From 4476a4dfafc28138c3064dbc0b119ffbe012c79c Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:36:46 +0000 Subject: [PATCH 8/8] Add more information about deployment ID to documentation --- scripts/test/nightly/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/test/nightly/README.md b/scripts/test/nightly/README.md index b116ccb31f..9f84bc4df5 100644 --- a/scripts/test/nightly/README.md +++ b/scripts/test/nightly/README.md @@ -29,7 +29,8 @@ cp /sleeper-builder/sleeper/scripts/test/nightly/nightlyTestSettings.json /sleep vim nightlyTestSettings.json ``` -You'll need to set a deployment ID, a VPC, subnets, a results S3 bucket and a path to your fork in GitHub. +You'll need to set a deployment ID, a VPC, subnets, a results S3 bucket and a path to your fork in GitHub. The +deployment ID is at most 2 characters, to avoid S3 naming conflicts between your deployment and any others. #### Automatic merge to main