Skip to content

Commit

Permalink
Updated the input s3 plugin unit tests to reflect the new changes to …
Browse files Browse the repository at this point in the history
…test multiple s3 bucket names and queue url override for sqs

Signed-off-by: abdullahzen <[email protected]>
  • Loading branch information
abdullahzen committed Dec 24, 2020
1 parent 5cd9607 commit 54e7b79
Showing 1 changed file with 76 additions and 5 deletions.
81 changes: 76 additions & 5 deletions test/test_in_s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setup
CONFIG = %[
aws_key_id test_key_id
aws_sec_key test_sec_key
s3_bucket test_bucket
s3_buckets test_bucket
buffer_type memory
<sqs>
queue_name test_queue
Expand All @@ -47,7 +47,7 @@ def test_default
actual = {
aws_key_id: d.instance.aws_key_id,
aws_sec_key: d.instance.aws_sec_key,
s3_bucket: d.instance.s3_bucket,
s3_buckets: d.instance.s3_buckets,
s3_region: d.instance.s3_region,
sqs_queue_name: d.instance.sqs.queue_name,
extractor_ext: extractor.ext,
Expand All @@ -56,7 +56,7 @@ def test_default
expected = {
aws_key_id: "test_key_id",
aws_sec_key: "test_sec_key",
s3_bucket: "test_bucket",
s3_buckets: "test_bucket",
s3_region: "us-east-1",
sqs_queue_name: "test_queue",
extractor_ext: "gz",
Expand All @@ -65,6 +65,77 @@ def test_default
assert_equal(expected, actual)
end

def test_with_multiple_buckets
conf = %[
aws_key_id test_key_id
aws_sec_key test_sec_key
s3_buckets test_bucket1,test_bucket2
buffer_type memory
<sqs>
queue_name test_queue
queue_owner_aws_account_id 123456789123
</sqs>
]
d = create_driver(conf)
extractor = d.instance.instance_variable_get(:@extractor)
actual = {
aws_key_id: d.instance.aws_key_id,
aws_sec_key: d.instance.aws_sec_key,
s3_buckets: d.instance.s3_buckets,
s3_region: d.instance.s3_region,
sqs_queue_name: d.instance.sqs.queue_name,
extractor_ext: extractor.ext,
extractor_content_type: extractor.content_type
}
expected = {
aws_key_id: "test_key_id",
aws_sec_key: "test_sec_key",
s3_buckets: "test_bucket1,test_bucket2",
s3_region: "us-east-1",
sqs_queue_name: "test_queue",
extractor_ext: "gz",
extractor_content_type: "application/x-gzip"
}
assert_equal(expected, actual)
end

def test_with_multiple_buckets_and_sqs_queue_url_override
conf = %[
aws_key_id test_key_id
aws_sec_key test_sec_key
s3_buckets test_bucket1,test_bucket2
buffer_type memory
<sqs>
queue_name test_queue
queue_owner_aws_account_id 123456789123
queue_url https://sqs.us-east-1.amazonaws.com/345678912345/test_override_queue
</sqs>
]
d = create_driver(conf)
extractor = d.instance.instance_variable_get(:@extractor)
actual = {
aws_key_id: d.instance.aws_key_id,
aws_sec_key: d.instance.aws_sec_key,
s3_buckets: d.instance.s3_buckets,
s3_region: d.instance.s3_region,
sqs_queue_name: d.instance.sqs.queue_name,
extractor_ext: extractor.ext,
extractor_content_type: extractor.content_type,
sqs_queue_url: d.instance.sqs.queue_url
}
expected = {
aws_key_id: "test_key_id",
aws_sec_key: "test_sec_key",
s3_buckets: "test_bucket1,test_bucket2",
s3_region: "us-east-1",
sqs_queue_name: "test_queue",
extractor_ext: "gz",
extractor_content_type: "application/x-gzip",
sqs_queue_url: "https://sqs.us-east-1.amazonaws.com/345678912345/test_override_queue"
}
assert_equal(expected, actual)
end

def test_empty
assert_raise(Fluent::ConfigError) do
create_driver("")
Expand All @@ -75,7 +146,7 @@ def test_without_sqs_section
conf = %[
aws_key_id test_key_id
aws_sec_key test_sec_key
s3_bucket test_bucket
s3_buckets test_bucket
]
assert_raise_message("'<sqs>' sections are required") do
create_driver(conf)
Expand Down Expand Up @@ -137,7 +208,7 @@ def test_sqs_endpoint_with_invalid_endpoint(endpoint)
conf = <<"EOS"
aws_key_id test_key_id
aws_sec_key test_sec_key
s3_bucket test_bucket
s3_buckets test_bucket
buffer_type memory
<sqs>
queue_name test_queue
Expand Down

0 comments on commit 54e7b79

Please sign in to comment.