org.springframework.cloud.deployer.spi.task.LaunchState Java Examples

The following examples show how to use org.springframework.cloud.deployer.spi.task.LaunchState. 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: KubernetesTaskLauncher.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 6 votes vote down vote up
@Override
public String launch(AppDeploymentRequest request) {
	String appId = createDeploymentId(request);
	TaskStatus status = status(appId);

	if (!status.getState().equals(LaunchState.unknown)) {
		throw new IllegalStateException("Task " + appId + " already exists with a state of " + status);
	}

	if (this.maxConcurrentExecutionsReached()) {
		throw new IllegalStateException(
			String.format("Cannot launch task %s. The maximum concurrent task executions is at its limit [%d].",
				request.getDefinition().getName(), this.getMaximumConcurrentTasks())
		);
	}

	logPossibleDownloadResourceMessage(request.getResource());
	try {
		launch(appId, request);
		return appId;
	} catch (RuntimeException e) {
		logger.error(e.getMessage(), e);
		throw e;
	}
}
 
Example #2
Source File: CloudFoundryTaskLauncherTests.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
@Test
public void testStatusTimeout() {
	// Delay twice as much as 40% of statusTimeout, which is what the deployer uses
	long delay = (long) (this.deploymentProperties.getStatusTimeout() * .4f * 2);

	givenRequestGetTask("test-task-id", Mono
		.delay(Duration.ofMillis(delay))
		.then(Mono.just(GetTaskResponse.builder()
			.id("test-task-id")
				.memoryInMb(1024)
				.diskInMb(1024)
				.dropletId("1")
				.createdAt(new Date().toString())
				.updatedAt(new Date().toString())
				.sequenceId(1)
				.name("test-task-id")
			.state(TaskState.SUCCEEDED)
			.build())));

	assertThat(this.launcher.status("test-task-id").getState(), equalTo(LaunchState.error));
}
 
Example #3
Source File: AbstractCloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 6 votes vote down vote up
protected TaskStatus toTaskStatus(GetTaskResponse response) {
	switch (response.getState()) {
	case SUCCEEDED:
		return new TaskStatus(response.getId(), LaunchState.complete, null);
	case RUNNING:
		return new TaskStatus(response.getId(), LaunchState.running, null);
	case PENDING:
		return new TaskStatus(response.getId(), LaunchState.launching, null);
	case CANCELING:
		return new TaskStatus(response.getId(), LaunchState.cancelled, null);
	case FAILED:
		return new TaskStatus(response.getId(), LaunchState.failed, null);
	default:
		throw new IllegalStateException(String.format("Unsupported CF task state %s", response.getState()));
	}
}
 
Example #4
Source File: LocalTaskLauncher.java    From spring-cloud-deployer-local with Apache License 2.0 6 votes vote down vote up
private void pruneTaskInstanceHistory(String taskDefinitionName, String taskLaunchId) {
	CopyOnWriteArrayList<String> oldTaskInstanceIds = taskInstanceHistory.get(taskDefinitionName);
	if (oldTaskInstanceIds == null) {
		oldTaskInstanceIds = new CopyOnWriteArrayList<>();
		taskInstanceHistory.put(taskDefinitionName, oldTaskInstanceIds);
	}

	for (String oldTaskInstanceId : oldTaskInstanceIds) {
		TaskInstance oldTaskInstance = running.get(oldTaskInstanceId);
		if (oldTaskInstance != null && oldTaskInstance.getState() != LaunchState.running
				&& oldTaskInstance.getState() != LaunchState.launching) {
			running.remove(oldTaskInstanceId);
			oldTaskInstanceIds.remove(oldTaskInstanceId);
		} else {
			oldTaskInstanceIds.remove(oldTaskInstanceId);
		}
	}
	oldTaskInstanceIds.add(taskLaunchId);
}
 
