use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState in project pinpoint by naver.
the class HbaseAgentLifeCycleDaoTest method status_should_be_unknown_if_status_cannot_be_found.
@Test
public void status_should_be_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);
// When
AgentStatus agentStatus = this.agentLifeCycleDao.getAgentStatus(expectedAgentId, expectedTimestamp);
// Then
Assert.assertEquals(expectedAgentId, agentStatus.getAgentId());
Assert.assertEquals(expectedTimestamp, agentStatus.getEventTimestamp());
Assert.assertEquals(expectedAgentLifeCycleState, agentStatus.getState());
}
use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState in project pinpoint by naver.
the class HbaseAgentLifeCycleDaoTest method status_should_be_set_appropriately_if_status_is_known.
@Test
public void status_should_be_set_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
AgentStatus agentStatus = this.agentLifeCycleDao.getAgentStatus(expectedAgentId, expectedTimestamp);
// Then
Assert.assertEquals(expectedAgentId, agentStatus.getAgentId());
Assert.assertEquals(expectedTimestamp, agentStatus.getEventTimestamp());
Assert.assertEquals(expectedAgentLifeCycleState, agentStatus.getState());
}
use of com.navercorp.pinpoint.common.server.util.AgentLifeCycleState 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.common.server.util.AgentLifeCycleState 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.common.server.util.AgentLifeCycleState 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());
}
Aggregations