|
|
|
@ -44,6 +44,7 @@ public class K8sTaskTest {
|
|
|
|
|
|
|
|
|
|
private K8sTask k8sTask = null; |
|
|
|
|
private final String image = "ds-dev"; |
|
|
|
|
private final String imagePullPolicy = "IfNotPresent"; |
|
|
|
|
|
|
|
|
|
private final String namespace = "{\"name\":\"default\",\"cluster\":\"lab\"}"; |
|
|
|
|
|
|
|
|
@ -65,6 +66,7 @@ public class K8sTaskTest {
|
|
|
|
|
public void before() { |
|
|
|
|
k8sTaskParameters = new K8sTaskParameters(); |
|
|
|
|
k8sTaskParameters.setImage(image); |
|
|
|
|
k8sTaskParameters.setImagePullPolicy(imagePullPolicy); |
|
|
|
|
k8sTaskParameters.setNamespace(namespace); |
|
|
|
|
k8sTaskParameters.setMinCpuCores(minCpuCores); |
|
|
|
|
k8sTaskParameters.setMinMemorySpace(minMemorySpace); |
|
|
|
@ -97,7 +99,7 @@ public class K8sTaskTest {
|
|
|
|
|
@Test |
|
|
|
|
public void testBuildCommandNormal() { |
|
|
|
|
String expectedStr = |
|
|
|
|
"{\"image\":\"ds-dev\",\"command\":\"[\\\"/bin/bash\\\", \\\"-c\\\"]\",\"args\":\"[\\\"echo hello world\\\"]\",\"namespaceName\":\"default\",\"clusterName\":\"lab\",\"minCpuCores\":2.0,\"minMemorySpace\":10.0,\"paramsMap\":{\"day\":\"20220507\"},\"labelMap\":{\"test\":\"1234\"},\"nodeSelectorRequirements\":[{\"key\":\"node-label\",\"operator\":\"In\",\"values\":[\"1234\",\"12345\"]}]}"; |
|
|
|
|
"{\"image\":\"ds-dev\",\"command\":\"[\\\"/bin/bash\\\", \\\"-c\\\"]\",\"args\":\"[\\\"echo hello world\\\"]\",\"namespaceName\":\"default\",\"clusterName\":\"lab\",\"imagePullPolicy\":\"IfNotPresent\",\"minCpuCores\":2.0,\"minMemorySpace\":10.0,\"paramsMap\":{\"day\":\"20220507\"},\"labelMap\":{\"test\":\"1234\"},\"nodeSelectorRequirements\":[{\"key\":\"node-label\",\"operator\":\"In\",\"values\":[\"1234\",\"12345\"]}]}"; |
|
|
|
|
String commandStr = k8sTask.buildCommand(); |
|
|
|
|
Assertions.assertEquals(expectedStr, commandStr); |
|
|
|
|
} |
|
|
|
@ -105,7 +107,7 @@ public class K8sTaskTest {
|
|
|
|
|
@Test |
|
|
|
|
public void testGetParametersNormal() { |
|
|
|
|
String expectedStr = |
|
|
|
|
"K8sTaskParameters(image=ds-dev, namespace={\"name\":\"default\",\"cluster\":\"lab\"}, command=[\"/bin/bash\", \"-c\"], customizedLabels=[Label(label=test, value=1234)], nodeSelectors=[NodeSelectorExpression(key=node-label, operator=In, values=1234,12345)], args=[\"echo hello world\"], minCpuCores=2.0, minMemorySpace=10.0)"; |
|
|
|
|
"K8sTaskParameters(image=ds-dev, namespace={\"name\":\"default\",\"cluster\":\"lab\"}, command=[\"/bin/bash\", \"-c\"], args=[\"echo hello world\"], imagePullPolicy=IfNotPresent, minCpuCores=2.0, minMemorySpace=10.0, customizedLabels=[Label(label=test, value=1234)], nodeSelectors=[NodeSelectorExpression(key=node-label, operator=In, values=1234,12345)])"; |
|
|
|
|
String result = k8sTask.getParameters().toString(); |
|
|
|
|
Assertions.assertEquals(expectedStr, result); |
|
|
|
|
} |
|
|
|
|