aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/query
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-12-13 08:34:42 +0100
committerJon Bratseth <bratseth@gmail.com>2021-12-13 08:34:42 +0100
commitcf7cf81ea64c016e5dcc9032462624ddb4460842 (patch)
tree39d1d97aafa73bdb8ca5d290f1148b9dc9116fa1 /container-search/src/test/java/com/yahoo/search/query
parentda72f32fa5bfcce81b6bcc8dbe717be0869bcc77 (diff)
Revert "Merge pull request #20456 from vespa-engine/revert-20439-bratseth/zoneinfo-in-query-profile-context"
This reverts commit 2780822f7d1fc66ea2833b2b7aaa2b9cb74f5833, reversing changes made to 8ff6429daf9a695f2fa5d45a8033c75fdadfcfe2.
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/query')
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
index 231020c4fa5..3542e1413eb 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/QueryProfileVariantsTestCase.java
@@ -1,6 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.profile.test;
+import ai.vespa.cloud.ApplicationId;
+import ai.vespa.cloud.Environment;
+import ai.vespa.cloud.Zone;
+import ai.vespa.cloud.ZoneInfo;
+import com.yahoo.jdisc.application.Application;
import com.yahoo.jdisc.http.HttpRequest.Method;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.processing.request.CompoundName;
@@ -1331,6 +1336,53 @@ public class QueryProfileVariantsTestCase {
assertEquals("yahoo/alerts", cAlert.get("vertical.custid", toMap("entry=alert", "intl=us", "lang=en-US")));
}
+ @Test
+ public void testZoneInfoInContext() {
+ QueryProfileRegistry registry = new QueryProfileRegistry();
+ QueryProfile profile = new QueryProfile("test");
+ profile.setDimensions(new String[] { "environment", "region", "instance" });
+ profile.set("value", "default", registry);
+ profile.set("value", "prod-region1-instance1",
+ toMap("environment=prod", "region=region1", "instance=instance1"),
+ registry);
+ profile.set("value", "prod-instance2",
+ toMap("environment=prod", "instance=instance2"),
+ registry);
+ profile.set("value", "prod-region3",
+ toMap("environment=prod", "region=region3"),
+ registry);
+ profile.set("value", "dev",
+ toMap("environment=dev"),
+ registry);
+ registry.register(profile);
+
+ CompiledQueryProfileRegistry cRegistry = registry.compile();
+ CompiledQueryProfile cTest = cRegistry.findQueryProfile("test");
+
+ assertValueForZone("default", ZoneInfo.defaultInfo(), cTest);
+ assertValueForZone("prod-region1-instance1",
+ new ZoneInfo(new ApplicationId("tenant1", "application1", "instance1"),
+ new Zone(Environment.prod, "region1")),
+ cTest);
+ assertValueForZone("prod-instance2",
+ new ZoneInfo(new ApplicationId("tenant2", "application2", "instance2"),
+ new Zone(Environment.prod, "region1")),
+ cTest);
+ assertValueForZone("prod-region3",
+ new ZoneInfo(new ApplicationId("tenant3", "application3", "instance3"),
+ new Zone(Environment.prod, "region3")),
+ cTest);
+ assertValueForZone("dev",
+ new ZoneInfo(new ApplicationId("tenant4", "application4", "instance4"),
+ new Zone(Environment.dev, "region4")),
+ cTest);
+ }
+
+ private void assertValueForZone(String expected, ZoneInfo zoneInfo, CompiledQueryProfile cTest) {
+ assertEquals(expected,
+ new Query.Builder().setQueryProfile(cTest).setZoneInfo(zoneInfo).build().properties().get("value"));
+ }
+
private void assertGet(String expectedValue, String parameter, String[] dimensionValues, QueryProfile profile, CompiledQueryProfile cprofile) {
Map<String,String> context=toMap(profile,dimensionValues);
assertEquals("Looking up '" + parameter + "' for '" + Arrays.toString(dimensionValues) + "'",expectedValue,cprofile.get(parameter,context));