Skip to content

Commit

Permalink
Added data to the execution meta data. Things like the number of tests,
Browse files Browse the repository at this point in the history
number of failed tests and the number of machines. 
Also updated the view to show the data in the table. 
Issue #21
  • Loading branch information
itaiag committed May 4, 2015
1 parent ac352b5 commit 3ca173f
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 3 deletions.
10 changes: 10 additions & 0 deletions difido-server/difido-report-server/docRoot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<th>Folder Name</th>
<th>Date</th>
<th>Time</th>
<th># Tests</th>
<th># Success</th>
<th># Warning</th>
<th># Fails</th>
<th># Machines</th>
<th>Active</th>
</tr>
</thead>
Expand Down Expand Up @@ -88,6 +93,11 @@
tr.append($('<td>').append($('<a>').text(this.folderName).attr("href",this.uri).attr("target","_blank")));
tr.append($('<td>').text(this.date));
tr.append($('<td>').text(this.time));
tr.append($('<td>').text(this.numOfTests));
tr.append($('<td>').text(this.numOfSuccessfulTests));
tr.append($('<td>').text(this.numOfTestsWithWarnings));
tr.append($('<td>').text(this.numOfFailedTests));
tr.append($('<td>').text(this.numOfMachines));
tr.append($('<td>').text(this.active));
$(table).append(tr);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import il.co.topq.difido.model.execution.Execution;
import il.co.topq.difido.model.execution.MachineNode;
import il.co.topq.difido.model.execution.Node;
import il.co.topq.difido.model.execution.ScenarioNode;
import il.co.topq.difido.model.execution.TestNode;
import il.co.topq.difido.model.test.TestDetails;
import il.co.topq.report.Common;
import il.co.topq.report.Configuration;
Expand Down Expand Up @@ -61,7 +64,7 @@ public int addExecution() {
}