Example #5
Source File: LocalTaskLauncher.java    From spring-cloud-deployer-local with Apache License 2.0 6 votes vote down vote up
public LaunchState getState() {
	if (cancelled) {
		return LaunchState.cancelled;
	}
	Integer exit = getProcessExitValue(process);
	// TODO: consider using exit code mapper concept from batch
	if (exit != null) {
		if (exit == 0) {
			return LaunchState.complete;
		}
		else {
			return LaunchState.failed;
		}
	}
	try {
		HttpURLConnection urlConnection = (HttpURLConnection) baseUrl.openConnection();
		urlConnection.setConnectTimeout(100);
		urlConnection.connect();
		urlConnection.disconnect();
		return LaunchState.running;
	}
	catch (IOException e) {
		return LaunchState.launching;
	}
}
 
Example #6
Source File: AbstractTaskLauncherIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #7
Source File: AbstractTaskLauncherIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #8
Source File: LocalTaskLauncherIntegrationTests.java    From spring-cloud-deployer-local with Apache License 2.0 6 votes vote down vote up
@Test
public void testAppLogRetrieval() {
	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);

	String launchId1 = taskLauncher().launch(request);

	Timeout timeout = deploymentTimeout();

	assertThat(launchId1, eventually(hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause));
	String logContent = taskLauncher().getLog(launchId1);
	assertThat(logContent, containsString("Starting DeployerIntegrationTestApplication"));
}
 
Example #9
Source File: AbstractTaskLauncherIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #10
Source File: DefaultTaskExecutionServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void testUpgradeDueToDeploymentPropsChangeForCloudFoundryFailsWhenAlreadyRunning() throws IOException {
	this.launcherRepository.delete(this.launcher);
	this.launcherRepository.save(new Launcher("default", "Cloud Foundry", taskLauncher));
	initializeSuccessfulRegistry(appRegistry);
	TaskExecution myTask = this.taskRepository.createTaskExecution(TASK_NAME_ORIG);
	TaskManifest manifest = new TaskManifest();
	manifest.setPlatformName("default");
	AppDeploymentRequest request = new AppDeploymentRequest(new AppDefinition("some-name", null),
			new FileUrlResource("src/test/resources/apps/foo-task"));
	manifest.setTaskDeploymentRequest(request);
	this.dataflowTaskExecutionMetadataDao.save(myTask, manifest);
	this.taskRepository.startTaskExecution(myTask.getExecutionId(), TASK_NAME_ORIG, new Date(), new ArrayList<>(), null);
	this.taskRepository.updateExternalExecutionId(myTask.getExecutionId(), "abc");
	when(this.taskLauncher.launch(any())).thenReturn("abc");
	when(this.taskLauncher.status("abc")).thenReturn(new TaskStatus("abc", LaunchState.running,new HashMap<>()));
	thrown.expect(IllegalStateException.class);
	thrown.expectMessage("Unable to update application due to currently running applications");
	this.taskExecutionService.executeTask(TASK_NAME_ORIG, new HashMap<>(), new LinkedList<>());
}
 
Example #11
Source File: DefaultTaskExecutionServiceTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
@DirtiesContext
public void testUpgradeDueToDeploymentPropsChangeForCloudFoundrySucceedsIfNotReallyRunning() throws IOException {
	this.launcherRepository.delete(this.launcher);
	this.launcherRepository.save(new Launcher("default", "Cloud Foundry", taskLauncher));
	initializeSuccessfulRegistry(appRegistry);
	TaskExecution myTask = this.taskRepository.createTaskExecution(TASK_NAME_ORIG);
	TaskManifest manifest = new TaskManifest();
	manifest.setPlatformName("default");
	AppDeploymentRequest request = new AppDeploymentRequest(new AppDefinition("some-name", null),
			new FileUrlResource("src/test/resources/apps/foo-task"));
	manifest.setTaskDeploymentRequest(request);
	this.dataflowTaskExecutionMetadataDao.save(myTask, manifest);
	this.taskRepository.startTaskExecution(myTask.getExecutionId(), TASK_NAME_ORIG, new Date(), new ArrayList<>(), null);
	this.taskRepository.updateExternalExecutionId(myTask.getExecutionId(), "abc");
	when(this.taskLauncher.launch(any())).thenReturn("abc");
	when(this.taskLauncher.status("abc")).thenReturn(new TaskStatus("abc", LaunchState.failed, new HashMap<>()));
	this.taskExecutionService.executeTask(TASK_NAME_ORIG, new HashMap<>(), new LinkedList<>());
	verify(this.taskLauncher).destroy(TASK_NAME_ORIG);
}
 
