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

Time consumer detection #6

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f9c4113
Ignite 2.7.5 released. no need for staging
dspavlov Jun 11, 2019
6a5572f
TC Bot modules refactoring: GitHub module extracted
dspavlov Jun 13, 2019
ef7ba95
TC Bot modules refactoring: JIRA module extracted, PR processor moved…
dspavlov Jun 13, 2019
c38dcdb
Build and tests fix after modules refactoring, version update
dspavlov Jun 18, 2019
47f23e7
Trusted tests & suite history performance fixes: Storage into persist…
dspavlov Jun 25, 2019
be469c9
Fix of too-short history
dspavlov Jun 26, 2019
9801cc6
Fix of too-short history: negative values in build start time cache fix
dspavlov Jun 26, 2019
5573467
Issue detection bug fixed: build TS problem fixed
dspavlov Jul 1, 2019
f77b3af
Added ability to filter failed suites by tag on status test page (#130)
akalash Jul 1, 2019
72f53ef
Updates for issue list page
dspavlov Jul 1, 2019
ab47aab
IGNITE-11947: More debug information added to locate problem with not…
dspavlov Jul 1, 2019
8f69c4a
IGNITE-11947: Fix for handling failures of email/slack sending, retri…
dspavlov Jul 1, 2019
a4433f3
IGNITE-11947: Fix for resending relatively fresh failures: removed di…
dspavlov Jul 1, 2019
26622f3
IGNITE-11947: Extracting heuristics into constants
dspavlov Jul 2, 2019
5ea380b
Fix in master trends: sorting list of builds
dspavlov Jul 4, 2019
01b8722
Build time collection callable: first version, too long execution time
dspavlov Jul 5, 2019
72fb441
Build time collection callable: change scan flow to build ref instead…
dspavlov Jul 5, 2019
a0f564b
Build time collection callable: Build running time collection impleme…
dspavlov Jul 5, 2019
023c9e6
Time consuming builds detection: Supported return of results > 1h by bt
dspavlov Jul 6, 2019
f88ba17
Time consuming builds detection: Prefiltering server side
dspavlov Jul 6, 2019
e0b4e78
Time consuming builds detection: moved to async computation in scheduler
dspavlov Jul 6, 2019
f5c7802
Time consuming builds detection
dspavlov Jul 6, 2019
ced1624
Time consuming builds detection, including timed out suites
dspavlov Jul 6, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ subprojects {
}

allprojects {
apply plugin: 'java'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

ext {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'

jettyVer = '9.4.12.v20180830'

Expand All @@ -58,13 +59,19 @@ allprojects {
slf4jVer = '1.7.25'

gsonVer = '2.8.2'

junitVer = '4.12'
mockitoVer = '2.22.0'
}

repositories {
//uncomment for RC testing
maven {
url "https://repository.apache.org/content/repositories/orgapacheignite-1463/"
}
// maven {
// url "https://repository.apache.org/content/repositories/orgapacheignite-1463/"
// }

mavenCentral()
mavenLocal()
}
}

Expand Down
12 changes: 0 additions & 12 deletions ignite-tc-helper-web/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@
apply plugin: 'java'
apply plugin: 'war'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'

repositories {
mavenCentral()
mavenLocal()
}

// https://www.apache.org/legal/resolved.html#category-a
dependencies {
compile (project(":tcbot-common"));
Expand Down Expand Up @@ -72,12 +64,8 @@ dependencies {
}

processResources {

// Minify json resources
from(sourceSets.test.resources.srcDirs) {
include "**/*.json"

// Minify every file here
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ public static <K, V> CacheConfiguration<K, V> getCacheV2TxConfig(String name) {

}

@NotNull
public static <K, V> CacheConfiguration<K, V> getCache8PartsConfig(String name) {
CacheConfiguration<K, V> ccfg = new CacheConfiguration<>(name);

ccfg.setAffinity(new RendezvousAffinityFunction(false, 8));

return ccfg;
}

public static class LocalOnlyTcpDiscoveryIpFinder implements TcpDiscoveryIpFinder {
/** Port. */
private int port;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import org.apache.ignite.Ignite;
import org.apache.ignite.ci.db.Ignite1Init;
import org.apache.ignite.ci.di.cache.GuavaCachedModule;
import org.apache.ignite.ci.di.scheduler.SchedulerModule;
import org.apache.ignite.ci.github.ignited.GitHubIgnitedModule;
import org.apache.ignite.ci.jira.ignited.JiraIgnitedModule;
import org.apache.ignite.tcbot.persistence.scheduler.SchedulerModule;
import org.apache.ignite.githubignited.GitHubIgnitedModule;
import org.apache.ignite.jiraignited.JiraIgnitedModule;
import org.apache.ignite.ci.observer.BuildObserver;
import org.apache.ignite.ci.observer.ObserverTask;
import org.apache.ignite.ci.tcbot.TcBotBusinessServicesModule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.ignite.ci.issue;

import com.google.common.base.MoreObjects;

public class ChangeUi {
public final String username;
public final String webUrl;
Expand All @@ -41,4 +43,12 @@ public String toSlackMarkup() {
public String toPlainText() {
return username + " " + webUrl;
}

/** {@inheritDoc} */
@Override public String toString() {
return MoreObjects.toStringHelper(this)
.add("username", username)
.add("webUrl", webUrl)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,27 @@
import com.google.common.base.MoreObjects;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.Map;
import java.util.TreeSet;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.ignite.tcbot.persistence.Persisted;
import org.apache.ignite.tcbot.common.util.TimeUtil;
import org.jetbrains.annotations.Nullable;

/**
*
* Issue used both for saving into DB and in UI (in issue history).
*/
@SuppressWarnings("WeakerAccess")
@SuppressWarnings({"WeakerAccess", "PublicField"})
@Persisted
public class Issue {
/** Type code. Null of older versions of issue */
@Nullable
private String type;
public String type;

/** Display type. for issue. Kept for backward compatibilty with older records without type code. */
private String displayType;
Expand All @@ -57,7 +60,7 @@ public class Issue {
@Nullable
public String displayName;

/** Build start timestamp. */
/** Build start timestamp. Builds which is older that 10 days not notified. */
@Nullable public Long buildStartTs;

/** Detected timestamp. */
Expand All @@ -66,11 +69,21 @@ public class Issue {
/** Set of build tags detected. */
public Set<String> buildTags = new TreeSet<>();

public Issue(IssueKey issueKey, IssueType type) {
/** Statistics of subscribers for this issue. Filled accordignly recent update. */
public Map<String, Object> stat = new HashMap<>();

/** Notification failed: Map from address to exception text */
@Nullable public Map<String, String> notificationFailed = new HashMap<>();

public int notificationRetry = 0;

public Issue(IssueKey issueKey, IssueType type,
@Nullable Long buildStartTs) {
this.issueKey = issueKey;
this.detectedTs = System.currentTimeMillis();
this.type = type.code();
this.displayType = type.displayName();
this.buildStartTs = buildStartTs;
}

public void addChange(String username, String webUrl) {
Expand Down Expand Up @@ -230,4 +243,32 @@ public String toPlainText(boolean includeChangesInfo) {
public String type() {
return type;
}

/** {@inheritDoc} */
@Override public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Issue issue = (Issue)o;
return notificationRetry == issue.notificationRetry &&
Objects.equals(type, issue.type) &&
Objects.equals(displayType, issue.displayType) &&
Objects.equals(trackedBranchName, issue.trackedBranchName) &&
Objects.equals(issueKey, issue.issueKey) &&
Objects.equals(changes, issue.changes) &&
Objects.equals(addressNotified, issue.addressNotified) &&
Objects.equals(webUrl, issue.webUrl) &&
Objects.equals(displayName, issue.displayName) &&
Objects.equals(buildStartTs, issue.buildStartTs) &&
Objects.equals(detectedTs, issue.detectedTs) &&
Objects.equals(buildTags, issue.buildTags) &&
Objects.equals(stat, issue.stat) &&
Objects.equals(notificationFailed, issue.notificationFailed);
}

/** {@inheritDoc} */
@Override public int hashCode() {
return Objects.hash(type, displayType, trackedBranchName, issueKey, changes, addressNotified, webUrl, displayName, buildStartTs, detectedTs, buildTags, stat, notificationFailed, notificationRetry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

package org.apache.ignite.ci.issue;

import java.util.HashMap;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import javax.annotation.Nullable;
import javax.cache.Cache;
import javax.inject.Inject;
import javax.inject.Provider;
Expand Down Expand Up @@ -52,17 +54,60 @@ public static IgniteCache<IssueKey, Issue> botDetectedIssuesCache(Ignite ignite)
}

/** {@inheritDoc} */
@Override public boolean setNotified(IssueKey issueKey, String to) {
@Override public boolean getIsNewAndSetNotified(IssueKey issueKey, String to,
@Nullable Exception e) {
Issue issue = cache().get(issueKey);
if (issue == null)
return false;

boolean add = issue.addressNotified.add(to);
boolean update;
if (e == null) {
if (issue.notificationRetry >= 2 && issue.notificationFailed.containsKey(to))
return false; // no more tries;

if (add)
update = issue.addressNotified.add(to);

if (update && issue.notificationFailed != null)
issue.notificationFailed.remove(to);
}
else {
if (issue.notificationRetry < 2)
issue.addressNotified.remove(to);

issue.notificationRetry++;

if (issue.notificationFailed == null)
issue.notificationFailed = new HashMap<>();

issue.notificationFailed.put(to, e.getClass().getSimpleName() + ": " + e.getMessage());

update = true;
}

if (update)
cache().put(issueKey, issue);

return add;
return update;
}

@Override
public void saveIssueSubscribersStat(IssueKey issueKey, int cntSrvAllowed, int cntSubscribed,
int cntTagsFilterPassed) {
Issue issue = cache().get(issueKey);
if (issue == null)
return;

int hashCode = issue.hashCode();

if (issue.stat == null)
issue.stat = new HashMap<>();

issue.stat.put("cntSrvAllowed", cntSrvAllowed);
issue.stat.put("cntSubscribed", cntSubscribed);
issue.stat.put("cntTagsFilterPassed", cntTagsFilterPassed);

if (issue.hashCode() != hashCode)
cache().put(issueKey, issue); // protect from odd writes
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
* Class for sending email with configured credentials.
*/
public class EmailSender {
public static boolean sendEmail(String to, String subject, String html, String plainText,
NotificationsConfig notifications) {
public static void sendEmail(String to, String subject, String html, String plainText,
NotificationsConfig notifications) throws MessagingException {

String user = notifications.emailUsernameMandatory();

Expand All @@ -58,42 +58,34 @@ public static boolean sendEmail(String to, String subject, String html, String p
}
});

try {
// Create a default MimeMessage object.
MimeMessage msg = new MimeMessage(ses);
// Create a default MimeMessage object.
MimeMessage msg = new MimeMessage(ses);

// Set From: header field of the header.
msg.setFrom(new InternetAddress(from));
// Set From: header field of the header.
msg.setFrom(new InternetAddress(from));

// Set To: header field of the header.
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
// Set To: header field of the header.
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to));

// Set Subject: header field
msg.setSubject(subject);
// Set Subject: header field
msg.setSubject(subject);

final MimeBodyPart textPart = new MimeBodyPart();
textPart.setContent(plainText, "text/plain");
// HTML version
final MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(html, "text/html");
final MimeBodyPart textPart = new MimeBodyPart();
textPart.setContent(plainText, "text/plain");
// HTML version
final MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(html, "text/html");

// Create the Multipart. Add BodyParts to it.
final Multipart mp = new MimeMultipart("alternative");
mp.addBodyPart(textPart);
mp.addBodyPart(htmlPart);
// Set Multipart as the message's content
msg.setContent(mp);
// Create the Multipart. Add BodyParts to it.
final Multipart mp = new MimeMultipart("alternative");
mp.addBodyPart(textPart);
mp.addBodyPart(htmlPart);
// Set Multipart as the message's content
msg.setContent(mp);

// Send message
Transport.send(msg);
// Send message
Transport.send(msg);

System.out.println("Sent message successfully to [" + to + "]...");

return true;
}
catch (MessagingException mex) {
mex.printStackTrace();
}
return false;
System.out.println("Sent message successfully to [" + to + "]...");
}
}
Loading