use of org.influxdb.InfluxDB in project spring-boot by spring-projects.
the class InfluxDbHealthIndicatorTests method influxDbIsUp.
@Test
void influxDbIsUp() {
Pong pong = mock(Pong.class);
given(pong.getVersion()).willReturn("0.9");
InfluxDB influxDb = mock(InfluxDB.class);
given(influxDb.ping()).willReturn(pong);
InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDb);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("version")).isEqualTo("0.9");
then(influxDb).should().ping();
}
use of org.influxdb.InfluxDB in project spring-boot by spring-projects.
the class InfluxDbHealthIndicatorTests method influxDbIsDown.
@Test
void influxDbIsDown() {
InfluxDB influxDb = mock(InfluxDB.class);
given(influxDb.ping()).willThrow(new InfluxDBException(new IOException("Connection failed")));
InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDb);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
assertThat((String) health.getDetails().get("error")).contains("Connection failed");
then(influxDb).should().ping();
}
use of org.influxdb.InfluxDB in project cloudstack by apache.
the class StatsCollectorTest method configureAndTestCreateInfluxDbConnection.
private void configureAndTestCreateInfluxDbConnection(boolean databaseExists) {
statsCollector.externalStatsHost = HOST_ADDRESS;
statsCollector.externalStatsPort = INFLUXDB_DEFAULT_PORT;
InfluxDB influxDbConnection = Mockito.mock(InfluxDB.class);
Mockito.when(influxDbConnection.databaseExists(DEFAULT_DATABASE_NAME)).thenReturn(databaseExists);
PowerMockito.mockStatic(InfluxDBFactory.class);
PowerMockito.when(InfluxDBFactory.connect(URL)).thenReturn(influxDbConnection);
InfluxDB returnedConnection = statsCollector.createInfluxDbConnection();
Assert.assertEquals(influxDbConnection, returnedConnection);
}
use of org.influxdb.InfluxDB in project cloudstack by apache.
the class StatsCollectorTest method writeBatchesTest.
@Test
public void writeBatchesTest() {
InfluxDB influxDbConnection = Mockito.mock(InfluxDB.class);
Mockito.doNothing().when(influxDbConnection).write(Mockito.any(Point.class));
Builder builder = Mockito.mock(Builder.class);
BatchPoints batchPoints = Mockito.mock(BatchPoints.class);
PowerMockito.mockStatic(BatchPoints.class);
PowerMockito.when(BatchPoints.database(DEFAULT_DATABASE_NAME)).thenReturn(builder);
Mockito.when(builder.build()).thenReturn(batchPoints);
Map<String, String> tagsToAdd = new HashMap<>();
tagsToAdd.put("hostId", "1");
Map<String, Object> fieldsToAdd = new HashMap<>();
fieldsToAdd.put("total_memory_kbs", 10000000);
Point point = Point.measurement("measure").tag(tagsToAdd).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS).fields(fieldsToAdd).build();
List<Point> points = new ArrayList<>();
points.add(point);
Mockito.when(batchPoints.point(point)).thenReturn(batchPoints);
statsCollector.writeBatches(influxDbConnection, DEFAULT_DATABASE_NAME, points);
Mockito.verify(influxDbConnection).write(batchPoints);
}
use of org.influxdb.InfluxDB in project wildfly-camel by wildfly-extras.
the class InfluxDBIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
cubeController.create(CONTAINER_INFLUX_DB);
cubeController.start(CONTAINER_INFLUX_DB);
InfluxDB influxDB = InfluxDBFactory.connect("http://" + TestUtils.getDockerHost() + ":8086", "admin", "admin");
influxDB.createDatabase(INFLUX_DB_NAME);
context.bind(INFLUX_DB_BIND_NAME, influxDB);
}
Aggregations