Example #12
Source File: KubernetesTaskLauncher.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 6 votes vote down vote up
private TaskStatus buildPodStatus(String id) {
	Pod pod = getPodByName(id);
	if (pod == null) {
		return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
	}

	PodStatus podStatus = pod.getStatus();
	if (podStatus == null) {
		return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
	}

	String phase = podStatus.getPhase();

	switch (phase) {
	case "Pending":
		return new TaskStatus(id, LaunchState.launching, new HashMap<>());
	case "Failed":
		return new TaskStatus(id, LaunchState.failed, new HashMap<>());
	case "Succeeded":
		return new TaskStatus(id, LaunchState.complete, new HashMap<>());
	default:
		return new TaskStatus(id, LaunchState.running, new HashMap<>());
	}
}
 
Example #13
Source File: DefaultTaskExecutionService.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * A task should not be allowed to be launched when one is running (allowing the upgrade
 * to proceed may kill running task instances of that definition on certain platforms).
 *
 * @param taskName task name to check
 * @param taskExecution the candidate TaskExecution
 * @param taskLauncher the TaskLauncher used to verify the status of a recorded task execution.
 */
private void verifyTaskIsNotRunning(String taskName, TaskExecution taskExecution, TaskLauncher taskLauncher) {
	Page<TaskExecution> runningTaskExecutions =
			this.taskExplorer.findRunningTaskExecutions(taskName, PageRequest.of(0, 1));

	//Found only the candidate TaskExecution
	if(runningTaskExecutions.getTotalElements() == 1 && runningTaskExecutions.toList().get(0).getExecutionId() == taskExecution.getExecutionId()) {
		return;
	}

	/*
	 * The task repository recorded a different task execution for the task which is started but not completed.
	 * It is possible that the task failed and terminated before updating the task repository.
	 * Use the TaskLauncher to verify the actual state.
	 */
	if (runningTaskExecutions.getTotalElements() > 0) {

		LaunchState launchState = taskLauncher.status(runningTaskExecutions.toList().get(0).getExternalExecutionId()).getState();
		if (launchState.equals(LaunchState.running) || launchState.equals(LaunchState.launching)) {
			throw new IllegalStateException("Unable to update application due to currently running applications");
		}
		else {
			logger.warn("Task repository shows a running task execution for task {} but the actual state is {}."
					+ launchState.toString(), taskName, launchState);
		}
	}
}
 
Example #14
Source File: TaskLauncherLocalSinkIntegrationTests.java    From spring-cloud-stream-app-starters with Apache License 2.0 5 votes vote down vote up
@Test
@Ignore
public void sendRequest() throws IOException {
	TaskSinkConfiguration.TestTaskLauncher testTaskLauncher =
			(TaskSinkConfiguration.TestTaskLauncher) applicationContext.getBean(TaskSinkConfiguration.TestTaskLauncher.class);

	TaskLaunchRequest request = new TaskLaunchRequest("maven://org.springframework.cloud.task.app:timestamp-task:jar:1.0.0.BUILD-SNAPSHOT", null, null, null);
	sink.input().send(new GenericMessage<>(request));
	assertEquals(LaunchState.complete, testTaskLauncher.status("TESTSTATUS").getState());
}
 
Example #15
Source File: TaskConfiguration.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Override
public String launch(AppDeploymentRequest request) {
	this.state = LaunchState.complete;
	this.commandlineArguments = request.getCommandlineArguments();
	this.applicationName = request.getDefinition().getName();
	return null;
}
 
Example #16
Source File: TaskLauncherSinkTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void verifySuccessWithParams(
		TaskConfiguration.TestTaskLauncher testTaskLauncher) {
	assertThat(testTaskLauncher.status(DEFAULT_STATUS).getState())
			.isEqualTo(LaunchState.complete);
	assertThat(testTaskLauncher.getCommandlineArguments().size()).isEqualTo(2);
	assertThat(testTaskLauncher.getCommandlineArguments().get(0)).isEqualTo(PARAM1);
	assertThat(testTaskLauncher.getCommandlineArguments().get(1)).isEqualTo(PARAM2);
	assertThat(testTaskLauncher.getApplicationName().startsWith(TASK_NAME_PREFIX))
			.isTrue();
}
 
