Skip to main content

Interactions between API and Analyzer

Overview

Communication between API service and analyzer service is carried out using AMQP 0-9-1 and RabbitMQ as message broker. API service creates virtual host inside RabbitMQ with name analyzer on start. Analyzers in theirs turn connect to the virtual host and declare exchange with name and arguments. Any type of request from API and response from analyzer stores in the same queue. Request and response messages is presented as JSON.

Declaring exchange

Each analyzer has to declare direct exchange with the following arguments:

  • analyzer - Name of analyzer (string)
  • version - Analyzer version (string)
  • analyzer_index - Is indexing supported (boolean, false by default)
  • analyzer_log_search - Is log searching supported (boolean, false by default)
  • analyzer_priority - Priority of analyzer (number). The lower the number, the higher the priority.

Declaring queues

Each analyzer has to declare 5 queues with names: analyze, search, index, clean, delete.

Indexing

Index request can be used to store info about logs and then analysis will be proceed based on the info. Requests and responses use index queue.

Index request structure from API:

IndexLaunch:

AttributeDescriptionExample
launchIdId of launch101
launchNameName of launchSmoke Test
projectId of project12
analyzerConfigAnalyzer configuration
testItemsArray of test items

AnalyzerConfig:

AttributeDescriptionExample
minDocFreqThe minimum frequency of the saved logs1
minTermFreqThe minimum frequency of the word in the analyzed log1
minShouldMatchPercent of words equality between analyzed log and particular log from index95
numberOfLogLinesThe number of first lines of log message that should be considered in indeT-1
isAutoAnalyzerEnabledIs auto analysis enabledtrue
analyzerModeAnalysis mode. Allowable values: "all", "launch_name", "current_launch"all
indexingRunningIs indexing runningfalse

IndexTestItem:

AttributeDescriptionExample
testItemIdId of test item123
issueTypeIssue type locatorpb001
uniqueIdUnique id of test itemauto:c6edafc24a03c6f69b6ec070d1fd0089
isAutoAnalyzedIs test item auto analyzedfalse
logsArray of test item logs

IndexLog:

AttributeDescrioptionExample
logIdId of log125
logLevelLog level40000
messageLog messagejava.lang.AssertionError: 1 expectation failed. Expected status code <200> but was <400>. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

API send array of IndexLaunch entities that have to be indexed.

Example in json :

[
{
"launchId":110,
"launchName":"Smoke Test",
"project":11,
"analyzerConfig":{
"minDocFreq":1,
"minTermFreq":1,
"minShouldMatch":95,
"numberOfLogLines":-1,
"isAutoAnalyzerEnabled":true,
"analyzerMode":"all",
"indexingRunning":false
},
"testItems":[
{
"testItemId":101,
"issueType":"pb001",
"uniqueId":"auto:c6edafc24a03c6f69b6ec070d1fd0089",
"isAutoAnalyzed":false,
"logs":[
{
"logId":111,
"logLevel":40000,
"message":"java.lang.AssertionError: 1 expectation failed. Expected status code <200> but was <400>."
},
{
"logId":112,
"logLevel":40000,
"message":"java.lang.AssertionError: 1 expectation failed. Expected status code <200> but was <500>."
}
]
}
]
}
]

Analyzer should return response with number of indexed logs.

Analyze

Analyze request can be used to find matches from request in indexed data. Requests and responses use analyze queue.

Analyze request is the same as IndexLaunch entity used for indexing. It contains info about test items and logs thad have to be analyzed.

Response from analyzer should contain array of the following entities (info about analyzed test items):

AnalyzedItemRs:

AttributeDescriptionExample
itemIdId of analyzed test item111
relevantItemIdId of relevant test item123
issueTypeIssue type locatorpb001

Search logs

Search request can be used to find similar logs from test items with to_investigate type. Requests and responses use search queue.

Search logs request from API:

SearchRq:

AttributeDescriptionExample
launchIdId of launch111
launchNameName of launchSmoke Test
itemIdId of test item112
projectIdId of project10
filteredLaunchIdsArray of launch ids, among with search would be applied[1,2,3]
logMessagesArray of log messages looking for["first message", "second message"]
logLinesNumber of logs lines that will be used in comparison5

Analyzer should return array of log ids that matches as a response.

Clean

Clean request can be used to remove stored log from index. Requests use clean queue.

Clean logs request from API:

CleanIndexRq:

AttributeDescriptionExample
projectId of project10
idsArray of log ids to be removed[111, 122, 123]

Analyzer do not send response on the request.

Delete

Delete request can be used to delete entire index. Requests use delete queue.

Request message from API contains only id of index.

Analyzer do not send response on the request.

Examples

Custom analyzer written in java using Spring AMQP.