Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Aug 24, 2023
1 parent c25b55e commit 5a9b288
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 27 deletions.
19 changes: 7 additions & 12 deletions test/commons/test_esclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from unittest.mock import MagicMock

import httpretty
import sure

import app.commons.launch_objects as launch_objects
from app.commons import esclient
Expand Down Expand Up @@ -361,7 +362,7 @@ def test_clean_index(self):
]

for idx, test in enumerate(tests):
try:
with sure.ensure('Error in the test case index: {0}', idx):
self._start_server(test["test_calls"])
app_config = self.app_config
if "app_config" in test:
Expand All @@ -373,12 +374,9 @@ def test_clean_index(self):

response = es_client.delete_logs(test["rq"])

assert test["expected_count"] == response
test["expected_count"].should.equal(response)

TestEsClient.shutdown_server(test["test_calls"])
except AssertionError as err:
raise AssertionError(f'Error in the test case number: {idx}'). \
with_traceback(err.__traceback__)

@utils.ignore_warnings
def test_index_logs(self):
Expand Down Expand Up @@ -646,7 +644,7 @@ def test_index_logs(self):
]

for idx, test in enumerate(tests):
try:
with sure.ensure('Error in the test case index: {0}', idx):
self._start_server(test["test_calls"])
app_config = self.app_config
if "app_config" in test:
Expand All @@ -656,14 +654,11 @@ def test_index_logs(self):
launches = [launch_objects.Launch(**launch) for launch in json.loads(test["index_rq"])]
response = es_client.index_logs(launches)

assert test["has_errors"] == response.errors
assert test["expected_count"] == response.took
assert test["expected_log_exceptions"] == response.logResults
test["has_errors"].should.equal(response.errors)
test["expected_count"].should.equal(response.took)
test["expected_log_exceptions"].should.equal(response.logResults)

TestEsClient.shutdown_server(test["test_calls"])
except AssertionError as err:
raise AssertionError(f'Error in the test case number: {idx}'). \
with_traceback(err.__traceback__)

