Skip to content
Permalink
Browse files
Merge pull request #413 from lvotypko/JENKINS-49026
Avoid JENKINS-49026.
  • Loading branch information
olivergondza committed Mar 8, 2018
2 parents b452448 + 6a9d98e commit 2a6b4ce0b06abc0e547f91e447839cb1e0766325
@@ -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;
@@ -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();
@@ -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.
*/
@@ -197,6 +221,9 @@ public void should_set_build_to_unstable_if_total_warnings_threshold_set() {
*/
@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);
@@ -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();
@@ -2,6 +2,7 @@

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

@@ -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);

@@ -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);

@@ -67,6 +67,9 @@
@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();
@@ -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;
@@ -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;
@@ -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 -> {

0 comments on commit 2a6b4ce

Please sign in to comment.