Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shmsr committed Aug 2, 2023
1 parent 0335be6 commit 6a553d5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions x-pack/metricbeat/module/sql/query/test_sql_mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ class Test(XPackTest):
@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, "integration test")
def test_query_without_fetch_from_all_databases(self):
"""
SQL MSSQL custom query with fetch_from_all_databases=false
SQL MSSQL custom query with fetch_from_all_databases="false"
1 document will be received from the default selected database: 'master'
1 document will be received from the default selected database: 'master'.
"""
self.run_query_test(fetch_from_all_databases=False, expected_output_count=1)
self.run_query_test(fetch_from_all_databases="false", expected_output_count=1)

@unittest.skipUnless(metricbeat.INTEGRATION_TESTS, "integration test")
def test_query_with_fetch_from_all_databases(self):
"""
SQL MSSQL custom query with fetch_from_all_databases=true
SQL MSSQL custom query with fetch_from_all_databases="true"
4 documents will be received because 4 databases are present by default in MSSQL and 1 document per database will received.
"""
self.run_query_test(fetch_from_all_databases=True, expected_output_count=4)
self.run_query_test(fetch_from_all_databases="true", expected_output_count=4)


def run_query_test(self, fetch_from_all_databases: bool, expected_output_count: int) -> list:
def run_query_test(self, fetch_from_all_databases: str, expected_output_count: int) -> list:
self.render_config_template(modules=[{
"name": "sql",
"metricsets": ["query"],
"hosts": ['sqlserver://{}:{}@{}'.format(self.get_username(), self.get_password(), self.compose_host())],
"period": "5s",
"additional_content": f"""
driver: mssql
fetch_from_all_databases: {str(fetch_from_all_databases).lower()}
fetch_from_all_databases: {fetch_from_all_databases}
sql_query: SELECT DB_NAME() AS 'database_name';
sql_response_format: table"""
}])
Expand All @@ -46,7 +46,6 @@ def run_query_test(self, fetch_from_all_databases: bool, expected_output_count:
self.assert_no_logged_warnings()

output = self.read_output_json()

self.assertEqual(len(output), expected_output_count)

for evt in output:
Expand Down

0 comments on commit 6a553d5

Please sign in to comment.