private void writeExecutionMeta() {
if (null == executionsCache){
if (null == executionsCache) {
return;
}
synchronized (fileAccessLockObject) {
Expand Down Expand Up @@ -89,7 +92,7 @@ private int getMaxId() {

private void readExecutionMeta() {
if (executionsCache != null) {
//We read it already
// We read it already
return;
}
synchronized (fileAccessLockObject) {
Expand All @@ -103,7 +106,7 @@ private void readExecutionMeta() {
new TypeReference<Map<Integer, ExecutionMetaData>>() {
});
executionsCache = Collections.synchronizedMap(executionsCache);
for (ExecutionMetaData meta : executionsCache.values()){
for (ExecutionMetaData meta : executionsCache.values()) {
meta.setActive(false);
}
} catch (IOException e) {
Expand All @@ -118,12 +121,69 @@ private void readExecutionMeta() {
public ExecutionMetaData getExecutionMetaData(int executionId) {
readExecutionMeta();
ExecutionMetaData executionMetaData = executionsCache.get(executionId);
if (executionMetaData.isActive()) {
updateSingleExecutionMeta(executionId);
}
return new ExecutionMetaData(executionMetaData);
}

private void updateSingleExecutionMeta(int executionId) {
ExecutionMetaData executionMetaData = executionsCache.get(executionId);
if (executionMetaData.getExecution() == null || executionMetaData.getExecution().getLastMachine() == null) {
return;
}
int numOfTests = 0;
int numOfSuccessfulTests = 0;
int numOfFailedTests = 0;
int numOfTestsWithWarnings = 0;
int numOfMachines = 0;

for (MachineNode machine : executionMetaData.getExecution().getMachines()) {
numOfMachines++;
final List<ScenarioNode> scenarios = machine.getChildren();
if (null == scenarios) {
continue;
}
for (ScenarioNode scenario : scenarios) {
for (Node node : scenario.getChildren(true)) {
if (node instanceof TestNode) {
numOfTests++;
switch (node.getStatus()) {
case success:
numOfSuccessfulTests++;
break;
case error:
case failure:
numOfFailedTests++;
break;
case warning:
numOfTestsWithWarnings++;
default:
break;
}
}
}
}
}
synchronized (executionMetaData) {
executionMetaData.setNumOfTests(numOfTests);
executionMetaData.setNumOfFailedTests(numOfFailedTests);
executionMetaData.setNumOfSuccessfulTests(numOfSuccessfulTests);
executionMetaData.setNumOfTestsWithWarnings(numOfTestsWithWarnings);
executionMetaData.setNumOfMachines(numOfMachines);
}

}

public ExecutionMetaData[] getAllMetaData() {
readExecutionMeta();
final List<ExecutionMetaData> result = new ArrayList<ExecutionMetaData>();
for (int executionId : executionsCache.keySet()) {
ExecutionMetaData meta = executionsCache.get(executionId);
if (meta.isActive()) {
updateSingleExecutionMeta(executionId);
}
}
result.addAll(executionsCache.values());
return result.toArray(new ExecutionMetaData[] {});
}
Expand Down Expand Up @@ -172,6 +232,8 @@ private boolean isExecutionActive(int index) {

@Override
public void executionAdded(int executionId, Execution execution) {
// This method is mostly triggered by this class, so there is not much
// sense usually to add logic in here.
}

@Override
Expand All @@ -180,6 +242,7 @@ public void executionEnded(int executionId, Execution execution) {
if (null == metadata) {
log.error("Trying to disable execution with id " + executionId + " which is not exist");
}
updateMetaData();
metadata.setActive(false);
writeExecutionMeta();
}
Expand All @@ -195,6 +258,22 @@ private void updateExecutionLastUpdateTime(int executionId) {
@Override
public void machineAdded(int executionId, MachineNode machine) {
updateExecutionLastUpdateTime(executionId);
updateMetaData();
writeExecutionMeta();
}

/**
* Updates the state of all the active executions.
*/
private void updateMetaData() {
for (int executionId : executionsCache.keySet()) {
final ExecutionMetaData meta = executionsCache.get(executionId);
if (!meta.active) {
continue;
}
updateSingleExecutionMeta(executionId);
}

}

@Override
Expand Down Expand Up @@ -233,8 +312,19 @@ public static class ExecutionMetaData {
private String time;

private boolean active;

private long lastAccessedTime;

private int numOfTests;

private int numOfSuccessfulTests;

private int numOfFailedTests;

private int numOfTestsWithWarnings;

private int numOfMachines;

@JsonIgnore
private Execution execution;
private String timestamp;
Expand All @@ -254,6 +344,11 @@ public ExecutionMetaData(final ExecutionMetaData metaData) {
this.time = metaData.time;
this.timestamp = metaData.timestamp;
this.uri = metaData.uri;
this.numOfTests = metaData.numOfTests;
this.numOfSuccessfulTests = metaData.numOfSuccessfulTests;
this.numOfFailedTests = metaData.numOfFailedTests;
this.numOfTestsWithWarnings = metaData.numOfTestsWithWarnings;
this.numOfMachines = metaData.numOfMachines;
}
}

Expand Down Expand Up @@ -338,6 +433,46 @@ public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}

public int getNumOfTests() {
return numOfTests;
}

public void setNumOfTests(int numOfTests) {
this.numOfTests = numOfTests;
}

public int getNumOfSuccessfulTests() {
return numOfSuccessfulTests;
}

public void setNumOfSuccessfulTests(int numOfSuccessfulTests) {
this.numOfSuccessfulTests = numOfSuccessfulTests;
}

public int getNumOfFailedTests() {
return numOfFailedTests;
}

public void setNumOfFailedTests(int numOfFailedTests) {
this.numOfFailedTests = numOfFailedTests;
}

public int getNumOfTestsWithWarnings() {
return numOfTestsWithWarnings;
}

public void setNumOfTestsWithWarnings(int numOfTestsWithWarnings) {
this.numOfTestsWithWarnings = numOfTestsWithWarnings;
}

public int getNumOfMachines() {
return numOfMachines;
}

public void setNumOfMachines(int numOfMachines) {
this.numOfMachines = numOfMachines;
}

}

}

0 comments on commit 3ca173f

Please sign in to comment.