Skip to content

Commit

Permalink
Merge pull request #50 from invenia/fix-describe-log-streams
Browse files Browse the repository at this point in the history
Fix describe_log_streams error
  • Loading branch information
mattBrzezinski committed Apr 6, 2023
2 parents 454d857 + 1b3f458 commit 5d6dcfb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/stream.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ end
function describe_log_streams(
config::AWSConfig, log_group_name::AbstractString, params::AbstractDict
)
return CloudWatch_Logs.describe_log_streams(log_group_name, params; aws_config=config)
full_params = Dict{String,Any}("logGroupName" => log_group_name)
merge!(full_params, params)
return CloudWatch_Logs.describe_log_streams(full_params; aws_config=config)
end

"""
Expand Down
38 changes: 27 additions & 11 deletions test/online.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
@test create_stream(CFG, TEST_LOG_GROUP, stream_name) == stream_name

response = CloudWatch_Logs.describe_log_streams(
TEST_LOG_GROUP,
Dict(
"logGroupName" => TEST_LOG_GROUP,
"logStreamNamePrefix" => stream_name,
"limit" => 1,
"orderBy" => "LogStreamName",
Expand All @@ -129,8 +129,8 @@
delete_stream(CFG, TEST_LOG_GROUP, stream_name)

response = CloudWatch_Logs.describe_log_streams(
TEST_LOG_GROUP,
Dict(
"logGroupName" => TEST_LOG_GROUP,
"logStreamNamePrefix" => stream_name,
"limit" => 1,
"orderBy" => "LogStreamName",
Expand All @@ -145,8 +145,8 @@
stream_name = create_stream(CFG, TEST_LOG_GROUP)

response = CloudWatch_Logs.describe_log_streams(
TEST_LOG_GROUP,
Dict(
"logGroupName" => TEST_LOG_GROUP,
"logStreamNamePrefix" => stream_name,
"limit" => 1,
"orderBy" => "LogStreamName",
Expand All @@ -160,8 +160,8 @@
delete_stream(CFG, TEST_LOG_GROUP, stream_name)

response = CloudWatch_Logs.describe_log_streams(
TEST_LOG_GROUP,
Dict(
"logGroupName" => TEST_LOG_GROUP,
"logStreamNamePrefix" => stream_name,
"limit" => 1,
"orderBy" => "LogStreamName",
Expand Down Expand Up @@ -192,7 +192,8 @@

sleep(2) # wait until AWS has injested the logs; this may or may not be enough
response = CloudWatch_Logs.get_log_events(
TEST_LOG_GROUP, stream_name, Dict("startFromHead" => true)
stream_name,
Dict("logGroupName" => TEST_LOG_GROUP, "startFromHead" => true),
)

time_range = (start_time - 10):(CloudWatchLogs.unix_timestamp_ms() + 10)
Expand Down Expand Up @@ -302,7 +303,8 @@

sleep(5) # wait until AWS has injested the logs; this may or may not be enough
response = CloudWatch_Logs.get_log_events(
TEST_LOG_GROUP, stream_name, Dict("startFromHead" => true)
stream_name,
Dict("logGroupName" => TEST_LOG_GROUP, "startFromHead" => true),
)

@test length(response["events"]) == 3
Expand Down Expand Up @@ -370,7 +372,8 @@

sleep(1) # wait until AWS has injested the logs; this may or may not be enough
response = CloudWatch_Logs.get_log_events(
TEST_LOG_GROUP, stream_name, Dict("startFromHead" => true)
stream_name,
Dict("logGroupName" => TEST_LOG_GROUP, "startFromHead" => true),
)

time_range = (start_time - 10):(CloudWatchLogs.unix_timestamp_ms() + 10)
Expand Down Expand Up @@ -414,7 +417,9 @@

# wait for the logs to be submitted and for AWS to injest them
sleep(10)
response = CloudWatch_Logs.get_log_events(TEST_LOG_GROUP, stream_name)
response = CloudWatch_Logs.get_log_events(
stream_name, Dict("logGroupName" => TEST_LOG_GROUP)
)
prev_token = ""
num_events_injested = 0
while prev_token != response["nextBackwardToken"]
Expand All @@ -423,7 +428,8 @@
num_events_injested += length(response["events"])

response = CloudWatch_Logs.get_log_events(
TEST_LOG_GROUP, stream_name, Dict("nextToken" => prev_token)
stream_name,
Dict("logGroupName" => TEST_LOG_GROUP, "nextToken" => prev_token),
)
end
@test num_events_injested == num_events
Expand Down Expand Up @@ -456,7 +462,12 @@

sleep(10) # wait until AWS has injested the logs; this may or may not be enough
response = CloudWatch_Logs.get_log_events(
TEST_LOG_GROUP, stream_name, Dict("startFromHead" => true, "limit" => 1)
stream_name,
Dict(
"logGroupName" => TEST_LOG_GROUP,
"startFromHead" => true,
"limit" => 1,
),
)

@test length(response["events"]) == 1
Expand All @@ -465,7 +476,12 @@

sleep(10) # wait until AWS has injested the logs; this may or may not be enough
response = CloudWatch_Logs.get_log_events(
TEST_LOG_GROUP, stream_name, Dict("startFromHead" => false, "limit" => 1)
stream_name,
Dict(
"logGroupName" => TEST_LOG_GROUP,
"startFromHead" => false,
"limit" => 1,
),
)

@test length(response["events"]) == 1
Expand Down

2 comments on commit 5d6dcfb

@mattBrzezinski
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/81153

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.2.0 -m "<description of version>" 5d6dcfbcba3466a2be0b29c6fbab3de76a0cfe56
git push origin v2.2.0

Please sign in to comment.