Skip to content

Commit

Permalink
RadarGun reports should include server configuration file for client-…
Browse files Browse the repository at this point in the history
…server mode tests
  • Loading branch information
mgencur committed Jan 18, 2017
1 parent 471da10 commit 26db768
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Expand Up @@ -26,7 +26,7 @@
*/
public class IndexDocument extends HtmlDocument {
private static final Log log = LogFactory.getLog(IndexDocument.class);
private Map<Report, Set<OriginalConfig>> configs = new HashMap<>();
private Map<Report, Map<String, Set<OriginalConfig>>> configs = new HashMap<>();
private Set<String> normalized = new HashSet<>();

public IndexDocument(String directory) {
Expand All @@ -45,17 +45,17 @@ private void writeConfig(Cluster cluster, Configuration.Setup setup, OriginalCon
}
}

private void addToConfigs(Set<OriginalConfig> configs, int slave, String filename, byte[] content) {
private void addToConfigs(Map<String, Set<OriginalConfig>> configs, String group, int slave, String filename, byte[] content) {
boolean found = false;
for (OriginalConfig config : configs) {
for (OriginalConfig config : configs.get(group)) {
if (config.filename.equals(filename) && Arrays.equals(config.content, content)) {
config.slaves.add(slave);
found = true;
break;
}
}
if (!found) {
configs.add(new OriginalConfig(slave, filename, content));
configs.get(group).add(new OriginalConfig(slave, filename, content));
}
}

Expand All @@ -66,26 +66,28 @@ private void addToConfigs(Set<OriginalConfig> configs, int slave, String filenam
*/
public void prepareServiceConfigs(Collection<Report> reports) {
for (Report report : reports) {
Map<String, Set<OriginalConfig>> configs = new HashMap<>();
for (Configuration.Setup setup : report.getConfiguration().getSetups()) {
Set<Integer> slaves = report.getCluster().getSlaves(setup.group);

if (configs.get(setup.group) == null) {
configs.put(setup.group, new HashSet<>());
}
for (Map.Entry<Integer, Map<String, Properties>> entry : report.getNormalizedServiceConfigs().entrySet()) {
if (slaves.contains(entry.getKey()) && entry.getValue() != null) {
normalized.addAll(entry.getValue().keySet());
}
}

Set<OriginalConfig> configs = new HashSet<>();
for (Map.Entry<Integer, Map<String, byte[]>> entry : report.getOriginalServiceConfig().entrySet()) {
if (slaves.contains(entry.getKey()) && entry.getValue() != null) {
for (Map.Entry<String, byte[]> file : entry.getValue().entrySet()) {
addToConfigs(configs, entry.getKey(), file.getKey(), file.getValue());
addToConfigs(configs, setup.group, entry.getKey(), file.getKey(), file.getValue());
}
}
}
this.configs.put(report, configs);

for (OriginalConfig config : configs) {
for (OriginalConfig config : configs.get(setup.group)) {
writeConfig(report.getCluster(), setup, config);
}
}
Expand All @@ -97,8 +99,8 @@ public void prepareServiceConfigs(Collection<Report> reports) {
* e.g. method getPercentiles() can be used as getPercentiles() or percentiles in template
*/

public Set<OriginalConfig> getConfigs(Report report) {
return configs.get(report);
public Set<OriginalConfig> getConfigs(Report report, String groupName) {
return configs.get(report).get(groupName);
}

public String getFilename(String configName, String groupName, Cluster cluster, String config) {
Expand Down
Expand Up @@ -30,15 +30,15 @@
<ul>
<li>Plugin: ${setup.plugin}</li>
<li>Service: ${setup.service}</li>
<#if (indexDocument.getConfigs(report))?size == 0>
<#if (indexDocument.getConfigs(report, setup.group))?size == 0>
<#assign fileName = (setup.properties["file"])!" no file" />
<li>Configuration file: ${fileName}</li>

<#else>
<li>
Configuration files:
<ul>
<#list (indexDocument.getConfigs(report)) as config>
<#list (indexDocument.getConfigs(report, setup.group)) as config>
<li>
<a href="${getConfigFileName(setup.configuration.name, setup.group, report.cluster.clusterIndex, config.filename)}"> ${config.filename}</a>
</li>
Expand Down

0 comments on commit 26db768

Please sign in to comment.