From d4a65d477bf3b57081fc789260d67c768fbd4b48 Mon Sep 17 00:00:00 2001 From: Jackson Price <59149601+jprice8@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:53:05 -0600 Subject: [PATCH] test: scope pagination checks to their fixtures (#7615) Select Application Auto Scaling fixture IDs before pagination, assert both page identities, and exclude an interleaved target. Filter Resource Explorer by the created table ARN before checking its tags. Port the pagination fixture changes from AndreKurait/floci#208 at 004988a7f4dc63cbcf48cde66abbb9b7a7ef1d85. Signed-off-by: Andre Kurait Signed-off-by: Andre Kurait Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com> Co-authored-by: Andre Kurait --- ...ApplicationAutoScalingIntegrationTest.java | 53 ++++++++++++++----- .../ResourceExplorer2IntegrationTest.java | 15 +++--- 2 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/test/java/io/github/hectorvent/floci/services/applicationautoscaling/ApplicationAutoScalingIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/applicationautoscaling/ApplicationAutoScalingIntegrationTest.java index cf91bcec0f..1457b587d1 100644 --- a/src/test/java/io/github/hectorvent/floci/services/applicationautoscaling/ApplicationAutoScalingIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/applicationautoscaling/ApplicationAutoScalingIntegrationTest.java @@ -43,6 +43,7 @@ class ApplicationAutoScalingIntegrationTest { private static final String ALARM_CLUSTER = "aas-it-cluster"; private static final String ALARM_SERVICE = "aas-it-alarm-service"; private static final String DIMENSION = "ecs:service:DesiredCount"; + private static final String EXCLUDED_RESOURCE_ID = "service/aas-it-cluster/aas-it-service-excluded"; private static String scalableTargetArn; @@ -144,20 +145,46 @@ class ApplicationAutoScalingIntegrationTest { """.formatted(PAGED_RESOURCE_ID, DIMENSION)) .when().post("/").then().statusCode(200); - String nextToken = call("DescribeScalableTargets") - .body("{ \"ServiceNamespace\": \"ecs\", \"MaxResults\": 1 }") - .when().post("/") - .then().statusCode(200) - .body("ScalableTargets", hasSize(1)) - .body("NextToken", notNullValue()) - .extract().path("NextToken"); + call("RegisterScalableTarget") + .body(""" + { + "ServiceNamespace": "ecs", + "ResourceId": "%s", + "ScalableDimension": "%s", + "MinCapacity": 1, + "MaxCapacity": 2 + } + """.formatted(EXCLUDED_RESOURCE_ID, DIMENSION)) + .when().post("/").then().statusCode(200); - call("DescribeScalableTargets") - .body("{ \"ServiceNamespace\": \"ecs\", \"MaxResults\": 1, \"NextToken\": \"%s\" }" - .formatted(nextToken)) - .when().post("/").then().statusCode(200) - .body("ScalableTargets", hasSize(1)) - .body("NextToken", nullValue()); + try { + String nextToken = call("DescribeScalableTargets") + .body(""" + { "ServiceNamespace": "ecs", "ResourceIds": ["%s", "%s"], "MaxResults": 1 } + """.formatted(RESOURCE_ID, PAGED_RESOURCE_ID)) + .when().post("/") + .then().statusCode(200) + .body("ScalableTargets", hasSize(1)) + .body("NextToken", notNullValue()) + .body("ScalableTargets[0].ResourceId", equalTo(RESOURCE_ID)) + .extract().path("NextToken"); + + call("DescribeScalableTargets") + .body(""" + { "ServiceNamespace": "ecs", "ResourceIds": ["%s", "%s"], + "MaxResults": 1, "NextToken": "%s" } + """.formatted(RESOURCE_ID, PAGED_RESOURCE_ID, nextToken)) + .when().post("/").then().statusCode(200) + .body("ScalableTargets", hasSize(1)) + .body("ScalableTargets[0].ResourceId", equalTo(PAGED_RESOURCE_ID)) + .body("NextToken", nullValue()); + } finally { + call("DeregisterScalableTarget") + .body(""" + { "ServiceNamespace": "ecs", "ResourceId": "%s", "ScalableDimension": "%s" } + """.formatted(EXCLUDED_RESOURCE_ID, DIMENSION)) + .when().post("/").then().statusCode(200); + } } @Test diff --git a/src/test/java/io/github/hectorvent/floci/services/resourceexplorer2/ResourceExplorer2IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/resourceexplorer2/ResourceExplorer2IntegrationTest.java index dc2c446d99..c5eee34a76 100644 --- a/src/test/java/io/github/hectorvent/floci/services/resourceexplorer2/ResourceExplorer2IntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/resourceexplorer2/ResourceExplorer2IntegrationTest.java @@ -47,6 +47,7 @@ class ResourceExplorer2IntegrationTest { private static final String BOUNDED_SCOPE = "service:s3,dynamodb"; private static boolean fixturesProvisioned = false; + private static String fixtureTableArn; private record IndexRef(String auth, String arn) {} @@ -103,7 +104,7 @@ class ResourceExplorer2IntegrationTest { .statusCode(200); // Create DynamoDB table with tags used by ListResources, DataProvenance, and FilterSemantics groups - given() + fixtureTableArn = given() .header("X-Amz-Target", "DynamoDB_20120810.CreateTable") .contentType(DYNAMO_TYPE) .body(""" @@ -119,7 +120,8 @@ class ResourceExplorer2IntegrationTest { .post("/") .then() .statusCode(200) - .body("TableDescription.TableName", equalTo("re2-test-table")); + .body("TableDescription.TableName", equalTo("re2-test-table")) + .extract().path("TableDescription.TableArn"); // Lambda function (Resource Explorer 2 provider coverage) given() @@ -986,17 +988,12 @@ class ResourceExplorer2IntegrationTest { @Test void propertiesPopulatedWhenViewIncludesTags() { - // Target the known-tagged fixture table by ARN. A positional Resources[0] is - // unsafe: the full test suite shares one emulator instance, so other classes' - // untagged DynamoDB tables land in this same service:dynamodb result set and any - // of them may sort ahead of the tagged fixture. + // Filter before pagination so unrelated tables cannot push the fixture off the first page. String table = "Resources.find { it.Arn.contains('re2-test-table') }"; given() .header("Authorization", AUTH) .contentType("application/json") - .body(""" - {"Filters": {"FilterString": "service:dynamodb"}} - """) + .body(Map.of("Filters", Map.of("FilterString", "id:" + fixtureTableArn))) .when() .post("/ListResources") .then()