|
1 | 1 | package org.csanchez.jenkins.plugins.kubernetes;
|
2 | 2 |
|
3 |
| -import static org.junit.Assert.assertEquals; |
4 |
| -import static org.junit.Assert.assertNull; |
5 |
| -import static org.junit.Assert.fail; |
6 |
| - |
7 | 3 | import java.util.ArrayList;
|
8 | 4 | import java.util.Arrays;
|
9 | 5 | import java.util.Collections;
|
|
21 | 17 | import com.gargoylesoftware.htmlunit.html.HtmlFormUtil;
|
22 | 18 | import com.gargoylesoftware.htmlunit.html.HtmlInput;
|
23 | 19 | import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
| 20 | +import hudson.model.Label; |
| 21 | +import hudson.slaves.Cloud; |
24 | 22 | import org.apache.commons.beanutils.PropertyUtils;
|
25 | 23 | import org.apache.commons.lang3.RandomStringUtils;
|
26 | 24 | import org.apache.commons.lang3.RandomUtils;
|
|
38 | 36 |
|
39 | 37 | import jenkins.model.JenkinsLocationConfiguration;
|
40 | 38 |
|
| 39 | +import static org.junit.Assert.*; |
| 40 | + |
41 | 41 | public class KubernetesCloudTest {
|
42 | 42 |
|
43 | 43 | @Rule
|
@@ -297,6 +297,20 @@ public void readResolveContainerCapZero() {
|
297 | 297 | assertEquals(cloud.getContainerCap(), Integer.MAX_VALUE);
|
298 | 298 | }
|
299 | 299 |
|
| 300 | + @Test |
| 301 | + public void maintenanceModeNoProvision() throws Exception { |
| 302 | + String testNodeLabel="test-node"; |
| 303 | + PodTemplate podTemplate=new PodTemplate("test"); |
| 304 | + podTemplate.setLabel(testNodeLabel); |
| 305 | + KubernetesCloud cloud = new KubernetesCloud("kubernetes"); |
| 306 | + cloud.addTemplate(podTemplate); |
| 307 | + Cloud.CloudState state=new Cloud.CloudState(Label.parseExpression(testNodeLabel),1); |
| 308 | + assertTrue(cloud.canProvision(state)); |
| 309 | + // disable provision |
| 310 | + cloud.setMaintenanceMode(true); |
| 311 | + assertFalse(cloud.canProvision(state)); |
| 312 | + } |
| 313 | + |
300 | 314 | public HtmlInput getInputByName(DomElement root, String name) {
|
301 | 315 | DomNodeList<HtmlElement> inputs = root.getElementsByTagName("input");
|
302 | 316 | for (HtmlElement input : inputs) {
|
|
0 commit comments