org.springframework.cloud.deployer.spi.app.AppDeployer Java Examples
The following examples show how to use
org.springframework.cloud.deployer.spi.app.AppDeployer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeployAppStep.java From spring-cloud-skipper with Apache License 2.0 | 6 votes |
private Map<String, String> deploy(Release replacingRelease, List<String> applicationNamesToUpgrade, AppDeployer appDeployer) { List<? extends SpringCloudDeployerApplicationManifest> applicationSpecList = this.applicationManifestReader .read(replacingRelease .getManifest().getData()); Map<String, String> appNameDeploymentIdMap = new HashMap<>(); for (SpringCloudDeployerApplicationManifest applicationManifest : applicationSpecList) { if (applicationNamesToUpgrade.contains(applicationManifest.getApplicationName())) { AppDeploymentRequest appDeploymentRequest = appDeploymentRequestFactory.createAppDeploymentRequest( applicationManifest, replacingRelease.getName(), String.valueOf(replacingRelease.getVersion())); // ============= // DEPLOY DEPLOY // ============= String deploymentId = appDeployer.deploy(appDeploymentRequest); appNameDeploymentIdMap.put(applicationManifest.getApplicationName(), deploymentId); } } return appNameDeploymentIdMap; }
Example #2
Source File: ConsulBinderTests.java From spring-cloud-consul with Apache License 2.0 | 6 votes |
/** * Launch an application in a separate JVM. * @param clz the main class to launch * @param properties the properties to pass to the application * @param args the command line arguments for the application * @return a string identifier for the application */ private String launchApplication(Class<?> clz, Map<String, String> properties, List<String> args) { Resource resource = new UrlResource( clz.getProtectionDomain().getCodeSource().getLocation()); properties.put(AppDeployer.GROUP_PROPERTY_KEY, "test-group"); properties.put("main", clz.getName()); properties.put("classpath", System.getProperty("java.class.path")); String appName = String.format("%s-%s", clz.getSimpleName(), properties.get("server.port")); AppDefinition definition = new AppDefinition(appName, properties); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, properties, args); return this.deployer.deploy(request); }
Example #3
Source File: ApplicationDeploymentController.java From spring-cloud-dashboard with Apache License 2.0 | 6 votes |
public ApplicationDeploymentController(ApplicationDefinitionRepository definitionRepository, DeploymentIdRepository deploymentIdRepository, EavRegistryRepository eavRegistryRepository, AppDeployer appDeployer, AppRegistry appRegistry, ApplicationConfigurationMetadataResolver metadataResolver, CommonApplicationProperties commonProperties) { Assert.notNull(definitionRepository, "ApplicationDefinitionRepository must not be null"); Assert.notNull(deploymentIdRepository, "DeploymentIdRepository must not be null"); Assert.notNull(eavRegistryRepository, "EavRegistryRepository must not be null"); Assert.notNull(appDeployer, "AppDeployer must not be null"); Assert.notNull(appRegistry, "AppRegistry must not be null"); Assert.notNull(commonProperties, "CommonApplicationProperties must not be null"); Assert.notNull(metadataResolver, "MetadataResolver must not be null"); this.definitionRepository = definitionRepository; this.deploymentIdRepository = deploymentIdRepository; this.eavRegistryRepository = eavRegistryRepository; this.appDeployer = appDeployer; this.appRegistry = appRegistry; this.whitelistProperties = new WhitelistProperties(metadataResolver); this.commonApplicationProperties = commonProperties; }
Example #4
Source File: LocalAppDeployerEnvironmentIntegrationTests.java From spring-cloud-deployer-local with Apache License 2.0 | 6 votes |
@Test // was triggered by GH-50 and subsequently GH-55 public void testNoStdoutStderrOnInheritLoggingAndNoNPEOnGetAttributes() { Map<String, String> properties = new HashMap<>(); AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.singletonMap(LocalDeployerProperties.INHERIT_LOGGING, "true")); AppDeployer deployer = appDeployer(); String deploymentId = deployer.deploy(request); AppStatus appStatus = deployer.status(deploymentId); assertTrue(appStatus.getInstances().size() > 0); for (Entry<String, AppInstanceStatus> instanceStatusEntry : appStatus.getInstances().entrySet()) { Map<String, String> attributes = instanceStatusEntry.getValue().getAttributes(); assertFalse(attributes.containsKey("stdout")); assertFalse(attributes.containsKey("stderr")); } deployer.undeploy(deploymentId); }
Example #5
Source File: LocalAppDeployerIntegrationTests.java From spring-cloud-deployer-local with Apache License 2.0 | 6 votes |
@Test // was triggered by GH-50 and subsequently GH-55 public void testNoStdoutStderrOnInheritLoggingAndNoNPEOnGetAttributes() { Map<String, String> properties = new HashMap<>(); AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.singletonMap(LocalDeployerProperties.INHERIT_LOGGING, "true")); AppDeployer deployer = appDeployer(); String deploymentId = deployer.deploy(request); AppStatus appStatus = deployer.status(deploymentId); assertTrue(appStatus.getInstances().size() > 0); for (Entry<String, AppInstanceStatus> instanceStatusEntry : appStatus.getInstances().entrySet()) { Map<String, String> attributes = instanceStatusEntry.getValue().getAttributes(); assertFalse(attributes.containsKey("stdout")); assertFalse(attributes.containsKey("stderr")); } deployer.undeploy(deploymentId); }
Example #6
Source File: DefaultReleaseManager.java From spring-cloud-skipper with Apache License 2.0 | 6 votes |
public Release delete(Release release) { AppDeployer appDeployer = this.deployerRepository.findByNameRequired(release.getPlatformName()) .getAppDeployer(); AppDeployerData appDeployerData = this.appDeployerDataRepository .findByReleaseNameAndReleaseVersionRequired(release.getName(), release.getVersion()); List<String> deploymentIds = (appDeployerData != null) ? appDeployerData.getDeploymentIds() : Collections.EMPTY_LIST; if (!deploymentIds.isEmpty()) { for (String deploymentId : deploymentIds) { try { appDeployer.undeploy(deploymentId); } catch (Exception e) { this.logger.error(String.format("Exception undeploying the application with the deploymentId %s. " + "Exception message: %s", deploymentId, e.getMessage())); } } Status deletedStatus = new Status(); deletedStatus.setStatusCode(StatusCode.DELETED); release.getInfo().setStatus(deletedStatus); release.getInfo().setDescription("Delete complete"); this.releaseRepository.save(release); } return release; }
Example #7
Source File: TickTock.java From spring-cloud-deployer-local with Apache License 2.0 | 6 votes |
private static AppDeploymentRequest createAppDeploymentRequest(String app, String stream) { MavenResource resource = new MavenResource.Builder() .artifactId(app) .groupId("org.springframework.cloud.stream.app") .version("1.0.0.BUILD-SNAPSHOT") .build(); Map<String, String> properties = new HashMap<>(); properties.put("server.port", "0"); if (app.contains("-source-")) { properties.put("spring.cloud.stream.bindings.output.destination", stream); } else { properties.put("spring.cloud.stream.bindings.input.destination", stream); properties.put("spring.cloud.stream.bindings.input.group", "default"); } AppDefinition definition = new AppDefinition(app, properties); Map<String, String> deploymentProperties = new HashMap<>(); deploymentProperties.put(AppDeployer.GROUP_PROPERTY_KEY, stream); /* * This will allow output to be logged to the output of the process that started * the application. */ deploymentProperties.put(LocalDeployerProperties.INHERIT_LOGGING, "true"); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, deploymentProperties); return request; }
Example #8
Source File: JavaExecutionCommandBuilderTests.java From spring-cloud-deployer-local with Apache License 2.0 | 5 votes |
@Test public void testDirectJavaMemoryOption() { deploymentProperties.put(AppDeployer.MEMORY_PROPERTY_KEY, "1024m"); commandBuilder.addJavaOptions(args, deploymentProperties, localDeployerProperties); assertThat(args.size(), is(1)); assertThat(args.get(0), is("-Xmx1024m")); }
Example #9
Source File: ApplicationDefinitionController.java From spring-cloud-dashboard with Apache License 2.0 | 5 votes |
public ApplicationDefinitionController(ApplicationDefinitionRepository definitionRepository, DeploymentIdRepository deploymentIdRepository, ApplicationDeploymentController deploymentController, AppDeployer appDeployer, AppRegistry appRegistry) { Assert.notNull(definitionRepository, "ApplicationDefinitionRepository must not be null"); Assert.notNull(deploymentIdRepository, "DeploymentIdRepository must not be null"); Assert.notNull(deploymentController, "ApplicationDeploymentController must not be null"); Assert.notNull(appDeployer, "AppDeployer must not be null"); Assert.notNull(appRegistry, "AppRegistry must not be null"); this.definitionRepository = definitionRepository; this.deploymentIdRepository = deploymentIdRepository; this.deploymentController = deploymentController; this.appDeployer = appDeployer; this.appRegistry = appRegistry; }
Example #10
Source File: JavaExecutionCommandBuilderTests.java From spring-cloud-deployer-local with Apache License 2.0 | 5 votes |
@Test public void testDirectMemoryOptionsWithOtherOptions() { deploymentProperties.put(AppDeployer.MEMORY_PROPERTY_KEY, "1024m"); deploymentProperties.put(PREFIX + ".javaOpts", "-Dtest=foo"); commandBuilder.addJavaOptions(args, deploymentProperties, localDeployerProperties); assertThat(args.size(), is(2)); assertThat(args.get(0), is("-Xmx1024m")); assertThat(args.get(1), is("-Dtest=foo")); }
Example #11
Source File: DefaultReleaseManager.java From spring-cloud-skipper with Apache License 2.0 | 5 votes |
@Override public LogInfo getLog(Release release, String appName) { if (release.getInfo().getStatus().getStatusCode().equals(StatusCode.DELETED)) { return new LogInfo(Collections.EMPTY_MAP); } AppDeployerData appDeployerData = this.appDeployerDataRepository .findByReleaseNameAndReleaseVersion(release.getName(), release.getVersion()); if (appDeployerData == null) { return new LogInfo(Collections.EMPTY_MAP); } AppDeployer appDeployer = this.deployerRepository.findByNameRequired(release.getPlatformName()) .getAppDeployer(); Map<String, String> logMap = new HashMap<>(); Map<String, String> appNameDeploymentIdMap = appDeployerData.getDeploymentDataAsMap(); Map<String, String> logApps = new HashMap<>(); if (StringUtils.hasText(appName)) { for (Map.Entry<String, String> nameDeploymentId : appNameDeploymentIdMap.entrySet()) { if (appName.equalsIgnoreCase(nameDeploymentId.getValue())) { logApps.put(nameDeploymentId.getKey(), nameDeploymentId.getValue()); } } } else { logApps = appNameDeploymentIdMap; } for (Map.Entry<String, String> deploymentIdEntry: logApps.entrySet()) { logMap.put(deploymentIdEntry.getValue(), appDeployer.getLog(deploymentIdEntry.getValue())); } return new LogInfo(logMap); }
Example #12
Source File: DeleteStep.java From spring-cloud-skipper with Apache License 2.0 | 5 votes |
public Release delete(Release release, AppDeployerData existingAppDeployerData, List<String> applicationNamesToDelete) { AppDeployer appDeployer = this.deployerRepository.findByNameRequired(release.getPlatformName()) .getAppDeployer(); Map<String, String> appNamesAndDeploymentIds = (existingAppDeployerData!= null) ? existingAppDeployerData.getDeploymentDataAsMap() : Collections.EMPTY_MAP; for (Map.Entry<String, String> appNameAndDeploymentId : appNamesAndDeploymentIds.entrySet()) { if (applicationNamesToDelete.contains(appNameAndDeploymentId.getKey())) { AppStatus appStatus = appDeployer.status(appNameAndDeploymentId.getValue()); if (appStatus.getState().equals(DeploymentState.deployed)) { appDeployer.undeploy(appNameAndDeploymentId.getValue()); } else { logger.warn("For Release name {}, did not undeploy existing app {} as its status is not " + "'deployed'.", release.getName(), appNameAndDeploymentId.getKey()); } } } Status deletedStatus = new Status(); deletedStatus.setStatusCode(StatusCode.DELETED); release.getInfo().setStatus(deletedStatus); release.getInfo().setDescription("Delete complete"); this.releaseRepository.save(release); return release; }
Example #13
Source File: LocalAppDeployerIntegrationTests.java From spring-cloud-deployer-local with Apache License 2.0 | 5 votes |
@Test public void testInDebugModeWithSuspendedUseCamelCase() throws Exception { Map<String, String> properties = new HashMap<>(); AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); Map<String, String> deploymentProperties = new HashMap<>(); deploymentProperties.put(LocalDeployerProperties.PREFIX + ".debugPort", "8888"); deploymentProperties.put(LocalDeployerProperties.PREFIX + ".debugSuspend", "y"); deploymentProperties.put(LocalDeployerProperties.PREFIX + ".inheritLogging", "true"); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, deploymentProperties); AppDeployer deployer = appDeployer(); String deploymentId = deployer.deploy(request); Thread.sleep(5000); AppStatus appStatus = deployer.status(deploymentId); if (resource instanceof DockerResource) { try { String containerId = getCommandOutput("docker ps -q --filter ancestor="+ TESTAPP_DOCKER_IMAGE_NAME); String logOutput = getCommandOutput("docker logs "+ containerId); assertTrue(logOutput.contains("Listening for transport dt_socket at address: 8888")); } catch (IOException e) { } } else { assertEquals("deploying", appStatus.toString()); } deployer.undeploy(deploymentId); }
Example #14
Source File: LocalAppDeployerIntegrationTests.java From spring-cloud-deployer-local with Apache License 2.0 | 5 votes |
@Test public void testUseDefaultDeployerProperties() throws IOException { LocalDeployerProperties localDeployerProperties = new LocalDeployerProperties(); Path tmpPath = new File(System.getProperty("java.io.tmpdir")).toPath(); Path customWorkDirRoot = tmpPath.resolve("test-default-directory"); localDeployerProperties.setWorkingDirectoriesRoot(customWorkDirRoot.toFile().getAbsolutePath()); // Create a new LocalAppDeployer using a working directory that is different from the default value. AppDeployer appDeployer = new LocalAppDeployer(localDeployerProperties); List<Path> beforeDirs = getBeforePaths(customWorkDirRoot); Map<String, String> properties = new HashMap<>(); properties.put("server.port", "0"); AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); // Deploy String deploymentId = appDeployer.deploy(request); Timeout timeout = deploymentTimeout(); assertThat(deploymentId, eventually(hasStatusThat( appDeployer, Matchers.<AppStatus>hasProperty("state", is(deployed))), timeout.maxAttempts, timeout.pause)); timeout = undeploymentTimeout(); // Undeploy appDeployer.undeploy(deploymentId); assertThat(deploymentId, eventually(hasStatusThat( appDeployer, Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause)); List<Path> afterDirs = getAfterPaths(customWorkDirRoot); assertThat("Additional working directory not created", afterDirs.size(), CoreMatchers.is(beforeDirs.size()+1)); }
Example #15
Source File: LocalAppDeployerEnvironmentIntegrationTests.java From spring-cloud-deployer-local with Apache License 2.0 | 5 votes |
@Test public void testInDebugModeWithSuspended() throws Exception { Map<String, String> properties = new HashMap<>(); AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); Map<String, String> deploymentProperties = new HashMap<>(); deploymentProperties.put(LocalDeployerProperties.DEBUG_PORT, "9999"); deploymentProperties.put(LocalDeployerProperties.DEBUG_SUSPEND, "y"); deploymentProperties.put(LocalDeployerProperties.INHERIT_LOGGING, "true"); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, deploymentProperties); AppDeployer deployer = appDeployer(); String deploymentId = deployer.deploy(request); Thread.sleep(5000); AppStatus appStatus = deployer.status(deploymentId); if (resource instanceof DockerResource) { try { String containerId = getCommandOutput("docker ps -q --filter ancestor="+ TESTAPP_DOCKER_IMAGE_NAME); String logOutput = getCommandOutput("docker logs "+ containerId); assertTrue(logOutput.contains("Listening for transport dt_socket at address: 9999")); } catch (IOException e) { } } else { assertEquals("deploying", appStatus.toString()); } deployer.undeploy(deploymentId); }
Example #16
Source File: ApplicationDeploymentController.java From spring-cloud-dashboard with Apache License 2.0 | 5 votes |
private void deployApplication(ApplicationDefinition application, Map<String, String> applicationDeploymentProperties) { logger.info("Deploying application [" + application + "]"); if (applicationDeploymentProperties == null) { applicationDeploymentProperties = Collections.emptyMap(); } String type = eavRegistryRepository.findOne("spring-cloud-deployer-admin-app-" + application.getRegisteredAppName(), "type"); AppRegistration registration = this.appRegistry.find(application.getRegisteredAppName(), type); Map<String, String> deployerDeploymentProperties = DeploymentPropertiesUtils .extractAndQualifyDeployerProperties(applicationDeploymentProperties, application.getRegisteredAppName()); deployerDeploymentProperties.put(AppDeployer.GROUP_PROPERTY_KEY, application.getName()); Resource resource = registration.getResource(); AppDefinition revisedDefinition = mergeAndExpandAppProperties(application, resource, applicationDeploymentProperties); logger.info("Using AppDefinition [" + revisedDefinition + "]"); AppDeploymentRequest request = new AppDeploymentRequest(revisedDefinition, resource, deployerDeploymentProperties); logger.info("Using AppDeploymentRequest [" + request + "]"); try { String id = this.appDeployer.deploy(request); this.deploymentIdRepository.save(forApplicationDefinition(application), id); } // If the deployer implementation handles the deployment request synchronously, log error message if // any exception is thrown out of the deployment and proceed to the next deployment. catch (Exception e) { logger.error(String.format("Exception when deploying the app %s: %s", application, e.getMessage()), e); } }
Example #17
Source File: DataFlowControllerAutoConfiguration.java From spring-cloud-dashboard with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnBean(ApplicationDefinitionRepository.class) public ApplicationDeploymentController applicationDeploymentController(ApplicationDefinitionRepository repository, DeploymentIdRepository deploymentIdRepository, EavRegistryRepository eavRegistryRepository, AppDeployer deployer, AppRegistry appRegistry, ApplicationConfigurationMetadataResolver metadataResolver, CommonApplicationProperties appsProperties) { return new ApplicationDeploymentController(repository, deploymentIdRepository, eavRegistryRepository, deployer, appRegistry, metadataResolver, appsProperties); }
Example #18
Source File: JavaExecutionCommandBuilderTests.java From spring-cloud-deployer-local with Apache License 2.0 | 5 votes |
@Test public void testOverrideMemoryOptions() { deploymentProperties.put(AppDeployer.MEMORY_PROPERTY_KEY, "1024m"); deploymentProperties.put(PREFIX + ".javaOpts", "-Xmx2048m"); commandBuilder.addJavaOptions(args, deploymentProperties, localDeployerProperties); assertThat(args.size(), is(1)); assertThat(args.get(0), is("-Xmx2048m")); }
Example #19
Source File: JavaExecutionCommandBuilderTests.java From spring-cloud-deployer-local with Apache License 2.0 | 5 votes |
@Test public void testDirectJavaMemoryOptionWithG() { deploymentProperties.put(AppDeployer.MEMORY_PROPERTY_KEY, "1g"); commandBuilder.addJavaOptions(args, deploymentProperties, localDeployerProperties); assertThat(args.size(), is(1)); assertThat(args.get(0), is("-Xmx1024m")); }
Example #20
Source File: AbstractCloudFoundryDeployer.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
int diskQuota(AppScaleRequest request) { if (request.getProperties().isPresent() && request.getProperties().get() != null) { return (int) ByteSizeUtils.parseToMebibytes(request.getProperties().get().getOrDefault(AppDeployer.DISK_PROPERTY_KEY, this.deploymentProperties.getDisk())); } return (int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getDisk()); }
Example #21
Source File: AbstractKubernetesDeployer.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
/** * Creates a map of labels for a given application ID. * * @param appId the application id * @param request The {@link AppDeploymentRequest} * @return the built id map of labels */ Map<String, String> createIdMap(String appId, AppDeploymentRequest request) { Map<String, String> map = new HashMap<>(); map.put(SPRING_APP_KEY, appId); String groupId = request.getDeploymentProperties().get(AppDeployer.GROUP_PROPERTY_KEY); if (groupId != null) { map.put(SPRING_GROUP_KEY, groupId); } map.put(SPRING_DEPLOYMENT_KEY, appId); return map; }
Example #22
Source File: AbstractKubernetesDeployer.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
String createDeploymentId(AppDeploymentRequest request) { String groupId = request.getDeploymentProperties().get(AppDeployer.GROUP_PROPERTY_KEY); String deploymentId; if (groupId == null) { deploymentId = String.format("%s", request.getDefinition().getName()); } else { deploymentId = String.format("%s-%s", groupId, request.getDefinition().getName()); } // Kubernetes does not allow . in the name and does not allow uppercase in the name return deploymentId.replace('.', '-').toLowerCase(); }
Example #23
Source File: ChronosTaskLauncher.java From spring-cloud-deployer-mesos with Apache License 2.0 | 5 votes |
@Override public RuntimeEnvironmentInfo environmentInfo() { String apiVersion = "v1"; String hostVersion = "unknown"; return new RuntimeEnvironmentInfo.Builder() .spiClass(AppDeployer.class) .implementationName(this.getClass().getSimpleName()) .implementationVersion(RuntimeVersionUtils.getVersion(this.getClass())) .platformType("Mesos") .platformApiVersion(apiVersion) .platformClientVersion(RuntimeVersionUtils.getVersion(chronos.getClass())) .platformHostVersion(hostVersion) .build(); }
Example #24
Source File: StreamControllerTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Before public void setupMocks() { this.mockMvc = MockMvcBuilders.webAppContextSetup(wac) .defaultRequest(get("/").accept(MediaType.APPLICATION_JSON)).build(); streamStatusInfo = new Info(); streamStatusInfo.setStatus(new Status()); streamStatusInfo.getStatus().setStatusCode(StatusCode.UNKNOWN); when(skipperClient.status(anyString())).thenReturn(streamStatusInfo); Deployer deployer = new Deployer("default", "local", mock(AppDeployer.class)); when(skipperClient.listDeployers()).thenReturn(Arrays.asList(deployer)); when(skipperClient.search(anyString(), eq(false))).thenReturn(new ArrayList<PackageMetadata>()); }
Example #25
Source File: StreamControllerTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
@Test public void testDeployWithAppPropertiesOverride() throws Exception { repository.save(new StreamDefinition("myStream", "time --fixed-delay=2 | log --level=WARN")); Map<String, String> properties = new HashMap<>(); properties.put("app.time.fixed-delay", "4"); properties.put("app.log.level", "ERROR"); properties.put("app.time.producer.partitionKeyExpression", "payload"); mockMvc.perform(post("/streams/deployments/myStream").content(new ObjectMapper().writeValueAsBytes(properties)) .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated()); ArgumentCaptor<UploadRequest> uploadRequestCaptor = ArgumentCaptor.forClass(UploadRequest.class); verify(skipperClient, times(1)).upload(uploadRequestCaptor.capture()); ArgumentCaptor<InstallRequest> installRequestCaptor = ArgumentCaptor.forClass(InstallRequest.class); verify(skipperClient, times(1)).install(installRequestCaptor.capture()); List<UploadRequest> updateRequests = uploadRequestCaptor.getAllValues(); assertEquals(1, updateRequests.size()); Package pkg = SkipperPackageUtils.loadPackageFromBytes(uploadRequestCaptor); Package logPackage = findChildPackageByName(pkg, "log"); assertNotNull(logPackage); Package timePackage = findChildPackageByName(pkg, "time"); assertNotNull(timePackage); SpringCloudDeployerApplicationSpec logSpec = parseSpec(logPackage.getConfigValues().getRaw()); assertEquals("ERROR", logSpec.getApplicationProperties().get("log.level")); assertEquals("true", logSpec.getDeploymentProperties().get(AppDeployer.INDEXED_PROPERTY_KEY)); SpringCloudDeployerApplicationSpec timeSpec = parseSpec(timePackage.getConfigValues().getRaw()); assertEquals("4", timeSpec.getApplicationProperties().get("trigger.fixed-delay")); }
Example #26
Source File: CloudFoundryAppDeployer.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
@Override protected Map<String, String> getEnvironmentVariables(String deploymentId, AppDeploymentRequest request) { Map<String, String> envVariables = super.getEnvironmentVariables(deploymentId, request); envVariables.putAll(getCommandLineArguments(request)); String group = request.getDeploymentProperties().get(AppDeployer.GROUP_PROPERTY_KEY); if (StringUtils.hasText(group)) { envVariables.put("SPRING_CLOUD_APPLICATION_GROUP", group); } envVariables.put("SPRING_CLOUD_APPLICATION_GUID", "${vcap.application.name}:${vcap.application.instance_index}"); envVariables.put("SPRING_APPLICATION_INDEX", "${vcap.application.instance_index}"); return envVariables; }
Example #27
Source File: Deployer.java From spring-cloud-cli with Apache License 2.0 | 5 votes |
public Deployer(AppDeployer deployer, ResourceLoader resourceLoader, DeployerProperties properties, ConfigurableEnvironment environment) { this.deployer = deployer; this.resourceLoader = resourceLoader; this.properties = properties; this.environment = environment; }
Example #28
Source File: AbstractCloudFoundryDeployer.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
int memory(AppScaleRequest request) { if (request.getProperties().isPresent() && request.getProperties().get() != null) { return (int) ByteSizeUtils.parseToMebibytes(request.getProperties().get().getOrDefault(AppDeployer.MEMORY_PROPERTY_KEY, this.deploymentProperties.getMemory())); } return (int) ByteSizeUtils.parseToMebibytes(this.deploymentProperties.getMemory()); }
Example #29
Source File: CloudFoundryDeployerAutoConfiguration.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(AppDeployer.class) public AppDeployer appDeployer(CloudFoundryOperations operations, AppNameGenerator applicationNameGenerator) { return new CloudFoundryAppDeployer( applicationNameGenerator, connectionConfiguration.appDeploymentProperties(), operations, runtimeEnvironmentInfo(AppDeployer.class, CloudFoundryAppDeployer.class) ); }
Example #30
Source File: AbstractAppDeployerIntegrationTests.java From spring-cloud-deployer with Apache License 2.0 | 5 votes |
/** * Tests support for instance count support and individual instance status report. */ @Test public void testMultipleInstancesDeploymentAndPartialState() { Map<String, String> appProperties = new HashMap<>(); appProperties.put("matchInstances", "1"); // Only instance n°1 will kill itself appProperties.put("killDelay", "0"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); Map<String, String> deploymentProperties = new HashMap<>(); deploymentProperties.put(AppDeployer.COUNT_PROPERTY_KEY, "3"); deploymentProperties.put(AppDeployer.INDEXED_PROPERTY_KEY, "true"); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, deploymentProperties); log.info("Deploying {}...", request.getDefinition().getName()); String deploymentId = appDeployer().deploy(request); Timeout timeout = deploymentTimeout(); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<AppStatus>hasProperty("state", is(partial))), timeout.maxAttempts, timeout.pause)); // Assert individual instance state // Note we can't rely on instances order, neither on their id indicating their ordinal number List<DeploymentState> individualStates = new ArrayList<>(); for (AppInstanceStatus status : appDeployer().status(deploymentId).getInstances().values()) { individualStates.add(status.getState()); } assertThat(individualStates, containsInAnyOrder( is(deployed), is(deployed), is(failed) )); log.info("Undeploying {}...", deploymentId); timeout = undeploymentTimeout(); appDeployer().undeploy(deploymentId); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause)); }