diff --git a/api/api-cluster-profiles-v1/src/test/groovy/com/thoughtworks/go/apiv1/clusterprofiles/representers/ClusterProfileRepresenterTest.groovy b/api/api-cluster-profiles-v1/src/test/groovy/com/thoughtworks/go/apiv1/clusterprofiles/representers/ClusterProfileRepresenterTest.groovy index 2cd3ddc7c76a..28c8c036622c 100644 --- a/api/api-cluster-profiles-v1/src/test/groovy/com/thoughtworks/go/apiv1/clusterprofiles/representers/ClusterProfileRepresenterTest.groovy +++ b/api/api-cluster-profiles-v1/src/test/groovy/com/thoughtworks/go/apiv1/clusterprofiles/representers/ClusterProfileRepresenterTest.groovy @@ -99,7 +99,7 @@ class ClusterProfileRepresenterTest { def elasticAgentMetadataStore = ElasticAgentMetadataStore.instance() PluggableInstanceSettings pluggableInstanceSettings = new PluggableInstanceSettings(Arrays.asList( new PluginConfiguration("Password", new Metadata(true, true)))) - elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(pluginDescriptor(), pluggableInstanceSettings, null, null, null)) + elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(pluginDescriptor(), pluggableInstanceSettings, pluggableInstanceSettings, null, null, null)) def jsonReader = GsonTransformer.instance.jsonReaderFrom(clusterProfile) def object = ClusterProfileRepresenter.fromJSON(jsonReader) diff --git a/api/api-elastic-profile-v1/src/test/groovy/com/thoughtworks/go/apiv1/elasticprofile/representers/ElasticProfileRepresenterTest.groovy b/api/api-elastic-profile-v1/src/test/groovy/com/thoughtworks/go/apiv1/elasticprofile/representers/ElasticProfileRepresenterTest.groovy index 41fe5819c863..dcbc86b0e0a0 100644 --- a/api/api-elastic-profile-v1/src/test/groovy/com/thoughtworks/go/apiv1/elasticprofile/representers/ElasticProfileRepresenterTest.groovy +++ b/api/api-elastic-profile-v1/src/test/groovy/com/thoughtworks/go/apiv1/elasticprofile/representers/ElasticProfileRepresenterTest.groovy @@ -99,7 +99,7 @@ class ElasticProfileRepresenterTest { def elasticAgentMetadataStore = ElasticAgentMetadataStore.instance() PluggableInstanceSettings pluggableInstanceSettings = new PluggableInstanceSettings(Arrays.asList( new PluginConfiguration("Password", new Metadata(true, true)))) - elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(pluginDescriptor(), pluggableInstanceSettings, null, null, null)) + elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(pluginDescriptor(), pluggableInstanceSettings, pluggableInstanceSettings, null, null, null)) def jsonReader = GsonTransformer.instance.jsonReaderFrom(elasticProfile) def object = ElasticProfileRepresenter.fromJSON(jsonReader) diff --git a/api/api-elastic-profile-v2/src/test/groovy/com/thoughtworks/go/apiv2/elasticprofile/representers/ElasticProfileRepresenterTest.groovy b/api/api-elastic-profile-v2/src/test/groovy/com/thoughtworks/go/apiv2/elasticprofile/representers/ElasticProfileRepresenterTest.groovy index d836c12b7a56..1700b4b4867d 100644 --- a/api/api-elastic-profile-v2/src/test/groovy/com/thoughtworks/go/apiv2/elasticprofile/representers/ElasticProfileRepresenterTest.groovy +++ b/api/api-elastic-profile-v2/src/test/groovy/com/thoughtworks/go/apiv2/elasticprofile/representers/ElasticProfileRepresenterTest.groovy @@ -106,7 +106,7 @@ class ElasticProfileRepresenterTest { def elasticAgentMetadataStore = ElasticAgentMetadataStore.instance() PluggableInstanceSettings pluggableInstanceSettings = new PluggableInstanceSettings(Arrays.asList( new PluginConfiguration("Password", new Metadata(true, true)))) - elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(pluginDescriptor(), pluggableInstanceSettings, null, null, null)) + elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(pluginDescriptor(), pluggableInstanceSettings, pluggableInstanceSettings, null, null, null)) def jsonReader = GsonTransformer.instance.jsonReaderFrom(elasticProfile) def object = ElasticProfileRepresenter.fromJSON(jsonReader) @@ -183,7 +183,7 @@ class ElasticProfileRepresenterTest { def elasticAgentMetadataStore = ElasticAgentMetadataStore.instance() PluggableInstanceSettings pluggableInstanceSettings = new PluggableInstanceSettings(Arrays.asList( new PluginConfiguration("Password", new Metadata(true, true)))) - elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(pluginDescriptor(), pluggableInstanceSettings, null, null, null)) + elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(pluginDescriptor(), pluggableInstanceSettings, pluggableInstanceSettings, null, null, null)) def jsonReader = GsonTransformer.instance.jsonReaderFrom(elasticProfile) def object = ElasticProfileRepresenter.fromJSON(jsonReader) diff --git a/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ClusterProfile.java b/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ClusterProfile.java index d66f6c0bd5ea..efb4d6bf2bc1 100644 --- a/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ClusterProfile.java +++ b/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ClusterProfile.java @@ -51,12 +51,12 @@ protected boolean isSecure(String key) { ElasticAgentPluginInfo pluginInfo = this.metadataStore().getPluginInfo(getPluginId()); if (pluginInfo == null - || pluginInfo.getProfileSettings() == null - || pluginInfo.getProfileSettings().getConfiguration(key) == null) { + || pluginInfo.getClusterProfileSettings() == null + || pluginInfo.getClusterProfileSettings().getConfiguration(key) == null) { return false; } - return pluginInfo.getProfileSettings().getConfiguration(key).isSecure(); + return pluginInfo.getClusterProfileSettings().getConfiguration(key).isSecure(); } @Override diff --git a/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfile.java b/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfile.java index e595c3f39365..09f94850a685 100644 --- a/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfile.java +++ b/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfile.java @@ -69,12 +69,12 @@ protected boolean isSecure(String key) { ElasticAgentPluginInfo pluginInfo = this.metadataStore().getPluginInfo(getPluginId()); if (pluginInfo == null - || pluginInfo.getProfileSettings() == null - || pluginInfo.getProfileSettings().getConfiguration(key) == null) { + || pluginInfo.getElasticAgentProfileSettings() == null + || pluginInfo.getElasticAgentProfileSettings().getConfiguration(key) == null) { return false; } - return pluginInfo.getProfileSettings().getConfiguration(key).isSecure(); + return pluginInfo.getElasticAgentProfileSettings().getConfiguration(key).isSecure(); } @Override diff --git a/config/config-api/src/test/java/com/thoughtworks/go/config/elastic/ElasticProfileTest.java b/config/config-api/src/test/java/com/thoughtworks/go/config/elastic/ElasticProfileTest.java index e544fdf42f17..dfbae75fd40d 100644 --- a/config/config-api/src/test/java/com/thoughtworks/go/config/elastic/ElasticProfileTest.java +++ b/config/config-api/src/test/java/com/thoughtworks/go/config/elastic/ElasticProfileTest.java @@ -106,7 +106,7 @@ public void addConfigurations_shouldAddConfigurationsWithEncryptedValue() throws @Test public void addConfiguration_shouldEncryptASecureVariable() throws Exception { PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("password", new Metadata(true, true)))); - ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(pluginDescriptor("plugin_id"), profileSettings, null, null, null); + ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(pluginDescriptor("plugin_id"), profileSettings, profileSettings, null, null, null); store.setPluginInfo(pluginInfo); ElasticProfile profile = new ElasticProfile("id", "plugin_id"); @@ -118,7 +118,7 @@ public void addConfiguration_shouldEncryptASecureVariable() throws Exception { @Test public void addConfiguration_shouldIgnoreEncryptionInAbsenceOfCorrespondingConfigurationInStore() throws Exception { - ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(pluginDescriptor("plugin_id"), new PluggableInstanceSettings(new ArrayList<>()), null, null, null); + ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(pluginDescriptor("plugin_id"), new PluggableInstanceSettings(new ArrayList<>()), null, null, null, null); store.setPluginInfo(pluginInfo); ElasticProfile profile = new ElasticProfile("id", "plugin_id"); @@ -132,7 +132,7 @@ public void addConfiguration_shouldIgnoreEncryptionInAbsenceOfCorrespondingConfi @Test public void postConstruct_shouldEncryptSecureConfigurations() { PluggableInstanceSettings profileSettings = new PluggableInstanceSettings(Arrays.asList(new PluginConfiguration("password", new Metadata(true, true)))); - ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(pluginDescriptor("plugin_id"), profileSettings, null, null, null); + ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(pluginDescriptor("plugin_id"), profileSettings, profileSettings, null, null, null); store.setPluginInfo(pluginInfo); ElasticProfile profile = new ElasticProfile("id", "plugin_id", new ConfigurationProperty(new ConfigurationKey("password"), new ConfigurationValue("pass"))); diff --git a/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentPluginInfoBuilder.java b/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentPluginInfoBuilder.java index 609e1714b658..207531525428 100644 --- a/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentPluginInfoBuilder.java +++ b/plugin-infra/go-plugin-access/src/main/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentPluginInfoBuilder.java @@ -41,20 +41,30 @@ public ElasticAgentPluginInfoBuilder(ElasticAgentExtension extension) { public ElasticAgentPluginInfo pluginInfoFor(GoPluginDescriptor descriptor) { PluggableInstanceSettings pluggableInstanceSettings = getPluginSettingsAndView(descriptor, extension); - return new ElasticAgentPluginInfo(descriptor, elasticProfileSettings(descriptor.id()), image(descriptor.id()), - pluggableInstanceSettings, capabilities(descriptor.id())); + return new ElasticAgentPluginInfo(descriptor, + elasticElasticAgentProfileSettings(descriptor.id()), + elasticClusterProfileSettings(descriptor.id()), + image(descriptor.id()), + pluggableInstanceSettings, + capabilities(descriptor.id())); } private com.thoughtworks.go.plugin.domain.common.Image image(String pluginId) { return extension.getIcon(pluginId); } - private PluggableInstanceSettings elasticProfileSettings(String pluginId) { + private PluggableInstanceSettings elasticElasticAgentProfileSettings(String pluginId) { List profileMetadata = extension.getProfileMetadata(pluginId); String profileView = extension.getProfileView(pluginId); return new PluggableInstanceSettings(profileMetadata, new PluginView(profileView)); } + private PluggableInstanceSettings elasticClusterProfileSettings(String pluginId) { + List profileMetadata = extension.getClusterProfileMetadata(pluginId); + String profileView = extension.getClusterProfileView(pluginId); + return new PluggableInstanceSettings(profileMetadata, new PluginView(profileView)); + } + private Capabilities capabilities(String pluginId) { return extension.getCapabilities(pluginId); } diff --git a/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentMetadataLoaderTest.java b/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentMetadataLoaderTest.java index c7ec44dbc224..e593e44e4622 100644 --- a/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentMetadataLoaderTest.java +++ b/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentMetadataLoaderTest.java @@ -22,7 +22,6 @@ import org.junit.Before; import org.junit.Test; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; @@ -51,7 +50,7 @@ public void shouldBeAPluginChangeListener() throws Exception { public void onPluginLoaded_shouldAddPluginInfoToMetadataStore() throws Exception { GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false); ElasticAgentMetadataLoader metadataLoader = new ElasticAgentMetadataLoader(pluginManager, metadataStore, infoBuilder, extension); - ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(descriptor, null, null, null, null); + ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(descriptor, null, null, null, null, null); when(extension.canHandlePlugin(descriptor.id())).thenReturn(true); when(infoBuilder.pluginInfoFor(descriptor)).thenReturn(pluginInfo); @@ -78,7 +77,7 @@ public void onPluginLoaded_shouldIgnoreNonAuthorizationPlugins() throws Exceptio public void onPluginUnloded_shouldRemoveTheCorrespondingPluginInfoFromStore() throws Exception { GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false); ElasticAgentMetadataLoader metadataLoader = new ElasticAgentMetadataLoader(pluginManager, metadataStore, infoBuilder, extension); - ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(descriptor, null, null, null, null); + ElasticAgentPluginInfo pluginInfo = new ElasticAgentPluginInfo(descriptor, null, null, null, null, null); metadataStore.setPluginInfo(pluginInfo); diff --git a/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentPluginInfoBuilderTest.java b/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentPluginInfoBuilderTest.java index 5199a048da61..eb7d6039f92a 100644 --- a/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentPluginInfoBuilderTest.java +++ b/plugin-infra/go-plugin-access/src/test/java/com/thoughtworks/go/plugin/access/elastic/ElasticAgentPluginInfoBuilderTest.java @@ -70,7 +70,42 @@ public void shouldBuildPluginInfoWithProfileSettings() { assertThat(pluginInfo.getExtensionName(), is("elastic-agent")); assertThat(pluginInfo.getImage(), is(icon)); - assertThat(pluginInfo.getProfileSettings(), is(new PluggableInstanceSettings(pluginConfigurations, new PluginView("profile_view")))); + assertThat(pluginInfo.getElasticAgentProfileSettings(), is(new PluggableInstanceSettings(pluginConfigurations, new PluginView("profile_view")))); + assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(builder.configurations(pluginSettingsConfiguration), new PluginView("some html")))); + assertFalse(pluginInfo.supportsStatusReport()); + } + + @Test + public void shouldBuildPluginInfoWithClusterProfileSettings() { + GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin1", null, null, null, null, false); + List elasticAgentProfileConfigurations = Arrays.asList(new PluginConfiguration("aws_password", new Metadata(true, false))); + List clusterProfileConfigurations = Arrays.asList(new PluginConfiguration("aws_url", new Metadata(true, false))); + PluginSettingsProperty property = new PluginSettingsProperty("ami-id", "ami-123"); + PluginSettingsConfiguration pluginSettingsConfiguration = new PluginSettingsConfiguration(); + pluginSettingsConfiguration.add(property); + Image icon = new Image("content_type", "data", "hash"); + + when(pluginManager.resolveExtensionVersion("plugin1", ELASTIC_AGENT_EXTENSION, SUPPORTED_VERSIONS)).thenReturn("1.0"); + when(extension.getPluginSettingsConfiguration(descriptor.id())).thenReturn(pluginSettingsConfiguration); + when(extension.getPluginSettingsView(descriptor.id())).thenReturn("some html"); + + when(extension.getIcon(descriptor.id())).thenReturn(icon); + + when(extension.getClusterProfileMetadata(descriptor.id())).thenReturn(clusterProfileConfigurations); + when(extension.getClusterProfileView(descriptor.id())).thenReturn("cluster_profile_view"); + + when(extension.getProfileMetadata(descriptor.id())).thenReturn(elasticAgentProfileConfigurations); + when(extension.getProfileView(descriptor.id())).thenReturn("elastic_agent_profile_view"); + + ElasticAgentPluginInfoBuilder builder = new ElasticAgentPluginInfoBuilder(extension); + ElasticAgentPluginInfo pluginInfo = builder.pluginInfoFor(descriptor); + + assertThat(pluginInfo.getDescriptor(), is(descriptor)); + assertThat(pluginInfo.getExtensionName(), is("elastic-agent")); + + assertThat(pluginInfo.getImage(), is(icon)); + assertThat(pluginInfo.getElasticAgentProfileSettings(), is(new PluggableInstanceSettings(elasticAgentProfileConfigurations, new PluginView("elastic_agent_profile_view")))); + assertThat(pluginInfo.getClusterProfileSettings(), is(new PluggableInstanceSettings(clusterProfileConfigurations, new PluginView("cluster_profile_view")))); assertThat(pluginInfo.getPluginSettings(), is(new PluggableInstanceSettings(builder.configurations(pluginSettingsConfiguration), new PluginView("some html")))); assertFalse(pluginInfo.supportsStatusReport()); } @@ -96,7 +131,7 @@ public void shouldContinueWithBuildingPluginInfoIfPluginSettingsIsNotProvidedByT assertThat(pluginInfo.getExtensionName(), is("elastic-agent")); assertThat(pluginInfo.getImage(), is(icon)); - assertThat(pluginInfo.getProfileSettings(), is(new PluggableInstanceSettings(pluginConfigurations, new PluginView("profile_view")))); + assertThat(pluginInfo.getElasticAgentProfileSettings(), is(new PluggableInstanceSettings(pluginConfigurations, new PluginView("profile_view")))); assertNull(pluginInfo.getPluginSettings()); } diff --git a/plugin-infra/go-plugin-domain/src/main/java/com/thoughtworks/go/plugin/domain/elastic/ElasticAgentPluginInfo.java b/plugin-infra/go-plugin-domain/src/main/java/com/thoughtworks/go/plugin/domain/elastic/ElasticAgentPluginInfo.java index 9000b96e73f4..7713b5d2f88c 100644 --- a/plugin-infra/go-plugin-domain/src/main/java/com/thoughtworks/go/plugin/domain/elastic/ElasticAgentPluginInfo.java +++ b/plugin-infra/go-plugin-domain/src/main/java/com/thoughtworks/go/plugin/domain/elastic/ElasticAgentPluginInfo.java @@ -22,21 +22,29 @@ import com.thoughtworks.go.plugin.domain.common.PluginConstants; import com.thoughtworks.go.plugin.domain.common.PluginInfo; +import java.util.Objects; + public class ElasticAgentPluginInfo extends PluginInfo { private final PluggableInstanceSettings profileSettings; + private final PluggableInstanceSettings clusterProfileSettings; private final Capabilities capabilities; - public ElasticAgentPluginInfo(PluginDescriptor descriptor, PluggableInstanceSettings profileSettings, Image image, + public ElasticAgentPluginInfo(PluginDescriptor descriptor, PluggableInstanceSettings profileSettings, PluggableInstanceSettings clusterProfileSettings, Image image, PluggableInstanceSettings pluginSettings, Capabilities capabilities) { - super(descriptor, PluginConstants.ELASTIC_AGENT_EXTENSION, pluginSettings, image); + super(descriptor, PluginConstants.ELASTIC_AGENT_EXTENSION, pluginSettings, image); this.profileSettings = profileSettings; + this.clusterProfileSettings = clusterProfileSettings; this.capabilities = capabilities; } - public PluggableInstanceSettings getProfileSettings() { + public PluggableInstanceSettings getElasticAgentProfileSettings() { return profileSettings; } + public PluggableInstanceSettings getClusterProfileSettings() { + return clusterProfileSettings; + } + public Capabilities getCapabilities() { return capabilities; } @@ -50,22 +58,14 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; - ElasticAgentPluginInfo that = (ElasticAgentPluginInfo) o; - - if (profileSettings != null ? !profileSettings.equals(that.profileSettings) : that.profileSettings != null) - return false; - if (image != null ? !image.equals(that.image) : that.image != null) return false; - return capabilities != null ? capabilities.equals(that.capabilities) : that.capabilities == null; - + return Objects.equals(profileSettings, that.profileSettings) && + Objects.equals(clusterProfileSettings, that.clusterProfileSettings) && + Objects.equals(capabilities, that.capabilities); } @Override public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (profileSettings != null ? profileSettings.hashCode() : 0); - result = 31 * result + (image != null ? image.hashCode() : 0); - result = 31 * result + (capabilities != null ? capabilities.hashCode() : 0); - return result; + return Objects.hash(super.hashCode(), profileSettings, clusterProfileSettings, capabilities); } } diff --git a/plugin-infra/go-plugin-domain/src/test/java/com/thoughtworks/go/plugin/domain/common/CombinedPluginInfoTest.java b/plugin-infra/go-plugin-domain/src/test/java/com/thoughtworks/go/plugin/domain/common/CombinedPluginInfoTest.java index 00a82a9ad59b..79f18b093b8e 100644 --- a/plugin-infra/go-plugin-domain/src/test/java/com/thoughtworks/go/plugin/domain/common/CombinedPluginInfoTest.java +++ b/plugin-infra/go-plugin-domain/src/test/java/com/thoughtworks/go/plugin/domain/common/CombinedPluginInfoTest.java @@ -88,7 +88,7 @@ public void shouldFindFirstExtensionWithImageIfPluginImplementsAtleastOneExtensi Image image2 = new Image("c2", "d2", "hash2"); Image image3 = new Image("c3", "d3", "hash3"); - ElasticAgentPluginInfo elasticAgentPluginInfo = new ElasticAgentPluginInfo(null, null, image1, null, null); + ElasticAgentPluginInfo elasticAgentPluginInfo = new ElasticAgentPluginInfo(null, null, elasticClusterProfileSettings(descriptor.id()), image1, null, null); AuthorizationPluginInfo authorizationPluginInfo = new AuthorizationPluginInfo(null, null, null, image2, null); AnalyticsPluginInfo analyticsPluginInfo = new AnalyticsPluginInfo(null, image3, null, null); diff --git a/server/src/test-fast/java/com/thoughtworks/go/server/service/ElasticAgentPluginServiceTest.java b/server/src/test-fast/java/com/thoughtworks/go/server/service/ElasticAgentPluginServiceTest.java index 4afd1c2f313c..5cb2d495e0a8 100644 --- a/server/src/test-fast/java/com/thoughtworks/go/server/service/ElasticAgentPluginServiceTest.java +++ b/server/src/test-fast/java/com/thoughtworks/go/server/service/ElasticAgentPluginServiceTest.java @@ -285,7 +285,7 @@ void shouldNotAssignJobToAnAgentBroughtUpByADifferentElasticPlugin() { void shouldGetAPluginStatusReportWhenPluginSupportsStatusReport() { final Capabilities capabilities = new Capabilities(true); final GoPluginDescriptor descriptor = new GoPluginDescriptor("cd.go.example.plugin", null, null, null, null, false); - elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, capabilities)); + elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, elasticClusterProfileSettings(descriptor.id()), null, null, capabilities)); when(registry.getPluginStatusReport("cd.go.example.plugin")).thenReturn("
This is a plugin status report snippet.
"); @@ -298,7 +298,7 @@ void shouldGetAPluginStatusReportWhenPluginSupportsStatusReport() { void shouldErrorOutWhenPluginDoesNotSupportStatusReport() { final Capabilities capabilities = new Capabilities(false); final GoPluginDescriptor descriptor = new GoPluginDescriptor("cd.go.example.plugin", null, null, null, null, false); - elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, capabilities)); + elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, elasticClusterProfileSettings(descriptor.id()), null, null, capabilities)); final UnsupportedOperationException exception = assertThrows(UnsupportedOperationException.class, () -> service.getPluginStatusReport("cd.go.example.plugin")); assertThat(exception.getMessage()).isEqualTo("Plugin does not plugin support status report."); @@ -308,7 +308,7 @@ void shouldErrorOutWhenPluginDoesNotSupportStatusReport() { void shouldGetAPluginAgentReportWhenPluginSupportsStatusReport() { final Capabilities capabilities = new Capabilities(false, true); final GoPluginDescriptor descriptor = new GoPluginDescriptor("cd.go.example.plugin", null, null, null, null, false); - elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, capabilities)); + elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, elasticClusterProfileSettings(descriptor.id()), null, null, capabilities)); when(registry.getAgentStatusReport("cd.go.example.plugin", null, "some-id")) .thenReturn("
This is a agent status report snippet.
"); @@ -322,7 +322,7 @@ void shouldGetAPluginAgentReportWhenPluginSupportsStatusReport() { void shouldErrorOutWhenPluginDoesNotAgentSupportStatusReport() { final Capabilities capabilities = new Capabilities(true, false); final GoPluginDescriptor descriptor = new GoPluginDescriptor("cd.go.example.plugin", null, null, null, null, false); - elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, capabilities)); + elasticAgentMetadataStore.setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, elasticClusterProfileSettings(descriptor.id()), null, null, capabilities)); final UnsupportedOperationException exception = assertThrows(UnsupportedOperationException.class, () -> service.getAgentStatusReport("cd.go.example.plugin", null, null)); assertThat(exception.getMessage()).isEqualTo("Plugin does not support agent status report."); diff --git a/server/src/test-integration/java/com/thoughtworks/go/server/controller/JobControllerIntegrationTest.java b/server/src/test-integration/java/com/thoughtworks/go/server/controller/JobControllerIntegrationTest.java index ae71432041a8..cfa93b095e99 100644 --- a/server/src/test-integration/java/com/thoughtworks/go/server/controller/JobControllerIntegrationTest.java +++ b/server/src/test-integration/java/com/thoughtworks/go/server/controller/JobControllerIntegrationTest.java @@ -182,7 +182,7 @@ public void jobDetailModel_shouldHaveTheElasticProfilePluginIdWhenAgentIsNotAssi JobInstance job = stage.getFirstJob(); GoPluginDescriptor.About about = new GoPluginDescriptor.About("name", "0.1", "17.3.0", "desc", null, null); GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin_id", null, about, null, null, false); - ElasticAgentMetadataStore.instance().setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, new Capabilities(false, true))); + ElasticAgentMetadataStore.instance().setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, elasticClusterProfileSettings(descriptor.id()), null, null, new Capabilities(false, true))); ElasticProfile profile = new ElasticProfile("profile_id", "plugin_id", "cluster_profile_id", Collections.EMPTY_LIST); ClusterProfile clusterProfile = new ClusterProfile("cluster_profile_id", "plugin_id", Collections.EMPTY_LIST); @@ -203,7 +203,7 @@ public void jobDetailModel_shouldHaveTheElasticPluginIdAndElasticAgentIdWhenAgen GoPluginDescriptor.About about = new GoPluginDescriptor.About("name", "0.1", "17.3.0", "desc", null, null); GoPluginDescriptor descriptor = new GoPluginDescriptor("plugin_id", null, about, null, null, false); - ElasticAgentMetadataStore.instance().setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, null, null, new Capabilities(false, true))); + ElasticAgentMetadataStore.instance().setPluginInfo(new ElasticAgentPluginInfo(descriptor, null, elasticClusterProfileSettings(descriptor.id()), null, null, new Capabilities(false, true))); ElasticProfile profile = new ElasticProfile("profile_id", "plugin_id", "cluster_profile_id", Collections.EMPTY_LIST); ClusterProfile clusterProfile = new ClusterProfile("cluster_profile_id", "plugin_id", Collections.EMPTY_LIST);