mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(pipes): validate ParallelizationFactor on Kinesis and DynamoDB sources (#3192)
* feat(pipes): validate ParallelizationFactor on Kinesis and DynamoDB sources SourceParameters is stored as an opaque JsonNode, so ParallelizationFactor already round-tripped through CreatePipe, UpdatePipe and DescribePipe with no bounds applied at all. Apply the AWS constraints in validateSourceConfiguration, which both the create and update paths already run: - reject the field on a source its parameter block does not describe, for example KinesisStreamParameters.ParallelizationFactor on an SQS source - require a numeric, then an integral value - require a value in [1, 10], reported with the offending value The tiering and message shape follow LambdaService.parseScalingConfig, which applies the equivalent MaximumConcurrency bounds for SQS event source mappings. The value is persisted and returned on the wire but not yet enforced: the poller opens an iterator on a single hardcoded shard and delivers one batch at a time, so there is no per-shard concurrency to scale. Record that on both iterator initializers and in an enforcement-status note in the docs, matching how ScalingConfig documents the same gap for Lambda. * fix(pipes): reject a ParallelizationFactor wider than an int asLong hands back the low 64 bits of a BigInteger, so a value such as 2^64 + 5 read as 5 and passed the [1, 10] bounds check: CreatePipe accepted it over raw HTTP and persisted the original digits. Gate the bounds on canConvertToInt and report the value with asText, so an oversized literal is rejected and named in full. Real AWS rejects it too, the field being an int32. Also correct the docs: ListPipes returns pipe summaries and omits SourceParameters entirely, so only DescribePipe echoes the factor back.
This commit is contained in:
1 parent
5864b013d2
commit
5fd89e27bc
6 files changed
+392
-3
No files matched your search
@@ -28,6 +28,10 @@ class PipesTest {
|
||||
return "arn:aws:sqs:" + REGION + ":" + ACCOUNT_ID + ":" + queueName;
|
||||
}
|
||||
|
||||
private static String kinesisArn(String streamName) {
|
||||
return "arn:aws:kinesis:" + REGION + ":" + ACCOUNT_ID + ":stream/" + streamName;
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
static void setup() {
|
||||
pipes = TestFixtures.pipesClient();
|
||||
@@ -344,4 +348,61 @@ class PipesTest {
|
||||
try { sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(nfTgtUrl).build()); } catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(14)
|
||||
void parallelizationFactorRoundTripsOnKinesisSource() {
|
||||
String pfPipeName = TestFixtures.uniqueName("pipe-pf");
|
||||
String pfStream = TestFixtures.uniqueName("pipe-pf-stream");
|
||||
|
||||
try {
|
||||
pipes.createPipe(CreatePipeRequest.builder()
|
||||
.name(pfPipeName)
|
||||
.source(kinesisArn(pfStream))
|
||||
.target(sqsArn(tgtQueue))
|
||||
.roleArn(ROLE_ARN)
|
||||
.desiredState(RequestedPipeState.STOPPED)
|
||||
.sourceParameters(PipeSourceParameters.builder()
|
||||
.kinesisStreamParameters(PipeSourceKinesisStreamParameters.builder()
|
||||
.startingPosition(KinesisStreamStartPosition.TRIM_HORIZON)
|
||||
.parallelizationFactor(4)
|
||||
.build())
|
||||
.build())
|
||||
.build());
|
||||
|
||||
DescribePipeResponse response = pipes.describePipe(DescribePipeRequest.builder()
|
||||
.name(pfPipeName).build());
|
||||
|
||||
assertThat(response.sourceParameters().kinesisStreamParameters().parallelizationFactor())
|
||||
.isEqualTo(4);
|
||||
} finally {
|
||||
try { pipes.deletePipe(DeletePipeRequest.builder().name(pfPipeName).build()); } catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void parallelizationFactorOutOfRangeIsRejected() {
|
||||
String pfPipeName = TestFixtures.uniqueName("pipe-pf-invalid");
|
||||
String pfStream = TestFixtures.uniqueName("pipe-pf-invalid-stream");
|
||||
|
||||
assertThatThrownBy(() -> pipes.createPipe(CreatePipeRequest.builder()
|
||||
.name(pfPipeName)
|
||||
.source(kinesisArn(pfStream))
|
||||
.target(sqsArn(tgtQueue))
|
||||
.roleArn(ROLE_ARN)
|
||||
.desiredState(RequestedPipeState.STOPPED)
|
||||
.sourceParameters(PipeSourceParameters.builder()
|
||||
.kinesisStreamParameters(PipeSourceKinesisStreamParameters.builder()
|
||||
.startingPosition(KinesisStreamStartPosition.TRIM_HORIZON)
|
||||
.parallelizationFactor(11)
|
||||
.build())
|
||||
.build())
|
||||
.build()))
|
||||
.isInstanceOf(ValidationException.class);
|
||||
|
||||
assertThatThrownBy(() -> pipes.describePipe(DescribePipeRequest.builder()
|
||||
.name(pfPipeName).build()))
|
||||
.isInstanceOf(NotFoundException.class);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user