use of com.navercorp.pinpoint.web.vo.AgentStatus in project pinpoint by naver.
the class HbaseAgentLifeCycleDaoTest method agentInfos_should_be_populated_accordingly_even_with_nulls.
@Test
public void agentInfos_should_be_populated_accordingly_even_with_nulls() {
// Given
final String expectedAgentId = "test-agent";
final long expectedTimestamp = 1000L;
final AgentLifeCycleState expectedAgentLifeCycleState = AgentLifeCycleState.RUNNING;
final AgentLifeCycleBo scannedLifeCycleBo = createAgentLifeCycleBo(expectedAgentId, expectedTimestamp, expectedAgentLifeCycleState);
when(this.hbaseOperations2.findParallel(any(TableName.class), anyListOf(Scan.class), any(ResultsExtractor.class))).thenReturn(Arrays.asList(scannedLifeCycleBo, scannedLifeCycleBo));
AgentInfo nonNullAgentInfo = new AgentInfo();
nonNullAgentInfo.setAgentId(expectedAgentId);
nonNullAgentInfo.setStartTimestamp(expectedTimestamp);
AgentInfo nullAgentInfo = null;
List<AgentInfo> givenAgentInfos = Arrays.asList(nonNullAgentInfo, nullAgentInfo, nonNullAgentInfo, nullAgentInfo);
// When
this.agentLifeCycleDao.populateAgentStatuses(givenAgentInfos, expectedTimestamp);
// Then
Assert.assertEquals(nonNullAgentInfo, givenAgentInfos.get(0));
Assert.assertEquals(nullAgentInfo, givenAgentInfos.get(1));
Assert.assertEquals(nonNullAgentInfo, givenAgentInfos.get(2));
Assert.assertEquals(nullAgentInfo, givenAgentInfos.get(3));
AgentStatus nonNullAgentInfoStatus = nonNullAgentInfo.getStatus();
Assert.assertEquals(expectedAgentId, nonNullAgentInfoStatus.getAgentId());
Assert.assertEquals(expectedTimestamp, nonNullAgentInfoStatus.getEventTimestamp());
Assert.assertEquals(expectedAgentLifeCycleState, nonNullAgentInfoStatus.getState());
}
use of com.navercorp.pinpoint.web.vo.AgentStatus in project pinpoint by naver.
the class HbaseAgentLifeCycleDaoTest method agentInfo_should_be_populated_as_unknown_if_status_cannot_be_found.
@Test
public void agentInfo_should_be_populated_as_unknown_if_status_cannot_be_found() {
// Given
final String expectedAgentId = "test-agent";
final long expectedTimestamp = 0L;
final AgentLifeCycleState expectedAgentLifeCycleState = AgentLifeCycleState.UNKNOWN;
final AgentLifeCycleBo scannedLifeCycleBo = null;
when(this.hbaseOperations2.find(any(TableName.class), any(Scan.class), any(ResultsExtractor.class))).thenReturn(scannedLifeCycleBo);
AgentInfo givenAgentInfo = new AgentInfo();
givenAgentInfo.setAgentId(expectedAgentId);
givenAgentInfo.setStartTimestamp(expectedTimestamp);
// When
this.agentLifeCycleDao.populateAgentStatus(givenAgentInfo, expectedTimestamp);
// Then
AgentStatus actualAgentStatus = givenAgentInfo.getStatus();
Assert.assertEquals(expectedAgentId, actualAgentStatus.getAgentId());
Assert.assertEquals(expectedTimestamp, actualAgentStatus.getEventTimestamp());
Assert.assertEquals(expectedAgentLifeCycleState, actualAgentStatus.getState());
}
use of com.navercorp.pinpoint.web.vo.AgentStatus in project pinpoint by naver.
the class AgentStatusTimelineTest method agentStatus.
@Test
public void agentStatus() {
// Given
Range timelineRange = new Range(100, 200);
AgentLifeCycleState expectedState = AgentLifeCycleState.RUNNING;
List<AgentStatusTimelineSegment> expectedTimelineSegments = Collections.singletonList(createSegment(100, 200, AgentState.fromAgentLifeCycleState(expectedState)));
// When
AgentStatus initialStatus = createAgentStatus(50, expectedState);
AgentStatusTimeline timeline = new AgentStatusTimelineBuilder(timelineRange, initialStatus).build();
// Then
Assert.assertEquals(expectedTimelineSegments, timeline.getTimelineSegments());
Assert.assertFalse(timeline.isIncludeWarning());
}
use of com.navercorp.pinpoint.web.vo.AgentStatus in project pinpoint by naver.
the class AgentStatusTimelineTest method agentStatus_nullAgentEvents.
@Test
public void agentStatus_nullAgentEvents() {
// Given
Range timelineRange = new Range(100, 200);
AgentLifeCycleState expectedState = AgentLifeCycleState.RUNNING;
List<AgentStatusTimelineSegment> expectedTimelineSegments = Collections.singletonList(createSegment(100, 200, AgentState.fromAgentLifeCycleState(expectedState)));
// When
AgentStatus initialStatus = createAgentStatus(50, expectedState);
AgentStatusTimeline timeline = new AgentStatusTimelineBuilder(timelineRange, initialStatus).from(null).build();
// Then
Assert.assertEquals(expectedTimelineSegments, timeline.getTimelineSegments());
Assert.assertFalse(timeline.isIncludeWarning());
}
use of com.navercorp.pinpoint.web.vo.AgentStatus in project pinpoint by naver.
the class AgentStatusTimelineTest method multipleLifeCycles_mixed.
@Test
public void multipleLifeCycles_mixed() {
// Given
Range timelineRange = new Range(100, 300);
List<AgentStatusTimelineSegment> expectedTimelineSegments = Arrays.asList(createSegment(100, 150, AgentState.RUNNING), createSegment(150, 160, AgentState.UNKNOWN), createSegment(160, 250, AgentState.RUNNING), createSegment(250, 260, AgentState.SHUTDOWN), createSegment(260, 290, AgentState.RUNNING), createSegment(290, 300, AgentState.UNKNOWN));
// When
long agentA = 90;
long agentB = 160;
long agentC = 220;
long agentD = 260;
AgentStatus initialStatus = createAgentStatus(90, AgentLifeCycleState.RUNNING);
AgentStatusTimeline timeline = new AgentStatusTimelineBuilder(timelineRange, initialStatus).from(Arrays.asList(createAgentEvent(agentA, 120, AgentEventType.AGENT_PING), createAgentEvent(agentA, 150, AgentEventType.AGENT_UNEXPECTED_CLOSE_BY_SERVER), createAgentEvent(agentB, 160, AgentEventType.AGENT_CONNECTED), createAgentEvent(agentB, 200, AgentEventType.AGENT_PING), createAgentEvent(agentC, 220, AgentEventType.AGENT_CONNECTED), createAgentEvent(agentB, 220, AgentEventType.AGENT_CLOSED_BY_SERVER), createAgentEvent(agentC, 250, AgentEventType.AGENT_SHUTDOWN), createAgentEvent(agentD, 260, AgentEventType.AGENT_CONNECTED), createAgentEvent(agentD, 290, AgentEventType.AGENT_CLOSED_BY_SERVER))).build();
// Then
Assert.assertEquals(expectedTimelineSegments, timeline.getTimelineSegments());
Assert.assertTrue(timeline.isIncludeWarning());
}
Aggregations