diff options
author | Harald Musum <musum@yahooinc.com> | 2021-09-08 10:01:16 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2021-09-08 10:01:16 +0200 |
commit | 9b1df9e54c467e996cf6540cc6f67a74ebbe48fe (patch) | |
tree | 743000ae9bfeda6091725e0a03e9b385a6804e0f | |
parent | 2e281a0e35a2a0bf96c34642fbe169d32fda19d6 (diff) |
Follow changes
7 files changed, 39 insertions, 33 deletions
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigTester.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigTester.java index fbf0a2fe869..1b009b80fc1 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigTester.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigTester.java @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.proxy; import com.yahoo.jrt.Request; @@ -25,6 +25,7 @@ import java.util.Optional; public class ConfigTester { private static final long defaultTimeout = 10000; + private static final List<String> defContent = Collections.singletonList("bar string"); static RawConfig fooConfig; static RawConfig barConfig; @@ -39,7 +40,6 @@ public class ConfigTester { ConfigPayload fooConfigPayload = createConfigPayload("bar", "value"); fooPayload = Payload.from(fooConfigPayload); - List<String> defContent = Collections.singletonList("bar string"); long generation = 1; String defMd5 = ConfigUtils.getDefMd5(defContent); String configMd5 = ConfigUtils.getMd5(fooConfigPayload); @@ -57,23 +57,22 @@ public class ConfigTester { JRTServerConfigRequest createRequest(RawConfig config, long timeout) { return createRequest(config.getName(), config.getConfigId(), config.getNamespace(), - config.getConfigMd5(), config.getDefMd5(), config.getGeneration(), timeout); + config.getConfigMd5(), config.getGeneration(), timeout); } JRTServerConfigRequest createRequest(String configName, String configId, String namespace, long timeout) { - return createRequest(configName, configId, namespace, "", null, 0, timeout); + return createRequest(configName, configId, namespace, null, 0, timeout); } private JRTServerConfigRequest createRequest(String configName, String configId, String namespace, String md5, - String defMd5, long generation, long timeout) { Request request = JRTClientConfigRequestV3. - createWithParams(new ConfigKey<>(configName, configId, namespace, defMd5, null), - DefContent.fromList(Collections.emptyList()), + createWithParams(new ConfigKey<>(configName, configId, namespace, null), + DefContent.fromList(defContent), "fromHost", md5, generation, diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpConfigRequest.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpConfigRequest.java index cdbd7378151..c01008fafa0 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpConfigRequest.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpConfigRequest.java @@ -1,13 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.http; -import java.util.Collections; -import java.util.Optional; -import java.util.Set; - import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.yahoo.collections.Tuple2; +import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.TenantName; import com.yahoo.container.jdisc.HttpRequest; @@ -17,11 +14,14 @@ import com.yahoo.vespa.config.GetConfigRequest; import com.yahoo.vespa.config.protocol.DefContent; import com.yahoo.vespa.config.protocol.VespaVersion; import com.yahoo.vespa.config.server.RequestHandler; -import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.config.server.http.v2.request.HttpConfigRequests; import com.yahoo.vespa.config.server.http.v2.request.TenantRequest; import com.yahoo.vespa.config.util.ConfigUtils; +import java.util.Collections; +import java.util.Optional; +import java.util.Set; + /** * A request to get config, bound to tenant and app id. Used by both v1 and v2 of the config REST API. * @@ -191,4 +191,8 @@ public class HttpConfigRequest implements GetConfigRequest, TenantRequest { public boolean noCache() { return noCache; } + + @Override + public String getRequestDefMd5() { return ConfigUtils.getDefMd5(getDefContent().asList()); } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcRequestHandlerProvider.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcRequestHandlerProvider.java index 37c91cf255d..e4e19743950 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcRequestHandlerProvider.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcRequestHandlerProvider.java @@ -1,4 +1,4 @@ -// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.rpc; import com.google.inject.Inject; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java index d81bf6fada3..41af0296534 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java @@ -1,4 +1,4 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server; import com.yahoo.cloud.config.ConfigserverConfig; @@ -39,7 +39,6 @@ import com.yahoo.vespa.config.server.session.PrepareParams; import com.yahoo.vespa.config.server.session.Session; import com.yahoo.vespa.config.server.session.SessionRepository; import com.yahoo.vespa.config.server.session.SessionZooKeeperClient; -import com.yahoo.vespa.config.server.tenant.ApplicationRolesStore; import com.yahoo.vespa.config.server.tenant.Tenant; import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.tenant.TestTenantRepository; @@ -807,6 +806,10 @@ public class ApplicationRepositoryTest { public boolean noCache() { return false; } + + @Override + public String getRequestDefMd5() { return ""; } + }, Optional.empty()); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java index c58bd6d6b0a..eb1e541a540 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java @@ -74,7 +74,7 @@ public class SuperModelControllerTest { @Test(expected = UnknownConfigDefinitionException.class) public void test_unknown_config_definition() { String md5 = "asdfasf"; - Request request = JRTClientConfigRequestV3.createWithParams(new ConfigKey<>("foo", "id", "bar", md5, null), DefContent.fromList(Collections.emptyList()), + Request request = JRTClientConfigRequestV3.createWithParams(new ConfigKey<>("foo", "id", "bar", null), DefContent.fromList(Collections.emptyList()), "fromHost", md5, 1, 1, Trace.createDummy(), CompressionType.UNCOMPRESSED, Optional.empty()) .getRequest(); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java index acd0acc3792..44491667760 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java @@ -105,7 +105,7 @@ public class ApplicationTest { @Test(expected = UnknownConfigDefinitionException.class) public void require_that_def_file_must_exist() { - handler.resolveConfig(createRequest("unknown", "namespace", "a", emptySchema)); + handler.resolveConfig(createRequest("unknown", "namespace", emptySchema)); } @Test @@ -116,8 +116,9 @@ public class ApplicationTest { @Test public void require_that_build_config_can_be_resolved() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); - handler.resolveConfig(createRequest(ModelConfig.CONFIG_DEF_NAME, ModelConfig.CONFIG_DEF_NAMESPACE, - ModelConfig.CONFIG_DEF_MD5, ModelConfig.CONFIG_DEF_SCHEMA)) + handler.resolveConfig(createRequest(ModelConfig.CONFIG_DEF_NAME, + ModelConfig.CONFIG_DEF_NAMESPACE, + ModelConfig.CONFIG_DEF_SCHEMA)) .serialize(baos, CompressionType.UNCOMPRESSED); assertTrue(baos.toString().startsWith("{\"vespaVersion\":\"1.0.0\",\"hosts\":[{\"name\":\"mytesthost\"")); } @@ -132,23 +133,23 @@ public class ApplicationTest { String[] schema = new String[1]; schema[0] = "boolval bool default=true"; // changed to be true, original is false baos = new ByteArrayOutputStream(); - handler.resolveConfig(createRequest(SimpletypesConfig.CONFIG_DEF_NAME, SimpletypesConfig.CONFIG_DEF_NAMESPACE, "", schema)) + handler.resolveConfig(createRequest(SimpletypesConfig.CONFIG_DEF_NAME, SimpletypesConfig.CONFIG_DEF_NAMESPACE, schema)) .serialize(baos, CompressionType.UNCOMPRESSED); assertEquals("{\"boolval\":true,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}", baos.toString(Utf8.getCharset())); } @Test public void require_that_configs_are_cached() { - ConfigResponse response = handler.resolveConfig(createRequest(ModelConfig.CONFIG_DEF_NAME, ModelConfig.CONFIG_DEF_NAMESPACE, ModelConfig.CONFIG_DEF_MD5, ModelConfig.CONFIG_DEF_SCHEMA)); + ConfigResponse response = handler.resolveConfig(createRequest(ModelConfig.CONFIG_DEF_NAME, ModelConfig.CONFIG_DEF_NAMESPACE, ModelConfig.CONFIG_DEF_SCHEMA)); assertNotNull(response); - ConfigResponse cached_response = handler.resolveConfig(createRequest(ModelConfig.CONFIG_DEF_NAME, ModelConfig.CONFIG_DEF_NAMESPACE, ModelConfig.CONFIG_DEF_MD5, ModelConfig.CONFIG_DEF_SCHEMA)); + ConfigResponse cached_response = handler.resolveConfig(createRequest(ModelConfig.CONFIG_DEF_NAME, ModelConfig.CONFIG_DEF_NAMESPACE, ModelConfig.CONFIG_DEF_SCHEMA)); assertNotNull(cached_response); assertTrue(response == cached_response); } - private static GetConfigRequest createRequest(String name, String namespace, String defMd5, String[] schema) { + private static GetConfigRequest createRequest(String name, String namespace, String[] schema) { Request request = JRTClientConfigRequestV3. - createWithParams(new ConfigKey<>(name, "admin/model", namespace, defMd5, null), DefContent.fromArray(schema), + createWithParams(new ConfigKey<>(name, "admin/model", namespace, null), DefContent.fromArray(schema), "fromHost", "", 0, 100, Trace.createDummy(), CompressionType.UNCOMPRESSED, Optional.empty()).getRequest(); return JRTServerConfigRequestV3.createFromRequest(request); @@ -157,7 +158,7 @@ public class ApplicationTest { private static GetConfigRequest createSimpleConfigRequest() { return createRequest(SimpletypesConfig.CONFIG_DEF_NAME, SimpletypesConfig.CONFIG_DEF_NAMESPACE, - SimpletypesConfig.CONFIG_DEF_MD5, ApplicationTest.emptySchema); } + } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponseTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponseTest.java index 8c62fe77557..738e8c9827d 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponseTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponseTest.java @@ -1,4 +1,4 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.rpc; import com.yahoo.config.provision.ApplicationId; @@ -29,7 +29,6 @@ import static org.junit.Assert.assertTrue; /** * @author Ulf Lilleengen - * @since 5.1 */ public class DelayedConfigResponseTest { @@ -42,7 +41,7 @@ public class DelayedConfigResponseTest { MockRpcServer rpc = new MockRpcServer(13337, temporaryFolder.newFolder()); DelayedConfigResponses responses = new DelayedConfigResponses(rpc, 1, false); assertThat(responses.size(), is(0)); - JRTServerConfigRequest req = createRequest("foo", "md5", "myid", "mymd5", 3, 1000000, "bar"); + JRTServerConfigRequest req = createRequest("foo", "myid", "mymd5", 3, 1000000, "bar"); req.setDelayedResponse(true); GetConfigContext context = GetConfigContext.testContext(ApplicationId.defaultId()); responses.delayResponse(req, context); @@ -50,7 +49,7 @@ public class DelayedConfigResponseTest { req.setDelayedResponse(false); responses.delayResponse(req, context); - responses.delayResponse(createRequest("foolio", "md5", "myid", "mymd5", 3, 100000, "bar"), context); + responses.delayResponse(createRequest("foolio", "myid", "mymd5", 3, 100000, "bar"), context); assertThat(responses.size(), is(2)); assertTrue(req.isDelayedResponse()); List<DelayedConfigResponses.DelayedConfigResponse> it = responses.allDelayedResponses(); @@ -62,7 +61,7 @@ public class DelayedConfigResponseTest { GetConfigContext context = GetConfigContext.testContext(ApplicationId.defaultId()); MockRpcServer rpc = new MockRpcServer(13337, temporaryFolder.newFolder()); DelayedConfigResponses responses = new DelayedConfigResponses(rpc, 1, false); - responses.delayResponse(createRequest("foolio", "md5", "myid", "mymd5", 3, 100000, "bar"), context); + responses.delayResponse(createRequest("foolio", "myid", "mymd5", 3, 100000, "bar"), context); assertThat(responses.size(), is(1)); responses.allDelayedResponses().get(0).cancelAndRemove(); assertThat(responses.size(), is(0)); @@ -74,15 +73,15 @@ public class DelayedConfigResponseTest { DelayedConfigResponses responses = new DelayedConfigResponses(rpc, 1, false); assertThat(responses.size(), is(0)); assertThat(responses.toString(), is("DelayedConfigResponses. Average Size=0")); - JRTServerConfigRequest req = createRequest("foo", "md5", "myid", "mymd5", 3, 100, "bar"); + JRTServerConfigRequest req = createRequest("foo", "myid", "mymd5", 3, 100, "bar"); responses.delayResponse(req, GetConfigContext.testContext(ApplicationId.defaultId())); rpc.waitUntilSet(Duration.ofSeconds(5)); assertThat(rpc.latestRequest, is(req)); } - private JRTServerConfigRequest createRequest(String configName, String defMd5, String configId, String md5, long generation, long timeout, String namespace) { + private JRTServerConfigRequest createRequest(String configName, String configId, String md5, long generation, long timeout, String namespace) { Request request = JRTClientConfigRequestV3. - createWithParams(new ConfigKey<>(configName, configId, namespace, defMd5, null), DefContent.fromList(Collections.emptyList()), + createWithParams(new ConfigKey<>(configName, configId, namespace, null), DefContent.fromList(Collections.emptyList()), "fromHost", md5, generation, timeout, Trace.createDummy(), CompressionType.UNCOMPRESSED, Optional.empty()).getRequest(); return JRTServerConfigRequestV3.createFromRequest(request); |