diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2020-11-19 19:30:40 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2020-11-19 19:30:40 +0100 |
commit | 2a00cc99b5a0cc92d286725af22fe46d0aa00142 (patch) | |
tree | ca20fa55c48d13f521672a0b131c1638e64b1713 /configserver | |
parent | 1f65e089ab875952bea5914b9630360145d92b9f (diff) |
Use proper ValidationId instead of their String names in ConfigChangeAction subclasses
Diffstat (limited to 'configserver')
8 files changed, 38 insertions, 33 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ConfigChangeActionsBuilder.java b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ConfigChangeActionsBuilder.java index b5194432682..9724e92e34c 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ConfigChangeActionsBuilder.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ConfigChangeActionsBuilder.java @@ -44,20 +44,20 @@ public class ConfigChangeActionsBuilder { } - ConfigChangeActionsBuilder refeed(String name, boolean allowed, String message, String documentType, String clusterName, String serviceName) { - actions.add(new MockRefeedAction(name, + ConfigChangeActionsBuilder refeed(ValidationId validationId, boolean allowed, String message, String documentType, String clusterName, String serviceName) { + actions.add(new MockRefeedAction(validationId, allowed, message, List.of(createService(clusterName, "myclustertype", "myservicetype", serviceName)), documentType)); return this; } - ConfigChangeActionsBuilder reindex(String name, boolean allowed, String message, String documentType, String clusterName, String serviceName) { + ConfigChangeActionsBuilder reindex(ValidationId validationId, boolean allowed, String message, String documentType, String clusterName, String serviceName) { List<ServiceInfo> services = List.of(createService(clusterName, "myclustertype", "myservicetype", serviceName)); ValidationOverrides overrides = mock(ValidationOverrides.class); when(overrides.allows((String) any(), any())).thenReturn(allowed); when(overrides.allows((ValidationId) any(), any())).thenReturn(allowed); - actions.add(VespaReindexAction.of(ClusterSpec.Id.from(clusterName), name, overrides, message, services, documentType, Instant.now())); + actions.add(VespaReindexAction.of(ClusterSpec.Id.from(clusterName), validationId, overrides, message, services, documentType, Instant.now())); return this; } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ConfigChangeActionsSlimeConverterTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ConfigChangeActionsSlimeConverterTest.java index d145a796725..33e60a4ce39 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ConfigChangeActionsSlimeConverterTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ConfigChangeActionsSlimeConverterTest.java @@ -97,7 +97,7 @@ public class ConfigChangeActionsSlimeConverterTest { " ],\n" + " \"refeed\": [\n" + " {\n" + - " \"name\": \"change-id\",\n" + + " \"name\": \"field-type-change\",\n" + " \"allowed\": true,\n" + " \"documentType\": \"music\",\n" + " \"clusterName\": \"foo\",\n" + @@ -114,7 +114,7 @@ public class ConfigChangeActionsSlimeConverterTest { " ]\n" + " },\n" + " {\n" + - " \"name\": \"other-change-id\",\n" + + " \"name\": \"indexing-change\",\n" + " \"allowed\": false,\n" + " \"documentType\": \"book\",\n" + " \"clusterName\": \"foo\",\n" + @@ -151,7 +151,7 @@ public class ConfigChangeActionsSlimeConverterTest { " ],\n" + " \"reindex\": [\n" + " {\n" + - " \"name\": \"change-id\",\n" + + " \"name\": \"field-type-change\",\n" + " \"allowed\": true,\n" + " \"documentType\": \"music\",\n" + " \"clusterName\": \"foo\",\n" + diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/MockRefeedAction.java b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/MockRefeedAction.java index 11f2a46994c..c3cb88d2807 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/MockRefeedAction.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/MockRefeedAction.java @@ -1,6 +1,7 @@ // Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.configchange; +import com.yahoo.config.application.api.ValidationId; import com.yahoo.config.model.api.ConfigChangeRefeedAction; import com.yahoo.config.model.api.ServiceInfo; @@ -11,19 +12,19 @@ import java.util.List; */ public class MockRefeedAction extends MockConfigChangeAction implements ConfigChangeRefeedAction { - private final String name; + private final ValidationId validationId; private final boolean allowed; private final String documentType; - public MockRefeedAction(String name, boolean allowed, String message, List<ServiceInfo> services, String documentType) { + public MockRefeedAction(ValidationId validationId, boolean allowed, String message, List<ServiceInfo> services, String documentType) { super(message, services); - this.name = name; + this.validationId = validationId; this.allowed = allowed; this.documentType = documentType; } @Override - public String name() { return name; } + public ValidationId validationId() { return validationId; } @Override public boolean allowed() { return allowed; } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsFormatterTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsFormatterTest.java index 48d6833129e..246d4b88163 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsFormatterTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsFormatterTest.java @@ -17,7 +17,7 @@ public class RefeedActionsFormatterTest { RefeedActions actions = new ConfigChangeActionsBuilder(). refeed(CHANGE_ID, false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). build().getRefeedActions(); - assertEquals("change-id: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + + assertEquals("field-type-change: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + " 1) change\n", new RefeedActionsFormatter(actions).format()); } @@ -31,14 +31,14 @@ public class RefeedActionsFormatterTest { refeed(CHANGE_ID_2, true, CHANGE_MSG_2, DOC_TYPE, CLUSTER, SERVICE_NAME). refeed(CHANGE_ID, false, CHANGE_MSG_2, DOC_TYPE_2, CLUSTER, SERVICE_NAME). build().getRefeedActions(); - assertEquals("change-id: Consider removing data and re-feed document type 'book' in cluster 'foo' because:\n" + + assertEquals("field-type-change: Consider removing data and re-feed document type 'book' in cluster 'foo' because:\n" + " 1) other change\n" + - "change-id: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + + "field-type-change: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + " 1) change\n" + " 2) other change\n" + - "other-change-id: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + + "indexing-change: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + " 1) other change\n" + - "(allowed) other-change-id: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + + "(allowed) indexing-change: Consider removing data and re-feed document type 'music' in cluster 'foo' because:\n" + " 1) other change\n", new RefeedActionsFormatter(actions).format()); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsTest.java index 7235b8905c5..befb2c06106 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/RefeedActionsTest.java @@ -1,6 +1,7 @@ // 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.configchange; +import com.yahoo.config.application.api.ValidationId; import com.yahoo.config.model.api.ServiceInfo; import org.junit.Test; @@ -32,8 +33,8 @@ public class RefeedActionsTest { @Test public void action_with_multiple_reasons() { List<RefeedActions.Entry> entries = new ConfigChangeActionsBuilder(). - refeed("change-id", false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). - refeed("change-id", false, CHANGE_MSG_2, DOC_TYPE, CLUSTER, SERVICE_NAME). + refeed(ValidationId.indexModeChange, false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). + refeed(ValidationId.indexModeChange, false, CHANGE_MSG_2, DOC_TYPE, CLUSTER, SERVICE_NAME). build().getRefeedActions().getEntries(); assertThat(entries.size(), is(1)); assertThat(toString(entries.get(0)), equalTo("music.foo:[baz][change,other change]")); @@ -42,8 +43,8 @@ public class RefeedActionsTest { @Test public void actions_with_multiple_services() { List<RefeedActions.Entry> entries = new ConfigChangeActionsBuilder(). - refeed("change-id", false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). - refeed("change-id", false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME_2). + refeed(ValidationId.indexModeChange, false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). + refeed(ValidationId.indexModeChange, false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME_2). build().getRefeedActions().getEntries(); assertThat(entries.size(), is(1)); assertThat(toString(entries.get(0)), equalTo("music.foo:[baz,qux][change]")); @@ -52,8 +53,8 @@ public class RefeedActionsTest { @Test public void actions_with_multiple_document_types() { List<RefeedActions.Entry> entries = new ConfigChangeActionsBuilder(). - refeed("change-id", false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). - refeed("change-id", false, CHANGE_MSG, DOC_TYPE_2, CLUSTER, SERVICE_NAME). + refeed(ValidationId.indexModeChange, false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). + refeed(ValidationId.indexModeChange, false, CHANGE_MSG, DOC_TYPE_2, CLUSTER, SERVICE_NAME). build().getRefeedActions().getEntries(); assertThat(entries.size(), is(2)); assertThat(toString(entries.get(0)), equalTo("book.foo:[baz][change]")); @@ -63,8 +64,8 @@ public class RefeedActionsTest { @Test public void actions_with_multiple_clusters() { List<RefeedActions.Entry> entries = new ConfigChangeActionsBuilder(). - refeed("change-id", false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). - refeed("change-id", false, CHANGE_MSG, DOC_TYPE, CLUSTER_2, SERVICE_NAME). + refeed(ValidationId.indexModeChange, false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). + refeed(ValidationId.indexModeChange, false, CHANGE_MSG, DOC_TYPE, CLUSTER_2, SERVICE_NAME). build().getRefeedActions().getEntries(); assertThat(entries.size(), is(2)); assertThat(toString(entries.get(0)), equalTo("music.bar:[baz][change]")); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ReindexActionsFormatterTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ReindexActionsFormatterTest.java index e9dd3f3bbfc..6650b9c523d 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ReindexActionsFormatterTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/ReindexActionsFormatterTest.java @@ -23,7 +23,7 @@ public class ReindexActionsFormatterTest { ReindexActions actions = new ConfigChangeActionsBuilder(). reindex(CHANGE_ID, false, CHANGE_MSG, DOC_TYPE, CLUSTER, SERVICE_NAME). build().getReindexActions(); - assertEquals("change-id: Consider re-indexing document type 'music' in cluster 'foo' because:\n" + + assertEquals("field-type-change: Consider re-indexing document type 'music' in cluster 'foo' because:\n" + " 1) change\n", new ReindexActionsFormatter(actions).format()); } @@ -37,14 +37,14 @@ public class ReindexActionsFormatterTest { reindex(CHANGE_ID_2, true, CHANGE_MSG_2, DOC_TYPE, CLUSTER, SERVICE_NAME). reindex(CHANGE_ID, false, CHANGE_MSG_2, DOC_TYPE_2, CLUSTER, SERVICE_NAME). build().getReindexActions(); - assertEquals("change-id: Consider re-indexing document type 'book' in cluster 'foo' because:\n" + + assertEquals("field-type-change: Consider re-indexing document type 'book' in cluster 'foo' because:\n" + " 1) other change\n" + - "change-id: Consider re-indexing document type 'music' in cluster 'foo' because:\n" + + "field-type-change: Consider re-indexing document type 'music' in cluster 'foo' because:\n" + " 1) change\n" + " 2) other change\n" + - "other-change-id: Consider re-indexing document type 'music' in cluster 'foo' because:\n" + + "indexing-change: Consider re-indexing document type 'music' in cluster 'foo' because:\n" + " 1) other change\n" + - "(allowed) other-change-id: Consider re-indexing document type 'music' in cluster 'foo' because:\n" + + "(allowed) indexing-change: Consider re-indexing document type 'music' in cluster 'foo' because:\n" + " 1) other change\n", new ReindexActionsFormatter(actions).format()); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/Utils.java b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/Utils.java index 8499c12f648..e02e1e2b143 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/Utils.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/configchange/Utils.java @@ -1,14 +1,16 @@ // 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.configchange; +import com.yahoo.config.application.api.ValidationId; + /** * @author geirst * @since 5.44 */ public class Utils { - final static String CHANGE_ID = "change-id"; - final static String CHANGE_ID_2 = "other-change-id"; + final static ValidationId CHANGE_ID = ValidationId.fieldTypeChange; + final static ValidationId CHANGE_ID_2 = ValidationId.indexingChange; final static String CHANGE_MSG = "change"; final static String CHANGE_MSG_2 = "other change"; final static String DOC_TYPE = "music"; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java index 4d1b9341e7f..d7ff891d1d3 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java @@ -3,6 +3,7 @@ package com.yahoo.vespa.config.server.deploy; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; +import com.yahoo.config.application.api.ValidationId; import com.yahoo.config.application.api.ValidationOverrides; import com.yahoo.config.model.api.ConfigChangeAction; import com.yahoo.config.model.api.ModelContext; @@ -401,7 +402,7 @@ public class HostedDeployTest { ManualClock clock = new ManualClock(Instant.EPOCH); List<ModelFactory> modelFactories = List.of( new ConfigChangeActionsModelFactory(Version.fromString("6.1.0"), - VespaReindexAction.of(ClusterSpec.Id.from("test"), "indexing-mode-change", ValidationOverrides.empty, + VespaReindexAction.of(ClusterSpec.Id.from("test"), ValidationId.indexModeChange, ValidationOverrides.empty, "reindex please", services, "music", clock.instant()), new VespaRestartAction(ClusterSpec.Id.from("test"), "change", services))); @@ -422,7 +423,7 @@ public class HostedDeployTest { ManualClock clock = new ManualClock(Instant.EPOCH); List<ModelFactory> modelFactories = List.of( new ConfigChangeActionsModelFactory(Version.fromString("6.1.0"), - VespaReindexAction.of(ClusterSpec.Id.from("test"), "indexing-mode-change", ValidationOverrides.all, + VespaReindexAction.of(ClusterSpec.Id.from("test"), ValidationId.indexModeChange, ValidationOverrides.all, "reindex please", services, "music", clock.instant()), new VespaRestartAction(ClusterSpec.Id.from("test"), "change", services))); |