Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integ tests #131

Merged
merged 5 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@ public void testQuery() {
executionContext);
}

@Test
public void testQuerySelectionUsingAggregateFunctionUsingMapAttribute() {
Builder builder = QueryRequest.newBuilder();
builder.addSelection(
createFunctionExpression(
"sum", createComplexAttributeExpression("Span.tags", "otel.status_code").build()));
ViewDefinition viewDefinition = getDefaultViewDefinition();
defaultMockingForExecutionContext();

assertPQLQuery(
builder.build(),
"Select sum(mapValue(tags__KEYS,'otel.status_code',tags__VALUES)) FROM SpanEventView "
+ "where "
+ viewDefinition.getTenantIdColumn()
+ " = '"
+ TENANT_ID
+ "'",
viewDefinition,
executionContext);
}

@Test
public void testQuerySelectionUsingMapAttributeWithSubPath() {
Builder builder = QueryRequest.newBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,19 @@ public void testAttributeExpressionQueries(
assertEquals(expectedValue, rows.get(0).getColumn(0).getString());
}

@Test
public void testNotContainsKeyQuery() throws IOException {
LOG.info("Not contains key query");
Iterator<ResultSetChunk> itr =
queryServiceClient.executeQuery(
buildQueryFromJsonFile("not_contains_key_query.json"), TENANT_ID_MAP, 10000);
List<ResultSetChunk> list = Streams.stream(itr).collect(Collectors.toList());
List<Row> rows = list.get(0).getRowList();
assertEquals(10, rows.size());
assertEquals(
"\"http.status_code\":\"200\"", rows.get(0).getColumn(0).getString().split(",")[1]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all the rows are having the same values? Would this always be true that the first-row first column will have this value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all the rows are having the same values?

No

Would this always be true that the first-row first column will have this value?

Should be as we are generating same load ?

}

private static Stream<Arguments> provideQueryRequestForServiceQueries()
throws InvalidProtocolBufferException {
QueryRequest queryRequest1 = ServicesQueries.buildQuery1();
Expand Down Expand Up @@ -446,7 +459,8 @@ private static Stream<Arguments> provideQueryRequestForExplorerQueries()
private static Stream<Arguments> provideQueryRequestForAttributeExpressionQueries()
throws IOException {
return Stream.of(
Arguments.arguments(buildQueryFromJsonFile("query1.json"), 10, "server"),
Arguments.arguments(buildQueryFromJsonFile("query2.json"), 2, "server"));
Arguments.arguments(buildQueryFromJsonFile("order_by_query.json"), 10, "server"),
Arguments.arguments(buildQueryFromJsonFile("group_by_query.json"), 2, "server"),
Arguments.arguments(buildQueryFromJsonFile("aggregated_function_query.json"), 1, "0.0"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"selection": [{
"function": {
"functionName": "sum",
"arguments": [{
"attributeExpression": {
"attributeId": "EVENT.spanTags",
"subpath": "otel.status_code"
}
}]
}
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"filter": {
"lhs": {
"attributeExpression": {
"attributeId": "EVENT.spanTags"
}
},
"operator": "NOT_CONTAINS_KEY",
"rhs": {
"literal": {
"value": {
"string": "Flags"
}
}
}
},
"selection": [{
"attributeExpression": {
"attributeId": "EVENT.spanTags"
}
}]
}