Skip to content

Commit

Permalink
Release 2.3 (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
clauguinovart authored Mar 18, 2024
1 parent 43eed1e commit 8a484e0
Show file tree
Hide file tree
Showing 33 changed files with 3,267 additions and 553 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.blazemeter</groupId>
<artifactId>jmeter-bzm-correlation-recorder</artifactId>
<packaging>jar</packaging>
<version>2.2.1</version>
<version>2.3</version>
<name>Correlation Recorder as JMeter plugin</name>
<description>Correlation Recorder Plugin for JMeter</description>
<url>https://github.com/Blazemeter/CorrelationRecorder</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.blazemeter.jmeter.correlation.core.InvalidRulePartElementException;
import com.blazemeter.jmeter.correlation.core.RulesGroup;
import com.blazemeter.jmeter.correlation.core.automatic.CorrelationHistory;
import com.blazemeter.jmeter.correlation.core.automatic.FileManagementUtils;
import com.blazemeter.jmeter.correlation.core.automatic.JMeterElementUtils;
import com.blazemeter.jmeter.correlation.core.automatic.ResultFileParser;
import com.blazemeter.jmeter.correlation.core.proxy.ComparableCookie;
Expand Down Expand Up @@ -90,8 +91,8 @@ public class CorrelationProxyControl extends ProxyControl implements
private static final String CORRELATION_COMPONENTS = "CorrelationProxyControl.components";
private static final String RESPONSE_FILTER = "CorrelationProxyControl.responseFilter";
private static final String TEMPLATE_PATH = "CorrelationProxyControl.templatePath";
private static final String CORRELATION_HISTORY_PATH =
"CorrelationProxyControl.correlationHistoryPath";
private static final String CORRELATION_HISTORY_ID =
"CorrelationProxyControl.correlationHistoryId";
private static final String RECORDER_NAME = "bzm - Correlation Recorder";
// we use reflection to be able to call these non visible methods and not have to re implement
// them.
Expand Down Expand Up @@ -119,7 +120,7 @@ public class CorrelationProxyControl extends ProxyControl implements
private JMeterTreeNode target = null;
private List<SampleResult> samples = new ArrayList<>();
private Method putSamplesIntoModel;
private CorrelationHistory history = new CorrelationHistory();
private CorrelationHistory history;
private Runnable onStopRecordingMethod;
private String originalDisablingValue = null;

Expand Down Expand Up @@ -151,6 +152,7 @@ public CorrelationProxyControl(
templateRepositoryConfig;
this.localConfiguration = localConfiguration;
this.correlationEngine = correlationEngine;
configHistory();
}

public CorrelationTemplatesRepositoriesConfiguration getTemplateRepositoryConfig() {
Expand Down Expand Up @@ -291,7 +293,12 @@ public CorrelationRulesTestElement getCorrelationRulesTestElement() {
@Override
public synchronized void deliverSampler(HTTPSamplerBase sampler, TestElement[] testElements,
SampleResult result) {
pendingProxies.get(Thread.currentThread()).update(sampler, testElements, result);
if (pendingProxies.containsKey(Thread.currentThread())) {
pendingProxies.get(Thread.currentThread()).update(sampler, testElements, result);
} else {
LOG.error("Unexpected error. Proxy not found! {}", Thread.currentThread());
LOG.error(pendingProxies.keySet().toString());
}
}

public synchronized void startedProxy(Thread proxy) {
Expand All @@ -305,6 +312,7 @@ public synchronized void endedProxy(Thread proxy) {
is not invoked for used clientSocket
*/
if (pendingProxy == null) {
deliverPendingCompletedRequests();
return;
}
/*
Expand All @@ -324,7 +332,7 @@ private void deliverPendingCompletedRequests() {
while (it.hasNext()) {
PendingProxy proxy = it.next();
if (!proxy.isComplete()) {
return;
continue;
}
deliverCompletedProxy(proxy);
it.remove();
Expand Down Expand Up @@ -548,12 +556,12 @@ public void setCorrelationGroups(List<RulesGroup> groups) {
removeProperty(CORRELATION_RULES);
}

public void setCorrelationHistoryPath(String path) {
setProperty(CORRELATION_HISTORY_PATH, path);
public void setCorrelationHistoryId(String id) {
setProperty(CORRELATION_HISTORY_ID, id);
}

public void getCorrelationHistoryPath() {
getPropertyAsString(CORRELATION_HISTORY_PATH);
public String getCorrelationHistoryId() {
return getPropertyAsString(CORRELATION_HISTORY_ID);
}

public String getCorrelationComponents() {
Expand Down Expand Up @@ -658,12 +666,10 @@ public List<Template> getInstalledCorrelationTemplates() {
return localConfiguration.getInstalledTemplates();
}

public void update(String correlationComponents, List<RulesGroup> groups, String responseFilter,
String correlationHistoryPath) {
public void update(String correlationComponents, List<RulesGroup> groups, String responseFilter) {
setCorrelationComponents(correlationComponents);
setCorrelationGroups(groups);
setResponseFilter(responseFilter);
setCorrelationHistoryPath(correlationHistoryPath);
}

@Override
Expand Down Expand Up @@ -837,6 +843,20 @@ private void readObject(ObjectInputStream inputStream)
setName(RECORDER_NAME);
}

public CorrelationHistory configHistory() {
if (history == null) {
String correlationHistoryId = getCorrelationHistoryId();
if (!correlationHistoryId.isEmpty()) {
history = CorrelationHistory.loadFromFile(correlationHistoryId);
}
if (history == null) { // When no HistoryID or valid History load, create a new one
history = new CorrelationHistory();
history.configHistoryId(FileManagementUtils.getHistoryFilenamePropertyName());
}
}
return history;
}

public List<SampleResult> getSamples() {
return samples;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ public CorrelationProxyControlGui() {
Objects.requireNonNull(siebelPane).add("Correlation", rulesContainer);
add(new BlazemeterLabsLogo(), BorderLayout.SOUTH);

history = new CorrelationHistory();
wizard = new CorrelationWizard();
wizard.setHistory(history);
wizard.setRepositoriesSupplier(this::getRepositories);
wizard.setAddRuleConsumer(rulesContainer.obtainRulesExporter());
wizard.init();
Expand Down Expand Up @@ -148,15 +146,15 @@ public void modifyTestElement(TestElement el) {
super.modifyTestElement(el);
if (el instanceof CorrelationProxyControl) {
model = (CorrelationProxyControl) el;
history = model.configHistory();
model.update(rulesContainer.getCorrelationComponents(),
rulesContainer.getRulesGroups(),
rulesContainer.getResponseFilter(),
history.getHistoryPath());
rulesContainer.getResponseFilter());
//model.update(analysisPanel.getAnalysis());
model.setCorrelationHistory(history);
model.setCorrelationHistoryPath(history.getHistoryPath());
model.setCorrelationHistoryId(history.getHistoryId());
model.setOnStopRecordingMethod(() -> {
wizard.setHistory(history);
updateHistory(history);
wizard.requestPermissionToReplay();
});
}
Expand All @@ -178,15 +176,17 @@ public void configure(TestElement el) {
if (el instanceof CorrelationProxyControl) {
CorrelationProxyControl correlationProxyControl = (CorrelationProxyControl) el;
model = correlationProxyControl;
history = model.configHistory();
if (wizard != null) {
wizard.setRepositoriesConfiguration(model.getTemplateRepositoryConfig());
updateHistory(history);
}

CorrelationComponentsRegistry.getInstance().reset();
rulesContainer.configure(correlationProxyControl);
model.setOnStopRecordingMethod(() -> {
if (history != null) {
wizard.setHistory(history);
updateHistory(history);
}
wizard.requestPermissionToReplay();
});
Expand Down Expand Up @@ -373,4 +373,9 @@ public Map<String, Repository> getRepositories() {
return repositoryMap;
}

public void updateHistory(CorrelationHistory history) {
wizard.setHistory(history);
rulesContainer.setHistory(history);
}

}
Loading

0 comments on commit 8a484e0

Please sign in to comment.