-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
K8s Task launcher to use task launcher account properties #4546
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright 2017-2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.cloud.dataflow.server.config.kubernetes; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.cloud.dataflow.core.AbstractPlatformProperties; | ||
import org.springframework.cloud.deployer.spi.kubernetes.KubernetesTaskLauncherProperties; | ||
|
||
/** | ||
* @author Ilayaperumal Gopinathan | ||
*/ | ||
@ConfigurationProperties("spring.cloud.dataflow.task.platform.kubernetes") | ||
public class KubernetesPlatformTaskLauncherProperties extends AbstractPlatformProperties<KubernetesTaskLauncherProperties> { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2019 the original author or authors. | ||
* Copyright 2019-2021 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -25,23 +25,28 @@ | |
import org.springframework.cloud.deployer.spi.kubernetes.KubernetesDeployerProperties; | ||
import org.springframework.cloud.deployer.spi.kubernetes.KubernetesSchedulerProperties; | ||
import org.springframework.cloud.deployer.spi.kubernetes.KubernetesTaskLauncher; | ||
import org.springframework.cloud.deployer.spi.kubernetes.KubernetesTaskLauncherProperties; | ||
import org.springframework.cloud.deployer.spi.kubernetes.RestartPolicy; | ||
import org.springframework.test.util.ReflectionTestUtils; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* @author David Turanski | ||
* @author Ilayaperumal Gopinathan | ||
**/ | ||
public class KubernetesTaskPlatformFactoryTests { | ||
|
||
@Test | ||
public void kubernetesTaskPlatformNoScheduler() { | ||
KubernetesPlatformProperties platformProperties = new KubernetesPlatformProperties(); | ||
KubernetesDeployerProperties deployerProperties = new KubernetesDeployerProperties(); | ||
KubernetesTaskLauncherProperties taskLauncherProperties = new KubernetesTaskLauncherProperties(); | ||
platformProperties.setAccounts(Collections.singletonMap("k8s", deployerProperties)); | ||
|
||
KubernetesPlatformTaskLauncherProperties platformTaskLauncherProperties = new KubernetesPlatformTaskLauncherProperties(); | ||
platformTaskLauncherProperties.setAccounts(Collections.singletonMap("k8s", taskLauncherProperties)); | ||
KubernetesTaskPlatformFactory kubernetesTaskPlatformFactory = new KubernetesTaskPlatformFactory( | ||
platformProperties, false); | ||
platformProperties, false, platformTaskLauncherProperties); | ||
|
||
TaskPlatform taskPlatform = kubernetesTaskPlatformFactory.createTaskPlatform(); | ||
assertThat(taskPlatform.getName()).isEqualTo("Kubernetes"); | ||
|
@@ -60,10 +65,14 @@ public void kubernetesTaskPlatformWithScheduler() { | |
KubernetesPlatformProperties platformProperties = new KubernetesPlatformProperties(); | ||
KubernetesDeployerProperties deployerProperties = new KubernetesDeployerProperties(); | ||
deployerProperties.getLimits().setMemory("5555Mi"); | ||
KubernetesTaskLauncherProperties taskLauncherProperties = new KubernetesTaskLauncherProperties(); | ||
taskLauncherProperties.setBackoffLimit(5); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do we test for the backofflimit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. We aren't testing backoffLimit in this test case rather the next one does. I kept this test as it used to be (except adding the new properties arg) |
||
taskLauncherProperties.setRestartPolicy(RestartPolicy.Never); | ||
platformProperties.setAccounts(Collections.singletonMap("k8s", deployerProperties)); | ||
|
||
KubernetesPlatformTaskLauncherProperties platformTaskLauncherProperties = new KubernetesPlatformTaskLauncherProperties(); | ||
platformTaskLauncherProperties.setAccounts(Collections.singletonMap("k8s", taskLauncherProperties)); | ||
KubernetesTaskPlatformFactory kubernetesTaskPlatformFactory = new KubernetesTaskPlatformFactory( | ||
platformProperties, true); | ||
platformProperties, true, platformTaskLauncherProperties); | ||
|
||
TaskPlatform taskPlatform = kubernetesTaskPlatformFactory.createTaskPlatform(); | ||
assertThat(taskPlatform.getName()).isEqualTo("Kubernetes"); | ||
|
@@ -80,6 +89,11 @@ public void kubernetesTaskPlatformWithScheduler() { | |
|
||
+ "\\[.+\\], api version = \\[.+\\]$"); | ||
|
||
KubernetesTaskLauncherProperties taskLauncherProps = (KubernetesTaskLauncherProperties) ReflectionTestUtils.getField(taskLauncher.getTaskLauncher(), "taskLauncherProperties"); | ||
|
||
assertThat(taskLauncherProps.getBackoffLimit()).isEqualTo(5); | ||
assertThat(taskLauncherProps.getRestartPolicy()).isEqualTo(RestartPolicy.Never); | ||
|
||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2021