nextToken value in logs:describeLogStreams response (#3896)
* `nextToken` value in `logs:describeLogStreams` response Modified the pagination for FilterLogEvents to more closely follow the real AWS behaviour. * Make assertions work in py2 and py3.
This commit is contained in:
parent
6657b6db3e
commit
94a70e9ad1
2 changed files with 84 additions and 7 deletions
|
|
@ -554,3 +554,60 @@ def test_describe_log_groups_paging():
|
|||
resp = client.describe_log_groups(nextToken="invalid-token")
|
||||
resp["logGroups"].should.have.length_of(0)
|
||||
resp.should_not.have.key("nextToken")
|
||||
|
||||
|
||||
@mock_logs
|
||||
def test_describe_log_streams_paging():
|
||||
client = boto3.client("logs", "us-east-1")
|
||||
|
||||
log_group_name = "/aws/codebuild/lowercase-dev"
|
||||
stream_names = [
|
||||
"job/214/stage/unit_tests/foo",
|
||||
"job/215/stage/unit_tests/spam",
|
||||
"job/215/stage/e2e_tests/eggs",
|
||||
"job/216/stage/unit_tests/eggs",
|
||||
]
|
||||
|
||||
client.create_log_group(logGroupName=log_group_name)
|
||||
for name in stream_names:
|
||||
client.create_log_stream(logGroupName=log_group_name, logStreamName=name)
|
||||
|
||||
resp = client.describe_log_streams(logGroupName=log_group_name)
|
||||
resp["logStreams"].should.have.length_of(4)
|
||||
resp["logStreams"][0]["arn"].should.contain(log_group_name)
|
||||
resp.should_not.have.key("nextToken")
|
||||
|
||||
resp = client.describe_log_streams(logGroupName=log_group_name, limit=2)
|
||||
resp["logStreams"].should.have.length_of(2)
|
||||
resp["logStreams"][0]["arn"].should.contain(log_group_name)
|
||||
resp["nextToken"].should.equal(
|
||||
u"{}@{}".format(log_group_name, resp["logStreams"][1]["logStreamName"])
|
||||
)
|
||||
|
||||
resp = client.describe_log_streams(
|
||||
logGroupName=log_group_name, nextToken=resp["nextToken"], limit=1
|
||||
)
|
||||
resp["logStreams"].should.have.length_of(1)
|
||||
resp["logStreams"][0]["arn"].should.contain(log_group_name)
|
||||
resp["nextToken"].should.equal(
|
||||
u"{}@{}".format(log_group_name, resp["logStreams"][0]["logStreamName"])
|
||||
)
|
||||
|
||||
resp = client.describe_log_streams(
|
||||
logGroupName=log_group_name, nextToken=resp["nextToken"]
|
||||
)
|
||||
resp["logStreams"].should.have.length_of(1)
|
||||
resp["logStreams"][0]["arn"].should.contain(log_group_name)
|
||||
resp.should_not.have.key("nextToken")
|
||||
|
||||
resp = client.describe_log_streams(
|
||||
logGroupName=log_group_name, nextToken="invalid-token"
|
||||
)
|
||||
resp["logStreams"].should.have.length_of(0)
|
||||
resp.should_not.have.key("nextToken")
|
||||
|
||||
resp = client.describe_log_streams(
|
||||
logGroupName=log_group_name, nextToken="invalid@token"
|
||||
)
|
||||
resp["logStreams"].should.have.length_of(0)
|
||||
resp.should_not.have.key("nextToken")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue