-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
56d1e48
[JENKINS-57993] Integration test to verify that no warnings are print…
jglick 0b57163
Incremental deployment.
jglick ad084b6
Merge branch 'master' into quiet-JENKINS-57993
jglick 454db5c
Picking up another core fix, and streaming the agent log where any Ab…
jglick eb8ac21
Merge branch 'master' into quiet-JENKINS-57993
jglick b171034
Merged into 2.181.
jglick 5330793
Merge branch 'master' into quiet-JENKINS-57993
jglick 1c4aefa
Merge branch 'master' into quiet-JENKINS-57993
jglick f09ce18
Merge branch 'master' into quiet-JENKINS-57993
jglick 5a8e1de
Merge branch 'master' into quiet-JENKINS-57993
jglick 87cd5e5
Update to LTS.
jglick 58f52ed
Merge branch 'master' into quiet-JENKINS-57993
jglick 45edbbe
Need to ensure we have trilead-api in test scope.
jglick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,7 @@ | |
package org.csanchez.jenkins.plugins.kubernetes.pipeline; | ||
|
||
import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.*; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.hasEntry; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hamcrest.Matchers.*; | ||
import static org.junit.Assert.*; | ||
import static org.junit.Assume.*; | ||
|
||
|
@@ -39,6 +37,7 @@ | |
import java.util.logging.Logger; | ||
import java.util.stream.Collectors; | ||
|
||
import hudson.model.Computer; | ||
import com.gargoylesoftware.htmlunit.html.DomNodeUtil; | ||
import com.gargoylesoftware.htmlunit.html.HtmlElement; | ||
import com.gargoylesoftware.htmlunit.html.HtmlPage; | ||
|
@@ -60,6 +59,7 @@ | |
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.jvnet.hudson.test.JenkinsRuleNonLocalhost; | ||
import org.jvnet.hudson.test.LoggerRule; | ||
|
||
import hudson.model.Result; | ||
import java.util.Locale; | ||
|
@@ -75,13 +75,17 @@ public class KubernetesPipelineTest extends AbstractKubernetesPipelineTest { | |
@Rule | ||
public TemporaryFolder tmp = new TemporaryFolder(); | ||
|
||
@Rule | ||
public LoggerRule warnings = new LoggerRule(); | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
deletePods(cloud.connect(), getLabels(cloud, this, name), false); | ||
logs.capture(1000); | ||
warnings.record("", Level.WARNING).capture(1000); | ||
assertNotNull(createJobThenScheduleRun()); | ||
} | ||
|
||
@Issue("JENKINS-57993") | ||
@Test | ||
public void runInPod() throws Exception { | ||
SemaphoreStep.waitForStart("podTemplate/1", b); | ||
|
@@ -100,17 +104,29 @@ public void runInPod() throws Exception { | |
|
||
Map<String, String> labels = getLabels(cloud, this, name); | ||
SemaphoreStep.waitForStart("pod/1", b); | ||
for (Computer c : r.jenkins.getComputers()) { // TODO perhaps this should be built into JenkinsRule via ComputerListener.preLaunch? | ||
new Thread(() -> { | ||
long pos = 0; | ||
try { | ||
while (Jenkins.getInstanceOrNull() != null) { // otherwise get NPE from Computer.getLogDir | ||
if (c.getLogFile().isFile()) { // TODO should LargeText.FileSession handle this? | ||
pos = c.getLogText().writeLogTo(pos, System.out); | ||
} | ||
Thread.sleep(100); | ||
} | ||
} catch (Exception x) { | ||
x.printStackTrace(); | ||
} | ||
}, "watching logs for " + c.getDisplayName()).start(); | ||
System.out.println(c.getLog()); | ||
} | ||
PodList pods = cloud.connect().pods().withLabels(labels).list(); | ||
assertThat( | ||
"Expected one pod with labels " + labels + " but got: " | ||
+ pods.getItems().stream().map(pod -> pod.getMetadata()).collect(Collectors.toList()), | ||
pods.getItems(), hasSize(1)); | ||
SemaphoreStep.success("pod/1", null); | ||
|
||
for (String msg : logs.getMessages()) { | ||
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. Not very useful; left over from 23a0fce. |
||
System.out.println(msg); | ||
} | ||
|
||
PodTemplate template = templates.get(0); | ||
List<PodAnnotation> annotations = template.getAnnotations(); | ||
assertNotNull(annotations); | ||
|
@@ -136,6 +152,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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
jenkinsci/ssh-credentials-plugin#47