Class CustomLogRecordRepositoryImpl
java.lang.Object
org.qubership.atp.ram.repositories.impl.CustomLogRecordRepositoryImpl
- All Implemented Interfaces:
CustomLogRecordRepository,FieldConstants
@Repository
public class CustomLogRecordRepositoryImpl
extends Object
implements CustomLogRecordRepository, FieldConstants
-
Field Summary
Fields inherited from interface org.qubership.atp.ram.repositories.impl.FieldConstants
_ID, $_ID, $BROWSER_CONSOLE_LOGS_TABLE, $CHILDREN, $DURATION, $EXECUTION_REQUEST, $EXECUTION_REQUEST_ID, $FINISH_DATE, $ID, $ISSUE, $METADATA, $PARENT_LOG_RECORD_ID, $ROOT_CAUSE, $START_DATE, $TEST_RUN, $TESTING_STATUS, ANALYZED_BY_QA, BROWSER_CONSOLE_LOGS_TABLE, CHILDREN, CHILDREN_0, CHILDREN_DEPTH, CREATED_DATE, CREATED_DATE_STAMP, DURATION, END_DATE, ENTITIES, ENVIRONMENT, ENVIRONMENT_ID, EXECUTION_REQUEST, EXECUTION_REQUEST_ID, EXECUTION_REQUEST_NAME, EXECUTION_REQUESTS, EXECUTION_STATUS, EXECUTOR, EXECUTOR_ID, EXECUTOR_NAME, FAIL_PATTERN, FAIL_PATTERN_NAME_FIELD, FAIL_REASON, FAIL_REASON_NAME_FIELD, FAIL_TEST_RUNS_COUNT_FIELD, FAILED_RATE, FILE_NAME, FILE_TYPE, FILTERED_BY_LABELS, FILTERED_BY_LABELS_IDS, FINISH_DATE, ID, ISSUE, JIRA_DEFECTS, JIRA_TICKETS, LAST_UPDATED, LEVEL, LOG_COLLECTOR_DATA, LOG_RECORD_FILE_METADATA, LOG_RECORD_ID, LOG_RECORD_TEST_RUN_ID, MESSAGE, METADATA, NAME, OPERATOR, PARENT, PARENT_RECORD_ID, PARENT_TEST_RUN_ID, PASSED_RATE, PREVIEW, PROJECT_ID, QA_SYSTEM_INFO_LIST, RESOLVED, RESULTS, ROOT_CAUSE, ROOT_CAUSE_ID, START_DATE, TA_SYSTEM_INFO_LIST, TEST_RUN, TEST_RUN_ID, TESTCASE_ID, TESTCASE_NAME, TESTING_STATUS, TESTRUNS, TIMESTAMP, TOTAL_COUNT, TYPE, URL, USER_ID, UUID, VALIDATION_LABELS, VALIDATION_STEPS_LABELS, VALIDATION_TABLE, WARNING_RATE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindLastOrcLogRecordByTestRunAndExecutionStatus(UUID testRunId, ExecutionStatuses status) Find orchestrator log records.Find all LR-s by test runs ID and exist validation.findLogRecordsWithParentsByPreviewExists(UUID testRunId) Find all LR's with preview and list of parents (LR) by TR id.getAllHierarchicalChildrenLogRecords(UUID parentLogRecord) getLogRecordParentAndChildrenByTestingStatusAndTestRunId(UUID tesRunId, TestingStatuses testingStatus) Find first parent and children LR by TR is and status.getProjectIdByLogRecordId(UUID logRecordId) Get project id by logRecord id.getTopLogRecordsByFilterLookup(UUID testRunId, List<String> statuses, List<String> types, boolean showNotAnalyzedItemsOnly) Filter log records by lookup.getTopLogRecordsIdAndChildLogRecordsByFileTypeFilterLookup(UUID testRunId, FileType fileType) Get parent LR (top level) and list of child with pot files.
-
Constructor Details
-
CustomLogRecordRepositoryImpl
public CustomLogRecordRepositoryImpl()
-
-
Method Details
-
getTopLogRecordsByFilterLookup
public List<LogRecord> getTopLogRecordsByFilterLookup(UUID testRunId, List<String> statuses, List<String> types, boolean showNotAnalyzedItemsOnly) Filter log records by lookup. See here for details: https://docs.mongodb.com/manual/reference/operator/aggregation/graphLookup/ Query example: { $match: { testRunId: JUUID("00a2361c-0e54-467c-ab95-094df7f1eaeb"), parentRecordId: { "$exists": false }, rootCause: { "$exists": true } } }, { $graphLookup: { from: "logrecord", startWith: "$_id", connectFromField: "_id", connectToField: "parentRecordId", as: "children", depthField: "depth", restrictSearchWithMatch: { testingStatus: { $in: ["PASSED"] }, type: { $in: ["UI", "COMPOUND"] } } } }, { $match: { "children.0": { $exists: true } } }, { $project: { children: 0 } }- Specified by:
getTopLogRecordsByFilterLookupin interfaceCustomLogRecordRepository- Parameters:
testRunId- test run idstatuses- testing statusestypes- steps typesshowNotAnalyzedItemsOnly- is root cause present- Returns:
- search result
-
getAllHierarchicalChildrenLogRecords
- Specified by:
getAllHierarchicalChildrenLogRecordsin interfaceCustomLogRecordRepository
-
getTopLogRecordsIdAndChildLogRecordsByFileTypeFilterLookup
public List<LogRecordWithParentResponse> getTopLogRecordsIdAndChildLogRecordsByFileTypeFilterLookup(UUID testRunId, FileType fileType) Get parent LR (top level) and list of child with pot files. Query example: db.logrecord.aggregate( { $match: { testRunId: testRunIdVar, "fileMetadata.type": "POT", } }, { $graphLookup: { from: "logrecord", startWith: "$parentRecordId", connectFromField: "parentRecordId", connectToField: "_id", as: "parent", depthField: "depth", restrictSearchWithMatch: { testRunId: testRunIdVar } } } )- Specified by:
getTopLogRecordsIdAndChildLogRecordsByFileTypeFilterLookupin interfaceCustomLogRecordRepository- Parameters:
testRunId- id of TRfileType- type of file- Returns:
- map with parent ID and child
-
getLogRecordParentAndChildrenByTestingStatusAndTestRunId
public LogRecordWithChildrenResponse getLogRecordParentAndChildrenByTestingStatusAndTestRunId(UUID tesRunId, TestingStatuses testingStatus) Find first parent and children LR by TR is and status. Query example: var testRunIdVar = JUUID("12851ab0-5d4f-41b9-bfe2-e91a6c5c9783") db.logrecord.aggregate( { $match: { testRunId: testRunIdVar, parentRecordId: {$exists:false} } }, { $sort: { lastUpdated: 1 } }, { $graphLookup: { from: "logrecord", startWith: "$_id", connectFromField: "_id", connectToField: "parentRecordId", as: "children", depthField: "depth", restrictSearchWithMatch: { "testingStatus": "FAILED", } } }, { $match: { "children.0": {$exists: true} } }, { $unwind: "$children" }, { $sort: { "children.depth": -1 } }, { $limit: 1 } )- Specified by:
getLogRecordParentAndChildrenByTestingStatusAndTestRunIdin interfaceCustomLogRecordRepository- Parameters:
tesRunId- TR idtestingStatus- status- Returns:
- first LR with children
-
findLogRecordsByTestRunIdsAndValidationWithHint
Find all LR-s by test runs ID and exist validation.- Specified by:
findLogRecordsByTestRunIdsAndValidationWithHintin interfaceCustomLogRecordRepository- Parameters:
testRunIds- for found LR-s- Returns:
- list of LR-s
-
findLogRecordsWithParentsByPreviewExists
public List<LogRecordWithParentListResponse> findLogRecordsWithParentsByPreviewExists(UUID testRunId) Find all LR's with preview and list of parents (LR) by TR id. Query example: [ { "$match": { "testRunId": JUUID("26f1555b-85c6-489c-a2cf-691fa96e9f2f"), "preview": { "$exists": true, "$ne": "" } } }, { "$graphLookup": { "from": "logrecord", "startWith": "$parentRecordId", "connectFromField": "parentRecordId", "connectToField": "_id", "as": "parent", "depthField": "depth" } }, { "$project": { "name": 1, "testingStatus": 1, "startDate": 1, "parent": 1 } }, { "$sort": { "startDate": 1 } } ] Response example: [ { "_id":"4fc1dbbe-ab58-4090-9d4b-6363a068a315", "name":"Message", "startDate":2022-04-25T16:54:56.461Z, "testingStatus":"PASSED", "parent":[ { "_id": "32a63b59-18b2-40fa-9a35-dd137a7f5647", "name": "Login as \"user\" with password \"password\"", "type": "UI", "depth": 0 } ] } ]- Specified by:
findLogRecordsWithParentsByPreviewExistsin interfaceCustomLogRecordRepository- Parameters:
testRunId- Test Run id.- Returns:
- All LR's with preview and list of parents (LR).
-
findLastOrcLogRecordByTestRunAndExecutionStatus
public LogRecord findLastOrcLogRecordByTestRunAndExecutionStatus(UUID testRunId, ExecutionStatuses status) Find orchestrator log records. Query example: var testRunIdVar = JUUID("20d9e670-81e9-48c9-b0e9-8d22f4b850fa") var status = "IN PROGRESS"; db.logrecord.aggregate( [ { $match: { testRunId: testRunIdVar, executionStatus: status } }, { $sort: { createdDateStamp: -1 } }, { $graphLookup: { from: "logrecord", startWith: "$parentRecordId", connectFromField: "parentRecordId", connectToField: "_id", as: "parent", restrictSearchWithMatch: { testRunId: testRunIdVar } } }, { $match: { $or: [ { $and: [ { "parentRecordId": { $exists: false } }, { "type": {$ne: "COMPOUND"} } ] }, { $and: [ { "parent" : { $not: { $elemMatch: { "type": { $nin: ["COMPOUND"] } } } } }, { "parentRecordId": { $exists: true } } ] } ] } }, { $limit: 1 } ] )- Specified by:
findLastOrcLogRecordByTestRunAndExecutionStatusin interfaceCustomLogRecordRepository- Parameters:
testRunId- TR idstatus- execution status
-
getProjectIdByLogRecordId
Get project id by logRecord id. db.logrecord.aggregate([ { $match: { _id: LUUID("ff4ebd21-947b-86c0-b765-0237ac4adca4") } }, { $lookup: { from: "testrun", localField: "testRunId", foreignField: "_id", as: "testrun" } }, { $unwind: "$testrun" }, { $lookup: { from: "executionRequests", localField: "testrun.executionRequestId", foreignField: "_id", as: "executionRequest" } }, { $unwind: "$executionRequest" }, { $project: { "projectId": "$executionRequest.projectId", "_id": 0 } } ] )- Specified by:
getProjectIdByLogRecordIdin interfaceCustomLogRecordRepository
-