From 0813f97102cfe63016cd818528c84584fb7ebdb0 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Sun, 18 Oct 2020 16:06:31 +0300 Subject: [PATCH 1/2] Remove installers entity --- .../model/workspace/config/MachineConfig.java | 10 --- .../tracker/RamResourceUsageTrackerTest.java | 2 +- .../factory/server/FactoryServiceTest.java | 2 - .../server/builder/FactoryBuilderTest.java | 1 - .../server/spi/tck/FactoryDaoTest.java | 3 - .../installer/shared/dto/InstallerDto.java | 80 ------------------- .../api/installer/shared/model/Installer.java | 64 --------------- .../spi/tck/WorkspaceActivityDaoTest.java | 2 - .../shared/dto/MachineConfigDto.java | 8 -- .../api/workspace/server/DtoConverter.java | 3 +- .../workspace/server/WorkspaceValidator.java | 26 ------ .../server/model/impl/MachineConfigImpl.java | 41 +--------- .../server/WorkspaceManagerTest.java | 1 - .../server/WorkspaceServiceTest.java | 1 - .../server/WorkspaceValidatorTest.java | 24 ------ .../server/devfile/URLFetcherTest.java | 31 +++---- .../InternalEnvironmentFactoryTest.java | 2 +- .../server/spi/tck/WorkspaceDaoTest.java | 5 -- .../7.21.0/1__remove_installers.sql | 13 +++ .../che/core/db/jpa/TestObjectsFactory.java | 2 - wsmaster/pom.xml | 1 - 21 files changed, 33 insertions(+), 289 deletions(-) delete mode 100644 wsmaster/che-core-api-installer-shared/src/main/java/org/eclipse/che/api/installer/shared/dto/InstallerDto.java delete mode 100644 wsmaster/che-core-api-installer-shared/src/main/java/org/eclipse/che/api/installer/shared/model/Installer.java create mode 100644 wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.21.0/1__remove_installers.sql diff --git a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/MachineConfig.java b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/MachineConfig.java index 6d36e4d4446..40b811c65a4 100644 --- a/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/MachineConfig.java +++ b/core/che-core-api-model/src/main/java/org/eclipse/che/api/core/model/workspace/config/MachineConfig.java @@ -11,7 +11,6 @@ */ package org.eclipse.che.api.core.model.workspace.config; -import java.util.List; import java.util.Map; import org.eclipse.che.api.core.model.workspace.devfile.Component; @@ -75,15 +74,6 @@ public interface MachineConfig { */ String DEVFILE_COMPONENT_ALIAS_ATTRIBUTE = "component"; - /** - * Returns configured installers. - * - *

Values can be installer id with version separated with ':' symbol or just id then latest - * version will be used. Values examples: org.exec-agent:v1.0, org.exec-agent, - * org.exec-agent:latest. - */ - List getInstallers(); - /** Returns mapping of references to configurations of servers deployed into machine. */ Map getServers(); diff --git a/multiuser/api/che-multiuser-api-resource/src/test/java/org/eclipse/che/multiuser/resource/api/usage/tracker/RamResourceUsageTrackerTest.java b/multiuser/api/che-multiuser-api-resource/src/test/java/org/eclipse/che/multiuser/resource/api/usage/tracker/RamResourceUsageTrackerTest.java index c3ef72bac76..e5c2e335583 100644 --- a/multiuser/api/che-multiuser-api-resource/src/test/java/org/eclipse/che/multiuser/resource/api/usage/tracker/RamResourceUsageTrackerTest.java +++ b/multiuser/api/che-multiuser-api-resource/src/test/java/org/eclipse/che/multiuser/resource/api/usage/tracker/RamResourceUsageTrackerTest.java @@ -187,6 +187,6 @@ private static MachineImpl createMachine(long memoryMb) { private static MachineConfigImpl createMachineConfig(long memoryMb) { return new MachineConfigImpl( - null, null, null, ImmutableMap.of(MEMORY_LIMIT_ATTRIBUTE, valueOf(memoryMb)), null); + null, null, ImmutableMap.of(MEMORY_LIMIT_ATTRIBUTE, valueOf(memoryMb)), null); } } diff --git a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/FactoryServiceTest.java b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/FactoryServiceTest.java index fc32d51d5ec..954fde40a6b 100644 --- a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/FactoryServiceTest.java +++ b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/FactoryServiceTest.java @@ -13,7 +13,6 @@ import static com.jayway.restassured.RestAssured.given; import static java.lang.String.valueOf; -import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static javax.ws.rs.core.Response.Status.BAD_REQUEST; import static org.eclipse.che.api.factory.server.FactoryService.VALIDATE_QUERY_PARAMETER; @@ -242,7 +241,6 @@ private static EnvironmentDto createEnvDto() { environmentRecipe.setLocation("location"); final EnvironmentImpl env = new EnvironmentImpl(); final MachineConfigImpl extendedMachine = new MachineConfigImpl(); - extendedMachine.setInstallers(singletonList("agent")); extendedMachine.setAttributes(singletonMap("att1", "value")); extendedMachine.setServers( singletonMap( diff --git a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/builder/FactoryBuilderTest.java b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/builder/FactoryBuilderTest.java index e5517b80475..b14a2d81913 100644 --- a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/builder/FactoryBuilderTest.java +++ b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/builder/FactoryBuilderTest.java @@ -224,7 +224,6 @@ private static FactoryDto prepareFactory() { singletonMap( "devmachine", newDto(MachineConfigDto.class) - .withInstallers(singletonList("org.eclipse.che.ws-agent")) .withAttributes( singletonMap(MEMORY_LIMIT_ATTRIBUTE, "" + 512L * 1024L * 1024L)))); diff --git a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java index 49d14321e83..89fd6cd0ceb 100644 --- a/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java +++ b/wsmaster/che-core-api-factory/src/test/java/org/eclipse/che/api/factory/server/spi/tck/FactoryDaoTest.java @@ -347,7 +347,6 @@ private static WorkspaceConfigImpl createWorkspaceConfig(int index) { final ServerConfigImpl serverConf2 = new ServerConfigImpl("2266", "ftp", "/path2", singletonMap("key", "value")); exMachine1.setServers(ImmutableMap.of("ref1", serverConf1, "ref2", serverConf2)); - exMachine1.setInstallers(ImmutableList.of("agent5", "agent4")); exMachine1.setAttributes(singletonMap("att1", "val")); exMachine1.setEnv(singletonMap("CHE_ENV", "value")); @@ -357,7 +356,6 @@ private static WorkspaceConfigImpl createWorkspaceConfig(int index) { final ServerConfigImpl serverConf4 = new ServerConfigImpl("2334", "wss", "/path2", singletonMap("key", "value")); exMachine2.setServers(ImmutableMap.of("ref1", serverConf3, "ref2", serverConf4)); - exMachine2.setInstallers(ImmutableList.of("agent2", "agent1")); exMachine2.setAttributes(singletonMap("att1", "val")); exMachine2.setEnv(singletonMap("CHE_ENV2", "value")); @@ -365,7 +363,6 @@ private static WorkspaceConfigImpl createWorkspaceConfig(int index) { final ServerConfigImpl serverConf5 = new ServerConfigImpl("2333", "https", "/path3", singletonMap("key", "value")); exMachine3.setServers(singletonMap("ref1", serverConf5)); - exMachine3.setInstallers(ImmutableList.of("agent6", "agent2")); exMachine3.setAttributes(singletonMap("att1", "val")); exMachine3.setEnv(singletonMap("CHE_ENV3", "value")); diff --git a/wsmaster/che-core-api-installer-shared/src/main/java/org/eclipse/che/api/installer/shared/dto/InstallerDto.java b/wsmaster/che-core-api-installer-shared/src/main/java/org/eclipse/che/api/installer/shared/dto/InstallerDto.java deleted file mode 100644 index e064f000c91..00000000000 --- a/wsmaster/che-core-api-installer-shared/src/main/java/org/eclipse/che/api/installer/shared/dto/InstallerDto.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.che.api.installer.shared.dto; - -import java.util.List; -import java.util.Map; -import org.eclipse.che.api.installer.shared.model.Installer; -import org.eclipse.che.api.workspace.shared.dto.ServerConfigDto; -import org.eclipse.che.dto.shared.DTO; - -/** @author Anatoliy Bazko */ -@DTO -@Deprecated -public interface InstallerDto extends Installer { - - @Override - String getId(); - - void setId(String id); - - InstallerDto withId(String id); - - @Override - String getName(); - - void setName(String name); - - InstallerDto withName(String name); - - @Override - String getVersion(); - - void setVersion(String version); - - InstallerDto withVersion(String version); - - @Override - String getDescription(); - - void setDescription(String description); - - InstallerDto withDescription(String description); - - @Override - List getDependencies(); - - void setDependencies(List dependencies); - - InstallerDto withDependencies(List dependencies); - - @Override - String getScript(); - - void setScript(String script); - - InstallerDto withScript(String script); - - @Override - Map getProperties(); - - void setProperties(Map properties); - - InstallerDto withProperties(Map properties); - - @Override - Map getServers(); - - void setServers(Map servers); - - InstallerDto withServers(Map servers); -} diff --git a/wsmaster/che-core-api-installer-shared/src/main/java/org/eclipse/che/api/installer/shared/model/Installer.java b/wsmaster/che-core-api-installer-shared/src/main/java/org/eclipse/che/api/installer/shared/model/Installer.java deleted file mode 100644 index 93c54b5d4c0..00000000000 --- a/wsmaster/che-core-api-installer-shared/src/main/java/org/eclipse/che/api/installer/shared/model/Installer.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2012-2018 Red Hat, Inc. - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat, Inc. - initial API and implementation - */ -package org.eclipse.che.api.installer.shared.model; - -import java.util.List; -import java.util.Map; -import org.eclipse.che.api.core.model.workspace.config.ServerConfig; - -/** - * An entity that might additionally injected into machine and brings functionality. - * - * @author Anatoliy Bazko - * @author Alexander Garagatyi - */ -@Deprecated -public interface Installer { - - /** - * Name of a property from {@link #getProperties()} that can contain environment variables that - * should be injected into machine. - * - *

Example: { "environment" : "envVar1=value1,envVar2=value2" } - */ - String ENVIRONMENT_PROPERTY = "environment"; - - /** Returns the id of the installer. */ - String getId(); - - /** Returns the name of the installer. */ - String getName(); - - /** Returns the version of the installer. */ - String getVersion(); - - /** Returns the description of the installer. */ - String getDescription(); - - /** - * Returns the depending installers, that must be applied before. - * - *

Values can be installer id with version separated with ':' symbol or just id then latest - * version will be used. Values examples: org.exec-agent:v1.0, org.exec-agent, - * org.exec-agent:latest. - */ - List getDependencies(); - - /** Returns the script to be applied when machine is started. */ - String getScript(); - - /** Returns any machine specific properties. */ - Map getProperties(); - - /** Returns Che servers in the machine. */ - Map getServers(); -} diff --git a/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/spi/tck/WorkspaceActivityDaoTest.java b/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/spi/tck/WorkspaceActivityDaoTest.java index 82cb178dea1..57f9f7b1579 100644 --- a/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/spi/tck/WorkspaceActivityDaoTest.java +++ b/wsmaster/che-core-api-workspace-activity/src/test/java/org/eclipse/che/api/workspace/activity/spi/tck/WorkspaceActivityDaoTest.java @@ -21,7 +21,6 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.time.Instant; import java.util.ArrayList; @@ -368,7 +367,6 @@ private static WorkspaceConfigImpl createWorkspaceConfig(String name) { final ServerConfigImpl serverConf1 = new ServerConfigImpl("2265", "http", "path1", singletonMap("key", "value")); exMachine1.setServers(ImmutableMap.of("ref1", serverConf1)); - exMachine1.setInstallers(ImmutableList.of("agent5", "agent4")); exMachine1.setAttributes(singletonMap("att1", "val")); exMachine1.setEnv(ImmutableMap.of("CHE_ENV1", "value", "CHE_ENV2", "value")); exMachine1.setVolumes(ImmutableMap.of("vol1", new VolumeImpl().withPath("/path/1"))); diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/MachineConfigDto.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/MachineConfigDto.java index d162792720f..9907d490708 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/MachineConfigDto.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/dto/MachineConfigDto.java @@ -13,7 +13,6 @@ import static org.eclipse.che.api.core.factory.FactoryParameter.Obligation.OPTIONAL; -import java.util.List; import java.util.Map; import org.eclipse.che.api.core.factory.FactoryParameter; import org.eclipse.che.api.core.model.workspace.config.MachineConfig; @@ -22,13 +21,6 @@ /** @author Alexander Garagatyi */ @DTO public interface MachineConfigDto extends MachineConfig { - @Override - @FactoryParameter(obligation = OPTIONAL) - List getInstallers(); - - void setInstallers(List installers); - - MachineConfigDto withInstallers(List installers); @Override @FactoryParameter(obligation = OPTIONAL) diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java index 28dcb6d28e5..0f2f9235736 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/DtoConverter.java @@ -307,8 +307,7 @@ public static EnvironmentDto asDto(Environment env) { /** Converts {@link MachineConfig} to {@link MachineConfigDto}. */ public static MachineConfigDto asDto(MachineConfig machine) { - MachineConfigDto machineDto = - newDto(MachineConfigDto.class).withInstallers(machine.getInstallers()); + MachineConfigDto machineDto = newDto(MachineConfigDto.class); if (machine.getServers() != null) { machineDto.setServers( machine diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceValidator.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceValidator.java index 2564ffd91c8..d07027c25af 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceValidator.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceValidator.java @@ -19,7 +19,6 @@ import java.util.Map; import java.util.Map.Entry; -import java.util.Optional; import java.util.Set; import java.util.regex.Pattern; import javax.inject.Inject; @@ -94,9 +93,6 @@ public void validateConfig(WorkspaceConfig config) throws ValidationException, S command.getName(), config.getName()); } - - // ensure using either plugins or installers but not both - validatePlugins(config); } /** @@ -209,28 +205,6 @@ private void validateLongAttribute( } } - /** - * Check that workspace has either plugins defined in attributes (Che 7) or installers defined in - * machines (Che 6). - * - * @throws ValidationException if workspace config contains both installers section and nonempty - * plugins or editor field in attributes. - */ - private void validatePlugins(WorkspaceConfig config) throws ValidationException { - Optional installers = - config - .getEnvironments() - .values() - .stream() - .flatMap(env -> env.getMachines().values().stream()) - .flatMap(machine -> machine.getInstallers().stream()) - .findAny(); - Map attributes = config.getAttributes(); - if (isSidecarBasedWorkspace(attributes) && installers.isPresent()) { - throw new ValidationException("Workspace config cannot have both plugins and installers."); - } - } - /** * Checks that object reference is not null, throws {@link ValidationException} in the case of * null {@code object} with given {@code message}. diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/MachineConfigImpl.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/MachineConfigImpl.java index bd5b0853836..1f2d0efcbfe 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/MachineConfigImpl.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/model/impl/MachineConfigImpl.java @@ -11,9 +11,7 @@ */ package org.eclipse.che.api.workspace.server.model.impl; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -43,13 +41,6 @@ public class MachineConfigImpl implements MachineConfig { @Column(name = "id") private Long id; - @ElementCollection(fetch = FetchType.EAGER) - @CollectionTable( - name = "externalmachine_installers", - joinColumns = @JoinColumn(name = "externalmachine_id")) - @Column(name = "installers") - private List installers; - @ElementCollection(fetch = FetchType.EAGER) @CollectionTable( name = "externalmachine_attributes", @@ -79,14 +70,10 @@ public class MachineConfigImpl implements MachineConfig { public MachineConfigImpl() {} public MachineConfigImpl( - List installers, Map servers, Map env, Map attributes, Map volumes) { - if (installers != null) { - this.installers = new ArrayList<>(installers); - } if (servers != null) { this.servers = servers @@ -113,29 +100,7 @@ public MachineConfigImpl( } public MachineConfigImpl(MachineConfig machine) { - this( - machine.getInstallers(), - machine.getServers(), - machine.getEnv(), - machine.getAttributes(), - machine.getVolumes()); - } - - @Override - public List getInstallers() { - if (installers == null) { - installers = new ArrayList<>(); - } - return installers; - } - - public void setInstallers(List installers) { - this.installers = installers; - } - - public MachineConfigImpl withInstallers(List installers) { - this.installers = installers; - return this; + this(machine.getServers(), machine.getEnv(), machine.getAttributes(), machine.getVolumes()); } @Override @@ -216,7 +181,6 @@ public boolean equals(Object obj) { } final MachineConfigImpl that = (MachineConfigImpl) obj; return Objects.equals(id, that.id) - && getInstallers().equals(that.getInstallers()) && getEnv().equals(that.getEnv()) && getAttributes().equals(that.getAttributes()) && getServers().equals(that.getServers()) @@ -227,7 +191,6 @@ && getServers().equals(that.getServers()) public int hashCode() { int hash = 7; hash = 31 * hash + Objects.hashCode(id); - hash = 31 * hash + getInstallers().hashCode(); hash = 31 * hash + getEnv().hashCode(); hash = 31 * hash + getAttributes().hashCode(); hash = 31 * hash + getServers().hashCode(); @@ -240,8 +203,6 @@ public String toString() { return "MachineConfigImpl{" + "id=" + id - + ", installers=" - + installers + ", env=" + env + ", attributes=" diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceManagerTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceManagerTest.java index ee1dbb5880c..d8ccbd370cf 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceManagerTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceManagerTest.java @@ -1019,7 +1019,6 @@ private void mockAnyWorkspaceStartFailed(Exception cause) throws Exception { private static WorkspaceConfigImpl createConfig() { MachineConfigImpl machineConfig = new MachineConfigImpl( - singletonList("org.eclipse.che.ws-agent"), singletonMap("server", createServerConfig()), singletonMap("CHE_ENV", "value"), singletonMap(MEMORY_LIMIT_ATTRIBUTE, "10000"), diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java index ed1a6efd825..95d8ad2913c 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java @@ -954,7 +954,6 @@ private static ProjectConfigDto createProjectDto() { private static EnvironmentDto createEnvDto() { MachineConfigImpl devMachine = new MachineConfigImpl( - singletonList("org.eclipse.che.ws-agent"), null, singletonMap("CHE_ENV", "value"), singletonMap(MEMORY_LIMIT_ATTRIBUTE, "10000"), diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceValidatorTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceValidatorTest.java index 49fa2b2889c..003f2ab0730 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceValidatorTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceValidatorTest.java @@ -11,7 +11,6 @@ */ package org.eclipse.che.api.workspace.server; -import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static org.eclipse.che.api.core.model.workspace.config.MachineConfig.MEMORY_LIMIT_ATTRIBUTE; import static org.eclipse.che.api.core.model.workspace.config.MachineConfig.MEMORY_REQUEST_ATTRIBUTE; @@ -340,35 +339,12 @@ public void shouldFailValidationIfVolumePathIsNotAbsolute() throws Exception { wsValidator.validateConfig(config); } - @Test( - expectedExceptions = ValidationException.class, - expectedExceptionsMessageRegExp = ".*([pP]lugin.*[iI]nstaller|[iI]nstaller.*[pP]lugin).*") - public void shouldFailValidationIfBothPluginsAndInstallersPresent() throws Exception { - // createConfig creates config with one installer by default - final WorkspaceConfigDto config = createConfig(); - config.getAttributes().put(Constants.WORKSPACE_TOOLING_PLUGINS_ATTRIBUTE, "plugin1"); - - wsValidator.validateConfig(config); - } - - @Test( - expectedExceptions = ValidationException.class, - expectedExceptionsMessageRegExp = ".*([pP]lugin.*[iI]nstaller|[iI]nstaller.*[pP]lugin).*") - public void shouldFailValidationIfBothEditorAndInstallersPresent() throws Exception { - // createConfig creates config with one installer by default - final WorkspaceConfigDto config = createConfig(); - config.getAttributes().put(Constants.WORKSPACE_TOOLING_EDITOR_ATTRIBUTE, "editor1"); - - wsValidator.validateConfig(config); - } - private static WorkspaceConfigDto createConfig() { final WorkspaceConfigDto workspaceConfigDto = newDto(WorkspaceConfigDto.class).withName("ws-name").withDefaultEnv("dev-env"); MachineConfigDto machineConfig = newDto(MachineConfigDto.class) - .withInstallers(singletonList("org.eclipse.che.ws-agent")) .withServers( singletonMap( "ref1", diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/URLFetcherTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/URLFetcherTest.java index a788e1af64c..6d76c820746 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/URLFetcherTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/URLFetcherTest.java @@ -101,21 +101,22 @@ public void checkMissingContent() { assertNull(content); } - /** Check that when url doesn't exist */ - @Test( - expectedExceptions = IOException.class, - expectedExceptionsMessageRegExp = - ".*url_fetcher_test_resource.json-invalid \\(No such file or directory\\)") - public void checkMissingContentUnsafeGet() throws Exception { - - // test to download this class object - URL urlJson = getClass().getClassLoader().getResource("devfile/url_fetcher_test_resource.json"); - Assert.assertNotNull(urlJson); - - // add extra path to make url not found - String content = urlFetcher.fetch(urlJson.toString() + "-invalid"); - assertNull(content); - } + // /** Check that when url doesn't exist */ + // @Test( + // expectedExceptions = IOException.class, + // expectedExceptionsMessageRegExp = + // ".*url_fetcher_test_resource.json-invalid \\(No such file or directory\\)") + // public void checkMissingContentUnsafeGet() throws Exception { + // + // // test to download this class object + // URL urlJson = + // getClass().getClassLoader().getResource("devfile/url_fetcher_test_resource.json"); + // Assert.assertNotNull(urlJson); + // + // // add extra path to make url not found + // String content = urlFetcher.fetch(urlJson.toString() + "-invalid"); + // assertNull(content); + // } /** Check when we reach custom limit */ @Test diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/environment/InternalEnvironmentFactoryTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/environment/InternalEnvironmentFactoryTest.java index 8cc7d2c9f5e..9502d49b1b0 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/environment/InternalEnvironmentFactoryTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/environment/InternalEnvironmentFactoryTest.java @@ -99,7 +99,7 @@ public void shouldUseNormalizedServersWhileInternalEnvironmentCreation() throws doReturn(normalizedServers).when(environmentFactory).normalizeServers(any()); ImmutableMap sourceServers = ImmutableMap.of("server", server); - MachineConfigImpl machineConfig = new MachineConfigImpl(null, sourceServers, null, null, null); + MachineConfigImpl machineConfig = new MachineConfigImpl(sourceServers, null, null, null); EnvironmentImpl env = new EnvironmentImpl(null, ImmutableMap.of("machine", machineConfig)); diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java index b05593fa6c6..563bf32cb22 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/spi/tck/WorkspaceDaoTest.java @@ -488,7 +488,6 @@ public void shouldUpdateWorkspaceWithConfig() throws Exception { final ServerConfigImpl serverConf2 = new ServerConfigImpl("2266", "ftp", "path2", singletonMap("key", "value")); newMachine.setServers(ImmutableMap.of("ref1", serverConf1, "ref2", serverConf2)); - newMachine.setInstallers(ImmutableList.of("agent5", "agent4")); newMachine.setAttributes(singletonMap("att1", "val")); newMachine.setAttributes(singletonMap("CHE_ENV", "value")); final EnvironmentImpl newEnv = new EnvironmentImpl(); @@ -503,7 +502,6 @@ public void shouldUpdateWorkspaceWithConfig() throws Exception { final List machineNames = new ArrayList<>(defaultEnv.getMachines().keySet()); // Update an existing machine final MachineConfigImpl existingMachine = defaultEnv.getMachines().get(machineNames.get(1)); - existingMachine.setInstallers(asList("new-agent1", "new-agent2")); existingMachine.setAttributes( ImmutableMap.of( "attr1", "value1", @@ -780,7 +778,6 @@ public static WorkspaceConfigImpl createWorkspaceConfig(String name) { final ServerConfigImpl serverConf2 = new ServerConfigImpl("2266", "ftp", "path2", singletonMap("key", "value")); exMachine1.setServers(ImmutableMap.of("ref1", serverConf1, "ref2", serverConf2)); - exMachine1.setInstallers(ImmutableList.of("agent5", "agent4")); exMachine1.setAttributes(singletonMap("att1", "val")); exMachine1.setEnv(ImmutableMap.of("CHE_ENV1", "value", "CHE_ENV2", "value")); exMachine1.setVolumes( @@ -796,7 +793,6 @@ public static WorkspaceConfigImpl createWorkspaceConfig(String name) { final ServerConfigImpl serverConf4 = new ServerConfigImpl("2334", "wss", "path4", singletonMap("key", "value")); exMachine2.setServers(ImmutableMap.of("ref1", serverConf3, "ref2", serverConf4)); - exMachine2.setInstallers(ImmutableList.of("agent2", "agent1")); exMachine2.setAttributes(singletonMap("att1", "val")); exMachine2.setEnv(singletonMap("CHE_ENV2", "value")); exMachine2.setVolumes(ImmutableMap.of("vol2", new VolumeImpl().withPath("/path/2"))); @@ -805,7 +801,6 @@ public static WorkspaceConfigImpl createWorkspaceConfig(String name) { final ServerConfigImpl serverConf5 = new ServerConfigImpl("2333", "https", "path5", singletonMap("key", "value")); exMachine3.setServers(singletonMap("ref1", serverConf5)); - exMachine3.setInstallers(ImmutableList.of("agent6", "agent2")); exMachine3.setAttributes(singletonMap("att1", "val")); exMachine3.setEnv(singletonMap("CHE_ENV3", "value")); exMachine3.setVolumes(ImmutableMap.of("vol3", new VolumeImpl().withPath("/path/3"))); diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.21.0/1__remove_installers.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.21.0/1__remove_installers.sql new file mode 100644 index 00000000000..f0d5448dd21 --- /dev/null +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.21.0/1__remove_installers.sql @@ -0,0 +1,13 @@ +-- +-- Copyright (c) 2012-2020 Red Hat, Inc. +-- This program and the accompanying materials are made +-- available under the terms of the Eclipse Public License 2.0 +-- which is available at https://www.eclipse.org/legal/epl-2.0/ +-- +-- SPDX-License-Identifier: EPL-2.0 +-- +-- Contributors: +-- Red Hat, Inc. - initial API and implementation +-- + +DROP TABLE externalmachine_installers; \ No newline at end of file diff --git a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java index e57415e6f18..e872bed59ef 100644 --- a/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java +++ b/wsmaster/integration-tests/cascade-removal/src/test/java/org/eclipse/che/core/db/jpa/TestObjectsFactory.java @@ -16,7 +16,6 @@ import static java.util.Collections.singletonMap; import static org.eclipse.che.commons.lang.NameGenerator.generate; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.HashMap; import java.util.Map; @@ -203,7 +202,6 @@ public static EnvironmentImpl createEnv() { final ServerConfigImpl serverConf2 = new ServerConfigImpl("2266", "ftp", "/path2", singletonMap("key", "value")); newMachine.setServers(ImmutableMap.of("ref1", serverConf1, "ref2", serverConf2)); - newMachine.setInstallers(ImmutableList.of("agent5", "agent4")); newMachine.setAttributes(singletonMap("att1", "val")); newMachine.setEnv(singletonMap("CHE_ENV", "value")); diff --git a/wsmaster/pom.xml b/wsmaster/pom.xml index 25abc1e14f4..8c1e2b29d4d 100644 --- a/wsmaster/pom.xml +++ b/wsmaster/pom.xml @@ -24,7 +24,6 @@ pom Che Core :: API :: Che Master Parent - che-core-api-installer-shared che-core-api-auth-shared che-core-api-auth che-core-api-auth-github From 7b35b2c95fccab7efaa774456a5a0d7b6378fc10 Mon Sep 17 00:00:00 2001 From: Max Shaposhnik Date: Sun, 18 Oct 2020 18:33:53 +0300 Subject: [PATCH 2/2] fixup! Remove installers entity --- .../server/devfile/URLFetcherTest.java | 31 +++++++++---------- .../7.21.0/1__remove_installers.sql | 2 +- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/URLFetcherTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/URLFetcherTest.java index 6d76c820746..a788e1af64c 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/URLFetcherTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/devfile/URLFetcherTest.java @@ -101,22 +101,21 @@ public void checkMissingContent() { assertNull(content); } - // /** Check that when url doesn't exist */ - // @Test( - // expectedExceptions = IOException.class, - // expectedExceptionsMessageRegExp = - // ".*url_fetcher_test_resource.json-invalid \\(No such file or directory\\)") - // public void checkMissingContentUnsafeGet() throws Exception { - // - // // test to download this class object - // URL urlJson = - // getClass().getClassLoader().getResource("devfile/url_fetcher_test_resource.json"); - // Assert.assertNotNull(urlJson); - // - // // add extra path to make url not found - // String content = urlFetcher.fetch(urlJson.toString() + "-invalid"); - // assertNull(content); - // } + /** Check that when url doesn't exist */ + @Test( + expectedExceptions = IOException.class, + expectedExceptionsMessageRegExp = + ".*url_fetcher_test_resource.json-invalid \\(No such file or directory\\)") + public void checkMissingContentUnsafeGet() throws Exception { + + // test to download this class object + URL urlJson = getClass().getClassLoader().getResource("devfile/url_fetcher_test_resource.json"); + Assert.assertNotNull(urlJson); + + // add extra path to make url not found + String content = urlFetcher.fetch(urlJson.toString() + "-invalid"); + assertNull(content); + } /** Check when we reach custom limit */ @Test diff --git a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.21.0/1__remove_installers.sql b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.21.0/1__remove_installers.sql index f0d5448dd21..3d9cef16490 100644 --- a/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.21.0/1__remove_installers.sql +++ b/wsmaster/che-core-sql-schema/src/main/resources/che-schema/7.21.0/1__remove_installers.sql @@ -10,4 +10,4 @@ -- Red Hat, Inc. - initial API and implementation -- -DROP TABLE externalmachine_installers; \ No newline at end of file +DROP TABLE externalmachine_installers;