use of com.navercorp.pinpoint.web.vo.AgentInfo in project pinpoint by naver.
the class ServerInstanceListTest method createAgentInfo.
public static AgentInfo createAgentInfo(String agentId, String hostName) {
AgentInfoBo.Builder agentInfoBuilder = new AgentInfoBo.Builder();
agentInfoBuilder.setAgentId(agentId);
ServiceType serviceType = ServiceType.TEST_STAND_ALONE;
agentInfoBuilder.setServiceTypeCode(serviceType.getCode());
agentInfoBuilder.setHostName(hostName);
return new AgentInfo(agentInfoBuilder.build());
}
use of com.navercorp.pinpoint.web.vo.AgentInfo in project pinpoint by naver.
the class HbaseAgentLifeCycleDaoTest method agentInfo_should_be_populated_appropriately_if_status_is_known.
@Test
public void agentInfo_should_be_populated_appropriately_if_status_is_known() {
// 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.find(any(TableName.class), any(Scan.class), any(ResultsExtractor.class))).thenReturn(scannedLifeCycleBo);
// When
AgentInfo givenAgentInfo = new AgentInfo();
givenAgentInfo.setAgentId(expectedAgentId);
givenAgentInfo.setStartTimestamp(expectedTimestamp);
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.AgentInfo 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.AgentInfo 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.AgentInfo in project pinpoint by naver.
the class ServerInstanceListSerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
ObjectMapper mapper = createMapper();
AgentInfo agentInfo = ServerInstanceListTest.createAgentInfo("agentId1", "testHost");
Set<AgentInfo> agentInfoSet = new HashSet<>();
agentInfoSet.add(agentInfo);
ServerBuilder builder = new ServerBuilder();
builder.addAgentInfo(agentInfoSet);
ServerInstanceList serverInstanceList = builder.build();
ObjectWriter objectWriter = mapper.writerWithDefaultPrettyPrinter();
String json = objectWriter.writeValueAsString(serverInstanceList);
logger.debug(json);
}
Aggregations