diff --git a/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/Messages.java b/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/Messages.java index 979102b2e6..d0469ba013 100644 --- a/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/Messages.java +++ b/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/Messages.java @@ -109,6 +109,7 @@ public final class Messages { public static final String INVALID_SUPPORT_COMPONENTS = "Invalid SUPPORT_COMPONENTS \"{0}\""; public static final String INCOMPATIBLE_PARAMETERS = "Module \"{0}\" has parameters {1} that will be replaced by \"{2}\" due to inconsistency"; public static final String MODULE_0_DEPENDS_ON_MODULE_1_WHICH_CANNOT_BE_RESOLVED = "Module \"{0}\" depends on module \"{1}\", which is not an application and its state cannot be calculated. This dependency will be ignored during deployment."; + public static final String MODULE_0_WILL_BE_SKIPPED_DURING_DEPLOYMENT = "Module \"{0}\" will be skipped during deployment"; // Info messages public static final String PLATFORMS_NOT_SPECIFIED = "No platforms are specified in the environment."; diff --git a/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/cf/util/ModulesCloudModelBuilderContentCalculator.java b/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/cf/util/ModulesCloudModelBuilderContentCalculator.java index 3a3f789430..a19d448593 100644 --- a/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/cf/util/ModulesCloudModelBuilderContentCalculator.java +++ b/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/cf/util/ModulesCloudModelBuilderContentCalculator.java @@ -37,8 +37,8 @@ public ModulesCloudModelBuilderContentCalculator(Set mtaModulesInArchive public List calculateContentForBuilding(List modulesForDeployment) { initializeModulesDependencyTypes(modulesForDeployment); List calculatedModules = modulesForDeployment.stream() - .filter(module -> shouldDeployModule(module, mtaModulesInArchive, - deployedModules)) + .filter( + module -> shouldDeployModule(module, mtaModulesInArchive, deployedModules)) .filter(this::isModuleSpecifiedForDeployment) .collect(Collectors.toList()); validateCalculatedModules(calculatedModules); @@ -71,21 +71,25 @@ private boolean isModuleSpecifiedForDeployment(Module module) { } private boolean shouldDeployModule(Module module, Set mtaModulesInArchive, Set deployedModules) { + if (moduleToDeployHelper.shouldSkipDeploy(module)) { + printModuleWarningMessage(Messages.MODULE_0_WILL_BE_SKIPPED_DURING_DEPLOYMENT, module.getName()); + return false; + } if (moduleToDeployHelper.shouldDeployAlways(module) || isDockerModule(module)) { return true; } if (!mtaModulesInArchive.contains(module.getName()) || module.getType() == null) { if (deployedModules.contains(module.getName())) { - printMTAModuleNotFoundWarning(module.getName()); + printModuleWarningMessage(Messages.NOT_DESCRIBED_MODULE, module.getName()); } return false; } return true; } - private void printMTAModuleNotFoundWarning(String name) { + private void printModuleWarningMessage(String warningMessage, String moduleName) { if (userMessageLogger != null) { - userMessageLogger.warn(Messages.NOT_DESCRIBED_MODULE, name); + userMessageLogger.warn(warningMessage, moduleName); } } diff --git a/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/helpers/ModuleToDeployHelper.java b/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/helpers/ModuleToDeployHelper.java index 3fa47734ce..2258eb648a 100644 --- a/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/helpers/ModuleToDeployHelper.java +++ b/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/helpers/ModuleToDeployHelper.java @@ -1,7 +1,7 @@ package org.cloudfoundry.multiapps.controller.core.helpers; import jakarta.inject.Named; - +import org.cloudfoundry.multiapps.controller.core.model.SupportedParameters; import org.cloudfoundry.multiapps.mta.model.Module; @Named @@ -15,4 +15,13 @@ public boolean shouldDeployAlways(Module module) { return false; } + public boolean shouldSkipDeploy(Module module) { + Object skipDeployObj = module.getParameters() + .get(SupportedParameters.SKIP_DEPLOY); + if (skipDeployObj != null) { + return Boolean.parseBoolean(skipDeployObj.toString()); + } + return false; + } + } diff --git a/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/model/SupportedParameters.java b/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/model/SupportedParameters.java index dd49ce935e..62f21add8b 100644 --- a/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/model/SupportedParameters.java +++ b/multiapps-controller-core/src/main/java/org/cloudfoundry/multiapps/controller/core/model/SupportedParameters.java @@ -112,6 +112,7 @@ public class SupportedParameters { public static final String STOP_APP = "stop-app"; public static final String NO_START = "no-start"; public static final String CHECK_DEPLOY_ID = "check-deploy-id"; + public static final String SKIP_DEPLOY = "skip-deploy"; public static final String REGISTER_SERVICE_URL = "register-service-url"; public static final String REGISTER_SERVICE_URL_SERVICE_NAME = "service-name"; @@ -197,8 +198,8 @@ public class SupportedParameters { SUCCESS_MARKER, FAILURE_MARKER, STOP_APP, CHECK_DEPLOY_ID, REGISTER_SERVICE_URL, REGISTER_SERVICE_URL_SERVICE_NAME, REGISTER_SERVICE_URL_SERVICE_URL, MODULE_CONFIG, MANAGED, PATH, - APPS_UPLOAD_TIMEOUT, APPS_TASK_EXECUTION_TIMEOUT, - APPS_START_TIMEOUT, APPS_STAGE_TIMEOUT, DELETE_SERVICE_KEY_AFTER_DEPLOYMENT); + APPS_UPLOAD_TIMEOUT, APPS_TASK_EXECUTION_TIMEOUT, APPS_START_TIMEOUT, + APPS_STAGE_TIMEOUT, DELETE_SERVICE_KEY_AFTER_DEPLOYMENT, SKIP_DEPLOY); public static final Set RESOURCE_PARAMETERS = Set.of(APPLY_NAMESPACE, SERVICE_CONFIG, SYSLOG_DRAIN_URL, DEFAULT_CONTAINER_NAME, DEFAULT_SERVICE_NAME, DEFAULT_XS_APP_NAME, SERVICE, SERVICE_KEYS, diff --git a/multiapps-controller-core/src/test/java/org/cloudfoundry/multiapps/controller/core/cf/v2/CloudModelBuilderTest.java b/multiapps-controller-core/src/test/java/org/cloudfoundry/multiapps/controller/core/cf/v2/CloudModelBuilderTest.java index aa9dff0c50..0205650217 100644 --- a/multiapps-controller-core/src/test/java/org/cloudfoundry/multiapps/controller/core/cf/v2/CloudModelBuilderTest.java +++ b/multiapps-controller-core/src/test/java/org/cloudfoundry/multiapps/controller/core/cf/v2/CloudModelBuilderTest.java @@ -1,7 +1,5 @@ package org.cloudfoundry.multiapps.controller.core.cf.v2; -import static org.junit.jupiter.api.Assertions.assertEquals; - import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; @@ -12,6 +10,7 @@ import java.util.TreeMap; import java.util.stream.Stream; +import com.sap.cloudfoundry.client.facade.CloudControllerClient; import org.apache.commons.io.IOUtils; import org.cloudfoundry.multiapps.common.test.Tester; import org.cloudfoundry.multiapps.common.test.Tester.Expectation; @@ -46,7 +45,7 @@ import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mockito; -import com.sap.cloudfoundry.client.facade.CloudControllerClient; +import static org.junit.jupiter.api.Assertions.assertEquals; public class CloudModelBuilderTest { @@ -75,7 +74,7 @@ public class CloudModelBuilderTest { private static Stream getParameters() { return Stream.of( -// @formatter:off + // @formatter:off // (01) Full MTA: Arguments.of("/mta/javahelloworld/mtad.yaml", "/mta/javahelloworld/config.mtaext", "/mta/cf-platform.json", null, null, false, @@ -426,8 +425,49 @@ private static Stream getParameters() { new String[] {}, // deployedApps new Expectation("[]"), // services new Expectation(Expectation.Type.JSON, "keep-existing-routes/apps-with-nohostname.json") // applications - , DEFAULT_APP_SUFFIX_DETERMINER) -// @formatter:on + , DEFAULT_APP_SUFFIX_DETERMINER), + // (45) Test skip-deploy 1 of 2 modules + Arguments.of("/mta/skip-deploy/mtad-skip-deploy-true.yaml", "config-01.mtaext", "/mta/cf-platform.json", + null, // deployedMtaLocation + null, // namespace + false, // applyNamespace + new String[] { "skip-deploy-app", "foo" }, // mtaArchiveModules + new String[] { "foo" }, // mtaModules + new String[] {}, // deployedApps + new Expectation("[]"), // expectedServices + new Expectation(Expectation.Type.JSON, "/mta/skip-deploy/apps-skip-deploy-true.json"), // expectedApps (should contain only foo) + DEFAULT_APP_SUFFIX_DETERMINER), + // (46) Test skip-deploy module parameter with string "true" + Arguments.of( + "/mta/skip-deploy/mtad-skip-deploy-string-true.yaml", + "config-01.mtaext", + "/mta/cf-platform.json", + null, + null, + false, + new String[] { "skip-deploy-app", "foo" }, + new String[] { "foo" }, + new String[] {}, + new Expectation("[]"), + new Expectation(Expectation.Type.JSON, "/mta/skip-deploy/apps-skip-deploy-true.json"), + DEFAULT_APP_SUFFIX_DETERMINER + ), + // (47) Test skip-deploy module parameter with false + Arguments.of( + "/mta/skip-deploy/mtad-skip-deploy-false.yaml", + "config-01.mtaext", + "/mta/cf-platform.json", + null, + null, + false, + new String[] { "skip-deploy-app", "foo" }, + new String[] { "skip-deploy-app", "foo" }, + new String[] {}, + new Expectation("[]"), + new Expectation(Expectation.Type.JSON, "/mta/skip-deploy/apps-skip-deploy-false.json"), + DEFAULT_APP_SUFFIX_DETERMINER + ) + // @formatter:on ); } @@ -451,12 +491,11 @@ protected ServicesCloudModelBuilder getServicesCloudModelBuilder(DeploymentDescr return new ServicesCloudModelBuilder(deploymentDescriptor, namespace); } - protected ApplicationCloudModelBuilder - getApplicationCloudModelBuilder(DeploymentDescriptor deploymentDescriptor, boolean prettyPrinting, DeployedMta deployedMta, - AppSuffixDeterminer appSuffixDeterminer, boolean incrementalInstancesUpdate) { - deploymentDescriptor = new DescriptorReferenceResolver(deploymentDescriptor, - new ResolverBuilder(), - new ResolverBuilder(), + protected ApplicationCloudModelBuilder getApplicationCloudModelBuilder(DeploymentDescriptor deploymentDescriptor, + boolean prettyPrinting, DeployedMta deployedMta, + AppSuffixDeterminer appSuffixDeterminer, + boolean incrementalInstancesUpdate) { + deploymentDescriptor = new DescriptorReferenceResolver(deploymentDescriptor, new ResolverBuilder(), new ResolverBuilder(), Collections.emptySet()).resolve(); var client = Mockito.mock(CloudControllerClient.class); Mockito.when(client.getApplicationRoutes(Mockito.any())) @@ -560,15 +599,13 @@ protected void injectSystemParameters(DeploymentDescriptor descriptor, String de void testGetApplications(String deploymentDescriptorLocation, String extensionDescriptorLocation, String platformsLocation, String deployedMtaLocation, String namespace, boolean applyNamespace, String[] mtaArchiveModules, String[] mtaModules, String[] deployedApps, Expectation expectedServices, Expectation expectedApps, - AppSuffixDeterminer appSuffixDeterminer) - throws Exception { + AppSuffixDeterminer appSuffixDeterminer) throws Exception { initializeParameters(deploymentDescriptorLocation, extensionDescriptorLocation, platformsLocation, deployedMtaLocation, namespace, applyNamespace, mtaArchiveModules, mtaModules, deployedApps, appSuffixDeterminer, false); tester.test(() -> modulesCalculator.calculateContentForBuilding(deploymentDescriptor.getModules()) .stream() .map(module -> appBuilder.build(module, moduleToDeployHelper)) - .toList(), - expectedApps); + .toList(), expectedApps); } @ParameterizedTest @@ -576,8 +613,7 @@ void testGetApplications(String deploymentDescriptorLocation, String extensionDe void testGetServices(String deploymentDescriptorLocation, String extensionDescriptorLocation, String platformsLocation, String deployedMtaLocation, String namespace, boolean applyNamespace, String[] mtaArchiveModules, String[] mtaModules, String[] deployedApps, Expectation expectedServices, Expectation expectedApps, - AppSuffixDeterminer appSuffixDeterminer) - throws Exception { + AppSuffixDeterminer appSuffixDeterminer) throws Exception { initializeParameters(deploymentDescriptorLocation, extensionDescriptorLocation, platformsLocation, deployedMtaLocation, namespace, applyNamespace, mtaArchiveModules, mtaModules, deployedApps, appSuffixDeterminer, false); tester.test(() -> servicesBuilder.build(resourcesCalculator.calculateContentForBuilding(deploymentDescriptor.getResources())), @@ -604,8 +640,7 @@ void testGetApplicationsWithIncrementalBlueGreen() throws Exception { protected void initializeParameters(String deploymentDescriptorLocation, String extensionDescriptorLocation, String platformsLocation, String deployedMtaLocation, String namespace, boolean applyNamespace, String[] mtaArchiveModules, String[] mtaModules, String[] deployedApps, AppSuffixDeterminer appSuffixDeterminer, - boolean incrementalInstancesUpdate) - throws Exception { + boolean incrementalInstancesUpdate) throws Exception { this.deploymentDescriptorLocation = deploymentDescriptorLocation; this.extensionDescriptorLocation = extensionDescriptorLocation; this.platformLocation = platformsLocation; @@ -632,12 +667,9 @@ protected void initializeParameters(String deploymentDescriptorLocation, String private ModulesCloudModelBuilderContentCalculator getModulesCalculator(Set mtaArchiveModules, Set mtaModules, Set deployedApps) { - return new ModulesCloudModelBuilderContentCalculator(mtaArchiveModules, - deployedApps, - null, - getUserMessageLogger(), + return new ModulesCloudModelBuilderContentCalculator(mtaArchiveModules, deployedApps, null, getUserMessageLogger(), new ModuleToDeployHelper(), List.of(new UnresolvedModulesContentValidator(mtaModules, deployedApps))); } -} +} \ No newline at end of file diff --git a/multiapps-controller-core/src/test/java/org/cloudfoundry/multiapps/controller/core/helpers/ModuleToDeployHelperTest.java b/multiapps-controller-core/src/test/java/org/cloudfoundry/multiapps/controller/core/helpers/ModuleToDeployHelperTest.java new file mode 100644 index 0000000000..37133f6286 --- /dev/null +++ b/multiapps-controller-core/src/test/java/org/cloudfoundry/multiapps/controller/core/helpers/ModuleToDeployHelperTest.java @@ -0,0 +1,47 @@ +package org.cloudfoundry.multiapps.controller.core.helpers; + +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Stream; + +import org.cloudfoundry.multiapps.controller.core.model.SupportedParameters; +import org.cloudfoundry.multiapps.mta.model.Module; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class ModuleToDeployHelperTest { + + private ModuleToDeployHelper helper; + + @BeforeEach + void setUp() { + helper = new ModuleToDeployHelper(); + } + + static Stream skipDeployParameters() { + // @formatter:off + return Stream.of(Arguments.of(null, false), + Arguments.of(true, true), + Arguments.of(false, false), + Arguments.of("true", true), + Arguments.of("false", false), + Arguments.of("invalid", false)); + // @formatter:on + } + + @ParameterizedTest + @MethodSource("skipDeployParameters") + void testShouldSkipDeploy(Object skipDeployValue, boolean expected) { + Module module = Module.createV3(); + if (skipDeployValue != null) { + Map params = new HashMap<>(); + params.put(SupportedParameters.SKIP_DEPLOY, skipDeployValue); + module.setParameters(params); + } + assertEquals(expected, helper.shouldSkipDeploy(module)); + } +} diff --git a/multiapps-controller-core/src/test/resources/mta/skip-deploy/apps-skip-deploy-false.json b/multiapps-controller-core/src/test/resources/mta/skip-deploy/apps-skip-deploy-false.json new file mode 100644 index 0000000000..cd0233bf22 --- /dev/null +++ b/multiapps-controller-core/src/test/resources/mta/skip-deploy/apps-skip-deploy-false.json @@ -0,0 +1,104 @@ +[ + { + "name": "skip-deploy-app", + "v3Metadata": { + "annotations": { + "mta_id": "skip-deploy-mta", + "mta_version": "1.0.0", + "mta_module": "{\"name\":\"skip-deploy-app\"}", + "mta_module_provided_dependencies": "[\"skip-deploy-app\"]", + "mta_bound_services": "[]" + }, + "labels": { + "mta_id": "d499a3d8e88f9f9e8e956c8ac6b8c165" + } + }, + "moduleName": "skip-deploy-app", + "memory": 0, + "diskQuota": 0, + "instances": 0, + "staging": { + "buildpacks": [] + }, + "routes": [ + { + "appsUsingRoute": 0, + "domain": { + "name": "cfapps.neo.ondemand.com" + }, + "host": "skip-deploy-app", + "path": "", + "url": "skip-deploy-app.cfapps.neo.ondemand.com" + } + ], + "services": [], + "env": { + "DEPLOY_ATTRIBUTES": "{\"dependency-type\":\"soft\"}" + }, + "idleRoutes": [], + "bindingParameters": {}, + "tasks": [], + "serviceKeysToInject": [], + "restartParameters": { + "shouldRestartOnVcapAppChange": true, + "shouldRestartOnVcapServicesChange": true, + "shouldRestartOnUserProvidedChange": true + }, + "attributesUpdateStrategy": { + "shouldKeepExistingEnv": false, + "shouldKeepExistingServiceBindings": false, + "shouldKeepExistingRoutes": false + } + }, + { + "name": "foo", + "v3Metadata": { + "annotations": { + "mta_id": "skip-deploy-mta", + "mta_version": "1.0.0", + "mta_module": "{\"name\":\"foo\"}", + "mta_module_provided_dependencies": "[\"foo\"]", + "mta_bound_services": "[]" + }, + "labels": { + "mta_id": "d499a3d8e88f9f9e8e956c8ac6b8c165" + } + }, + "moduleName": "foo", + "memory": 0, + "diskQuota": 0, + "instances": 0, + "staging": { + "buildpacks": [] + }, + "routes": [ + { + "appsUsingRoute": 0, + "domain": { + "name": "cfapps.neo.ondemand.com" + }, + "host": "foo", + "path": "", + "url": "foo.cfapps.neo.ondemand.com" + } + ], + "services": [], + "env": { + "DEPLOY_ATTRIBUTES": "{\"dependency-type\":\"soft\"}" + }, + "idleRoutes": [], + "bindingParameters": {}, + "tasks": [], + "serviceKeysToInject": [], + "restartParameters": { + "shouldRestartOnVcapAppChange": true, + "shouldRestartOnVcapServicesChange": true, + "shouldRestartOnUserProvidedChange": true + }, + "attributesUpdateStrategy": { + "shouldKeepExistingEnv": false, + "shouldKeepExistingServiceBindings": false, + "shouldKeepExistingRoutes": false + } + } +] \ No newline at end of file diff --git a/multiapps-controller-core/src/test/resources/mta/skip-deploy/apps-skip-deploy-true.json b/multiapps-controller-core/src/test/resources/mta/skip-deploy/apps-skip-deploy-true.json new file mode 100644 index 0000000000..e041955ed3 --- /dev/null +++ b/multiapps-controller-core/src/test/resources/mta/skip-deploy/apps-skip-deploy-true.json @@ -0,0 +1,53 @@ +[ + { + "name": "foo", + "v3Metadata": { + "annotations": { + "mta_id": "skip-deploy-mta", + "mta_version": "1.0.0", + "mta_module": "{\"name\":\"foo\"}", + "mta_module_provided_dependencies": "[\"foo\"]", + "mta_bound_services": "[]" + }, + "labels": { + "mta_id": "d499a3d8e88f9f9e8e956c8ac6b8c165" + } + }, + "moduleName": "foo", + "memory": 0, + "diskQuota": 0, + "instances": 0, + "staging": { + "buildpacks": [] + }, + "routes": [ + { + "appsUsingRoute": 0, + "domain": { + "name": "cfapps.neo.ondemand.com" + }, + "host": "foo", + "path": "", + "url": "foo.cfapps.neo.ondemand.com" + } + ], + "services": [], + "env": { + "DEPLOY_ATTRIBUTES": "{\"dependency-type\":\"soft\"}" + }, + "idleRoutes": [], + "bindingParameters": {}, + "tasks": [], + "serviceKeysToInject": [], + "restartParameters": { + "shouldRestartOnVcapAppChange": true, + "shouldRestartOnVcapServicesChange": true, + "shouldRestartOnUserProvidedChange": true + }, + "attributesUpdateStrategy": { + "shouldKeepExistingEnv": false, + "shouldKeepExistingServiceBindings": false, + "shouldKeepExistingRoutes": false + } + } +] \ No newline at end of file diff --git a/multiapps-controller-core/src/test/resources/mta/skip-deploy/mtad-skip-deploy-false.yaml b/multiapps-controller-core/src/test/resources/mta/skip-deploy/mtad-skip-deploy-false.yaml new file mode 100644 index 0000000000..d2e9088c02 --- /dev/null +++ b/multiapps-controller-core/src/test/resources/mta/skip-deploy/mtad-skip-deploy-false.yaml @@ -0,0 +1,14 @@ +ID: skip-deploy-mta +_schema-version: '3' +version: 1.0.0 + +modules: + - name: skip-deploy-app + type: java + path: app + parameters: + skip-deploy: false + + - name: foo + type: java + path: app diff --git a/multiapps-controller-core/src/test/resources/mta/skip-deploy/mtad-skip-deploy-string-true.yaml b/multiapps-controller-core/src/test/resources/mta/skip-deploy/mtad-skip-deploy-string-true.yaml new file mode 100644 index 0000000000..99488c10f0 --- /dev/null +++ b/multiapps-controller-core/src/test/resources/mta/skip-deploy/mtad-skip-deploy-string-true.yaml @@ -0,0 +1,14 @@ +ID: skip-deploy-mta +_schema-version: '3' +version: 1.0.0 + +modules: + - name: skip-deploy-app + type: java + path: app + parameters: + skip-deploy: "true" + + - name: foo + type: java + path: app diff --git a/multiapps-controller-core/src/test/resources/mta/skip-deploy/mtad-skip-deploy-true.yaml b/multiapps-controller-core/src/test/resources/mta/skip-deploy/mtad-skip-deploy-true.yaml new file mode 100644 index 0000000000..a4401c88f0 --- /dev/null +++ b/multiapps-controller-core/src/test/resources/mta/skip-deploy/mtad-skip-deploy-true.yaml @@ -0,0 +1,14 @@ +ID: skip-deploy-mta +_schema-version: '3' +version: 1.0.0 + +modules: + - name: skip-deploy-app + type: java + path: app + parameters: + skip-deploy: true + + - name: foo + type: java + path: app diff --git a/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/steps/BuildCloudUndeployModelStep.java b/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/steps/BuildCloudUndeployModelStep.java index 25dd0fa55c..85f4c31efe 100644 --- a/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/steps/BuildCloudUndeployModelStep.java +++ b/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/steps/BuildCloudUndeployModelStep.java @@ -1,9 +1,5 @@ package org.cloudfoundry.multiapps.controller.process.steps; -import static java.util.stream.Collectors.groupingBy; -import static java.util.stream.Collectors.mapping; -import static java.util.stream.Collectors.toList; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -15,6 +11,11 @@ import java.util.Set; import java.util.stream.Collectors; +import com.sap.cloudfoundry.client.facade.CloudControllerClient; +import com.sap.cloudfoundry.client.facade.domain.CloudApplication; +import com.sap.cloudfoundry.client.facade.domain.CloudServiceKey; +import jakarta.inject.Inject; +import jakarta.inject.Named; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.cloudfoundry.multiapps.controller.api.model.ProcessType; @@ -33,6 +34,7 @@ import org.cloudfoundry.multiapps.controller.persistence.services.DescriptorBackupService; import org.cloudfoundry.multiapps.controller.process.Messages; import org.cloudfoundry.multiapps.controller.process.util.ExistingAppsToBackupCalculator; +import org.cloudfoundry.multiapps.controller.process.util.ModulesToUndeployCalculator; import org.cloudfoundry.multiapps.controller.process.util.ProcessTypeParser; import org.cloudfoundry.multiapps.controller.process.variables.Variables; import org.cloudfoundry.multiapps.mta.model.DeploymentDescriptor; @@ -41,12 +43,9 @@ import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.Scope; -import com.sap.cloudfoundry.client.facade.CloudControllerClient; -import com.sap.cloudfoundry.client.facade.domain.CloudApplication; -import com.sap.cloudfoundry.client.facade.domain.CloudServiceKey; - -import jakarta.inject.Inject; -import jakarta.inject.Named; +import static java.util.stream.Collectors.groupingBy; +import static java.util.stream.Collectors.mapping; +import static java.util.stream.Collectors.toList; @Named("buildCloudUndeployModelStep") @Scope(BeanDefinition.SCOPE_PROTOTYPE) @@ -72,7 +71,7 @@ protected StepPhase executeStep(ProcessContext context) { return StepPhase.DONE; } - List deploymentDescriptorModules = getDeploymentDescriptorModules(context); + List deploymentDescriptorModules = getDeploymentDescriptorModules(context); List subscriptionsToCreate = context.getVariable(Variables.SUBSCRIPTIONS_TO_CREATE); Set mtaModules = context.getVariable(Variables.MTA_MODULES); List appNames = context.getVariable(Variables.APPS_TO_DEPLOY); @@ -80,12 +79,14 @@ protected StepPhase executeStep(ProcessContext context) { getStepLogger().debug(Messages.MTA_MODULES, mtaModules); - List deployedAppsToUndeploy = computeModulesToUndeploy(deployedMta, mtaModules, appNames, - deploymentDescriptorModules); + ModulesToUndeployCalculator modulesToUndeployCalculator = new ModulesToUndeployCalculator(deployedMta, mtaModules, + deploymentDescriptorModules, + moduleToDeployHelper); + List deployedAppsToUndeploy = modulesToUndeployCalculator.computeModulesToUndeploy(appNames); getStepLogger().debug(Messages.MODULES_TO_UNDEPLOY, SecureSerialization.toJson(deployedAppsToUndeploy)); - List appsWithoutChange = computeModulesWithoutChange(deployedAppsToUndeploy, mtaModules, deployedMta); + List appsWithoutChange = modulesToUndeployCalculator.computeModulesWithoutChange(deployedAppsToUndeploy); getStepLogger().debug(Messages.MODULES_NOT_TO_BE_CHANGED, SecureSerialization.toJson(appsWithoutChange)); List subscriptionsToDelete = computeSubscriptionsToDelete(subscriptionsToCreate, deployedMta, @@ -103,8 +104,7 @@ protected StepPhase executeStep(ProcessContext context) { List appsToUndeploy = computeAppsToUndeploy(deployedAppsToUndeploy, context.getControllerClient()); DeployedMta backupMta = context.getVariable(Variables.BACKUP_MTA); - ExistingAppsToBackupCalculator existingAppsToBackupCalculator = new ExistingAppsToBackupCalculator(deployedMta, - backupMta, + ExistingAppsToBackupCalculator existingAppsToBackupCalculator = new ExistingAppsToBackupCalculator(deployedMta, backupMta, descriptorBackupService); List existingAppsToBackup = computeExistingAppsToBackup(context, appsToUndeploy, existingAppsToBackupCalculator); @@ -127,15 +127,12 @@ protected String getStepErrorMessage(ProcessContext context) { return Messages.ERROR_BUILDING_CLOUD_UNDEPLOY_MODEL; } - private List getDeploymentDescriptorModules(ProcessContext context) { + private List getDeploymentDescriptorModules(ProcessContext context) { DeploymentDescriptor deploymentDescriptor = context.getVariable(Variables.COMPLETE_DEPLOYMENT_DESCRIPTOR); if (deploymentDescriptor == null) { return Collections.emptyList(); } - return deploymentDescriptor.getModules() - .stream() - .map(Module::getName) - .collect(Collectors.toList()); + return deploymentDescriptor.getModules(); } private List getAllServiceNames(ProcessContext context) { @@ -161,27 +158,6 @@ private Set getServicesForApplications(ProcessContext context) { return servicesForApplications; } - private List computeModulesWithoutChange(List modulesToUndeploy, Set mtaModules, - DeployedMta deployedMta) { - return deployedMta.getApplications() - .stream() - .filter(existingModule -> shouldNotUndeployModule(modulesToUndeploy, existingModule)) - .filter(existingModule -> shouldNotDeployModule(mtaModules, existingModule)) - .collect(Collectors.toList()); - } - - private boolean shouldNotUndeployModule(List modulesToUndeploy, DeployedMtaApplication existingModule) { - String existingModuleName = existingModule.getModuleName(); - return modulesToUndeploy.stream() - .map(DeployedMtaApplication::getModuleName) - .noneMatch(existingModuleName::equals); - } - - private boolean shouldNotDeployModule(Set mtaModules, DeployedMtaApplication existingModule) { - String existingModuleName = existingModule.getModuleName(); - return !mtaModules.contains(existingModuleName); - } - private void setComponentsToUndeploy(ProcessContext context, List services, List apps, List subscriptions, List serviceKeys, List appsToBackup) { @@ -218,8 +194,8 @@ private boolean shouldDeleteService(ProcessContext context, DeployedMtaService s return appsToKeep.stream() .flatMap(module -> module.getBoundMtaServices() .stream()) - .noneMatch(serviceName -> serviceName.equalsIgnoreCase(service.getName())) - && !servicesForApplications.contains(service.getName()) && !servicesForCurrentDeployment.contains(service.getName()); + .noneMatch(serviceName -> serviceName.equalsIgnoreCase(service.getName())) && !servicesForApplications.contains( + service.getName()) && !servicesForCurrentDeployment.contains(service.getName()); } private boolean isExistingService(ProcessContext context, String serviceName) { @@ -253,8 +229,9 @@ private List computeServiceKeysToDelete(ProcessContext co private List computeUnusedServiceKeys(ProcessContext context, List deployedServiceKeys) { Map> deployedServiceKeysByService = deployedServiceKeys.stream() - .collect(groupingBy(key -> key.getServiceInstance() - .getName())); + .collect(groupingBy( + key -> key.getServiceInstance() + .getName())); getStepLogger().debug(Messages.DEPLOYED_SERVICE_KEYS, deployedServiceKeysByService); Map> additionalServiceKeys = context.getVariable(Variables.SERVICE_KEYS_FOR_CONTENT_DEPLOY); @@ -342,28 +319,6 @@ private String getServiceKeyName(Resource resource) { .getOrDefault(SupportedParameters.SERVICE_KEY_NAME, resource.getName()); } - private List computeModulesToUndeploy(DeployedMta deployedMta, Set mtaModules, - List appsToDeploy, List deploymentDescriptorModules) { - return deployedMta.getApplications() - .stream() - .filter(deployedApplication -> shouldBeCheckedForUndeployment(deployedApplication, mtaModules, - deploymentDescriptorModules)) - .filter(deployedApplication -> shouldUndeployModule(deployedApplication, appsToDeploy)) - .collect(Collectors.toList()); - } - - private boolean shouldBeCheckedForUndeployment(DeployedMtaApplication deployedApplication, Set mtaModules, - List deploymentDescriptorModules) { - return mtaModules.contains(deployedApplication.getModuleName()) - || !deploymentDescriptorModules.contains(deployedApplication.getModuleName()); - } - - private boolean shouldUndeployModule(DeployedMtaApplication deployedMtaApplication, List appsToDeploy) { - // The deployed module may be in the list of MTA modules, but the actual application that was created from it may have a - // different name: - return !appsToDeploy.contains(deployedMtaApplication.getName()); - } - private List computeExistingAppsToBackup(ProcessContext context, List appsToUndeploy, ExistingAppsToBackupCalculator existingAppsToBackupCalculator) { boolean shouldBackupExistingApps = context.getVariable(Variables.SHOULD_BACKUP_PREVIOUS_VERSION); @@ -402,11 +357,11 @@ private boolean willBeCreatedOrUpdated(ConfigurationSubscription existingSubscri } private boolean areEqual(ConfigurationSubscription subscription1, ConfigurationSubscription subscription2) { - return Objects.equals(subscription1.getAppName(), subscription2.getAppName()) - && Objects.equals(subscription1.getSpaceId(), subscription2.getSpaceId()) && Objects.equals(subscription1.getResourceDto() - .getName(), - subscription2.getResourceDto() - .getName()); + return Objects.equals(subscription1.getAppName(), subscription2.getAppName()) && Objects.equals(subscription1.getSpaceId(), + subscription2.getSpaceId()) + && Objects.equals(subscription1.getResourceDto() + .getName(), subscription2.getResourceDto() + .getName()); } protected ApplicationCloudModelBuilder getApplicationCloudModelBuilder(ProcessContext context) { diff --git a/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/steps/ProcessDescriptorStep.java b/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/steps/ProcessDescriptorStep.java index 465bb824bf..910363a573 100644 --- a/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/steps/ProcessDescriptorStep.java +++ b/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/steps/ProcessDescriptorStep.java @@ -9,9 +9,9 @@ import jakarta.inject.Inject; import jakarta.inject.Named; - import org.apache.commons.collections4.CollectionUtils; import org.cloudfoundry.multiapps.controller.core.cf.CloudHandlerFactory; +import org.cloudfoundry.multiapps.controller.core.helpers.ModuleToDeployHelper; import org.cloudfoundry.multiapps.controller.core.helpers.MtaDescriptorPropertiesResolver; import org.cloudfoundry.multiapps.controller.core.model.DynamicResolvableParameter; import org.cloudfoundry.multiapps.controller.core.model.ImmutableMtaDescriptorPropertiesResolverContext; @@ -32,8 +32,14 @@ @Scope(BeanDefinition.SCOPE_PROTOTYPE) public class ProcessDescriptorStep extends SyncFlowableStep { - @Inject private ConfigurationEntryService configurationEntryService; + private ModuleToDeployHelper moduleToDeployHelper; + + @Inject + public ProcessDescriptorStep(ConfigurationEntryService configurationEntryService, ModuleToDeployHelper moduleToDeployHelper) { + this.configurationEntryService = configurationEntryService; + this.moduleToDeployHelper = moduleToDeployHelper; + } @Override protected StepPhase executeStep(ProcessContext context) { @@ -54,10 +60,11 @@ protected StepPhase executeStep(ProcessContext context) { List modulesForDeployment = context.getVariable(Variables.MODULES_FOR_DEPLOYMENT); List invalidModulesSpecifiedForDeployment = findInvalidModulesSpecifiedForDeployment(descriptor, modulesForDeployment); if (!invalidModulesSpecifiedForDeployment.isEmpty()) { - throw new IllegalStateException(MessageFormat.format(Messages.MODULES_0_SPECIFIED_FOR_DEPLOYMENT_ARE_NOT_PART_OF_DEPLOYMENT_DESCRIPTOR_MODULES, - String.join(", ", invalidModulesSpecifiedForDeployment))); + throw new IllegalStateException( + MessageFormat.format(Messages.MODULES_0_SPECIFIED_FOR_DEPLOYMENT_ARE_NOT_PART_OF_DEPLOYMENT_DESCRIPTOR_MODULES, + String.join(", ", invalidModulesSpecifiedForDeployment))); } - Set mtaModules = getModuleNames(descriptor, modulesForDeployment); + Set mtaModules = getModuleNamesForDeployment(descriptor, modulesForDeployment); getStepLogger().debug(Messages.MTA_MODULES, mtaModules); context.setVariable(Variables.MTA_MODULES, mtaModules); @@ -97,14 +104,20 @@ private MtaDescriptorPropertiesResolverContext buildMtaDescriptorPropertiesResol .cloudTarget(cloudTarget) .currentSpaceId(currentSpaceId) .namespace(namespace) - .applyNamespaceAppNamesGlobalLevel(namespaceGlobalParameters.getApplyNamespaceAppNamesParameter()) - .applyNamespaceServiceNamesGlobalLevel(namespaceGlobalParameters.getApplyNamespaceServiceNamesParameter()) - .applyNamespaceAppRoutesGlobalLevel(namespaceGlobalParameters.getApplyNamespaceAppRoutesParameter()) - .applyNamespaceAsSuffixGlobalLevel(namespaceGlobalParameters.getApplyNamespaceAsSuffix()) + .applyNamespaceAppNamesGlobalLevel( + namespaceGlobalParameters.getApplyNamespaceAppNamesParameter()) + .applyNamespaceServiceNamesGlobalLevel( + namespaceGlobalParameters.getApplyNamespaceServiceNamesParameter()) + .applyNamespaceAppRoutesGlobalLevel( + namespaceGlobalParameters.getApplyNamespaceAppRoutesParameter()) + .applyNamespaceAsSuffixGlobalLevel( + namespaceGlobalParameters.getApplyNamespaceAsSuffix()) .applyNamespaceAsSuffixProcessVariable(applyNamespaceAsSuffixProcessVariable) .applyNamespaceAppNamesProcessVariable(applyNamespaceAppNamesProcessVariable) - .applyNamespaceServiceNamesProcessVariable(applyNamespaceServiceNamesProcessVariable) - .applyNamespaceAppRoutesProcessVariable(applyNamespaceAppRoutesProcessVariable) + .applyNamespaceServiceNamesProcessVariable( + applyNamespaceServiceNamesProcessVariable) + .applyNamespaceAppRoutesProcessVariable( + applyNamespaceAppRoutesProcessVariable) .shouldReserveTemporaryRoute(setIdleRoutes) .configurationEntryService(configurationEntryService) .applicationConfiguration(configuration) @@ -119,17 +132,6 @@ private void setDynamicResolvableParametersIfAbsent(ProcessContext context, MtaD } } - private Set getModuleNames(DeploymentDescriptor deploymentDescriptor, List moduleNamesForDeployment) { - if (moduleNamesForDeployment == null) { - return deploymentDescriptor.getModules() - .stream() - .map(Module::getName) - .collect(Collectors.toSet()); - } - - return new HashSet<>(moduleNamesForDeployment); - } - private List findInvalidModulesSpecifiedForDeployment(DeploymentDescriptor descriptor, List modulesForDeployment) { if (CollectionUtils.isEmpty(modulesForDeployment)) { return Collections.emptyList(); @@ -139,8 +141,25 @@ private List findInvalidModulesSpecifiedForDeployment(DeploymentDescript .map(Module::getName) .collect(Collectors.toSet()); return modulesForDeployment.stream() - .filter(moduleSpecifiedForDeployment -> !deploymentDescriptorModuleNames.contains(moduleSpecifiedForDeployment)) + .filter(moduleSpecifiedForDeployment -> !deploymentDescriptorModuleNames.contains( + moduleSpecifiedForDeployment)) .collect(Collectors.toList()); } + private Set getModuleNamesForDeployment(DeploymentDescriptor deploymentDescriptor, List moduleNamesForDeployment) { + if (moduleNamesForDeployment == null) { + return deploymentDescriptor.getModules() + .stream() + .filter(this::shouldDeployModule) + .map(Module::getName) + .collect(Collectors.toSet()); + } + + return new HashSet<>(moduleNamesForDeployment); + } + + private boolean shouldDeployModule(Module module) { + return !moduleToDeployHelper.shouldSkipDeploy(module); + } + } diff --git a/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/util/ModulesToUndeployCalculator.java b/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/util/ModulesToUndeployCalculator.java new file mode 100644 index 0000000000..137cff9738 --- /dev/null +++ b/multiapps-controller-process/src/main/java/org/cloudfoundry/multiapps/controller/process/util/ModulesToUndeployCalculator.java @@ -0,0 +1,77 @@ +package org.cloudfoundry.multiapps.controller.process.util; + +import java.util.List; +import java.util.Set; + +import org.cloudfoundry.multiapps.controller.core.helpers.ModuleToDeployHelper; +import org.cloudfoundry.multiapps.controller.core.model.DeployedMta; +import org.cloudfoundry.multiapps.controller.core.model.DeployedMtaApplication; +import org.cloudfoundry.multiapps.mta.model.Module; + +public class ModulesToUndeployCalculator { + + private final DeployedMta deployedMta; + private final Set selectedMtaModuleNames; + private final List deploymentDescriptorModules; + private final List deploymentDescriptorModuleNames; + private final ModuleToDeployHelper moduleToDeployHelper; + + public ModulesToUndeployCalculator(DeployedMta deployedMta, Set selectedMtaModuleNames, + List deploymentDescriptorModules, ModuleToDeployHelper moduleToDeployHelper) { + this.deployedMta = deployedMta; + this.selectedMtaModuleNames = selectedMtaModuleNames; + this.deploymentDescriptorModules = deploymentDescriptorModules; + this.deploymentDescriptorModuleNames = deploymentDescriptorModules.stream() + .map(Module::getName) + .toList(); + this.moduleToDeployHelper = moduleToDeployHelper; + } + + public List computeModulesToUndeploy(List appsToDeploy) { + return deployedMta.getApplications() + .stream() + .filter(this::shouldBeCheckedForUndeployment) + .filter(deployedApplication -> shouldUndeployModule(deployedApplication, appsToDeploy)) + .toList(); + } + + private boolean shouldBeCheckedForUndeployment(DeployedMtaApplication deployedApplication) { + boolean isSelectedMtaModule = selectedMtaModuleNames.contains(deployedApplication.getModuleName()); + boolean isNotInDescriptor = !deploymentDescriptorModuleNames.contains(deployedApplication.getModuleName()); + boolean isSkippedModule = shouldUndeploySkippedModule(deployedApplication, deploymentDescriptorModules); + return isSelectedMtaModule || isNotInDescriptor || isSkippedModule; + } + + private boolean shouldUndeploySkippedModule(DeployedMtaApplication deployedApplication, List deploymentDescriptorModules) { + return deploymentDescriptorModules.stream() + .filter(module -> module.getName() + .equals(deployedApplication.getModuleName())) + .anyMatch(moduleToDeployHelper::shouldSkipDeploy); + } + + private boolean shouldUndeployModule(DeployedMtaApplication deployedMtaApplication, List appsToDeploy) { + // The deployed module may be in the list of MTA modules, but the actual application that was created from it may have a + // different name: + return !appsToDeploy.contains(deployedMtaApplication.getName()); + } + + public List computeModulesWithoutChange(List modulesToUndeploy) { + return deployedMta.getApplications() + .stream() + .filter(existingModule -> shouldNotUndeployModule(modulesToUndeploy, existingModule)) + .filter(this::shouldNotDeployModule) + .toList(); + } + + private boolean shouldNotUndeployModule(List modulesToUndeploy, DeployedMtaApplication existingModule) { + String existingModuleName = existingModule.getModuleName(); + return modulesToUndeploy.stream() + .map(DeployedMtaApplication::getModuleName) + .noneMatch(existingModuleName::equals); + } + + private boolean shouldNotDeployModule(DeployedMtaApplication existingModule) { + String existingModuleName = existingModule.getModuleName(); + return !selectedMtaModuleNames.contains(existingModuleName); + } +} diff --git a/multiapps-controller-process/src/test/java/org/cloudfoundry/multiapps/controller/process/steps/BuildCloudUndeployModelStepTest.java b/multiapps-controller-process/src/test/java/org/cloudfoundry/multiapps/controller/process/steps/BuildCloudUndeployModelStepTest.java index af2de7dc3c..6cf273c190 100644 --- a/multiapps-controller-process/src/test/java/org/cloudfoundry/multiapps/controller/process/steps/BuildCloudUndeployModelStepTest.java +++ b/multiapps-controller-process/src/test/java/org/cloudfoundry/multiapps/controller/process/steps/BuildCloudUndeployModelStepTest.java @@ -1,10 +1,8 @@ package org.cloudfoundry.multiapps.controller.process.steps; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; -import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -18,7 +16,7 @@ import org.cloudfoundry.multiapps.common.util.JsonUtil; import org.cloudfoundry.multiapps.controller.api.model.ProcessType; import org.cloudfoundry.multiapps.controller.client.lib.domain.CloudApplicationExtended; -import org.cloudfoundry.multiapps.controller.client.lib.domain.CloudServiceInstanceExtended; +import org.cloudfoundry.multiapps.controller.client.lib.domain.ImmutableCloudApplicationExtended; import org.cloudfoundry.multiapps.controller.core.cf.v2.ApplicationCloudModelBuilder; import org.cloudfoundry.multiapps.controller.core.helpers.ModuleToDeployHelper; import org.cloudfoundry.multiapps.controller.core.model.DeployedMta; @@ -51,49 +49,51 @@ class BuildCloudUndeployModelStepTest extends SyncFlowableStepTest testExecute() { return Stream.of( // @formatter:off - // (0) No previously deployed MTA: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", Collections.emptyList(), "deployed-apps-01.json", new TreeSet<>(List.of("a", "b", "c")), null, "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c"))), + // (1) No previously deployed MTA: + Arguments.of(new StepInput(Collections.emptyList(), Collections.emptyList(), Set.of("a", "b", "c"), null, "empty-list.json", "empty-list.json", Set.of("a", "b", "c")), new StepOutput(Collections.emptyList(), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (1) There are obsolete modules: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", Collections.emptyList(), "deployed-apps-04.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-03.json", "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), + // (2) There are obsolete modules: + Arguments.of(new StepInput(Collections.emptyList(), List.of("a", "b", "c", "d", "e"), Set.of("a", "b", "c"), "deployed-mta-03.json", "empty-list.json", "empty-list.json", Set.of("a", "b", "c", "d", "e")), new StepOutput(List.of("d", "e"), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (2) All modules are obsolete: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", Collections.emptyList(), "deployed-apps-05.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-04.json", "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), + // (3) All modules are obsolete: + Arguments.of(new StepInput(Collections.emptyList(), List.of("d", "e"), Collections.emptySet(), "deployed-mta-04.json", "empty-list.json", "empty-list.json", Set.of("a", "b", "c", "d", "e")), new StepOutput(List.of("d", "e"), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (3) There are obsolete services: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", List.of("s-1", "s-2"), "deployed-apps-04.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-05.json", "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), - new StepOutput(List.of("d", "e"), List.of("s-3", "s-4"), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (4) All services are obsolete: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", List.of("s-3", "s-4"), "deployed-apps-05.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-06.json", "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), - new StepOutput(List.of("d", "e"), List.of("s-1", "s-2"), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (5) There are renamed applications: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", Collections.emptyList(),"deployed-apps-06.json", new TreeSet<>(List.of("a", "b", "c")), "deployed-mta-07.json", "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c"))), + // (4) There are obsolete services: + Arguments.of(new StepInput(List.of("s-1", "s-2"), List.of("a", "b", "c", "d", "e"), Set.of("a", "b", "c", "d", "e"), "deployed-mta-05.json", "empty-list.json", "empty-list.json", Set.of("a", "b", "c", "d", "e")), + new StepOutput(Collections.emptyList(), List.of("s-3", "s-4"), new Expectation(Expectation.Type.JSON, "empty-list.json"))), + // (5) All services are obsolete: + Arguments.of(new StepInput(List.of("s-3", "s-4"), List.of("d", "e"), Set.of("a", "b", "c", "d", "e"), "deployed-mta-06.json", "empty-list.json", "empty-list.json", Set.of("a", "b", "c", "d", "e")), + new StepOutput(Collections.emptyList(), List.of("s-1", "s-2"), new Expectation(Expectation.Type.JSON, "empty-list.json"))), + // (6) There are renamed applications: + Arguments.of(new StepInput(Collections.emptyList(),List.of("namespace.a", "namespace.b", "namespace.c"), Set.of("a", "b", "c"), "deployed-mta-07.json", "empty-list.json", "empty-list.json", Set.of("a", "b", "c")), new StepOutput(List.of("namespace.a", "namespace.b", "namespace.c"), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (6) There are no obsolete services: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", List.of("s-1", "s-2", "s-3"), "deployed-apps-04.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-08.json", "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), - new StepOutput(List.of("d", "e"), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (7) There are no obsolete modules: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", Collections.emptyList(), "deployed-apps-07.json", new TreeSet<>(List.of("a", "b", "c")), "deployed-mta-09.json", "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c"))), + // (7) There are no obsolete services: + Arguments.of(new StepInput(List.of("s-1", "s-2", "s-3"), List.of("a", "b", "c", "d", "e"), Set.of("a", "b", "c", "d", "e"), "deployed-mta-08.json", "empty-list.json", "empty-list.json", Set.of("a", "b", "c", "d", "e")), + new StepOutput(Collections.emptyList(), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), + // (8) There are no obsolete modules: + Arguments.of(new StepInput(Collections.emptyList(), List.of("a", "b"), Set.of("a", "b", "c"), "deployed-mta-09.json", "empty-list.json", "empty-list.json", Set.of("a", "b", "c")), + new StepOutput(Collections.emptyList(), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), + // (9) There are no obsolete published provided dependencies: + Arguments.of(new StepInput(Collections.emptyList(), List.of("a", "b", "c", "d", "e"), Set.of("a", "b", "c", "d", "e"), "deployed-mta-10.json", "empty-list.json", "empty-list.json", Set.of("a", "b", "c", "d", "e")), + new StepOutput(Collections.emptyList(), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), + // (10) There are no obsolete subscriptions: + Arguments.of(new StepInput(Collections.emptyList(), List.of("a", "b", "c", "d", "e"), Set.of("a", "b", "c", "d", "e"), "deployed-mta-03.json", "subscriptions-to-create-01.json","empty-list.json", Set.of("a", "b", "c", "d", "e")), new StepOutput(Collections.emptyList(), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (8) There are no obsolete published provided dependencies: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", Collections.emptyList(),"deployed-apps-04.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-10.json", "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), - new StepOutput(List.of("d", "e"), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (9) There are no obsolete subscriptions: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", Collections.emptyList(),"deployed-apps-04.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-03.json", "subscriptions-to-create-01.json","empty-list.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), - new StepOutput(List.of("d", "e"), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (10) There are obsolete subscriptions: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json","empty-list.json", Collections.emptyList(),"deployed-apps-04.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-03.json", "subscriptions-to-create-01.json", "existing-subscriptions-01.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), - new StepOutput(List.of("d", "e"), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "subscriptions-to-delete-01.json"))), // (11) There are obsolete subscriptions: - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", Collections.emptyList(),"deployed-apps-04.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-03.json", "empty-list.json", "existing-subscriptions-01.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), - new StepOutput(List.of("d", "e"), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "subscriptions-to-delete-02.json"))), - // (12) There are obsolete services because they are all unbound - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "empty-list.json", Collections.emptyList(), "deployed-apps-04.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-08.json", "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), - new StepOutput(List.of("d", "e"), List.of("s-1", "s-2", "s-3"), new Expectation(Expectation.Type.JSON, "empty-list.json"))), - // (13) - Arguments.of(new StepInput("modules-to-deploy-01.json", "apps-to-deploy-01.json", "services-to-create-02.json", Collections.emptyList(), "deployed-apps-04.json", new TreeSet<>(List.of("a", "b", "c", "d", "e")), "deployed-mta-08.json", "empty-list.json", "empty-list.json", new TreeSet<>(List.of("a", "b", "c", "d", "e"))), - new StepOutput(List.of("d", "e"), List.of("s-1", "s-2", "s-3"), new Expectation(Expectation.Type.JSON, "empty-list.json"))) -// @formatter:on + Arguments.of(new StepInput(Collections.emptyList(), List.of("a", "b", "c", "d", "e"), Set.of("a", "b", "c", "d", "e"), "deployed-mta-03.json", "subscriptions-to-create-01.json", "existing-subscriptions-01.json", Set.of("a", "b", "c", "d", "e")), + new StepOutput(Collections.emptyList(), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "subscriptions-to-delete-01.json"))), + // (12) There are obsolete subscriptions: + Arguments.of(new StepInput(Collections.emptyList(), List.of("a", "b", "c", "d", "e"), Set.of("a", "b", "c", "d", "e"), "deployed-mta-03.json", "empty-list.json", "existing-subscriptions-01.json", Set.of("a", "b", "c", "d", "e")), + new StepOutput(Collections.emptyList(), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "subscriptions-to-delete-02.json"))), + // (13) There are obsolete services because they are all unbound + Arguments.of(new StepInput(Collections.emptyList(), List.of("a", "b", "c", "d", "e"), Set.of("a", "b", "c", "d", "e"), "deployed-mta-08.json", "empty-list.json", "empty-list.json", Set.of("a", "b", "c", "d", "e")), + new StepOutput(Collections.emptyList(), List.of("s-1", "s-2", "s-3"), new Expectation(Expectation.Type.JSON, "empty-list.json"))), + // (14) There are modules with skip-deploy parameter set + Arguments.of( + new StepInput(Collections.emptyList(), List.of("a", "b", "c"), Set.of("a", "c"), "deployed-mta-13.json", "empty-list.json", "empty-list.json", Set.of("a", "b", "c")), + new StepOutput(List.of("b"), Collections.emptyList(), new Expectation(Expectation.Type.JSON, "empty-list.json")) + ) + // @formatter:on ); } @@ -112,11 +112,9 @@ public static Stream testExecute() { protected List modulesToDeploy; private List deployedApps; - private List servicesToCreate; - private List appsToDeploy; + private DeployedMta deployedMta; private List subscriptionsToCreate; private List existingSubscriptions; - private DeployedMta deployedMta; private DeploymentDescriptor deploymentDescriptor; private void prepareClient() { @@ -132,35 +130,31 @@ private void prepareDeploymentDescriptor(StepInput input) { List modules = input.deploymentDescriptorModules.stream() .map(this::getModuleFromName) .collect(Collectors.toList()); - deploymentDescriptor = DeploymentDescriptor.createV2() + deploymentDescriptor = DeploymentDescriptor.createV3() .setModules(modules) - .setSchemaVersion("2") + .setSchemaVersion("3") .setId("id") .setVersion("1"); } private Module getModuleFromName(String moduleName) { - return Module.createV2() + return Module.createV3() .setName(moduleName) .setType("a"); } private void loadParameters(StepInput input) { - String modulesToDeployString = TestUtil.getResourceAsString(input.modulesToDeployLocation, getClass()); - String appsToDeployString = TestUtil.getResourceAsString(input.appsToDeployLocation, getClass()); - String servicesToCreateString = TestUtil.getResourceAsString(input.servicesToCreateLocation, getClass()); - String deployedAppsString = TestUtil.getResourceAsString(input.deployedAppsLocation, getClass()); String subscriptionsToCreateString = TestUtil.getResourceAsString(input.subscriptionsToCreateLocation, getClass()); String existingSubscriptionsString = TestUtil.getResourceAsString(input.existingSubscriptionsLocation, getClass()); - modulesToDeploy = JsonUtil.fromJson(modulesToDeployString, new TypeReference<>() { - }); - deployedApps = JsonUtil.fromJson(deployedAppsString, new TypeReference<>() { - }); - servicesToCreate = JsonUtil.fromJson(servicesToCreateString, new TypeReference<>() { - }); - appsToDeploy = JsonUtil.fromJson(appsToDeployString, new TypeReference<>() { - }); + modulesToDeploy = input.mtaModules.stream() + .map(this::getModuleFromName) + .toList(); + deployedApps = input.deployedAppNames.stream() + .map(deployedAppName -> ImmutableCloudApplicationExtended.builder() + .name(deployedAppName) + .build()) + .collect(Collectors.toList()); subscriptionsToCreate = JsonUtil.fromJson(subscriptionsToCreateString, new TypeReference<>() { }); @@ -172,6 +166,10 @@ private void loadParameters(StepInput input) { deployedMta = JsonUtil.fromJson(deployedMtaString, DeployedMta.class); } when(moduleToDeployHelper.isApplication(any())).thenReturn(true); + when(moduleToDeployHelper.shouldSkipDeploy(any(Module.class))).thenAnswer(invocationModule -> { + Module module = (Module) invocationModule.getArgument(0); + return !input.mtaModules.contains(module.getName()); + }); when(applicationCloudModelBuilder.getAllApplicationServices(any())).thenReturn(input.services); @@ -180,11 +178,8 @@ private void loadParameters(StepInput input) { private void prepareContext(StepInput input) { context.setVariable(Variables.DEPLOYED_MTA, deployedMta); context.setVariable(Variables.MODULES_TO_DEPLOY, modulesToDeploy); - context.setVariable(Variables.SERVICES_TO_CREATE, servicesToCreate); - context.setVariable(Variables.ALL_MODULES_TO_DEPLOY, modulesToDeploy); - List appNamesToDeploy = new ArrayList<>(); - appsToDeploy.forEach(app -> appNamesToDeploy.add(app.getName())); - context.setVariable(Variables.APPS_TO_DEPLOY, appNamesToDeploy); + context.setVariable(Variables.APPS_TO_DEPLOY, input.mtaModules.stream() + .toList()); context.setVariable(Variables.SUBSCRIPTIONS_TO_CREATE, subscriptionsToCreate); context.setVariable(Variables.SPACE_GUID, SPACE_ID); context.setVariable(Variables.MTA_MODULES, input.mtaModules); @@ -194,9 +189,9 @@ private void prepareContext(StepInput input) { private void prepareSubscriptionService() { when(configurationSubscriptionService.createQuery()).thenReturn(configurationSubscriptionQuery); if (deployedMta != null) { - ConfigurationSubscriptionQuery mock = new MockBuilder<>(configurationSubscriptionQuery).on( - query -> query.mtaId(deployedMta.getMetadata() - .getId())) + ConfigurationSubscriptionQuery mock = new MockBuilder<>(configurationSubscriptionQuery).on(query -> query.mtaId( + deployedMta.getMetadata() + .getId())) .on(query -> query.spaceId(SPACE_ID)) .build(); when(mock.list()).thenReturn(filter(existingSubscriptions)); @@ -249,29 +244,22 @@ protected BuildCloudUndeployModelStepMock createStep() { private static class StepInput { - public final String modulesToDeployLocation; - public final String appsToDeployLocation; - public final String servicesToCreateLocation; public final List services; - public final String deployedAppsLocation; + public final List deployedAppNames; public final Set mtaModules; - public final String subscriptionsToCreateLocation; public final String deployedMtaLocation; + public final String subscriptionsToCreateLocation; public final String existingSubscriptionsLocation; public final Set deploymentDescriptorModules; - public StepInput(String modulesToDeployLocation, String appsToDeployLocation, String servicesToCreateLocation, - List services, String deployedAppsLocation, Set mtaModules, String deployedMtaLocation, + public StepInput(List services, List deployedAppNames, Set mtaModules, String deployedMtaLocation, String subscriptionsToCreateLocation, String existingSubscriptionsLocation, Set deploymentDescriptorModules) { - this.modulesToDeployLocation = modulesToDeployLocation; - this.appsToDeployLocation = appsToDeployLocation; - this.servicesToCreateLocation = servicesToCreateLocation; this.services = services; - this.deployedAppsLocation = deployedAppsLocation; + this.deployedAppNames = deployedAppNames; this.mtaModules = mtaModules; - this.subscriptionsToCreateLocation = subscriptionsToCreateLocation; this.deployedMtaLocation = deployedMtaLocation; + this.subscriptionsToCreateLocation = subscriptionsToCreateLocation; this.existingSubscriptionsLocation = existingSubscriptionsLocation; this.deploymentDescriptorModules = deploymentDescriptorModules; } @@ -298,4 +286,4 @@ protected ApplicationCloudModelBuilder getApplicationCloudModelBuilder(ProcessCo return applicationCloudModelBuilder; } } -} \ No newline at end of file +} diff --git a/multiapps-controller-process/src/test/java/org/cloudfoundry/multiapps/controller/process/steps/ProcessDescriptorStepTest.java b/multiapps-controller-process/src/test/java/org/cloudfoundry/multiapps/controller/process/steps/ProcessDescriptorStepTest.java index 2a516db9e8..e4c2553de2 100644 --- a/multiapps-controller-process/src/test/java/org/cloudfoundry/multiapps/controller/process/steps/ProcessDescriptorStepTest.java +++ b/multiapps-controller-process/src/test/java/org/cloudfoundry/multiapps/controller/process/steps/ProcessDescriptorStepTest.java @@ -1,28 +1,38 @@ package org.cloudfoundry.multiapps.controller.process.steps; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - +import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.stream.Stream; import org.cloudfoundry.multiapps.common.SLException; import org.cloudfoundry.multiapps.common.test.Tester.Expectation; +import org.cloudfoundry.multiapps.controller.core.helpers.ModuleToDeployHelper; import org.cloudfoundry.multiapps.controller.core.helpers.MtaDescriptorPropertiesResolver; import org.cloudfoundry.multiapps.controller.core.model.DynamicResolvableParameter; import org.cloudfoundry.multiapps.controller.core.model.ImmutableDynamicResolvableParameter; +import org.cloudfoundry.multiapps.controller.core.model.SupportedParameters; import org.cloudfoundry.multiapps.controller.core.test.DescriptorTestUtil; import org.cloudfoundry.multiapps.controller.process.Constants; import org.cloudfoundry.multiapps.controller.process.variables.Variables; import org.cloudfoundry.multiapps.mta.model.DeploymentDescriptor; +import org.cloudfoundry.multiapps.mta.model.Module; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mock; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + class ProcessDescriptorStepTest extends SyncFlowableStepTest { private static final Integer MTA_MAJOR_SCHEMA_VERSION = 2; @@ -32,6 +42,10 @@ class ProcessDescriptorStepTest extends SyncFlowableStepTest invocation.getArguments()[0]); + when(resolver.resolve(any())).thenAnswer((invocation) -> invocation.getArguments()[0]); Set dynamicParameters = Set.of(ImmutableDynamicResolvableParameter.builder() - .parameterName("service-guid") - .relationshipEntityName("service-1") - .value("service-guid") - .build()); + .parameterName("service-guid") + .relationshipEntityName("service-1") + .value("service-guid") + .build()); context.setVariable(Variables.DYNAMIC_RESOLVABLE_PARAMETERS, dynamicParameters); - + step.execute(execution); verify(execution, times(1)).setVariable(eq(Variables.DYNAMIC_RESOLVABLE_PARAMETERS.getName()), any()); } + static Stream testSetMtaModulesBasedOnSkipDeployParameter() { + return Stream.of(Arguments.of(true, false, Set.of("test-module-2")), Arguments.of(false, true, Set.of("test-module-1")), + Arguments.of(false, false, Set.of("test-module-1", "test-module-2")), + Arguments.of(true, true, Collections.emptySet())); + } + + @ParameterizedTest + @MethodSource + void testSetMtaModulesBasedOnSkipDeployParameter(boolean skipDeploy1, boolean skipDeploy2, Set expectedModuleNames) { + prepareContextForSkipDeployParameters(skipDeploy1, skipDeploy2); + + step.execute(execution); + + Set mtaModules = context.getVariable(Variables.MTA_MODULES); + assertEquals(expectedModuleNames, mtaModules); + } + + private void prepareContextForSkipDeployParameters(boolean skipDeploy1, boolean skipDeploy2) { + Module module1 = Module.createV3() + .setName("test-module-1"); + module1.setParameters(Map.of(SupportedParameters.SKIP_DEPLOY, skipDeploy1)); + + Module module2 = Module.createV3() + .setName("test-module-2"); + module2.setParameters(Map.of(SupportedParameters.SKIP_DEPLOY, skipDeploy2)); + + DeploymentDescriptor descriptor = DEPLOYMENT_DESCRIPTOR; + descriptor.setModules(List.of(module1, module2)); + + when(resolver.resolve(any())).thenReturn(descriptor); + when(moduleToDeployHelper.shouldSkipDeploy(module1)).thenReturn(skipDeploy1); + when(moduleToDeployHelper.shouldSkipDeploy(module2)).thenReturn(skipDeploy2); + + context.setVariable(Variables.DEPLOYMENT_DESCRIPTOR_WITH_SYSTEM_PARAMETERS, descriptor); + } + @Override protected ProcessDescriptorStep createStep() { - return new ProcessDescriptorStepMock(); + return new ProcessDescriptorStepMock(moduleToDeployHelper); } -} +} \ No newline at end of file diff --git a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/apps-to-deploy-01.json b/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/apps-to-deploy-01.json deleted file mode 100644 index dc71901356..0000000000 --- a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/apps-to-deploy-01.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "name": "a" - }, - { - "name": "b" - }, - { - "name": "c" - } -] \ No newline at end of file diff --git a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-01.json b/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-01.json deleted file mode 100644 index 0637a088a0..0000000000 --- a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-01.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-04.json b/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-04.json deleted file mode 100644 index da2e276561..0000000000 --- a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-04.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "name": "a" - }, - { - "name": "b" - }, - { - "name": "c" - }, - { - "name": "d" - }, - { - "name": "e" - } -] \ No newline at end of file diff --git a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-05.json b/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-05.json deleted file mode 100644 index ae139ad159..0000000000 --- a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-05.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - { - "name": "d" - }, - { - "name": "e" - } -] \ No newline at end of file diff --git a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-06.json b/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-06.json deleted file mode 100644 index 07d505ff78..0000000000 --- a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-06.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "name": "namespace.a" - }, - { - "name": "namespace.b" - }, - { - "name": "namespace.c" - } -] \ No newline at end of file diff --git a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-07.json b/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-07.json deleted file mode 100644 index 57b14217ad..0000000000 --- a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-apps-07.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - { - "name": "a" - }, - { - "name": "b" - } -] \ No newline at end of file diff --git a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-mta-13.json b/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-mta-13.json new file mode 100644 index 0000000000..7b14507140 --- /dev/null +++ b/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/deployed-mta-13.json @@ -0,0 +1,27 @@ +{ + "metadata": { + "id": "test", + "version": "0.1.0" + }, + "applications": [ + { + "moduleName": "a", + "name": "a", + "boundMtaServices": [], + "providedDependencyNames": [] + }, + { + "moduleName": "b", + "name": "b", + "boundMtaServices": [], + "providedDependencyNames": [] + }, + { + "moduleName": "c", + "name": "c", + "boundMtaServices": [], + "providedDependencyNames": [] + } + ], + "services": [] +} \ No newline at end of file diff --git a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/services-to-create-02.json b/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/services-to-create-02.json deleted file mode 100644 index e6c22f59dd..0000000000 --- a/multiapps-controller-process/src/test/resources/org/cloudfoundry/multiapps/controller/process/steps/services-to-create-02.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - { - "name": "s-3" - } -] \ No newline at end of file