Skip to main content

Coverage Collection Event Flow

Details#

Precondition#

An Agent has established a connection with the Drill Admin and Agent has been registered.

Flow#

  1. User executes HTTP request to start a session.
  2. Admin does an action StartNewSession.
  3. Admin's plugin part starts the session on its side and sends StartAgentSession to the agent's plugin part.
  4. Probes collection is started. Agent's plugin part responds SessionStarted to admin's plugin part.
  5. Agent's plugin part collect ExecClassData and sends СoverDataPart in chunks max. 65535 objects every 2 seconds to the admin's plugin part.

    Probes are sent only for the affected classes

  6. If the started session has real-time enabled:
    • agent's plugin part sends SessionChanged to the admin's plugin part.
    • admin's plugin part recalculates coverage.
  7. User executes HTTP request to stop session.
  8. Admin does an action StopSession.
  9. Admin's plugin part sends StopAgentSession to agent's plugin part.
  10. Repetition of the 5th point and finishes collecting probes.
  11. Agent's plugin part sends SessionsFinished to admin's plugin part.
  12. Admin's plugin part recalculates coverage and finishes session on its side.

Sequence Diagram#

Exception (Step 8)#

If CancelSession is received instead of StopSession flow is changed:

  1. Admin's plugin part cancels session on its side and sends CancelAgentSession to agent's plugin part.
  2. Probes collection is finished. Agent's plugin part responds SessionCancelled to admin's plugin part.

API#

Agent's Plugin Part (Incoming Messages):#

@Serializable
@SerialName("START_AGENT_SESSION")
data class StartAgentSession(val payload: StartSessionPayload) : AgentAction()
@Serializable
@SerialName("ADD_SESSION_DATA")
data class AddAgentSessionData(val payload: AgentSessionDataPayload) : AgentAction()
@SerialName("STOP")
@Serializable
data class StopAgentSession(val payload: AgentSessionPayload) : AgentAction()
@SerialName("STOP_ALL")
@Serializable
object StopAllAgentSessions : AgentAction()
@SerialName("CANCEL")
@Serializable
data class CancelAgentSession(val payload: AgentSessionPayload) : AgentAction()
@SerialName("CANCEL_ALL")
@Serializable
object CancelAllAgentSessions : AgentAction()
@Serializable
data class StartSessionPayload(
val sessionId: String,
val testType: String,
val testName: String?,
val isRealtime: Boolean,
val isGlobal: Boolean
)
@Serializable
data class AgentSessionPayload(
val sessionId: String
)
@Serializable
data class AgentSessionDataPayload(val sessionId: String, val data: String)

Agent's Plugin Part (Outgoing Messages):#

@SerialName("SESSION_STARTED")
@Serializable
data class SessionStarted(
val sessionId: String,
val testType: String,
val isRealtime: Boolean = false,
val ts: Long
) : CoverMessage()
@SerialName("SESSION_CANCELLED")
@Serializable
data class SessionCancelled(val sessionId: String, val ts: Long) : CoverMessage()
@SerialName("SESSIONS_CANCELLED")
@Serializable
data class SessionsCancelled(val ids: List<String>, val ts: Long) : CoverMessage()
@SerialName("COVERAGE_DATA_PART")
@Serializable
data class CoverDataPart(val sessionId: String, val data: List<ExecClassData>) : CoverMessage()
@SerialName("SESSION_CHANGED")
@Serializable
data class SessionChanged(val sessionId: String, val probeCount: Int) : CoverMessage()
@SerialName("SESSION_FINISHED")
@Serializable
data class SessionFinished(val sessionId: String, val ts: Long) : CoverMessage()
@SerialName("SESSIONS_FINISHED")
@Serializable
data class SessionsFinished(val ids: List<String>, val ts: Long) : CoverMessage()

Admin's Plugin Part (Incoming Messages from Admin):#

@SerialName("START")
@Serializable
data class StartNewSession(val payload: StartPayload) : Action()
@SerialName("CANCEL")
@Serializable
data class CancelSession(val payload: SessionPayload) : Action()
@SerialName("CANCEL_ALL")
@Serializable
object CancelAllSessions : Action()
@SerialName("STOP")
@Serializable
data class StopSession(val payload: StopSessionPayload) : Action()
@SerialName("STOP_ALL")
@Serializable
object StopAllSessions : Action()

Examples#

Agent Incoming Messages#

{
"type":"START_AGENT_SESSION",
"payload":{
"sessionId": "some-id",
"testType":"Manual or Auto or custom",
"testName":"some-name",
"isRealtime": "true or false",
"isGlobal":"true or false"
}
}
{
"type":"STOP",
"payload":{
"sessionId": "some-id"
}
}

Agent Outgoing Messages#

{
"type":"SESSION_STARTED",
"sessionId":"session-id",
"testType":"manual or auto",
"isRealtime":"true or false",
"ts":"start time"
}
{
"type":"SCOPE_INITIALIZED",
"id":"session-id",
"name":"scope-name",
"prevId":"some-id",
"ts":"start time"
}
{
"type":"INITIALIZED",
"msg":"Initialized"
}