Skip to content

Commit

Permalink
Extended validator to AbstractStructuredLogValidator (#1486)
Browse files Browse the repository at this point in the history
* extended validator to AbstractStructuredLogValidator

* deleted loadgenerator
  • Loading branch information
Danielzolty authored Dec 15, 2023
1 parent 7c30bf6 commit f751d85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public abstract class AbstractStructuredLogValidator implements IValidator {

protected CloudWatchService cloudWatchService;
protected final ObjectMapper mapper = new ObjectMapper();
protected ICaller caller;

@Override
public void init(
Expand All @@ -62,6 +63,7 @@ public void init(
FileConfig expectedDataTemplate)
throws Exception {
cloudWatchService = new CloudWatchService(context.getRegion());
this.caller = caller;
init(context, expectedDataTemplate);

if (StringUtils.isNullOrEmpty(logGroupName)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.amazon.aoc.validators;

import com.amazon.aoc.callers.ICaller;
import com.amazon.aoc.exception.BaseException;
import com.amazon.aoc.exception.ExceptionCode;
import com.amazon.aoc.fileconfigs.FileConfig;
import com.amazon.aoc.helpers.MustacheHelper;
import com.amazon.aoc.helpers.RetryHelper;
import com.amazon.aoc.models.Context;
import com.amazon.aoc.models.ValidationConfig;
import com.amazon.aoc.services.CloudWatchService;
import com.amazonaws.services.logs.model.OutputLogEvent;
import com.fasterxml.jackson.databind.JsonNode;
Expand All @@ -24,38 +22,25 @@
import lombok.extern.log4j.Log4j2;

@Log4j2
public class CWLogValidator implements IValidator {
public class CWLogValidator extends AbstractStructuredLogValidator {

protected String logStreamName = "otlp-logs";

private static final String LOGGROUPPATH = "/aws/ecs/otlp/%s/logs";

protected CloudWatchService cloudWatchService;
private static final int CHECK_INTERVAL_IN_MILLI = 30 * 1000;
private static final int CHECK_DURATION_IN_SECONDS = 2 * 60;
private static int MAX_RETRY_COUNT = 12;
private static final int QUERY_LIMIT = 100;
private JsonSchema schema;
protected String logGroupName;

private ICaller caller;

private Context context;
private String templateInput;

private ProcessingReport processingReport = null;

protected final ObjectMapper mapper = new ObjectMapper();

@Override
public void init(
Context context,
ValidationConfig validationConfig,
ICaller caller,
FileConfig expectedDataTemplate)
throws Exception {
this.context = context;
this.caller = caller;
void init(Context context, FileConfig expectedDataTemplate) throws Exception {
cloudWatchService = new CloudWatchService(context.getRegion());
logGroupName = String.format(LOGGROUPPATH, context.getTestingId());
MustacheHelper mustacheHelper = new MustacheHelper();
Expand All @@ -67,6 +52,12 @@ public void init(
.freeze();
JsonSchema jsonSchema = jsonSchemaFactory.getJsonSchema(jsonNode);
this.schema = jsonSchema;
schemasToValidate.put("json", this.schema);
}

@Override
String getJsonSchemaMappingKey(JsonNode jsonNode) {
return null;
}

@Override
Expand Down

0 comments on commit f751d85

Please sign in to comment.