-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
287 issue support for plaintext without a schema (#293)
* sending value string to kafka considering just one json str * added test and deleted JSON format validation * fixed codacy error * fixed to use generator for plainText * fixed codacy errors * fixed codacy error in ValueSimpleConfigElementTest * reduced cyclomatic complexity in configureValueGenerator method * changed parameter name in getLoadGenerator method * #287 Fix some style concepts * #287 Fix some style concepts * #287 Fix some style concepts Co-authored-by: Mike Ortiz <[email protected]> Co-authored-by: Diana Gómez <[email protected]> Co-authored-by: Jose Enrique García Maciñeiras <[email protected]>
- Loading branch information
1 parent
dcfbbed
commit 6f289ec
Showing
54 changed files
with
2,076 additions
and
2,277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/main/java/net/coru/kloadgen/config/valuesimple/ValueSimpleConfigElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package net.coru.kloadgen.config.valuesimple; | ||
|
||
import java.util.Objects; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.NoArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.coru.kloadgen.util.PropsKeysHelper; | ||
import org.apache.jmeter.config.ConfigTestElement; | ||
import org.apache.jmeter.engine.event.LoopIterationEvent; | ||
import org.apache.jmeter.engine.event.LoopIterationListener; | ||
import org.apache.jmeter.testbeans.TestBean; | ||
import org.apache.jmeter.threads.JMeterContextService; | ||
import org.apache.jmeter.threads.JMeterVariables; | ||
|
||
@Slf4j | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public final class ValueSimpleConfigElement extends ConfigTestElement implements TestBean, LoopIterationListener { | ||
|
||
private String valueSchemaProperties; | ||
|
||
private String schema = "NoSchema"; | ||
|
||
private String valueSubjectName = ""; | ||
|
||
private String valueSerializerConfiguration; | ||
|
||
@Override | ||
public void iterationStart(final LoopIterationEvent loopIterationEvent) { | ||
|
||
final JMeterVariables variables = JMeterContextService.getContext().getVariables(); | ||
variables.putObject(PropsKeysHelper.VALUE_SUBJECT_NAME, valueSubjectName); | ||
variables.putObject(PropsKeysHelper.VALUE_SCHEMA_TYPE, schema); | ||
variables.putObject(PropsKeysHelper.VALUE_SCHEMA_PROPERTIES, getValueSchemaProperties()); | ||
variables.putObject(PropsKeysHelper.VALUE_SERIALIZER_CLASS_PROPERTY, getValueSerializerConfiguration()); | ||
variables.putObject(PropsKeysHelper.SIMPLE_VALUED_MESSAGE_KEY, Boolean.TRUE); | ||
} | ||
|
||
public String getValueSchemaProperties() { | ||
return getPropertyAsString("valueSchemaProperties"); | ||
} | ||
|
||
public String getValueSerializerConfiguration() { | ||
return getPropertyAsString("valueSerializerConfiguration"); | ||
} | ||
|
||
public void setValueSchemaProperties(final String value) { | ||
setProperty("valueSchemaProperties", value); | ||
this.valueSchemaProperties = value; | ||
} | ||
|
||
public void setValueSerializerConfiguration(final String valueSerializerConfiguration) { | ||
setProperty("valueSerializerConfiguration", valueSerializerConfiguration); | ||
this.valueSerializerConfiguration = valueSerializerConfiguration; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
if (!super.equals(o)) { | ||
return false; | ||
} | ||
final ValueSimpleConfigElement that = (ValueSimpleConfigElement) o; | ||
return Objects.equals(getValueSchemaProperties(), that.getValueSchemaProperties()) | ||
&& Objects.equals(getValueSerializerConfiguration(), that.getValueSerializerConfiguration()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(super.hashCode(), getValueSchemaProperties(), getValueSerializerConfiguration()); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/net/coru/kloadgen/config/valuesimple/ValueSimpleConfigElementBeanInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package net.coru.kloadgen.config.valuesimple; | ||
|
||
import java.beans.PropertyDescriptor; | ||
|
||
import net.coru.kloadgen.property.editor.PlainValueSerializerPropertyEditor; | ||
import org.apache.jmeter.testbeans.BeanInfoSupport; | ||
|
||
public class ValueSimpleConfigElementBeanInfo extends BeanInfoSupport { | ||
|
||
private static final String VALUE_SCHEMA_PROPERTIES = "valueSchemaProperties"; | ||
|
||
private static final String VALUE_SERIALIZER_PROPERTY = "valueSerializerConfiguration"; | ||
|
||
public ValueSimpleConfigElementBeanInfo() { | ||
|
||
super(ValueSimpleConfigElement.class); | ||
|
||
createPropertyGroup("value_simple_configuration", new String[]{VALUE_SCHEMA_PROPERTIES, VALUE_SERIALIZER_PROPERTY}); | ||
|
||
final PropertyDescriptor keyValueProp = property(VALUE_SCHEMA_PROPERTIES); | ||
keyValueProp.setValue(DEFAULT, ""); | ||
keyValueProp.setValue(NOT_UNDEFINED, Boolean.TRUE); | ||
keyValueProp.setValue(NOT_EXPRESSION, Boolean.FALSE); | ||
|
||
final PropertyDescriptor schemaType = property(VALUE_SERIALIZER_PROPERTY); | ||
schemaType.setPropertyEditorClass(PlainValueSerializerPropertyEditor.class); | ||
schemaType.setValue(NOT_UNDEFINED, Boolean.TRUE); | ||
schemaType.setValue(DEFAULT, "org.apache.kafka.common.serialization.StringSerializer"); | ||
schemaType.setValue(NOT_EXPRESSION, Boolean.FALSE); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/net/coru/kloadgen/loadgen/impl/PlainTextLoadGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package net.coru.kloadgen.loadgen.impl; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import net.coru.kloadgen.loadgen.BaseLoadGenerator; | ||
import net.coru.kloadgen.model.FieldValueMapping; | ||
import net.coru.kloadgen.serializer.EnrichedRecord; | ||
|
||
@Slf4j | ||
@SuppressWarnings("checkstyle:AbbreviationAsWordInName") | ||
public final class PlainTextLoadGenerator implements SRLoadGenerator, BaseLoadGenerator { | ||
|
||
private List<FieldValueMapping> fieldExprMappings = new ArrayList<>(); | ||
|
||
@Override | ||
public void setUpGenerator(final Map<String, String> originals, final String avroSchemaName, final List<FieldValueMapping> fieldExprMappings) { | ||
this.fieldExprMappings = fieldExprMappings; | ||
} | ||
|
||
@Override | ||
public void setUpGenerator(final String schema, final List<FieldValueMapping> fieldExprMappings) { | ||
this.fieldExprMappings = fieldExprMappings; | ||
} | ||
|
||
public EnrichedRecord nextMessage() { | ||
final FieldValueMapping fieldValueMapping = fieldExprMappings.get(0); | ||
return EnrichedRecord.builder().genericRecord(fieldValueMapping.getFieldName()).build(); | ||
} | ||
|
||
} |
Oops, something went wrong.