org.springframework.cloud.deployer.spi.scheduler.ScheduleRequest Java Examples
The following examples show how to use
org.springframework.cloud.deployer.spi.scheduler.ScheduleRequest.
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: KubernetesSchedulerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testTaskServiceAccountNameDefault() { KubernetesSchedulerProperties kubernetesSchedulerProperties = new KubernetesSchedulerProperties(); if (kubernetesSchedulerProperties.getNamespace() == null) { kubernetesSchedulerProperties.setNamespace("default"); } KubernetesClient kubernetesClient = new DefaultKubernetesClient() .inNamespace(kubernetesSchedulerProperties.getNamespace()); KubernetesScheduler kubernetesScheduler = new KubernetesScheduler(kubernetesClient, kubernetesSchedulerProperties); AppDefinition appDefinition = new AppDefinition(randomName(), getAppProperties()); ScheduleRequest scheduleRequest = new ScheduleRequest(appDefinition, getSchedulerProperties(), getDeploymentProperties(), getCommandLineArgs(), randomName(), testApplication()); CronJob cronJob = kubernetesScheduler.createCronJob(scheduleRequest); CronJobSpec cronJobSpec = cronJob.getSpec(); String serviceAccountName = cronJobSpec.getJobTemplate().getSpec().getTemplate().getSpec() .getServiceAccountName(); assertEquals("Unexpected service account name", KubernetesSchedulerProperties.DEFAULT_TASK_SERVICE_ACCOUNT_NAME, serviceAccountName); kubernetesScheduler.unschedule(cronJob.getMetadata().getName()); }
Example #2
Source File: AuditServiceUtils.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
public Map<String, Object> convertScheduleRequestToAuditData(ScheduleRequest scheduleRequest) { Assert.notNull(scheduleRequest, "scheduleRequest must not be null"); Assert.hasText(scheduleRequest.getScheduleName(), "The scheduleName of the scheduleRequest must not be null or empty"); Assert.notNull(scheduleRequest.getDefinition(), "The task definition of the scheduleRequest must not be null"); final Map<String, Object> auditedData = new HashMap<>(3); auditedData.put(TASK_DEFINITION_NAME, scheduleRequest.getDefinition().getName()); if (scheduleRequest.getDefinition().getProperties() != null) { auditedData.put(TASK_DEFINITION_PROPERTIES, argumentSanitizer.sanitizeProperties(scheduleRequest.getDefinition().getProperties())); } if (scheduleRequest.getDeploymentProperties() != null) { auditedData.put(DEPLOYMENT_PROPERTIES, argumentSanitizer.sanitizeProperties(scheduleRequest.getDeploymentProperties())); } if (scheduleRequest.getCommandlineArguments() != null) { auditedData.put(COMMANDLINE_ARGUMENTS, argumentSanitizer.sanitizeArguments(scheduleRequest.getCommandlineArguments())); } return auditedData; }
Example #3
Source File: LocalSchedulerAutoConfiguration.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnMissingBean public Scheduler localScheduler() { return new Scheduler() { @Override public void schedule(ScheduleRequest scheduleRequest) { throw new UnsupportedOperationException("Scheduling is not implemented for local platform."); } @Override public void unschedule(String scheduleName) { throw new UnsupportedOperationException("Scheduling is not implemented for local platform."); } @Override public List<ScheduleInfo> list(String taskDefinitionName) { return Collections.emptyList(); } @Override public List<ScheduleInfo> list() { return Collections.emptyList(); } }; }
Example #4
Source File: BaseDocumentation.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
public Scheduler localTestScheduler() { return new Scheduler() { @Override public void schedule(ScheduleRequest scheduleRequest) { throw new UnsupportedOperationException("Interface is not implemented for schedule method."); } @Override public void unschedule(String scheduleName) { throw new UnsupportedOperationException("Interface is not implemented for unschedule method."); } @Override public List<ScheduleInfo> list(String taskDefinitionName) { throw new UnsupportedOperationException("Interface is not implemented for list method."); } @Override public List<ScheduleInfo> list() { return getSampleList(); } }; }
Example #5
Source File: LocalDataflowResource.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnMissingBean public Scheduler localScheduler() { return new Scheduler() { @Override public void schedule(ScheduleRequest scheduleRequest) { throw new UnsupportedOperationException("Interface is not implemented for schedule method."); } @Override public void unschedule(String scheduleName) { throw new UnsupportedOperationException("Interface is not implemented for unschedule method."); } @Override public List<ScheduleInfo> list(String taskDefinitionName) { throw new UnsupportedOperationException("Interface is not implemented for list method."); } @Override public List<ScheduleInfo> list() { throw new UnsupportedOperationException("Interface is not implemented for list method."); } }; }
Example #6
Source File: TestConfig.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
@Bean public Scheduler localScheduler() { // This is in auto-config package and we can depend on that, use same // dummy no-op impl here. return new Scheduler() { @Override public void schedule(ScheduleRequest scheduleRequest) { throw new UnsupportedOperationException("Scheduling is not implemented for local platform."); } @Override public void unschedule(String scheduleName) { throw new UnsupportedOperationException("Scheduling is not implemented for local platform."); } @Override public List<ScheduleInfo> list(String taskDefinitionName) { return Collections.emptyList(); } @Override public List<ScheduleInfo> list() { return Collections.emptyList(); } }; }
Example #7
Source File: CloudFoundryAppSchedulerTests.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 6 votes |
@Test public void testSuccessJobCreateFailedSchedule() { thrown.expect(CreateScheduleException.class); Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar"); mockAppResultsInAppList(); AppDefinition definition = new AppDefinition("test-application-1", null); Map badCronMap = new HashMap<String, String>(); badCronMap.put(CRON_EXPRESSION, CRON_EXPRESSION_FOR_SIX_MIN); ScheduleRequest request = new ScheduleRequest(definition, badCronMap, null, "test-schedule", resource); this.cloudFoundryAppScheduler.schedule(request); assertThat(((TestJobs) this.client.jobs()).getCreateJobResponse()).isNull(); }
Example #8
Source File: CloudFoundryAppSchedulerTests.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 6 votes |
@Test public void testInvalidCron() { thrown.expect(CreateScheduleException.class); thrown.expectMessage("Illegal characters for this position: 'FOO'"); Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar"); mockAppResultsInAppList(); AppDefinition definition = new AppDefinition("test-application-1", null); Map badCronMap = new HashMap<String, String>(); badCronMap.put(CRON_EXPRESSION, BAD_CRON_EXPRESSION); ScheduleRequest request = new ScheduleRequest(definition, badCronMap, null, "test-schedule", resource); this.cloudFoundryAppScheduler.schedule(request); assertThat(((TestJobs) this.client.jobs()).getCreateJobResponse()).isNull(); }
Example #9
Source File: AbstractSchedulerIntegrationTests.java From spring-cloud-deployer with Apache License 2.0 | 6 votes |
@Test public void testListFilter() { String definitionName = randomName(); String scheduleName = scheduleName() + definitionName; for (int i = 0; i < 4; i++) { ScheduleRequest request = createScheduleRequest(scheduleName + i, definitionName + i%2); taskScheduler().schedule(request); } ScheduleInfo scheduleInfo = new ScheduleInfo(); scheduleInfo.setScheduleName(scheduleName+0); scheduleInfo.setTaskDefinitionName(definitionName+0); assertThat(scheduleInfo, eventually( hasSpecifiedSchedulesByTaskDefinitionName(taskScheduler().list(definitionName+0), scheduleInfo.getTaskDefinitionName(), 2), this.scheduleTimeout.maxAttempts, this.scheduleTimeout.pause)); }
Example #10
Source File: KubernetesSchedulerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
private void testEnvironmentVariables(KubernetesSchedulerProperties kubernetesSchedulerProperties, Map<String, String> schedulerProperties, EnvVar[] expectedVars) { if (kubernetesSchedulerProperties.getNamespace() == null) { kubernetesSchedulerProperties.setNamespace("default"); } KubernetesClient kubernetesClient = new DefaultKubernetesClient() .inNamespace(kubernetesSchedulerProperties.getNamespace()); KubernetesScheduler kubernetesScheduler = new KubernetesScheduler(kubernetesClient, kubernetesSchedulerProperties); AppDefinition appDefinition = new AppDefinition(randomName(), getAppProperties()); ScheduleRequest scheduleRequest = new ScheduleRequest(appDefinition, schedulerProperties, null, getCommandLineArgs(), randomName(), testApplication()); CronJob cronJob = kubernetesScheduler.createCronJob(scheduleRequest); CronJobSpec cronJobSpec = cronJob.getSpec(); Container container = cronJobSpec.getJobTemplate().getSpec().getTemplate().getSpec().getContainers().get(0); assertTrue("Environment variables should not be empty", !container.getEnv().isEmpty()); assertThat(container.getEnv()).contains(expectedVars); kubernetesScheduler.unschedule(cronJob.getMetadata().getName()); }
Example #11
Source File: KubernetesSchedulerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testImagePullSecretDefault() { KubernetesSchedulerProperties kubernetesSchedulerProperties = new KubernetesSchedulerProperties(); if (kubernetesSchedulerProperties.getNamespace() == null) { kubernetesSchedulerProperties.setNamespace("default"); } KubernetesClient kubernetesClient = new DefaultKubernetesClient() .inNamespace(kubernetesSchedulerProperties.getNamespace()); KubernetesScheduler kubernetesScheduler = new KubernetesScheduler(kubernetesClient, kubernetesSchedulerProperties); AppDefinition appDefinition = new AppDefinition(randomName(), getAppProperties()); ScheduleRequest scheduleRequest = new ScheduleRequest(appDefinition, getSchedulerProperties(), getDeploymentProperties(), getCommandLineArgs(), randomName(), testApplication()); CronJob cronJob = kubernetesScheduler.createCronJob(scheduleRequest); CronJobSpec cronJobSpec = cronJob.getSpec(); List<LocalObjectReference> secrets = cronJobSpec.getJobTemplate().getSpec().getTemplate().getSpec() .getImagePullSecrets(); assertTrue("There should be no secrets", secrets.isEmpty()); kubernetesScheduler.unschedule(cronJob.getMetadata().getName()); }
Example #12
Source File: KubernetesSchedulerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testImagePullPolicyDefault() { KubernetesSchedulerProperties kubernetesSchedulerProperties = new KubernetesSchedulerProperties(); if (kubernetesSchedulerProperties.getNamespace() == null) { kubernetesSchedulerProperties.setNamespace("default"); } KubernetesClient kubernetesClient = new DefaultKubernetesClient() .inNamespace(kubernetesSchedulerProperties.getNamespace()); KubernetesScheduler kubernetesScheduler = new KubernetesScheduler(kubernetesClient, kubernetesSchedulerProperties); AppDefinition appDefinition = new AppDefinition(randomName(), getAppProperties()); ScheduleRequest scheduleRequest = new ScheduleRequest(appDefinition, getSchedulerProperties(), getDeploymentProperties(), getCommandLineArgs(), randomName(), testApplication()); CronJob cronJob = kubernetesScheduler.createCronJob(scheduleRequest); CronJobSpec cronJobSpec = cronJob.getSpec(); Container container = cronJobSpec.getJobTemplate().getSpec().getTemplate().getSpec().getContainers().get(0); assertEquals("Unexpected default image pull policy", ImagePullPolicy.IfNotPresent, ImagePullPolicy.relaxedValueOf(container.getImagePullPolicy())); kubernetesScheduler.unschedule(cronJob.getMetadata().getName()); }
Example #13
Source File: KubernetesSchedulerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testEntryPointStyleDefault() throws Exception { KubernetesSchedulerProperties kubernetesSchedulerProperties = new KubernetesSchedulerProperties(); if (kubernetesSchedulerProperties.getNamespace() == null) { kubernetesSchedulerProperties.setNamespace("default"); } KubernetesClient kubernetesClient = new DefaultKubernetesClient() .inNamespace(kubernetesSchedulerProperties.getNamespace()); KubernetesScheduler kubernetesScheduler = new KubernetesScheduler(kubernetesClient, kubernetesSchedulerProperties); AppDefinition appDefinition = new AppDefinition(randomName(), getAppProperties()); ScheduleRequest scheduleRequest = new ScheduleRequest(appDefinition, getSchedulerProperties(), getDeploymentProperties(), getCommandLineArgs(), randomName(), testApplication()); CronJob cronJob = kubernetesScheduler.createCronJob(scheduleRequest); CronJobSpec cronJobSpec = cronJob.getSpec(); Container container = cronJobSpec.getJobTemplate().getSpec().getTemplate().getSpec().getContainers().get(0); assertTrue("Environment variables should only have SPRING_CLOUD_APPLICATION_GUID", container.getEnv().size() == 1); assertTrue("Command line arguments should not be empty", !container.getArgs().isEmpty()); kubernetesScheduler.unschedule(cronJob.getMetadata().getName()); }
Example #14
Source File: KubernetesScheduler.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
protected CronJob createCronJob(ScheduleRequest scheduleRequest) { Map<String, String> labels = Collections.singletonMap(SPRING_CRONJOB_ID_KEY, scheduleRequest.getDefinition().getName()); Map<String, String> schedulerProperties = scheduleRequest.getSchedulerProperties(); String schedule = schedulerProperties.get(SchedulerPropertyKeys.CRON_EXPRESSION); Assert.hasText(schedule, "The property: " + SchedulerPropertyKeys.CRON_EXPRESSION + " must be defined"); PodSpec podSpec = createPodSpec(scheduleRequest); String taskServiceAccountName = this.deploymentPropertiesResolver.getTaskServiceAccountName(scheduleRequest.getSchedulerProperties()); if (StringUtils.hasText(taskServiceAccountName)) { podSpec.setServiceAccountName(taskServiceAccountName); } CronJob cronJob = new CronJobBuilder().withNewMetadata().withName(scheduleRequest.getScheduleName()) .withLabels(labels).endMetadata().withNewSpec().withSchedule(schedule).withNewJobTemplate() .withNewSpec().withNewTemplate().withSpec(podSpec).endTemplate().endSpec() .endJobTemplate().endSpec().build(); setImagePullSecret(scheduleRequest, cronJob); return this.client.batch().cronjobs().create(cronJob); }
Example #15
Source File: KubernetesSchedulerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Test public void testSchedulerPropertiesMerge() { final String baseScheduleName = "test-schedule1"; Map<String, String> schedulerProperties = new HashMap<>(); schedulerProperties.put(CRON_EXPRESSION, "0/10 * * * *"); schedulerProperties.put(KubernetesSchedulerProperties.KUBERNETES_SCHEDULER_PROPERTIES_PREFIX + ".imagePullPolicy", "Never"); Map<String, String> deploymentProperties = new HashMap<>(); deploymentProperties.put(KubernetesDeployerProperties.KUBERNETES_DEPLOYER_PROPERTIES_PREFIX + ".environmentVariables", "MYVAR1=MYVAL1,MYVAR2=MYVAL2"); deploymentProperties.put(KubernetesDeployerProperties.KUBERNETES_DEPLOYER_PROPERTIES_PREFIX + ".imagePullPolicy", "Always"); AppDefinition appDefinition = new AppDefinition(randomName(), null); ScheduleRequest scheduleRequest = new ScheduleRequest(appDefinition, schedulerProperties, deploymentProperties, null, baseScheduleName, testApplication()); Map<String, String> mergedProperties = KubernetesScheduler.mergeSchedulerProperties(scheduleRequest); assertTrue("Expected value from Scheduler properties, but found in Deployer properties", mergedProperties.get(KubernetesSchedulerProperties.KUBERNETES_SCHEDULER_PROPERTIES_PREFIX + ".imagePullPolicy").equals("Never")); assertTrue("Deployer property is expected to be merged as scheduler property", mergedProperties.get(KubernetesSchedulerProperties.KUBERNETES_SCHEDULER_PROPERTIES_PREFIX + ".environmentVariables").equals("MYVAR1=MYVAL1,MYVAR2=MYVAL2")); }
Example #16
Source File: KubernetesScheduler.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
/** * Merge the Deployment properties into Scheduler properties. * This way, the CronJob's scheduler properties are updated with the deployer properties if set any. * @param scheduleRequest the {@link ScheduleRequest} * @return the merged schedule properties */ static Map<String, String> mergeSchedulerProperties(ScheduleRequest scheduleRequest) { Map<String, String> deploymentProperties = scheduleRequest.getDeploymentProperties(); Map<String, String> schedulerProperties = new HashMap<>(); schedulerProperties.putAll(scheduleRequest.getSchedulerProperties()); if (deploymentProperties != null) { for (Map.Entry<String, String> deploymentProperty : deploymentProperties.entrySet()) { String deploymentPropertyKey = deploymentProperty.getKey(); if (StringUtils.hasText(deploymentPropertyKey) && deploymentPropertyKey.startsWith(KubernetesDeployerProperties.KUBERNETES_DEPLOYER_PROPERTIES_PREFIX)) { String schedulerPropertyKey = KubernetesSchedulerProperties.KUBERNETES_SCHEDULER_PROPERTIES_PREFIX + deploymentPropertyKey.substring(KubernetesDeployerProperties.KUBERNETES_DEPLOYER_PROPERTIES_PREFIX.length()); if (!schedulerProperties.containsKey(schedulerPropertyKey)) { schedulerProperties.put(schedulerPropertyKey, deploymentProperty.getValue()); } } } } return schedulerProperties; }
Example #17
Source File: KubernetesScheduler.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
@Override public void schedule(ScheduleRequest scheduleRequest) { scheduleRequest.setSchedulerProperties(mergeSchedulerProperties(scheduleRequest)); if(scheduleRequest != null) { validateScheduleName(scheduleRequest); } try { createCronJob(scheduleRequest); } catch (KubernetesClientException e) { String invalidCronExceptionMessage = getExceptionMessageForField(e, SCHEDULE_EXPRESSION_FIELD_NAME); if (StringUtils.hasText(invalidCronExceptionMessage)) { throw new CreateScheduleException(invalidCronExceptionMessage, e); } throw new CreateScheduleException("Failed to create schedule " + scheduleRequest.getScheduleName(), e); } }
Example #18
Source File: AbstractSchedulerIntegrationTests.java From spring-cloud-deployer with Apache License 2.0 | 5 votes |
@Test public void testDuplicateSchedule() { ScheduleRequest request = createScheduleRequest(); taskScheduler().schedule(request); ScheduleInfo scheduleInfo = new ScheduleInfo(); scheduleInfo.setScheduleName(request.getScheduleName()); this.expectedException.expect(CreateScheduleException.class); this.expectedException.expectMessage(String.format("Failed to create schedule %s", request.getScheduleName())); verifySchedule(scheduleInfo); taskScheduler().schedule(request); }
Example #19
Source File: CloudFoundryAppSchedulerTests.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
@Test public void testCreateWithCommandLineArgs() { Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar"); mockAppResultsInAppList(); AppDefinition definition = new AppDefinition("test-application-1", null); ScheduleRequest request = new ScheduleRequest(definition, getDefaultScheduleProperties(), null, Collections.singletonList("TestArg"), "test-schedule", resource); this.cloudFoundryAppScheduler.schedule(request); ArgumentCaptor<AppDeploymentRequest> argumentCaptor = ArgumentCaptor.forClass(AppDeploymentRequest.class); verify(this.taskLauncher).stage(argumentCaptor.capture()); assertEquals("TestArg", argumentCaptor.getValue().getCommandlineArguments().get(0)); }
Example #20
Source File: KubernetesScheduler.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
private void setImagePullSecret(ScheduleRequest scheduleRequest, CronJob cronJob) { String imagePullSecret = this.deploymentPropertiesResolver.getImagePullSecret(scheduleRequest.getSchedulerProperties()); if (StringUtils.hasText(imagePullSecret)) { LocalObjectReference localObjectReference = new LocalObjectReference(); localObjectReference.setName(imagePullSecret); cronJob.getSpec().getJobTemplate().getSpec().getTemplate().getSpec().getImagePullSecrets() .add(localObjectReference); } }
Example #21
Source File: CloudFoundryAppSchedulerTests.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
@Test public void testNameTooLong() { thrown.expect(CreateScheduleException.class); thrown.expectMessage("Schedule can not be created because its name " + "'j1-scdf-itcouldbesaidthatthisislongtoowaytoo-oopsitcouldbesaidthatthisis" + "longtoowaytoo-oopsitcouldbesaidthatthisislongtoowaytoo-oopsitcouldbe" + "saidthatthisislongtoowaytoo-oopsitcouldbesaidthatthisislongtoowaytoo-" + "oopsitcouldbesaidthatthisislongtoowaytoo-oops12' has too many characters. " + "Schedule name length must be 255 characters or less"); Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar"); mockAppResultsInAppList(); AppDefinition definition = new AppDefinition("test-application-1", null); Map cronMap = new HashMap<String, String>(); cronMap.put(CRON_EXPRESSION, DEFAULT_CRON_EXPRESSION); ScheduleRequest request = new ScheduleRequest(definition, cronMap, null, "j1-scdf-itcouldbesaidthatthisislongtoowaytoo-oopsitcouldbesaidthatthisis" + "longtoowaytoo-oopsitcouldbesaidthatthisislongtoowaytoo-oopsitcouldbe" + "saidthatthisislongtoowaytoo-oopsitcouldbesaidthatthisislongtoowaytoo-" + "oopsitcouldbesaidthatthisislongtoowaytoo-oops12", resource); this.cloudFoundryAppScheduler.schedule(request); assertThat(((TestJobs) this.client.jobs()).getCreateJobResponse()).isNull(); }
Example #22
Source File: CloudFoundryAppSchedulerTests.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
@Test public void testNoServiceCreate() { thrown.expect(SchedulerException.class); thrown.expectMessage("Scheduler Service returned a null response."); Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar"); mockAppResultsInAppList(); AppDefinition definition = new AppDefinition("test-application-1", null); ScheduleRequest request = new ScheduleRequest(definition, getDefaultScheduleProperties(), null, "test-schedule", resource); this.noServiceCloudFoundryAppScheduler.schedule(request); }
Example #23
Source File: CloudFoundryAppSchedulerTests.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
@Test public void testCreateNoCommandLineArgs() { Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar"); mockAppResultsInAppList(); AppDefinition definition = new AppDefinition("test-application-1", null); ScheduleRequest request = new ScheduleRequest(definition, getDefaultScheduleProperties(), null, "test-schedule", resource); this.cloudFoundryAppScheduler.schedule(request); assertThat(((TestJobs) this.client.jobs()).getCreateJobResponse().getId()).isEqualTo("test-job-id-1"); assertThat(((TestJobs) this.client.jobs()).getCreateJobResponse().getApplicationId()).isEqualTo("test-application-id-1"); assertThat(((TestJobs) this.client.jobs()).getCreateJobResponse().getCommand()).isEmpty(); }
Example #24
Source File: CloudFoundryAppSchedulerTests.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void testEmptySchedulerProperties() { Resource resource = new FileSystemResource("src/test/resources/demo-0.0.1-SNAPSHOT.jar"); AppDefinition definition = new AppDefinition("bar", null); ScheduleRequest request = new ScheduleRequest(definition, null, null, "testschedule", resource); this.cloudFoundryAppScheduler.schedule(request); }
Example #25
Source File: CloudFoundryAppScheduler.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
/** * Stages the application specified in the {@link ScheduleRequest} on the CF server. * @param scheduleRequest {@link ScheduleRequest} containing the information required to schedule a task. * @return the command string for the scheduled task. */ private String stageTask(ScheduleRequest scheduleRequest) { logger.debug(String.format("Staging Task: ", scheduleRequest.getDefinition().getName())); AppDeploymentRequest request = new AppDeploymentRequest( scheduleRequest.getDefinition(), scheduleRequest.getResource(), scheduleRequest.getDeploymentProperties(), scheduleRequest.getCommandlineArguments()); SummaryApplicationResponse response = taskLauncher.stage(request); return taskLauncher.getCommand(response, request); }
Example #26
Source File: KubernetesScheduler.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
public void validateScheduleName(ScheduleRequest request) { if(request.getScheduleName() == null) { throw new CreateScheduleException("The name for the schedule request is null", null); } if(request.getScheduleName().length() > 52) { throw new CreateScheduleException(String.format("because Schedule Name: '%s' has too many characters. Schedule name length must be 52 characters or less", request.getScheduleName()), null); } if(!Pattern.matches("^[a-z0-9]([-a-z0-9]*[a-z0-9])?$", request.getScheduleName())) { throw new CreateScheduleException("Invalid Format for Schedule Name. Schedule name can only contain lowercase letters, numbers 0-9 and hyphens.", null); } }
Example #27
Source File: AbstractSchedulerIntegrationTests.java From spring-cloud-deployer with Apache License 2.0 | 5 votes |
private ScheduleInfo createAndVerifySchedule() { ScheduleRequest request = createScheduleRequest(); taskScheduler().schedule(request); ScheduleInfo scheduleInfo = new ScheduleInfo(); scheduleInfo.setScheduleName(request.getScheduleName()); verifySchedule(scheduleInfo); return scheduleInfo; }
Example #28
Source File: AbstractSchedulerIntegrationTests.java From spring-cloud-deployer with Apache License 2.0 | 5 votes |
@Test public void testMultipleSchedule() { String definitionName = randomName(); String scheduleName = scheduleName() + definitionName; for (int i = 0; i < 4; i++) { ScheduleRequest request = createScheduleRequest(scheduleName + i, definitionName + i); taskScheduler().schedule(request); } List<ScheduleInfo> scheduleInfos = taskScheduler().list(); for (ScheduleInfo scheduleInfo : scheduleInfos) { verifySchedule(scheduleInfo); } }
Example #29
Source File: AbstractSchedulerIntegrationTests.java From spring-cloud-deployer with Apache License 2.0 | 5 votes |
@Test public void testInvalidCronExpression() { final String INVALID_EXPRESSION = "BAD"; String definitionName = randomName(); String scheduleName = scheduleName() + definitionName; Map<String, String> properties = new HashMap<>(getSchedulerProperties()); properties.put(SchedulerPropertyKeys.CRON_EXPRESSION, INVALID_EXPRESSION); AppDefinition definition = new AppDefinition(definitionName, properties); ScheduleRequest request = new ScheduleRequest(definition, properties, getDeploymentProperties(), getCommandLineArgs(), scheduleName, testApplication()); this.expectedException.expect(CreateScheduleException.class); taskScheduler().schedule(request); }
Example #30
Source File: AbstractSchedulerIntegrationTests.java From spring-cloud-deployer with Apache License 2.0 | 5 votes |
@After public void tearDown() { List<ScheduleRequest> scheduleRequests = new ArrayList<>(schedulerWrapper.getScheduledTasks().values()); for (ScheduleRequest scheduleRequest : scheduleRequests) { unscheduleTestSchedule(scheduleRequest.getScheduleName()); } }