Skip to content

Commit

Permalink
feat(#3333): add AWS integration tests
Browse files Browse the repository at this point in the history
* feat(#3333): Add basic structure for AWS tests

* feat(#3335): Cloudtrail integration tests (#3624)

* feat(#3335): add basic test for aws cloudtrail module

* feat(#3335): add utils for handle files in S3 buckets

* feat(#3335): add remove_from_bucket test for aws cloudtrail module

* feat(#3335): add fixture for delete s3_cloudtrail.db

* refactor(#3335): rename modules

* refactor(#3335): change the return of upload_file function

* refactor(#3335): Fix docstring and rename constant

* refactor(#3335): improve default test catching parser and module errors

* feat(#3335): add only_logs_from test for aws cloudtrail module

* feat(#3335): add path tests for aws cloudtrail module

* feat(#3335): add path_suffix tests for aws cloudtrail module

* feat(#3335): add regions tests for aws cloudtrail module

* refactor(#3335): Move wazuh_log_monitor to a fixture

* feat(#3335): add discard_regex tests for aws cloudtrail module

* feat(#3335): add only_logs_after tier_1 test for aws cloudtrail module

* refactor(#3335): Improve name of test cases

* refactor(#3335): Improve tests assertions

* refactor(#3335): Improve tier 1 test

* refactor(#3335): Implement new design for Tier 1 test

* style(#3335): Changed the extension from .yml to .yaml

* style(#3335): Fixed linter issues

* style(#3335): Apply suggestions from code review

Co-authored-by: José Luis López Sánchez <[email protected]>

* refactor(#3335): Add path parameter to get_db_connection

* style(#3335): Fix quotes use according to QA style

* style(#3335): Use google docstring style

* refactor(#3335): Add missing information about fixtures

* refactor(#3335): Change sqlite table name for backward compatibility

* style(#3335): Fix docstrings punctuation and capitalization

* refactor(#3335): Apply suggestions from code review

* style(#3335): Apply suggestions from code review

Fix punctuation in docstrings.

Co-authored-by: David Jose Iglesias Lopez <[email protected]>

* style(#3335): Apply suggestions from code review

Co-authored-by: David Jose Iglesias Lopez <[email protected]>

Co-authored-by: José Luis López Sánchez <[email protected]>
Co-authored-by: David Jose Iglesias Lopez <[email protected]>

* feat(#3336): VPC integration tests (#3699)

* feat(#3336): Add basic test for aws vpc integration

* feat(#3336): Add data generator for vpcflow type

* feat(#3336): Add remove_from_bucket test for aws vpc integration

* feat(#3336): Add only_logs_after tests for aws vpc integration

* feat(#3336): Add path tests for aws vpc integration

* feat(#3336): Add path_suffix tests for aws vpc integration

* feat(#3336): Add regions tests for aws vpc integration

* feat(#3336): Add discard_regex tests for aws vpc integration

* feat(#3336): Add only_logs_after tier_1 tests for aws vpc integration

* style(#3336): Fix linter issues

* feat(#3336): Use join in path builds

* feat(#3336): Fix cloudtrail cases

* feat(#3336): Detect found and skipped logs

* feat(#3336): Improve delete_file_from_s3 fixture

* fix(#3336): Add minor fixes

---------

Co-authored-by: David Jose Iglesias Lopez <[email protected]>

* refactor(#3333): Use utcnow() instead of now()

* feat(#3337): AWS Config integration tests (#3705)

* feat(#3337): Add basic test for aws config integration

* feat(#3337): Add remove_from_bucket test for aws config integration

* feat(#3337): Add only_logs_after tests for aws config integration

* feat(#3337): Add path tests for aws config integration

* feat(#3337): Add path_suffix tests for aws config integration

* feat(#3337): Add regions tests for aws config integration

* feat(#3337): Add discard_regex tests for aws config integration

* feat(#3337): Add only_logs_after tier_1 tests for aws config integration

* feat(#3337): Use non padaded month format

* feat(#3337): Use join in path builds

* feat(#3337): Improve message for check_non_processed_logs_from_output

* fix(#3337): Add minor fixes

* feat(#3338): ALB, CLB and NLB integration tests (#3711)

* feat(#3338): Add basic test for aws ALB integration

* feat(#3338): Add remove_from_bucket test for aws ALB integration

* feat(#3338): Add schema for ALB table

* feat(#3338): Add only_logs_after tests for aws ALB integration

* feat(#3338): Add path tests for aws ALB integration

* feat(#3338): Add regions tests for aws ALB integration

* feat(#3338): Add regions discard_regex for aws ALB integration

* feat(#3338): Add regions only_logs_after tier 1 for aws ALB integration

* feat(#3338): Improve upload_and_delete_file_to_s3 fixture

* feat(#3338): Skip remove_from_bucket test case for ALB

* feat(#3338): Add basic test for aws CLB integration

* feat(#3338): Add remove_from_bucket test for aws CLB integration

* feat(#3338): Add only_logs_after tests for aws CLB integration

* feat(#3338): Add path tests for aws CLB integration

* feat(#3338): Add regions only_logs_after tier 1 for aws CLB integration

* feat(#3338): Add regions discard_regex for aws CLB integration

* feat(#3338): Add only_logs_after tier 1 for aws CLB integration

* feat(#3338): Skip remove_from_bucket test case for CLB

* feat(#3338): Add basic test for aws NLB integration

* feat(#3338): Add remove_from_bucket test for aws NLB integration

* feat(#3338): Add only_logs_after tests for aws NLB integration

* feat(#3338): Add path tests for aws NLB integration

* feat(#3338): Add regions tests for aws NLB integration

* feat(#3338): Add only_logs_after tier 1 for aws NLB integration

* style(#3335): Fix linter issues

* feat(#3338): Move skip function to a fixture

* feat(#3338): Use join in path builds

* feat(#3338): Improve docstrings

* feat(#3338): Increase timeout to avoid random failures

* refactor(#3338): Use utcnow() instead of now() and typos

* refactor(#3338): Apply changes from CR

* feat(#3339): KMS integration tests (#3715)

* feat(#3339): Add basic test for aws KMS integration

* feat(#3339): Add data generator for KMS type

* feat(#3339): Add remove_from_bucket test for aws KMS integration

* feat(#3339): Add schema for custom table

* feat(#3339): Add only_logs_after tests for aws KMS integration

* feat(#3339): Add path tests for aws KMS integration

* feat(#3339): Add discard_regex tests for aws KMS integration

* feat(#3339): Adapt only_logs_after tier 1 test to custom types

* feat(#3339): Add only_logs_after tier 1 for aws KMS integration

* feat(#3339): Use join in path builds

* feat(#3339): Improve skipped logs count in tier 1 test

* feat(#3339): Add missing docstring

* style(#3339): Apply suggestions from code review

Co-authored-by: Facundo Dalmau <[email protected]>

* refactor(#3339): Use utcnow() instead of now() and typos

* fix(#3339): Apply suggestions from code review

Co-authored-by: David Jose Iglesias Lopez <[email protected]>

---------

Co-authored-by: Facundo Dalmau <[email protected]>
Co-authored-by: David Jose Iglesias Lopez <[email protected]>

* feat(#3340): Macie integration tests (#3734)

* feat(#3340): Add basic test for aws Macie integration

* feat(#3336): Add data generator for vpcflow type

* feat(#3340): Add remove_from_bucket test for aws Macie integration

* feat(#3340): Add only_logs_after tests for aws Macie integration

* feat(#3340): Add path tests for aws Macie integration

* feat(#3340): Add discard_regex tests for aws Macie integration

* feat(#3340): Add only_logs_after tier 1 for aws Macie integration

* feat(#3340): Use join in path builds

* fix(#3340): Fix typo

* fix(#3340): Remove unused arguments

* style(#3340): Apply suggestions from code review

Co-authored-by: David Jose Iglesias Lopez <[email protected]>

---------

Co-authored-by: David Jose Iglesias Lopez <[email protected]>

* fix(#3333): Improve test condition

* feat(#3341): Trusted Advisor integration tests (#3736)

* feat(#3341): Add basic test for aws Trusted Advisor integration

* feat(#3339): Add data generator for KMS type

* feat(#3341): Add remove_from_bucket test

* feat(#3341): Add only_logs_after tests for aws Trusted Advisor integration

* feat(#3341): Add path tests for aws Trusted Advisor integration

* feat(#3341): Add discard_regex tests for aws Trusted Advisor integration

* feat(#3341): Add only_logs_after tier 1 for aws Trusted Advisor integration

* feat(#3342): GuardDuty integration tests (#3762)

* feat(#3342): Add basic test for aws GuardDuty integration

* feat(#3342): Add remove_from_bucket test for aws Guard Duty integration

* feat(#3342): Add schema for GuardDuty table

* feat(#3342): Add only_logs_after tests for aws GuardDuty integration

* feat(#3342): Add path tests for aws GuardDuty integration

* feat(#3342): Add discard_regex tests for aws GuardDuty integration

* feat(#3342): Add only_logs_after tier 1 for aws GuarDuty integration

* fix(#3342): Adjust the number of found logs

* feat(#3342): Add missing docstring

* feat(#3342): Add data generator for Native GD

* feat(#3342): Add test cases for Native GuardDuty

* refactor(#3342): Improve tier 1 test findings

* fix(#3333): Improve some test findings

* feat(#3343): WAF integration tests (#3763)

* feat(#3343): Add basic test for aws WAF integration

* feat(#3343): Add data generator for WAF type

* feat(#3343): Add remove_from_bucket test for aws WAF integration

* feat(#3343): Add schema for WAF table

* feat(#3343): Add only_logs_after tests for aws WAF integration

* feat(#3343): Add path tests for aws WAF integration

* feat(#3343): Add discard_regex tests for aws WAF integration

* feat(#3343): Add only_logs_after tier 1 for aws WAF integration

* style(#3343): Apply suggestions from code review

Co-authored-by: Facundo Dalmau <[email protected]>

* refactor(#3343): Improve discard_regex test findings

---------

Co-authored-by: Facundo Dalmau <[email protected]>

* feat(#3344): Server Access integration tests (#3771)

* feat(#3344): Add basic test for aws server access integration

* feat(#3344): Add data generator for Server Access type

* feat(#3344): Add remove_from_bucket test for aws SA integration

* feat(#3344): Add schema for ServerAccess table

* feat(#3344): Add only_logs_after tests for aws SA integration

* feat(#3344): Add path tests for aws SA integration

* feat(#3344): Add discard_regex tests for aws FA integration

* feat(#3344): Add only_logs_after tier 1 for aws SA integration

* feat(#3344): Use table_name instead of bucket_type

* style(#3344): Apply suggestions from code review

Co-authored-by: Facundo Dalmau <[email protected]>

---------

Co-authored-by: Facundo Dalmau <[email protected]>

* feat(#3345): Add basic test for aws inspector integration

* feat(#3345): Add only_logs_after tests for aws Inspector integration

* feat(#3345): Add only_logs_after tier 1 for Inspector integration

* refactor(#3345): Minor fixes

* style(#3345): Apply suggestions from code review

Co-authored-by: Facundo Dalmau <[email protected]>

* style(#3345): Apply suggestions from code review

Co-authored-by: José Luis López Sánchez <[email protected]>

* feat(#3346): CloudWatch integration tests (#3857)

* feat(#3346): Add basic test for aws cloudwatch integration

* feat(#3346): Rename basic test for buckets integration

* feat(#3346): Add tools for cloudwatch integration

* feat(#3346): Add remove_log_streams test for aws cloudwatch integration

* feat(#3346): Add utils for cloudwatch tests

* feat(#3346): Add fixtures for cloudwatch tests

* feat(#3346): Add only_logs_after tests for aws CloudWatch integration

* feat(#3346): Rename only_logs_after tests for buckets integration

* feat(#3346): Add regions tests for aws CloudWatch integration

* feat(#3346): Rename regions tests for buckets integration

* feat(#3346): Add log_groups tests for aws CloudWatch integration

* feat(#3346): Add only_logs_after tier 1 for aws CloudWatch integration

* feat(#3346): Rename tier 1 tests for buckets integration

* refactor(#3346): Minor fixes

* style(#3346): Apply suggestions from code review

Co-authored-by: Facundo Dalmau <[email protected]>

* style(#3346): Apply suggestions from code review

Co-authored-by: Facundo Dalmau <[email protected]>

---------

Co-authored-by: Facundo Dalmau <[email protected]>

* feat(#3347): Umbrella integration tests (#3796)

* feat(#3347): Add basic test for aws umbrella integration

* feat(#3347): Add data generator for Umbrella type

* feat(#3347): Add remove_from_bucket test for aws Umbrella integration

* feat(#3347): Add schema for Umbrella table

* feat(#3347): Add only_logs_after tests for aws Umbrella integration

* feat(#3347): Add path tests for aws Umbrella integration

* feat(#3347): Add discard_regex tests for aws Umbrella integration

* feat(#3347): Add only_logs_after tier 1 for aws Umbrella integration

* style(#3347): Apply suggestions from code review

Co-authored-by: Facundo Dalmau <[email protected]>

* fix(#3347): Fix discard_regex test findings

---------

Co-authored-by: Facundo Dalmau <[email protected]>

* fix(#3333): Add missing PATH with empty value

* feat(#3581): Parser integration tests (#3882)

* feat(#3581): Add tests for mandatory missing params

* feat(#3581): Add tests for empty values

* feat(#3581): Add tests for invalid values

* feat(#3581): Add tests for multiple bucket and service tags

* style(#3581): Apply suggestions from code review

Co-authored-by: Facundo Dalmau <[email protected]>

* style(#3581): Apply suggestions from code review

Co-authored-by: Facundo Dalmau <[email protected]>

---------

Co-authored-by: Facundo Dalmau <[email protected]>

* fix(#3333): Adjust some tests values

* fix(#3333): Fix cloudwatchlogs_log_groups_with_data test

* fix(#3333): Adjust cisco_umbrella_only_logs_after_multiple_calls values

* fix(#3333): Normalize tier1 tests for all bucket integrations

* feat(#3348): AWS integration tests readme (#3892)

* docs(#3348): Add AWS integration tests README

* docs(#3348): Add referece to AWS tests

* refactor(#3348): Improve explanation about credentials

Co-authored-by: Facundo Dalmau <[email protected]>

---------

Co-authored-by: Facundo Dalmau <[email protected]>

* fix(#3333): Adjust inexistent_region test for services

* fix(#3333): Adjust parser tests

* fix(#3333): Change message to search for services region tests

* fix(#3333): Marked inspector tier 1 test as xfail

* fix(#3333): Splitted inspector and cloudwatch logs

* fix(#3333): Timeouts adjustments

* fix(#3333): Fixed tests cases for cloudwatch tier 1 tests

* fix(#3333): Fixed linter issues

* docs(#3333): Added changelog

* fix(#3333): Fixed order and format

* fix(#3333): Moved constants to __init__.py

* fix(#3333): Replaced wazuh_log_monitor with file_monitoring

* fix(#3333): Moved constants to wazuh_testing/__init__.py

* fix(#3333): Moved constants to test_aws/__init__.py

* fix(#3333): Improved docstring

* fix(#3333): Moved exception to new file

* fix(#3333): Improved fixtures and removed unused ones

* fix(#3333): Fixed quotation marks

* fix(#3333): Removed type hints

* fix(#3339): Apply suggestions from code review

Co-authored-by: Julia Magán <[email protected]>

* fix(#3333): Install boto3 only in linux

* fix(#3339): Apply suggestions from code review

Co-authored-by: Julia Magán <[email protected]>

* fix(#3333): Moved constants

---------

Co-authored-by: José Luis López Sánchez <[email protected]>
Co-authored-by: David Jose Iglesias Lopez <[email protected]>
Co-authored-by: Facundo Dalmau <[email protected]>
Co-authored-by: Julia Magán <[email protected]>
  • Loading branch information
5 people authored Apr 28, 2023
1 parent c440043 commit 87a6bde
Show file tree
Hide file tree
Showing 76 changed files with 8,220 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Release report: TBD

### Added

- Add integration tests for AWS module. ([#3911](https:/wazuh/wazuh-qa/pull/3911)) \- (Framework + Tests + Documentation)
- Add tests for msu patches with no associated CVE . ([#4009](https:/wazuh/wazuh-qa/pull/4009)) \- (Framework + Tests)
- Add tests with new options to avoid FIM synchronization overlapping. ([#3318](https:/wazuh/wazuh-qa/pull/3318)) \- (Framework + tests)
- Add Logcollector millisecond granularity support test case ([#3910](https:/wazuh/wazuh-qa/pull/3910)) \- (Tests)
Expand Down
2 changes: 2 additions & 0 deletions deps/wazuh_testing/wazuh_testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
WAZUH_TESTING_PATH = os.path.dirname(os.path.abspath(__file__))
WAZUH_TESTING_DATA_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data')
DEFAULT_AUTHD_PASS_PATH = os.path.join(WAZUH_PATH, 'etc', 'authd.pass')
TEMPLATE_DIR = 'configuration_template'
TEST_CASES_DIR = 'test_cases'


# Daemons
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def check_api_event(file_monitor=None, callback='', error_message=None, update_p
callback (str): log regex to check in the file
error_message (str): error message to show in case of expected event does not occur
update_position (boolean): filter configuration parameter to search in the file
timeout (str): timeout to check the event in the file
timeout (int): timeout to check the event in the file
prefix (str): log pattern regex
accum_results (int): Accumulation of matches.
file_to_monitor (str): File to be monitored.
"""
file_monitor = FileMonitor(file_to_monitor) if file_monitor is None else file_monitor
error_message = f"Could not find this event in {file_to_monitor}: {callback}" if error_message is None else \
Expand Down
58 changes: 58 additions & 0 deletions deps/wazuh_testing/wazuh_testing/modules/aws/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from pathlib import Path

from wazuh_testing import WAZUH_PATH

AWS_MODULE_PATH = Path(WAZUH_PATH, 'wodles', 'aws')
S3_CLOUDTRAIL_DB_PATH = Path(AWS_MODULE_PATH, 's3_cloudtrail.db')
AWS_SERVICES_DB_PATH = Path(AWS_MODULE_PATH, 'aws_services.db')

AWS_LOGS = 'AWSLogs'
RANDOM_ACCOUNT_ID = '819751203818'
CLOUDTRAIL = 'CloudTrail'
GUARDDUTY = 'GuardDuty'
VPC_FLOW_LOGS = 'vpcflowlogs'
FLOW_LOG_ID = 'fl-0754d951c16f517fa'
CONFIG = 'Config'
ELASTIC_LOAD_BALANCING = 'elasticloadbalancing'
SERVER_ACCESS_TABLE_NAME = 's3_server_access'
PERMANENT_CLOUDWATCH_LOG_GROUP = 'wazuh-cloudwatchlogs-integration-tests'
TEMPORARY_CLOUDWATCH_LOG_GROUP = 'temporary-log-group'
FAKE_CLOUDWATCH_LOG_GROUP = 'fake-log-group'

EVENT_TIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
PATH_DATE_FORMAT = '%Y/%m/%d'
PATH_DATE_NO_PADED_FORMAT = '%Y/%-m/%-d'
FILENAME_DATE_FORMAT = '%Y%m%dT%H%MZ'
ALB_DATE_FORMAT = '%Y-%m-%dT%H:%M:%fZ'

US_EAST_1_REGION = 'us-east-1'

JSON_EXT = '.json'
LOG_EXT = '.log'
JSON_GZ_EXT = '.jsonl.gz'
CSV_EXT = '.csv'

# Bucket types
CLOUD_TRAIL_TYPE = 'cloudtrail'
VPC_FLOW_TYPE = 'vpcflow'
CONFIG_TYPE = 'config'
ALB_TYPE = 'alb'
CLB_TYPE = 'clb'
NLB_TYPE = 'nlb'
KMS_TYPE = 'kms'
MACIE_TYPE = 'macie'
KMS_TYPE = 'kms'
TRUSTED_ADVISOR_TYPE = 'trusted'
CUSTOM_TYPE = 'custom'
GUARD_DUTY_TYPE = 'guardduty'
NATIVE_GUARD_DUTY_TYPE = 'native-guardduty'
WAF_TYPE = 'waf'
SERVER_ACCESS = 'server_access'
CISCO_UMBRELLA_TYPE = 'cisco_umbrella'

# Params

ONLY_LOGS_AFTER_PARAM = '--only_logs_after'


local_internal_options = {'wazuh_modules.debug': '2', 'monitord.rotate_log': '0'}
61 changes: 61 additions & 0 deletions deps/wazuh_testing/wazuh_testing/modules/aws/cli_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import subprocess
from pathlib import Path

from wazuh_testing import logger
from wazuh_testing.modules.aws import AWS_MODULE_PATH
from wazuh_testing.modules.aws.exceptions import OutputAnalysisError

AWS_BINARY_PATH = Path(AWS_MODULE_PATH, 'aws-s3')


def call_aws_module(*parameters):
"""Given some parameters call the AWS module and return the output.
Returns:
str: The command output.
"""
command = [AWS_BINARY_PATH, *parameters]
logger.debug("Calling AWS module with: '%s'", command)
command_result = subprocess.run(command, capture_output=True)

return command_result.stdout.decode()


def _default_callback(line: str):
print(line)
return line


def analyze_command_output(
command_output, callback=_default_callback, expected_results=1, error_message=''
):
"""Analyze the given command output searching for a pattern.
Args:
command_output (str): The output to analyze.
callback (Callable, optional): A callback to process each line. Defaults to _default_callback.
expected_results (int, optional): Number of expected results. Defaults to 1.
error_message (str, optional): Message to show with the exception. Defaults to ''.
Raises:
OutputAnalysisError: When the expected results are not correct.
"""

results = []

for line in command_output.splitlines():
logger.debug(line)
item = callback(line)

if item is not None:
results.append(item)

results_len = len(results)

if results_len != expected_results:
if error_message:
logger.error(error_message)
logger.error('Results found: %s', results_len)
logger.error('Results expected: %s', expected_results)
raise OutputAnalysisError(error_message)
raise OutputAnalysisError()
87 changes: 87 additions & 0 deletions deps/wazuh_testing/wazuh_testing/modules/aws/cloudwatch_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
"""AWS CloudWatch related utils"""

from time import time
from uuid import uuid4

import boto3
from wazuh_testing.modules.aws import PERMANENT_CLOUDWATCH_LOG_GROUP, US_EAST_1_REGION

session = boto3.Session(profile_name='qa')
logs = session.client('logs', region_name=US_EAST_1_REGION)


def create_log_group(log_group_name):
"""Create a log group.
Args:
log_group_name (str): Log group name to create.
"""
logs.create_log_group(logGroupName=log_group_name)


def delete_log_group(log_group_name):
"""Delete the given log group.
Args:
log_group_name (str): Log group name to delete.
"""
logs.delete_log_group(logGroupName=log_group_name)


def create_log_stream(log_group=PERMANENT_CLOUDWATCH_LOG_GROUP):
"""Create a log stream within the given log group.
Args:
log_group (str, optional): Log group to store the stream. Defaults to PERMANENT_CLOUDWATCH_LOG_GROUP.
Returns:
str: The name of the created log stream.
"""
log_stream_name = str(uuid4())
logs.create_log_stream(logGroupName=log_group, logStreamName=log_stream_name)

return log_stream_name


def delete_log_stream(log_stream, log_group=PERMANENT_CLOUDWATCH_LOG_GROUP):
"""Delete a log stream from the given log group.
Args:
log_stream (str): The log stream to delete.
log_group (str, optional): Log group to delete the stream. Defaults to PERMANENT_CLOUDWATCH_LOG_GROUP.
"""
logs.delete_log_stream(logGroupName=log_group, logStreamName=log_stream)


def create_log_events(log_stream, log_group=PERMANENT_CLOUDWATCH_LOG_GROUP, event_number=1):
"""Create a log event within the given log stream and group.
Args:
log_stream (str): The log stream to delete.
log_group (str, optional): Log group to delete the stream. Defaults to PERMANENT_CLOUDWATCH_LOG_GROUP.
event_number (int, optional): Number of events to create. Defaults to 1.
"""

events = [
{'timestamp': int(time() * 1000), 'message': f"Test event number {i}"} for i in range(event_number)
]

logs.put_log_events(
logGroupName=log_group, logStreamName=log_stream, logEvents=events,
)


def log_stream_exists(log_group, log_stream) -> bool:
"""Check if a log stream exists in a group.
Args:
log_group (str): Log group to search within.
log_stream (str): Log stream to search.
Returns:
bool: True if exists else False
"""
response = logs.describe_log_streams(logGroupName=log_group)
log_streams = [item['logStreamName'] for item in response['logStreams']]

return log_stream in log_streams
Loading

0 comments on commit 87a6bde

Please sign in to comment.