reportportal / reportportal

Main Repository. ReportPortal starts here - see readme below.
http://reportportal.io
Apache License 2.0
1.73k stars 466 forks source link

Unique error analysis detects clusters incorrectly #2210

Open rplevka opened 8 months ago

rplevka commented 8 months ago

Describe the bug I run a simple script that creates 1 parent test case (SUITE) with 5 child test cases (STEP), logs some unique error messages for each test as well as some common messages for some (not all tests). I am going to share the script and will add the comments before each logical section, describing what is going on:

python reproducer script
```python import requests from datetime import datetime rp_server = 'http://localhost:8080' rp_token = 'dolphins' rp_project = 'superadmin_personal' rp_api_url = f'{rp_server}/api/v2/{rp_project}' test_count = 5 # construct a HTTP session object that's going to be used across the script sesh = requests.Session() sesh.verify = False sesh.headers={ 'Content-Type': 'application/json', 'Authorization': f'Bearer {rp_token}' } # create a helper function to properly format time and def _time(): return datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S") # function to submit a `POST` request with a proper payload to log stuff under a given item def _log(launch_uuid, item_uuid, level, msg): sesh.post( url=f'{rp_api_url}/log/entry', json={ 'itemUuid': item_uuid, 'launchUuid': launch_uuid, 'level': level, 'message': msg, 'time': _time() } ) # Start Launch launch_start_req = sesh.post( url=f'{rp_api_url}/launch', json={ 'name': 'unique_failures_test', 'startTime': _time(), 'rerun': False } ) launch_start_req.raise_for_status() launch_start_req = launch_start_req.json() # Start Parent Test ptest_start_req = sesh.post( url=f'{rp_api_url}/item', json={ 'name': 'parent_suite', 'type': 'SUITE', 'launchUuid': launch_start_req['id'], 'startTime': _time() } ) ptest_start_req.raise_for_status() ptest_start_req = ptest_start_req.json() # try to also log an error message under the parent item - because why not _log(launch_start_req['id'], ptest_start_req['id'], "ERROR", "err message 1") # create x child tests tests = {} for i in range(test_count): # Start Child Test ctest_start_req = sesh.post( url=f'{rp_api_url}/item/{ptest_start_req["id"]}', json={ 'name': f'test{i}', 'description': '', 'type': 'STEP', 'retry': False, 'launchUuid': launch_start_req['id'], 'startTime': _time(), 'attributes': [] } ) ctest_start_req.raise_for_status() tests[i] = ctest_start_req.json() # Log stuff lid = launch_start_req['id'] for i in range(test_count): _log(lid, tests[i]['id'], "DEBUG", "debug message 1") _log(lid, tests[i]['id'], "INFO", "info message 1") _log(lid, tests[i]['id'], "INFO", "info message 1") _log(lid, tests[i]['id'], "INFO", "bold font") _log(lid, tests[i]['id'], "WARN", "warn message 1") _log(lid, tests[i]['id'], "ERROR", f"err message {i}") # this should create unique error for each child test # log some additional errors to some of the tests _log(lid, tests[3]['id'], "ERROR", "err message 2") _log(lid, tests[4]['id'], "ERROR", "err message 2") _log(lid, tests[2]['id'], "ERROR", "err message 3") # ^ after this step, i'd expect at least 2 clusters to be created about the `err message 2` and `err message 3` # Let's finish everything up for t in tests.keys(): # Finish Child Test sesh.put( url=f'{rp_api_url}/item/{tests[t]["id"]}', json={ 'status': 'FAILED', 'launchUuid': launch_start_req['id'], 'endTime': _time() } ) # Finish Parent Test ptest_stop_req = sesh.put( url=f'{rp_api_url}/item/{ptest_start_req["id"]}', json={ 'status': 'FAILED', 'launchUuid': launch_start_req['id'], 'endTime': _time() } ) ptest_stop_req.raise_for_status() ptest_stop_req = ptest_stop_req.json() # Finish Launch launch_stop_req = sesh.put( url=f'{rp_api_url}/launch/{launch_start_req["id"]}/finish', json={ 'status': "FAILED", 'endTime': _time() } ) launch_stop_req.raise_for_status() ```

Expected behavior not sure, if errors in parent test cases should count, but if they did, i'd expect the following clusters to be detected:

[
    {
         "err message 0":  [
             "test0"
         ]
     },
    {
         "err message 1":  [
             "parent_suite",
             "test1"
         ]
     },
     {
         "err message 2": [
             "test2",
             "test3",
             "test4"
         ]
     },
     {
         "err message 3": [
             "test2",
             "test3"
         ]
     },
    {
         "err message 4":  [
             "test4"
         ]
     },
]

Actual behavior only a single 'unique' error for the launch is detected and it groups all the tests, including those, that don't even contain the error:

[
    {
         "err message 1":  [
             "test0",
             "test1",
             "test2",
             "test3",
             "test4"
         ]
     }
]

Screenshots Selection_442 Selection_446 Selection_447

Versions:

Pink-Bumblebee commented 8 months ago

Hello @rplevka I will draw the attention of our engineers to your scripts. But, as far as I understand, unique errors are indeed unique errors which occur throughout the entire launch. They are displayed only for step items; they do not look at the logs for parent items.