Skip to content
Permalink
Browse files
Mutes page fix: support configurable prefix for Jira ticket names. - F…
…ixes #103.

Signed-off-by: Dmitriy Pavlov <dpavlov@apache.org>
  • Loading branch information
SomeFire authored and dspavlov committed Dec 21, 2018
1 parent f27995d commit 88579f81a103341d374c72388510ac28b84aceaa
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 14 deletions.
@@ -6,6 +6,7 @@ git.api_url=https://api.github.com/repos/apache/ignite/
jira.api_url=https://issues.apache.org/jira/rest/api/2/

jira.url=https://issues.apache.org/jira/
jira.ticket_template=IGNITE-

#specify JIRA Auth token (if needed)
jira.auth_token=
@@ -63,6 +63,9 @@ public class HelperConfig {
/** JIRA URL to build links to tickets. */
public static final String JIRA_URL = "jira.url";

/** Template for JIRA ticket names. */
public static final String JIRA_TICKET_TEMPLATE = "jira.ticket_template";

/** Slack authorization token property name. */
public static final String SLACK_AUTH_TOKEN = "slack.auth_token";
public static final String SLACK_CHANNEL = "slack.channel";
@@ -55,6 +55,9 @@ public Visa notifyJira(String srvId, ICredentialsProv prov, String buildTypeId,
/** */
public String jiraUrl();

/** */
public String ticketTemplate();

/** */
public void init(String srvId);

@@ -38,6 +38,9 @@ public class Jira implements IJiraIntegration {
/** */
private String jiraUrl;

/** */
private String jiraTicketTemplate;

/** {@inheritDoc} */
@Override public void init(String srvId) {
final File workDir = HelperConfig.resolveWorkDir();
@@ -47,13 +50,20 @@ public class Jira implements IJiraIntegration {
final Properties props = HelperConfig.loadAuthProperties(workDir, cfgName);

jiraUrl = props.getProperty(HelperConfig.JIRA_URL);
jiraTicketTemplate = props.getProperty(HelperConfig.JIRA_TICKET_TEMPLATE,
"IGNITE-");
}

/** {@inheritDoc} */
@Override public String jiraUrl() {
return jiraUrl;
}

/** {@inheritDoc} */
@Override public String ticketTemplate() {
return jiraTicketTemplate;
}

/** {@inheritDoc} */
@Override public Visa notifyJira(String srvId, ICredentialsProv prov, String buildTypeId, String branchForTc,
String ticket) {
@@ -32,11 +32,11 @@ public class Ticket {
public Fields fields;

/**
* @param ticketTemplate Ticket name template.
* @return Ignite id (like 123 in IGNITE-123).
*/
public int igniteId() {
//todo support non ignite/configurable prefix/string ID from compactor;
return Integer.valueOf(key.substring("IGNITE-".length()));
public int igniteId(String ticketTemplate) {
return Integer.valueOf(key.substring(ticketTemplate.length()));
}

/**
@@ -91,9 +91,10 @@ public static long ticketToCacheKey(int srvIdMaskHigh, int igniteId) {
*
* @param srvIdMaskHigh Server id mask high.
* @param chunk Chunk.
* @param ticketTemplate Ticket name template.
*/
@AutoProfiling
public void saveChunk(int srvIdMaskHigh, Collection<Ticket> chunk) {
public void saveChunk(int srvIdMaskHigh, Collection<Ticket> chunk, String ticketTemplate) {
Preconditions.checkNotNull(jiraCache, "init() was not called");

if (F.isEmpty(chunk))
@@ -102,8 +103,8 @@ public void saveChunk(int srvIdMaskHigh, Collection<Ticket> chunk) {
HashMap<Long, TicketCompacted> compactedTickets = new HashMap<>(U.capacity(chunk.size()));

for (Ticket ticket : chunk) {
long key = ticketToCacheKey(srvIdMaskHigh, ticket.igniteId());
TicketCompacted val = new TicketCompacted(ticket, compactor);
long key = ticketToCacheKey(srvIdMaskHigh, ticket.igniteId(ticketTemplate));
TicketCompacted val = new TicketCompacted(ticket, compactor, ticketTemplate);

compactedTickets.put(key, val);
}
@@ -69,7 +69,7 @@ private String actualizeJiraTickets(int srvIdMaskHigh, ITeamcityConn conn, ICred
if (F.isEmpty(page))
return "Something went wrong - no tickets found. Check jira availability.";

jiraDao.saveChunk(srvIdMaskHigh, page);
jiraDao.saveChunk(srvIdMaskHigh, page, jira.ticketTemplate());

int ticketsSaved = page.size();

@@ -84,7 +84,7 @@ private String actualizeJiraTickets(int srvIdMaskHigh, ITeamcityConn conn, ICred
if (F.isEmpty(page))
break;

jiraDao.saveChunk(srvIdMaskHigh, page);
jiraDao.saveChunk(srvIdMaskHigh, page, jira.ticketTemplate());

ticketsSaved += page.size();
}
@@ -38,11 +38,11 @@ public class TicketCompacted {
/**
* @param ticket Jira ticket.
* @param comp Compactor.
* @param ticketTemplate Ticket name template.
*/
public TicketCompacted(Ticket ticket, IStringCompactor comp) {
public TicketCompacted(Ticket ticket, IStringCompactor comp, String ticketTemplate) {
id = ticket.id;
//todo support non ignite/configurable prefix/string ID from compactor;
igniteId = Integer.valueOf(ticket.key.substring("IGNITE-".length()));
igniteId = Integer.valueOf(ticket.key.substring(ticketTemplate.length()));
status = comp.getStringId(ticket.fields.status.name);
}

@@ -82,6 +82,7 @@
table.DataTable({
data: mutes,
"iDisplayLength": 30, //rows to be shown by default
"order": [[ 0, 'asc' ], [ 1, 'asc' ]],
stateSave: true,
columnDefs: [
{
@@ -194,9 +195,7 @@
}
}
]
})
.order( [[ 0, 'asc' ], [ 1, 'asc' ]] )
.draw();
});
}

function separateMutedTests(result) {

0 comments on commit 88579f8

Please sign in to comment.