use of com.google.cloud.videointelligence.v1p3beta1.Entity in project hypertrace-ingester by hypertrace.
the class KafkaBackendProviderTest method TestOTBackendEventResolution.
@Test
public void TestOTBackendEventResolution() {
String brokerHost = "kafka-test.hypertrace.com";
String brokerPort = "9092";
Entity entity = backendEntityEnricher.resolve(getOTKafkaBackendEvent(brokerHost, brokerPort), structuredTrace, structuredTraceGraph).get().getEntity();
Assertions.assertEquals(String.format("%s:%s", brokerHost, brokerPort), entity.getEntityName());
}
use of com.google.cloud.videointelligence.v1p3beta1.Entity in project hypertrace-ingester by hypertrace.
the class KafkaBackendProviderTest method TestOtelBackendEventResolution.
@Test
public void TestOtelBackendEventResolution() {
String broker = "kafka-test.hypertrace.com:9092";
BackendInfo backendInfo = backendEntityEnricher.resolve(getOtelKafkaBackendEvent(broker), structuredTrace, structuredTraceGraph).get();
Entity entity = backendInfo.getEntity();
Assertions.assertEquals(broker, entity.getEntityName());
Map<String, AttributeValue> attributes = backendInfo.getAttributes();
assertEquals(Map.of("BACKEND_OPERATION", AttributeValueCreator.create("receive")), attributes);
}
use of com.google.cloud.videointelligence.v1p3beta1.Entity in project beam by apache.
the class DatastoreV1Test method testReadFnRetriesErrors.
/**
* Tests that {@link ReadFn} retries after an error.
*/
@Test
public void testReadFnRetriesErrors() throws Exception {
// An empty query to read entities.
Query query = Query.newBuilder().setLimit(Int32Value.newBuilder().setValue(1)).build();
// Use mockResponseForQuery to generate results.
when(mockDatastore.runQuery(any(RunQueryRequest.class))).thenThrow(new DatastoreException("RunQuery", Code.DEADLINE_EXCEEDED, "", null)).thenAnswer(invocationOnMock -> {
Query q = ((RunQueryRequest) invocationOnMock.getArguments()[0]).getQuery();
return mockResponseForQuery(q);
});
ReadFn readFn = new ReadFn(V_1_OPTIONS, mockDatastoreFactory);
DoFnTester<Query, Entity> doFnTester = DoFnTester.of(readFn);
doFnTester.setCloningBehavior(CloningBehavior.DO_NOT_CLONE);
doFnTester.processBundle(query);
verifyMetricWasSet("BatchDatastoreRead", "ok", NAMESPACE, 1);
verifyMetricWasSet("BatchDatastoreRead", "unknown", NAMESPACE, 1);
}
use of com.google.cloud.videointelligence.v1p3beta1.Entity in project beam by apache.
the class DatastoreV1Test method testAddEntities.
@Test
public /**
* Test that entities with valid keys are transformed to upsert mutations.
*/
void testAddEntities() throws Exception {
Key key = makeKey("bird", "finch").build();
Entity entity = Entity.newBuilder().setKey(key).build();
UpsertFn upsertFn = new UpsertFn();
Mutation expectedMutation = makeUpsert(entity).build();
assertEquals(expectedMutation, upsertFn.apply(entity));
}
use of com.google.cloud.videointelligence.v1p3beta1.Entity in project beam by apache.
the class EntityToRowRowToEntityTest method testRowToEntityConverterWithoutKey.
@Test
public void testRowToEntityConverterWithoutKey() {
Schema schemaWithoutKey = Schema.builder().addFields(SCHEMA.getFields().stream().filter(f -> !f.getName().equals("__key__")).collect(Collectors.toList())).build();
Row rowWithoutKey = Row.withSchema(schemaWithoutKey).addValues(schemaWithoutKey.getFieldNames().stream().map(ROW::getValue).collect(Collectors.toList())).build();
PCollection<Entity> result = pipeline.apply(Create.of(rowWithoutKey)).setRowSchema(schemaWithoutKey).apply(RowToEntity.createTest(UUID_VALUE, "__key__", KIND));
PAssert.that(result).containsInAnyOrder(ENTITY);
pipeline.run().waitUntilFinish();
}
Aggregations