Example #17
Source File: TaskLauncherSinkTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void verifySuccessWithAppName(
		TaskConfiguration.TestTaskLauncher testTaskLauncher) {
	assertThat(testTaskLauncher.status(DEFAULT_STATUS).getState())
			.isEqualTo(LaunchState.complete);
	assertThat(testTaskLauncher.getCommandlineArguments().size()).isEqualTo(0);
	assertThat(testTaskLauncher.getApplicationName()).isEqualTo(APP_NAME);
}
 
Example #18
Source File: LocalTaskLauncher.java    From spring-cloud-deployer-local with Apache License 2.0 5 votes vote down vote up
@Override
public TaskStatus status(String id) {
	TaskInstance instance = running.get(id);
	if (instance != null) {
		return new TaskStatus(id, instance.getState(), instance.getAttributes());
	}
	return new TaskStatus(id, LaunchState.unknown, null);
}
 
Example #19
Source File: TaskLauncherSinkTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
private void verifySuccessWithNoParams(
		TaskConfiguration.TestTaskLauncher testTaskLauncher) {
	assertThat(testTaskLauncher.status(DEFAULT_STATUS).getState())
			.isEqualTo(LaunchState.complete);
	assertThat(testTaskLauncher.getCommandlineArguments().size()).isEqualTo(0);
	assertThat(testTaskLauncher.getApplicationName().startsWith(TASK_NAME_PREFIX))
			.isTrue();
}
 
Example #20
Source File: TaskLauncherSinkTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoRun() {
	TaskConfiguration.TestTaskLauncher testTaskLauncher = this.context
			.getBean(TaskConfiguration.TestTaskLauncher.class);
	assertThat(testTaskLauncher.status(DEFAULT_STATUS).getState())
			.isEqualTo(LaunchState.unknown);
}
 
Example #21
Source File: AbstractCloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 5 votes vote down vote up
private Mono<TaskStatus> getStatus(String id) {
	return requestGetTask(id)
			.map(this::toTaskStatus)
			.onErrorResume(isNotFoundError(), t -> {
				logger.debug("Task for id={} does not exist", id);
				return Mono.just(new TaskStatus(id, LaunchState.unknown, null));
			})
			.transform(statusRetry(id))
			.onErrorReturn(createErrorTaskStatus(id));
}
 
Example #22
Source File: ChronosTaskLauncher.java    From spring-cloud-deployer-mesos with Apache License 2.0 5 votes vote down vote up
protected TaskStatus buildTaskStatus(ChronosTaskLauncherProperties properties, String id, Job job, String csv) {
	if (job == null) {
		return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
	}
	String last = null;
	String state= null;
	if (StringUtils.hasText(csv)) {
		List<String> csvLines = Arrays.asList(csv.split("\\r?\\n"));
		for (String line : csvLines) {
			if (line.startsWith("node")) {
				List<String> values = Arrays.asList(line.split("\\s*,\\s*"));
				if (values.size() >= 4) {
					if (id.equals(values.get(1))) {
						last = values.get(2);
						state = values.get(3);
						break;
					}
				}
			}
		}
	}
	if ("running".equals(state)) {
		return new TaskStatus(id, LaunchState.running, new HashMap<>());
	}
	if ("queued".equals(state)) {
		return new TaskStatus(id, LaunchState.launching, new HashMap<>());
	}
	if ("success".equals(last)) {
		return new TaskStatus(id, LaunchState.complete, new HashMap<>());
	}
	else {
		// TODO: state == idle could indicate cancelled?
		return new TaskStatus(id, LaunchState.failed, new HashMap<>());
	}
}
 
