Skip to content
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

[JENKINS-57993] Verify no warnings are printed for a basic build #503

Merged
merged 13 commits into from
Oct 7, 2019
Merged
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<connectorHost />
<jenkins.host.address />
<java.level>8</java.level>
<jenkins.version>2.138.4</jenkins.version>
<jenkins.version>2.181-SNAPSHOT</jenkins.version> <!-- TODO https://github.com/jenkinsci/jenkins/pull/4066 -->
jglick marked this conversation as resolved.
Show resolved Hide resolved
<no-test-jar>false</no-test-jar>
<useBeta>true</useBeta>
<surefire.rerunFailingTestsCount>0</surefire.rerunFailingTestsCount>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
package org.csanchez.jenkins.plugins.kubernetes.pipeline;

import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.*;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;

import java.util.List;
Expand All @@ -49,6 +48,7 @@
import org.junit.rules.TemporaryFolder;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRuleNonLocalhost;
import org.jvnet.hudson.test.LoggerRule;

import hudson.model.Result;
import java.util.Locale;
Expand All @@ -64,20 +64,24 @@ public class KubernetesPipelineTest extends AbstractKubernetesPipelineTest {
@Rule
public TemporaryFolder tmp = new TemporaryFolder();

@Rule
public LoggerRule warnings = new LoggerRule();

WorkflowJob p;

WorkflowRun b;

@Before
public void setUp() throws Exception {
deletePods(cloud.connect(), getLabels(cloud, this, name), false);
logs.capture(1000);
warnings.record("", Level.WARNING).capture(1000);
p = r.jenkins.createProject(WorkflowJob.class, getProjectName());
p.setDefinition(new CpsFlowDefinition(loadPipelineScript(name.getMethodName() + ".groovy"), true));
b = p.scheduleBuild2(0).waitForStart();
assertNotNull(b);
}

@Issue("JENKINS-57993")
@Test
public void runInPod() throws Exception {
SemaphoreStep.waitForStart("podTemplate/1", b);
Expand All @@ -103,10 +107,6 @@ public void runInPod() throws Exception {
pods.getItems(), hasSize(1));
SemaphoreStep.success("pod/1", null);

for (String msg : logs.getMessages()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very useful; left over from 23a0fce.

System.out.println(msg);
}

PodTemplate template = templates.get(0);
List<PodAnnotation> annotations = template.getAnnotations();
assertNotNull(annotations);
Expand All @@ -132,6 +132,11 @@ public void runInPod() throws Exception {
r.assertLogContains("script file contents: ", b);
assertFalse("There are pods leftover after test execution, see previous logs",
deletePods(cloud.connect(), getLabels(cloud, this, name), true));
assertThat("routine build should not issue warnings",
warnings.getRecords().stream().
filter(lr -> lr.getLevel().intValue() >= Level.WARNING.intValue()). // TODO .record(…, WARNING) does not accomplish this
map(lr -> lr.getSourceClassName() + "." + lr.getSourceMethodName() + ": " + lr.getMessage()).collect(Collectors.toList()), // LogRecord does not override toString
emptyIterable());
}

@Test
Expand Down