diff --git a/validator/build.gradle b/validator/build.gradle index 1558cc52b..02350df2b 100644 --- a/validator/build.gradle +++ b/validator/build.gradle @@ -53,7 +53,6 @@ dependencies { implementation 'com.amazonaws:aws-java-sdk-xray' implementation 'com.amazonaws:aws-java-sdk-logs' implementation 'com.amazonaws:aws-java-sdk-sts' - implementation group: 'javax.json', name: 'javax.json-api', version: '1.0-b01' // aws ecs sdk implementation 'com.amazonaws:aws-java-sdk-ecs' @@ -74,7 +73,6 @@ dependencies { // k8s client implementation "io.kubernetes:client-java-extended:18.0.1" - testImplementation("com.github.rholder:guava-retrying:2.0.0") } application { diff --git a/validator/src/main/java/com/amazon/aoc/App.java b/validator/src/main/java/com/amazon/aoc/App.java index 72a2bcdd9..1c75a73b0 100644 --- a/validator/src/main/java/com/amazon/aoc/App.java +++ b/validator/src/main/java/com/amazon/aoc/App.java @@ -149,15 +149,12 @@ public Integer call() throws Exception { context.setLanguage(language); context.setKubernetesContext(this.buildKubernetesContext()); log.info(context); - log.info("URL is: " + configPath); // load config List validationConfigList = new ConfigLoadHelper().loadConfigFromFile(configPath); - log.info("App - config was loaded"); // run validation validate(context, validationConfigList); - log.info("App - validation completed"); Instant endTime = Instant.now(); Duration duration = Duration.between(startTime, endTime); log.info("Validation has completed in {} minutes.", duration.toMinutes()); diff --git a/validator/src/main/java/com/amazon/aoc/callers/HttpCaller.java b/validator/src/main/java/com/amazon/aoc/callers/HttpCaller.java index 3b79071b0..1640fe5fb 100644 --- a/validator/src/main/java/com/amazon/aoc/callers/HttpCaller.java +++ b/validator/src/main/java/com/amazon/aoc/callers/HttpCaller.java @@ -47,15 +47,12 @@ public HttpCaller(String endpoint, String path) { @Override public SampleAppResponse callSampleApp() throws Exception { - log.info("Sample app was called"); OkHttpClient client = new OkHttpClient(); - log.info("Sample app - OkHttpClient"); Request request = new Request.Builder().url(url).build(); - log.info("Sample app - request builder"); + AtomicReference sampleAppResponseAtomicReference = new AtomicReference<>(); - log.info("Sample app - Atomic reference"); RetryHelper.retry( - 15, + 40, () -> { try (Response response = client.newCall(request).execute()) { String responseBody = response.body().string(); diff --git a/validator/src/main/java/com/amazon/aoc/helpers/MustacheHelper.java b/validator/src/main/java/com/amazon/aoc/helpers/MustacheHelper.java index 83115430f..ca9a8953c 100644 --- a/validator/src/main/java/com/amazon/aoc/helpers/MustacheHelper.java +++ b/validator/src/main/java/com/amazon/aoc/helpers/MustacheHelper.java @@ -45,13 +45,9 @@ public String render(FileConfig fileConfig, Object dataToInject) throws IOExcept private String render(URL path, Object dataToInject) throws IOException { log.info("fetch config: {}", path); String templateContent = IOUtils.toString(path); - log.info("Got template Content"); Mustache mustache = mustacheFactory.compile(new StringReader(templateContent), path.getPath()); - log.info("Got mustache"); StringWriter stringWriter = new StringWriter(); - log.info("fGot stringWriter"); mustache.execute(stringWriter, dataToInject).flush(); - log.info("Mustache executed"); return stringWriter.getBuffer().toString(); } } diff --git a/validator/src/main/java/com/amazon/aoc/helpers/RetryHelper.java b/validator/src/main/java/com/amazon/aoc/helpers/RetryHelper.java index f559f8792..1681d3fb0 100644 --- a/validator/src/main/java/com/amazon/aoc/helpers/RetryHelper.java +++ b/validator/src/main/java/com/amazon/aoc/helpers/RetryHelper.java @@ -43,7 +43,6 @@ public static boolean retry( } catch (Exception ex) { exceptionInTheEnd = ex; if (retryCount != 0) { // don't sleep before leave this loop - log.info("Error that occured:" + ex.getMessage()); log.info( "retrying after {} seconds", TimeUnit.MILLISECONDS.toSeconds(sleepInMilliSeconds)); TimeUnit.MILLISECONDS.sleep(sleepInMilliSeconds); diff --git a/validator/src/main/java/com/amazon/aoc/validators/CWLogValidator.java b/validator/src/main/java/com/amazon/aoc/validators/CWLogValidator.java index 1691e2e88..c1dffe991 100644 --- a/validator/src/main/java/com/amazon/aoc/validators/CWLogValidator.java +++ b/validator/src/main/java/com/amazon/aoc/validators/CWLogValidator.java @@ -46,60 +46,23 @@ public void init( ICaller caller, FileConfig expectedDataTemplate) throws Exception { - log.info("CWLog init starting"); this.context = context; cloudWatchService = new CloudWatchService(context.getRegion()); logGroupName = String.format("otlp-receiver", context.getCloudWatchContext().getClusterName()); - log.info("CW Log group name is: " + logGroupName); - // cloudWatchService = new CloudWatchService(context.getRegion()); MustacheHelper mustacheHelper = new MustacheHelper(); String templateInput = mustacheHelper.render(expectedDataTemplate, context); - log.info("Template input: " + templateInput); JsonNode jsonNode = JsonLoader.fromString(templateInput); - log.info("Trying to get jsonNode string: " + jsonNode.textValue()); JsonSchemaFactory jsonSchemaFactory = JsonSchemaFactory.newBuilder() .setReportProvider(new ListReportProvider(LogLevel.INFO, LogLevel.FATAL)) .freeze(); JsonSchema jsonSchema = jsonSchemaFactory.getJsonSchema(jsonNode); this.schema = jsonSchema; - log.info(("CWLog init ending")); - Map mapping = new ObjectMapper().readValue(templateInput, HashMap.class); - // ObjectMapper mapper = new ObjectMapper(); - // ObjectNode jsonObject = mapper.readValue(templateInput, ObjectNode.class); - // Map result = - // mapper.convertValue(jsonObject, new TypeReference>() {}); - log.info("Mapper is:" + mapping.toString()); caller.callSampleApp(); } - // @Override - // public void init( - // Context context, - // ValidationConfig validationConfig, - // ICaller caller, - // FileConfig expectedDataTemplate) - // throws Exception { - // log.info("CWLog init starting"); - // this.context = context; - // logGroupName = String.format("otlp-receiver", - // context.getCloudWatchContext().getClusterName()); - // cloudWatchService = new CloudWatchService(context.getRegion()); - // MustacheHelper mustacheHelper = new MustacheHelper(); - // String templateInput = mustacheHelper.render(expectedDataTemplate, context); - // JsonNode jsonNode = JsonLoader.fromString(templateInput); - // JsonSchemaFactory jsonSchemaFactory = - // JsonSchemaFactory.newBuilder() - // .setReportProvider(new ListReportProvider(LogLevel.INFO, LogLevel.FATAL)) - // .freeze(); - // JsonSchema schema = jsonSchemaFactory.getJsonSchema(jsonNode); - // this.schema = schema; - // log.info(("CWLog init ending")); - // } - @Override public void validate() throws Exception { - log.info(("CWLog validate starting")); RetryHelper.retry( getMaxRetryCount(), CHECK_INTERVAL_IN_MILLI, @@ -107,13 +70,11 @@ public void validate() throws Exception { () -> { Instant startTime = Instant.now().minusSeconds(CHECK_DURATION_IN_SECONDS).truncatedTo(ChronoUnit.MINUTES); - log.info("Start time is: " + startTime.toEpochMilli()); fetchAndValidateLogs(startTime); }); } protected void fetchAndValidateLogs(Instant startTime) throws Exception { - log.info(("CWLog fetch starting")); List logEvents = cloudWatchService.getLogs( logGroupName, logStreamName, startTime.toEpochMilli(), QUERY_LIMIT); @@ -124,9 +85,7 @@ protected void fetchAndValidateLogs(Instant startTime) throws Exception { "[StructuredLogValidator] no logs found under log stream %s" + " in log group %s", logStreamName, logGroupName)); } - log.info("Number of log events: " + logEvents.size()); for (OutputLogEvent logEvent : logEvents) { - log.info("Log message: " + logEvent.getMessage()); if (logEvent.getMessage().contains("Executing outgoing-http-call")) { validateJsonSchema(logEvent.getMessage()); } @@ -134,14 +93,10 @@ protected void fetchAndValidateLogs(Instant startTime) throws Exception { } protected void validateJsonSchema(String logEventMsg) throws Exception { - log.info("In validateJsonSchema"); JsonNode logEventNode = mapper.readTree(logEventMsg); - log.info("In validateJsonSchema - post readTree"); if (schema != null) { - log.info("In validateJsonSchema - schema isn't null"); ProcessingReport report = schema.validate(JsonLoader.fromString(logEventNode.toString())); if (report.isSuccess()) { - // validatedSchema.add(key); log.info("Report was a success"); } else { // This will probably generate a lot of extra logs diff --git a/validator/src/main/java/com/amazon/aoc/validators/ValidatorFactory.java b/validator/src/main/java/com/amazon/aoc/validators/ValidatorFactory.java index 1f668fa7b..872697432 100644 --- a/validator/src/main/java/com/amazon/aoc/validators/ValidatorFactory.java +++ b/validator/src/main/java/com/amazon/aoc/validators/ValidatorFactory.java @@ -23,9 +23,7 @@ import com.amazon.aoc.models.Context; import com.amazon.aoc.models.ValidationConfig; import com.amazon.aoc.services.TaskService; -import lombok.extern.log4j.Log4j2; -@Log4j2 public class ValidatorFactory { private Context context; @@ -42,7 +40,6 @@ public ValidatorFactory(Context context) { */ public IValidator launchValidator(ValidationConfig validationConfig) throws Exception { // get validator - log.info("validator factory launch started"); IValidator validator; FileConfig expectedData = null; switch (validationConfig.getValidationType()) { @@ -54,12 +51,10 @@ public IValidator launchValidator(ValidationConfig validationConfig) throws Exce validator = new LoadBalancingValidator(); break; case "cw-metric": - log.info("cw-metrics got picked"); validator = new CWMetricValidator(); expectedData = validationConfig.getExpectedMetricTemplate(); break; case "cw-logs": - log.info("cw-logs got picked"); validator = new CWLogValidator(); expectedData = validationConfig.getExpectedLogStructureTemplate(); break; diff --git a/validator/src/main/resources/validations/spark-otel-log-validation.yml b/validator/src/main/resources/validations/spark-otel-log-validation.yml index f7f2b32e4..41a9f52af 100644 --- a/validator/src/main/resources/validations/spark-otel-log-validation.yml +++ b/validator/src/main/resources/validations/spark-otel-log-validation.yml @@ -3,4 +3,4 @@ httpPath: "/outgoing-http-call" httpMethod: "get" callingType: "http" - expectedLogStructureTemplate: "DEFAULT_EXPECTED_LOG" \ No newline at end of file + expectedLogStructureTemplate: "DEFAULT_EXPECTED_LOG"