Example #23
Source File: AbstractTaskLauncherIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #24
Source File: YarnTaskLauncher.java    From spring-cloud-deployer-yarn with Apache License 2.0 5 votes vote down vote up
@Override
public TaskStatus status(String id) {
	logger.info("Status request for module {}", id);
	DeploymentKey key = new DeploymentKey(id);

	Collection<CloudAppInstanceInfo> instances = yarnCloudAppService.getInstances(CloudAppType.TASK);
	for (CloudAppInstanceInfo instance : instances) {
		if (instance.getApplicationId().equals(key.applicationId)) {
			if (instance.getState() == "RUNNING") {
				return new TaskStatus(id, LaunchState.running, null);
			}
		}
	}
	return new TaskStatus(id, LaunchState.unknown, null);
}
 
Example #25
Source File: KubernetesTaskLauncher.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 5 votes vote down vote up
TaskStatus buildTaskStatus(String id) {

		if(properties.isCreateJob()){
			Job job = getJob(id);

			if (job == null) {
				return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
			}

			JobStatus jobStatus = job.getStatus();

			if (jobStatus == null) {
				return new TaskStatus(id, LaunchState.unknown, new HashMap<>());
			}

			boolean failed = jobStatus.getFailed() != null && jobStatus.getFailed() > 0;
			boolean succeeded = jobStatus.getSucceeded() != null && jobStatus.getSucceeded() > 0;
			if (failed) {
				return new TaskStatus(id, LaunchState.failed, new HashMap<>());
			}
			if (succeeded) {
				return new TaskStatus(id, LaunchState.complete, new HashMap<>());
			}
			return new TaskStatus(id, LaunchState.launching, new HashMap<>());

		} else {
			return buildPodStatus(id);
		}
	}
 
Example #26
Source File: KubernetesTaskLauncher.java    From spring-cloud-deployer-kubernetes with Apache License 2.0 5 votes vote down vote up
@Override
public int getRunningTaskExecutionCount() {
	List<String> taskIds = getIdsForTasks(Optional.empty(), false);
	AtomicInteger executionCount = new AtomicInteger();

	taskIds.forEach(id-> {
		if (buildPodStatus(id).getState() == LaunchState.running) {
			executionCount.incrementAndGet();
		}
	});

	return executionCount.get();
}
 
Example #27
Source File: AbstractCloudFoundryTaskLauncher.java    From spring-cloud-deployer-cloudfoundry with Apache License 2.0 4 votes vote down vote up
private TaskStatus createErrorTaskStatus(String id) {
	return new TaskStatus(id, LaunchState.error, null);
}
 
Example #28
Source File: LocalTaskLauncherIntegrationTests.java    From spring-cloud-deployer-local with Apache License 2.0 4 votes vote down vote up
private void basicLaunchAndValidation(AppDefinition definition, Map<String, String> deploymentProperties) {
	List<String> commandLineArgs = new ArrayList<>(1);
	// Test to ensure no issues parsing server.port command line arg.
	commandLineArgs.add(LocalTaskLauncher.SERVER_PORT_KEY_COMMAND_LINE_ARG + SocketUtils.findAvailableTcpPort(LocalTaskLauncher.DEFAULT_SERVER_PORT));

	AppDeploymentRequest request = new AppDeploymentRequest(definition, this.testApplication(), deploymentProperties, commandLineArgs);


	this.log.info("Launching {}...", request.getDefinition().getName());

	String launchId = this.taskLauncher().launch(request);
	assertThat(taskLauncher.getRunningTaskExecutionCount(), eventually(is(1)));
	Timeout timeout = this.deploymentTimeout();

	Assert.assertThat(launchId, EventuallyMatcher.eventually(this.hasStatusThat(Matchers.hasProperty("state", Matchers.is(LaunchState.complete))), timeout.maxAttempts, timeout.pause));

	this.taskLauncher().destroy(definition.getName());
	assertThat(taskLauncher.getRunningTaskExecutionCount(), eventually(is(0)));
}
 
Example #29
Source File: TaskSinkConfiguration.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@Override
public String launch(AppDeploymentRequest request) {
	state = LaunchState.complete;
	return null;
}
 
Example #30
Source File: AbstractTaskLauncherIntegrationTests.java    From spring-cloud-deployer with Apache License 2.0 4 votes vote down vote up
@Test
public void testNonExistentAppsStatus() {
	assertThat(randomName(), hasStatusThat(
			Matchers.<TaskStatus>hasProperty("state", is(LaunchState.unknown))));
}