def test_defect_update(self):
tests = [
Expand Down
2 changes: 1 addition & 1 deletion test_res/fixtures/index_logs_rq.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{"index":{"_index":"idx2","_type":"log","_id":"1_m"}}
{"issue_type":"AB001","launch_name":"Launch 1","log_level":40000,"original_message_lines":1,"original_message_words_number":2,"message":"","test_item":1,"test_item_name":"first test","start_time":"2020-01-15 10:57:43","unique_id":"unique1","test_case_hash": -1126886180,"detected_message":"","detected_message_with_numbers":"","only_numbers":"12","merged_small_logs":"message http localhost admin java.lang.noclassdeffounderror","stacktrace":"","urls":"http localhost admin","paths":"","message_params":"","potential_status_codes":"","found_exceptions":"java.lang.noclassdeffounderror","found_exceptions_extended":"java.lang.noclassdeffounderror lang.noclassdeffounderror noclassdeffounderror","found_tests_and_methods":"","stacktrace_extended":"","message_extended":"","detected_message_extended":"","detected_message_without_params_extended":"message java.lang lang.noclassdeffounderror noclassdeffounderror","message_without_params_extended":"","message_without_params_and_brackets":"","detected_message_without_params_and_brackets":"","whole_message":"Message 12 \r\n java.lang lang.NoClassDefFoundError\r\n","is_merged":true}
{"issue_type":"AB001","launch_name":"Launch 1","log_level":40000,"original_message_lines":1,"original_message_words_number":2,"message":"","test_item":1,"test_item_name":"first test","start_time":"2020-01-15 10:57:43","unique_id":"unique1","test_case_hash":-1126886180,"detected_message":"","detected_message_with_numbers":"","only_numbers":"12","merged_small_logs":"message http localhost admin java.lang.noclassdeffounderror","stacktrace":"","urls":"http localhost admin","paths":"","message_params":"","potential_status_codes":"","found_exceptions":"java.lang.noclassdeffounderror","found_exceptions_extended":"java.lang.noclassdeffounderror lang.noclassdeffounderror noclassdeffounderror","found_tests_and_methods":"","stacktrace_extended":"","message_extended":"","detected_message_extended":"","detected_message_without_params_extended":"message java.lang lang.noclassdeffounderror noclassdeffounderror","message_without_params_extended":"","message_without_params_and_brackets":"","detected_message_without_params_and_brackets":"","whole_message":"Message 12 \r\n java.lang lang.NoClassDefFoundError\r\n","is_merged":true}
4 changes: 2 additions & 2 deletions test_res/fixtures/index_logs_rq_big_messages.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{"index":{"_index":"2","_id":1}}
{"launch_id":1234567892,"launch_name":"Launch with test items with logs","launch_start_time":"2020-01-15 10:57:43","test_item":1,"test_item_name":"first test","unique_id":"unique1","test_case_hash": -1126886180,"cluster_id":"0","cluster_message":"","test_case_hash":0,"is_auto_analyzed":false,"issue_type":"ti001","log_time":"2020-01-15 10:57:43","log_level":40000,"original_message_lines":5,"original_message_words_number":9,"message":"Message \r\n Message 'prod_en' /src/prod/results.html \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator \r","is_merged":false,"start_time":"2020-01-15 10:57:43","merged_small_logs":"","detected_message":"Message \r\n Message 'prod_en' /src/prod/results.html \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator \r","detected_message_with_numbers":"Message 1 \r\n Message 2 \r\n Message 3 'prod_en' /src/prod/results.html \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator \r","stacktrace":"","only_numbers":"1 2 3","found_exceptions":"java.lang.NoClassDefFoundError","whole_message":"Message 1 \r\n Message 2 \r\n Message 3 'prod_en' \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator \n ","potential_status_codes":"","found_tests_and_methods":"","cluster_with_numbers":false,"urls":"","paths":"/src/prod/results.html","message_params":"prod_en","found_exceptions_extended":"java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError","detected_message_extended":"Message \r\n Message 'prod_en' /src/prod/results.html \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator impl.MandatoryAttributesValidator MandatoryAttributesValidator \r","detected_message_without_params_extended":"Message \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator impl.MandatoryAttributesValidator MandatoryAttributesValidator ","stacktrace_extended":"","message_extended":"Message \r\n Message 'prod_en' /src/prod/results.html \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator impl.MandatoryAttributesValidator MandatoryAttributesValidator \r","message_without_params_extended":"Message \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator impl.MandatoryAttributesValidator MandatoryAttributesValidator ","detected_message_without_params_and_brackets":"Message \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator","message_without_params_and_brackets":"Message \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator"}
{"launch_id":1234567892,"launch_name":"Launch with test items with logs","launch_start_time":"2020-01-15 10:57:43","test_item":1,"test_item_name":"first test","unique_id":"unique1","cluster_id":"0","cluster_message":"","test_case_hash":-1126886180,"is_auto_analyzed":false,"issue_type":"ti001","log_time":"2020-01-15 10:57:43","log_level":40000,"original_message_lines":5,"original_message_words_number":9,"message":"Message \r\n Message 'prod_en' /src/prod/results.html \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator \r","is_merged":false,"start_time":"2020-01-15 10:57:43","merged_small_logs":"","detected_message":"Message \r\n Message 'prod_en' /src/prod/results.html \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator \r","detected_message_with_numbers":"Message 1 \r\n Message 2 \r\n Message 3 'prod_en' /src/prod/results.html \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator \r","stacktrace":"","only_numbers":"1 2 3","found_exceptions":"java.lang.NoClassDefFoundError","whole_message":"Message 1 \r\n Message 2 \r\n Message 3 'prod_en' \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator \n ","potential_status_codes":"","found_tests_and_methods":"","cluster_with_numbers":false,"urls":"","paths":"/src/prod/results.html","message_params":"prod_en","found_exceptions_extended":"java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError","detected_message_extended":"Message \r\n Message 'prod_en' /src/prod/results.html \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator impl.MandatoryAttributesValidator MandatoryAttributesValidator \r","detected_message_without_params_extended":"Message \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator impl.MandatoryAttributesValidator MandatoryAttributesValidator ","stacktrace_extended":"","message_extended":"Message \r\n Message 'prod_en' /src/prod/results.html \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator impl.MandatoryAttributesValidator MandatoryAttributesValidator \r","message_without_params_extended":"Message \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator impl.MandatoryAttributesValidator MandatoryAttributesValidator ","detected_message_without_params_and_brackets":"Message \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator","message_without_params_and_brackets":"Message \r\n java.lang.NoClassDefFoundError\r\n de.hybris.platform.servicelayer.interceptor.impl.MandatoryAttributesValidator"}
{"index":{"_index":"2","_id":2}}
{"launch_id":1234567892,"launch_name":"Launch with test items with logs","launch_start_time":"2020-01-15 10:57:43","test_item":1,"test_item_name":"first test","unique_id":"unique1","test_case_hash": -1126886180,"cluster_id":"0","cluster_message":"","test_case_hash":0,"is_auto_analyzed":false,"issue_type":"ti001","log_time":"2020-01-15 10:57:43","log_level":40000,"original_message_lines":4,"original_message_words_number":7,"message":"Message \r\n Message http : localhost/admin \r\n java.lang.NoClassDefFoundError\r","is_merged":false,"start_time":"2020-01-15 10:57:43","merged_small_logs":"","detected_message":"Message \r\n Message http : localhost/admin \r\n java.lang.NoClassDefFoundError\r","detected_message_with_numbers":"Message 2 \r\n Message 4 \r\n Message 5 http : localhost/admin \r\n java.lang.NoClassDefFoundError\r","stacktrace":"","only_numbers":"2 4 5","found_exceptions":"java.lang.NoClassDefFoundError","whole_message":"Message 2 \r\n Message 4 \r\n Message 5 \r\n java.lang.NoClassDefFoundError \n ","potential_status_codes":"","found_tests_and_methods":"","cluster_with_numbers":false,"urls":"http:localhost/admin","paths":"","message_params":"","found_exceptions_extended":"java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError","detected_message_extended":"Message \r\n Message http : localhost/admin \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r","detected_message_without_params_extended":"Message \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError ","stacktrace_extended":"","message_extended":"Message \r\n Message http : localhost/admin \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r","message_without_params_extended":"Message \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError ","detected_message_without_params_and_brackets":"Message \r\n java.lang.NoClassDefFoundError","message_without_params_and_brackets":"Message \r\n java.lang.NoClassDefFoundError"}
{"launch_id":1234567892,"launch_name":"Launch with test items with logs","launch_start_time":"2020-01-15 10:57:43","test_item":1,"test_item_name":"first test","unique_id":"unique1","cluster_id":"0","cluster_message":"","test_case_hash":-1126886180,"is_auto_analyzed":false,"issue_type":"ti001","log_time":"2020-01-15 10:57:43","log_level":40000,"original_message_lines":4,"original_message_words_number":7,"message":"Message \r\n Message http : localhost/admin \r\n java.lang.NoClassDefFoundError\r","is_merged":false,"start_time":"2020-01-15 10:57:43","merged_small_logs":"","detected_message":"Message \r\n Message http : localhost/admin \r\n java.lang.NoClassDefFoundError\r","detected_message_with_numbers":"Message 2 \r\n Message 4 \r\n Message 5 http : localhost/admin \r\n java.lang.NoClassDefFoundError\r","stacktrace":"","only_numbers":"2 4 5","found_exceptions":"java.lang.NoClassDefFoundError","whole_message":"Message 2 \r\n Message 4 \r\n Message 5 \r\n java.lang.NoClassDefFoundError \n ","potential_status_codes":"","found_tests_and_methods":"","cluster_with_numbers":false,"urls":"http:localhost/admin","paths":"","message_params":"","found_exceptions_extended":"java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError","detected_message_extended":"Message \r\n Message http : localhost/admin \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r","detected_message_without_params_extended":"Message \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError ","stacktrace_extended":"","message_extended":"Message \r\n Message http : localhost/admin \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError \r","message_without_params_extended":"Message \r\n java.lang.NoClassDefFoundError lang.NoClassDefFoundError NoClassDefFoundError ","detected_message_without_params_and_brackets":"Message \r\n java.lang.NoClassDefFoundError","message_without_params_and_brackets":"Message \r\n java.lang.NoClassDefFoundError"}
Loading

0 comments on commit 5a9b288

Please sign in to comment.