Skip to content

Commit

Permalink
[ALL] Uniform Replay PLugins..all
Browse files Browse the repository at this point in the history
  • Loading branch information
kendarorg committed Nov 28, 2024
1 parent 31d6496 commit 217d0e7
Show file tree
Hide file tree
Showing 34 changed files with 518 additions and 657 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Independent from the stack you are using
### Scenarios

* Simulate what-if without hitting real servers
* Testing resiliency, errors, latency, throttling and wrong data
* Testing resiliency, errors and wrong data
* Security analisys (what goes on the wire)
* Test new APIs easily
* Understand all consequences of changes
Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
<module>jacoco</module>
<module>protocol-http</module>
<module>sample-plugins</module>
<module>protocol-common-jdbc</module>
</modules>

<properties>
<revision>2.1.2</revision>
<revision>2.1.3</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
Expand All @@ -38,7 +39,7 @@
<mongodb.version>4.11.0</mongodb.version>
<snappy.version>1.1.8.4</snappy.version>
<zstd.version>1.5.2-2</zstd.version>
<hibernate.version>5.2.6.Final</hibernate.version>
<hibernate.version>5.4.0.Final</hibernate.version>
<jaxb.api.version>2.3.0</jaxb.api.version>
<commons.cli.version>1.6.0</commons.cli.version>
<amqp.client.version>5.20.0</amqp.client.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.kendar.events.EventsQueue;
import org.kendar.events.WriteItemEvent;
import org.kendar.plugins.settings.BasicRecordPluginSettings;
import org.kendar.proxy.PluginContext;
import org.kendar.settings.GlobalSettings;
import org.kendar.settings.PluginSettings;
import org.kendar.settings.ProtocolSettings;
import org.kendar.sql.jdbc.SelectResult;
import org.kendar.sql.jdbc.proxy.JdbcCall;
Expand All @@ -16,7 +18,8 @@

import java.util.List;

public abstract class JdbcRecordingPlugin extends RecordingPlugin {
public abstract class JdbcRecordPlugin extends RecordPlugin<BasicRecordPluginSettings> {


@Override
protected void postCall(PluginContext pluginContext, Object obIn, Object obOUt) {
Expand Down Expand Up @@ -64,16 +67,16 @@ public List<ProtocolPhase> getPhases() {
}

@Override
public PluginDescriptor initialize(GlobalSettings global, ProtocolSettings protocol) {
public PluginDescriptor initialize(GlobalSettings global, ProtocolSettings protocol, PluginSettings pluginSetting) {
withStorage((StorageRepository) global.getService("storage"));
super.initialize(global, protocol);
super.initialize(global, protocol, pluginSetting);
return this;
}

@Override
protected void handleActivation(boolean active) {
if(this.isActive()!=active){
this.storage.isRecording(getInstanceId(),active);
if (this.isActive() != active) {
this.storage.isRecording(getInstanceId(), active);
}
if (!active) {
terminate();
Expand Down

This file was deleted.

25 changes: 5 additions & 20 deletions protocol-common/src/main/java/org/kendar/plugins/MockPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

public abstract class MockPlugin<T, K> extends ProtocolPluginDescriptor<T, K> {
public abstract class MockPlugin<T, K> extends ProtocolPluginDescriptor<T, K, BasicMockPluginSettings> {
protected final ConcurrentHashMap<Long, AtomicInteger> counters = new ConcurrentHashMap<>();
protected List<MockStorage> mocks = new ArrayList<>();
private String mocksDir;
Expand Down Expand Up @@ -70,23 +70,13 @@ protected abstract void writeOutput(T request, K response,
protected abstract List<MockStorage> firstCheckOnMainPart(T request);

@Override
public PluginDescriptor initialize(GlobalSettings global, ProtocolSettings protocol) {
public PluginDescriptor initialize(GlobalSettings global, ProtocolSettings protocol, PluginSettings pluginSetting) {

super.initialize(global, protocol);
var thisPlugin = (BasicMockPluginSettings) protocol.getPlugins().get(getId());
if (thisPlugin != null) {
mocksDir = thisPlugin.getDataDir();
}
return this;

}


public PluginDescriptor setSettings(GlobalSettings globalSettings, PluginSettings plugin) {
super.setSettings(globalSettings, plugin);
this.mocksDir = ((BasicMockPluginSettings) plugin).getDataDir();
super.initialize(global, protocol, pluginSetting);
mocksDir = getSettings().getDataDir();
loadMocks();
return this;

}

protected void loadMocks() {
Expand Down Expand Up @@ -125,11 +115,6 @@ public void terminate() {

}

@Override
public Class<?> getSettingClass() {
return BasicMockPluginSettings.class;
}

public String getMocksDir() {
return mocksDir;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,66 @@

import java.util.List;

public interface PluginDescriptor extends ExtensionPoint {
/**
* Basic Protocol Plugin
*/
public interface PluginDescriptor<W extends PluginSettings> extends ExtensionPoint {
/**
* Phases for the protocol
*
* @return
*/
List<ProtocolPhase> getPhases();

/**
* Id of the plugin
*
* @return
*/
String getId();

/**
* Associable protocols
*
* @return
*/
String getProtocol();

PluginDescriptor initialize(GlobalSettings global, ProtocolSettings protocol);
/**
* Initialize the plugin and protocol
*
* @param global
* @param protocol
* @param pluginSetting
* @return
*/
PluginDescriptor initialize(GlobalSettings global, ProtocolSettings protocol, PluginSettings pluginSetting);

/**
* Terminate the plugin
*/
void terminate();

/**
* Clone, this is need to overcome the missing construtors in plugin system
*
* @return
*/
PluginDescriptor clone();

/**
* The settings class
*
* @return
*/
Class<?> getSettingClass();

PluginDescriptor setSettings(GlobalSettings globalSettings, PluginSettings plugin);

boolean isActive();

void setActive(boolean active);
void forceActivation();

void refreshStatus();

PluginApiHandler getApiHandler();
}
Loading

0 comments on commit 217d0e7

Please sign in to comment.