AppDefinition appDefinition = new AppDefinition(currentApp.getName(), expandedAppUpdateTimeProperties); AppDeploymentRequest request = new AppDeploymentRequest(appDefinition, appResource, deployerDeploymentProperties, commandlineArguments);
private void launchTask(TaskLaunchRequest taskLaunchRequest) { Assert.notNull(this.taskLauncher, "TaskLauncher has not been initialized"); logger.info("Launching Task for the following uri " + taskLaunchRequest.getUri()); Resource resource = this.resourceLoader.getResource(taskLaunchRequest.getUri()); AppDefinition definition = new AppDefinition(taskLaunchRequest.getApplicationName(), taskLaunchRequest.getEnvironmentProperties()); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, taskLaunchRequest.getDeploymentProperties(), taskLaunchRequest.getCommandlineArguments()); this.taskLauncher.launch(request); }
AppDefinition appDefinition = new AppDefinition(currentApp.getName(), expandedAppUpdateTimeProperties); AppDeploymentRequest request = new AppDeploymentRequest(appDefinition, appResource, deployerDeploymentProperties, commandlineArguments);
/** * Tests that command line args can be passed in. */ @Test public void testCommandLineArgs() { Map<String, String> properties = new HashMap<>(); properties.put("killDelay", "1000"); AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.<String, String>emptyMap(), Collections.singletonList("--exitCode=0")); log.info("Launching {}...", request.getDefinition().getName()); String deploymentId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(complete))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
@Test public void testSimpleLaunch() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "0"); appProperties.put("exitCode", "0"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
/** * Tests that command line args can be passed in. */ @Test public void testCommandLineArgs() { Map<String, String> properties = new HashMap<>(); properties.put("killDelay", "1000"); AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, Collections.<String, String>emptyMap(), Collections.singletonList("--exitCode=0")); log.info("Launching {}...", request.getDefinition().getName()); String deploymentId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(complete))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
@Test public void testSimpleLaunch() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "0"); appProperties.put("exitCode", "0"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
@Test public void testErrorExit() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "0"); appProperties.put("exitCode", "1"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.failed))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
@Test public void testErrorExit() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "0"); appProperties.put("exitCode", "1"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.failed))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
@Test public void testReLaunch() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "0"); appProperties.put("exitCode", "0"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause)); log.info("Re-Launching {}...", request.getDefinition().getName()); String newLaunchId = taskLauncher().launch(request); assertThat(newLaunchId, not(is(launchId))); timeout = deploymentTimeout(); assertThat(newLaunchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
@Test public void testReLaunch() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "0"); appProperties.put("exitCode", "0"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause)); log.info("Re-Launching {}...", request.getDefinition().getName()); String newLaunchId = taskLauncher().launch(request); assertThat(newLaunchId, not(is(launchId))); timeout = deploymentTimeout(); assertThat(newLaunchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
@Test public void testFailedDeployment() { Map<String, String> properties = new HashMap<>(); properties.put("killDelay", "0"); AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, properties); log.info("Deploying {}...", request.getDefinition().getName()); String deploymentId = appDeployer().deploy(request); Timeout timeout = deploymentTimeout(); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<AppStatus>hasProperty("state", is(failed))), timeout.maxAttempts, timeout.pause)); log.info("Undeploying {}...", deploymentId); timeout = undeploymentTimeout(); appDeployer().undeploy(deploymentId); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause)); }
@Test public void testFailedDeployment() { Map<String, String> properties = new HashMap<>(); properties.put("killDelay", "0"); AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, properties); log.info("Deploying {}...", request.getDefinition().getName()); String deploymentId = appDeployer().deploy(request); Timeout timeout = deploymentTimeout(); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<AppStatus>hasProperty("state", is(failed))), timeout.maxAttempts, timeout.pause)); log.info("Undeploying {}...", deploymentId); timeout = undeploymentTimeout(); appDeployer().undeploy(deploymentId); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause)); }
/** * Tests that an app which takes a long time to deploy is correctly reported as deploying. * Test that such an app can be undeployed. */ @Test public void testDeployingStateCalculationAndCancel() { Map<String, String> properties = new HashMap<>(); properties.put("initDelay", "" + 1000 * 60 * 60); // 1hr AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, properties); log.info("Deploying {}...", request.getDefinition().getName()); String deploymentId = appDeployer().deploy(request); Timeout timeout = deploymentTimeout(); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<AppStatus>hasProperty("state", is(deploying))), timeout.maxAttempts, timeout.pause)); log.info("Undeploying {}...", deploymentId); timeout = undeploymentTimeout(); appDeployer().undeploy(deploymentId); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause)); }
@Test public void testSimpleCancel() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "-1"); appProperties.put("exitCode", "0"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.running))), timeout.maxAttempts, timeout.pause)); log.info("Cancelling {}...", request.getDefinition().getName()); taskLauncher().cancel(launchId); timeout = undeploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.cancelled))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
@Test public void testSimpleCancel() throws InterruptedException { Map<String, String> appProperties = new HashMap<>(); appProperties.put("killDelay", "-1"); appProperties.put("exitCode", "0"); AppDefinition definition = new AppDefinition(randomName(), appProperties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource); log.info("Launching {}...", request.getDefinition().getName()); String launchId = taskLauncher().launch(request); Timeout timeout = deploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.running))), timeout.maxAttempts, timeout.pause)); log.info("Cancelling {}...", request.getDefinition().getName()); taskLauncher().cancel(launchId); timeout = undeploymentTimeout(); assertThat(launchId, eventually(hasStatusThat( Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.cancelled))), timeout.maxAttempts, timeout.pause)); taskLauncher().destroy(definition.getName()); }
/** * Tests that an app which takes a long time to deploy is correctly reported as deploying. * Test that such an app can be undeployed. */ @Test public void testDeployingStateCalculationAndCancel() { Map<String, String> properties = new HashMap<>(); properties.put("initDelay", "" + 1000 * 60 * 60); // 1hr AppDefinition definition = new AppDefinition(randomName(), properties); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource, properties); log.info("Deploying {}...", request.getDefinition().getName()); String deploymentId = appDeployer().deploy(request); Timeout timeout = deploymentTimeout(); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<AppStatus>hasProperty("state", is(deploying))), timeout.maxAttempts, timeout.pause)); log.info("Undeploying {}...", deploymentId); timeout = undeploymentTimeout(); appDeployer().undeploy(deploymentId); assertThat(deploymentId, eventually(hasStatusThat( Matchers.<AppStatus>hasProperty("state", is(unknown))), timeout.maxAttempts, timeout.pause)); }
AppDefinition definition = new AppDefinition(randomName(), null); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);
AppDefinition definition = new AppDefinition(randomName(), null); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);
AppDefinition definition = new AppDefinition(randomName(), null); Resource resource = testApplication(); AppDeploymentRequest request = new AppDeploymentRequest(definition, resource);