aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorOla Aunrønning <olaa@verizonmedia.com>2021-06-14 13:00:23 +0200
committerOla Aunrønning <olaa@verizonmedia.com>2021-06-14 13:00:23 +0200
commit7e6d6fc65b5e1bfeb800f7469750f5cfc2ef37c9 (patch)
treeb3e2deda8c118c488bf5eaf51b1fbc46d05e5033 /controller-server
parent52822d71c014047e09a4e31f43d55b094426f7c6 (diff)
Assume AND if operand is not specified
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/horizon/TsdbQueryRewriter.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/horizon/TsdbQueryRewriterTest.java4
-rw-r--r--controller-server/src/test/resources/horizon/filters-meta-query.expected.json39
-rw-r--r--controller-server/src/test/resources/horizon/filters-meta-query.json72
-rw-r--r--controller-server/src/test/resources/horizon/meta-query.json29
5 files changed, 70 insertions, 76 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/horizon/TsdbQueryRewriter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/horizon/TsdbQueryRewriter.java
index 0dadfa93940..2060336487d 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/horizon/TsdbQueryRewriter.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/horizon/TsdbQueryRewriter.java
@@ -68,7 +68,7 @@ public class TsdbQueryRewriter {
ObjectNode prev = ((ObjectNode) parent.get("filter"));
ArrayNode filters;
// If we dont already have a filter object, or the object that we have is not an AND filter
- if (prev == null || !"Chain".equals(prev.get("type").asText()) || prev.get("op") == null || !"AND".equals(prev.get("op").asText())) {
+ if (prev == null || !"Chain".equals(prev.get("type").asText()) || prev.get("op") != null && !"AND".equals(prev.get("op").asText())) {
// Create new filter object
filters = parent.putObject("filter")
.put("type", "Chain")
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/horizon/TsdbQueryRewriterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/horizon/TsdbQueryRewriterTest.java
index 7c1a84f80bc..ab9d50f8eae 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/horizon/TsdbQueryRewriterTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/horizon/TsdbQueryRewriterTest.java
@@ -36,8 +36,8 @@ public class TsdbQueryRewriterTest {
"no-filters.expected.json",
Role.reader(TenantName.from("tenant2")), Role.athenzTenantAdmin(TenantName.from("tenant3")));
- assertRewrite("meta-query.json",
- "filters-meta-query.json",
+ assertRewrite("filters-meta-query.json",
+ "filters-meta-query.expected.json",
Role.reader(TenantName.from("tenant2")), Role.athenzTenantAdmin(TenantName.from("tenant3")));
}
diff --git a/controller-server/src/test/resources/horizon/filters-meta-query.expected.json b/controller-server/src/test/resources/horizon/filters-meta-query.expected.json
new file mode 100644
index 00000000000..6c8cab217fa
--- /dev/null
+++ b/controller-server/src/test/resources/horizon/filters-meta-query.expected.json
@@ -0,0 +1,39 @@
+{
+ "from": 0,
+ "to": 1,
+ "order": "ASCENDING",
+ "type": "TAG_KEYS_AND_VALUES",
+ "source": "",
+ "aggregationSize": 1000,
+ "queries": [
+ {
+ "id": "id-0",
+ "namespace": "Vespa",
+ "filter": {
+ "type": "Chain",
+ "filters": [
+ {
+ "type": "TagValueRegex",
+ "filter": ".*",
+ "tagKey": "applicationId"
+ },
+ {
+ "type": "MetricLiteral",
+ "metric": "vespa.distributor.vds.distributor.docsstored.average|vespa.searchnode.content.proton.resource_usage.disk.average|vespa.searchnode.content.proton.resource_usage.memory.average|vespa.container.peak_qps.max"
+ },
+ {
+ "type": "TagValueLiteralOr",
+ "filter": "public",
+ "tagKey": "system"
+ },
+ {
+ "type": "TagValueRegex",
+ "filter": "^(tenant2|tenant3)\\..*",
+ "tagKey": "applicationId"
+ }
+ ]
+ }
+ }
+ ],
+ "aggregationField": "applicationId"
+}
diff --git a/controller-server/src/test/resources/horizon/filters-meta-query.json b/controller-server/src/test/resources/horizon/filters-meta-query.json
index 0a9429fd833..ed59bef5eaa 100644
--- a/controller-server/src/test/resources/horizon/filters-meta-query.json
+++ b/controller-server/src/test/resources/horizon/filters-meta-query.json
@@ -1,45 +1,29 @@
{
- "from": 0,
- "to": 1,
- "order": "ASCENDING",
- "type": "TAG_KEYS_AND_VALUES",
- "source": "",
- "aggregationSize": 1000,
- "queries": [
- {
- "id": "id-0",
- "namespace": "Vespa",
- "filter": {
- "type": "Chain",
- "op": "AND",
- "filters": [
- {
- "type": "Chain",
- "filters": [
- {
- "type": "TagValueRegex",
- "filter": ".*",
- "tagKey": "applicationId"
- },
- {
- "type": "MetricLiteral",
- "metric": "vespa.distributor.vds.distributor.docsstored.average|vespa.searchnode.content.proton.resource_usage.disk.average|vespa.searchnode.content.proton.resource_usage.memory.average|vespa.container.peak_qps.max"
- }
- ]
- },
- {
- "type": "TagValueLiteralOr",
- "filter": "public",
- "tagKey": "system"
- },
- {
- "type": "TagValueRegex",
- "filter": "^(tenant2|tenant3)\\..*",
- "tagKey": "applicationId"
- }
- ]
- }
- }
- ],
- "aggregationField": "applicationId"
-}
+ "from": 0,
+ "to": 1,
+ "order": "ASCENDING",
+ "type": "TAG_KEYS_AND_VALUES",
+ "source": "",
+ "aggregationSize": 1000,
+ "queries": [
+ {
+ "id": "id-0",
+ "namespace": "Vespa",
+ "filter": {
+ "type": "Chain",
+ "filters": [
+ {
+ "type": "TagValueRegex",
+ "filter": ".*",
+ "tagKey": "applicationId"
+ },
+ {
+ "type": "MetricLiteral",
+ "metric": "vespa.distributor.vds.distributor.docsstored.average|vespa.searchnode.content.proton.resource_usage.disk.average|vespa.searchnode.content.proton.resource_usage.memory.average|vespa.container.peak_qps.max"
+ }
+ ]
+ }
+ }
+ ],
+ "aggregationField": "applicationId"
+} \ No newline at end of file
diff --git a/controller-server/src/test/resources/horizon/meta-query.json b/controller-server/src/test/resources/horizon/meta-query.json
deleted file mode 100644
index ed59bef5eaa..00000000000
--- a/controller-server/src/test/resources/horizon/meta-query.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "from": 0,
- "to": 1,
- "order": "ASCENDING",
- "type": "TAG_KEYS_AND_VALUES",
- "source": "",
- "aggregationSize": 1000,
- "queries": [
- {
- "id": "id-0",
- "namespace": "Vespa",
- "filter": {
- "type": "Chain",
- "filters": [
- {
- "type": "TagValueRegex",
- "filter": ".*",
- "tagKey": "applicationId"
- },
- {
- "type": "MetricLiteral",
- "metric": "vespa.distributor.vds.distributor.docsstored.average|vespa.searchnode.content.proton.resource_usage.disk.average|vespa.searchnode.content.proton.resource_usage.memory.average|vespa.container.peak_qps.max"
- }
- ]
- }
- }
- ],
- "aggregationField": "applicationId"
-} \ No newline at end of file