Skip to content

Commit

Permalink
Merge pull request #413 from lvotypko/JENKINS-49026
Browse files Browse the repository at this point in the history
  • Loading branch information
olivergondza committed Mar 8, 2018
2 parents b452448 + 6a9d98e commit 2a6b4ce
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
30 changes: 30 additions & 0 deletions src/test/java/plugins/AbstractAnalysisTest.java
Expand Up @@ -10,6 +10,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -148,6 +150,9 @@ protected DumbSlave createDockerAgent() {
// TODO: we should have two builds so that the numbers are different
@Test @Issue("JENKINS-25501") @WithPlugins("email-ext")
public void should_send_mail_with_expanded_tokens() {
//avoid JENKINS-49026
checkExtensionAreDeployed("hudson.plugins.analysis.tokens.AbstractTokenMacro", Collections.EMPTY_SET);

setUpMailer();

FreeStyleJob job = createFreeStyleJob();
Expand All @@ -168,6 +173,25 @@ public void should_send_mail_with_expanded_tokens() {
String.format("%s: %d-0-%d", title, getNumberOfWarnings(), getNumberOfWarnings()));
}


/**
* Restart Jenkins if there is not required extension - see JENKINS-49026
*/
protected void checkExtensionAreDeployed(String extensionPointName, Set<String> extensionNames){
String result = jenkins.runScript("Jenkins.instance.getExtensionList(" + extensionPointName + ")");
boolean contains = false;
for(String s:extensionNames){
if(!result.contains(s)){
contains = false;
break;
}
contains = true;
}
if(result.contains("[]") || (!extensionNames.isEmpty() && !contains)){
jenkins.restart();
}
}

/**
* Runs a job with warning threshold configured once and validates that build is marked as unstable.
*/
Expand Down Expand Up @@ -197,6 +221,9 @@ private Class<? extends AnalysisSettings> getFreeStyleSettingsFor(final FreeStyl
*/
@Test @Issue("JENKINS-39947") @WithPlugins({"dashboard-view", "nested-view", "cloudbees-folder", "analysis-core@1.87"})
public void should_show_warnings_in_folder() {
//avoid JENKINS-49026
checkExtensionAreDeployed("hudson.plugins.analysis.dashboard.AbstractPortlet", Collections.EMPTY_SET);

NestedView nested = jenkins.getViews().create(NestedView.class);

DashboardView dashboard = nested.getViews().create(DashboardView.class);
Expand Down Expand Up @@ -230,6 +257,9 @@ public void should_show_warnings_in_folder() {
*/
@Test @WithPlugins("dashboard-view")
public void should_show_warning_totals_in_dashboard_portlet_with_link_to_results() {
//avoid JENKINS-49026
checkExtensionAreDeployed("hudson.plugins.analysis.dashboard.AbstractPortlet", Collections.EMPTY_SET);

FreeStyleJob job = createFreeStyleJob();

buildJobAndWait(job).shouldSucceed();
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/plugins/AnalysisCollectorPluginTest.java
Expand Up @@ -2,6 +2,7 @@

import javax.inject.Inject;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -322,6 +323,9 @@ public void should_set_warnings_count_in_list_view_column() {
@Test @Issue({"JENKINS-39950"}) @WithPlugins({"dashboard-view", "nested-view", "git", "workflow-job", "workflow-cps", "workflow-basic-steps", "workflow-durable-task-step", "workflow-multibranch"})
@WithDocker @WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = {"warnings", "/org/jenkinsci/test/acceptance/docker/fixtures/GitContainer/unsafe"})
public void should_open_links_in_folder_dashboard_and_nested_views() {
//avoid JENKINS-49026
checkExtensionAreDeployed("hudson.plugins.analysis.dashboard.AbstractPortlet", Collections.EMPTY_SET);

// Given
NestedView nested = jenkins.getViews().create(NestedView.class);

Expand Down Expand Up @@ -402,6 +406,9 @@ private WarningsPerProjectPortlet addWarningsPortlet(DashboardView dashboard) {
*/
@Test @WithPlugins("dashboard-view")
public void should_aggregate_warnings_in_dashboard_portlet() {
//avoid JENKINS-49026
checkExtensionAreDeployed("hudson.plugins.analysis.dashboard.AbstractPortlet", Collections.EMPTY_SET);

FreeStyleJob job = createFreeStyleJob();
buildSuccessfulJob(job);

Expand Down
3 changes: 3 additions & 0 deletions src/test/java/plugins/CheckStylePluginTest.java
Expand Up @@ -67,6 +67,9 @@ public class CheckStylePluginTest extends AbstractAnalysisTest<CheckStyleAction>
@Test @WithPlugins({"git", "dashboard-view", "analysis-core@1.88-SNAPSHOT"}) @WithDocker @Issue("JENKINS-6748")
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = {CREDENTIALS_ID, CREDENTIALS_KEY})
public void should_show_warnings_per_user() {
//avoid JENKINS-49026
jenkins.restart();

DumbSlave agent = createDockerAgent();

String gitRepositoryUrl = createGitRepositoryInDockerContainer();
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/plugins/WarningsPluginTest.java
@@ -1,5 +1,6 @@
package plugins;

import com.google.common.collect.Sets;
import org.jenkinsci.test.acceptance.junit.Resource;
import org.jenkinsci.test.acceptance.junit.WithCredentials;
import org.jenkinsci.test.acceptance.junit.WithDocker;
Expand Down Expand Up @@ -40,11 +41,7 @@
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -704,6 +701,9 @@ private void assertThatFilesTabIsCorrectlyFilled(final MatrixProject job) {
// TODO: check if we can remove this test since a similar one in parent
@Test @Issue("25501") @WithPlugins("email-ext")
public void should_send_mail_with_expanded_tokens() {
//avoid JENKINS-49026
checkExtensionAreDeployed( "hudson.plugins.analysis.tokens.AbstractTokenMacro", Sets.newHashSet("hudson.plugins.warnings.tokens.WarningsResultTokenMacro"));

setUpMailer();

FreeStyleJob job = createFreeStyleJob(settings -> {
Expand Down

0 comments on commit 2a6b4ce

Please sign in to comment.