diff options
author | 2018-08-14 11:23:35 +0200 | |
---|---|---|
committer | 2018-08-14 11:23:35 +0200 | |
commit | 05dd5d2fd893f526eb6a807afb5725c8e426dd52 (patch) | |
tree | 780c4506ed6e69d053b49c5c116f5727648838d9 /vid-automation/src/test/java/org/opencomp/vid/more/LoggerFormatTest.java | |
parent | a55efc25f0ec1cca1a1accedb2bb7fce66d597a9 (diff) |
Renaming vid-automation #6
Change-Id: I0971c966ddcd76927bdf1a4c4d47afc900987ddf
Issue-ID: VID-205
Signed-off-by: kurczews <krzysztof.kurczewski@nokia.com>
Diffstat (limited to 'vid-automation/src/test/java/org/opencomp/vid/more/LoggerFormatTest.java')
-rw-r--r-- | vid-automation/src/test/java/org/opencomp/vid/more/LoggerFormatTest.java | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/vid-automation/src/test/java/org/opencomp/vid/more/LoggerFormatTest.java b/vid-automation/src/test/java/org/opencomp/vid/more/LoggerFormatTest.java deleted file mode 100644 index 8b3d244b5..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/more/LoggerFormatTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.opencomp.vid.more; - -import com.fasterxml.jackson.databind.JsonNode; -import org.apache.commons.lang3.StringUtils; -import org.opencomp.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; -import org.opencomp.vid.api.BaseApiTest; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.web.client.RestTemplate; -import org.testng.SkipException; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import vid.automation.test.services.SimulatorApi; - -import java.net.URI; -import java.time.LocalDate; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static java.util.Collections.singletonList; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.junit.Assert.assertThat; - -public class LoggerFormatTest extends BaseApiTest { - - - // See: https://wiki.web.att.com/display/KSAT/REST-based+Log+Checker - private final static String logChecker = "http://eelflogcheck.it.att.com:31820/validate"; - - @BeforeClass - public void login() { - super.login(); - } - - @BeforeClass - public void setAaiSubscribers() { - SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); - } - - @Test - public void validateAuditLogsFormat() { - validateLogsFormat("audit"); - } - - @Test(enabled = false) // no total-score is returned for error-log - public void validateErrorLogsFormat() { - validateLogsFormat("error"); - } - - @Test - public void validateMetricsLogsFormat() { - validateLogsFormat("metrics", "metric"); - } - - private void validateLogsFormat(String logName) { - validateLogsFormat(logName, logName); - } - - private void validateLogsFormat(String logName, String logType) { - - String logLines = getLogLines(logName); - JsonNode response = getCheckerResults(logType, logLines); - - System.out.println(response); - double fieldscore = response.path("summary").path("score").path("fieldscore").asDouble(); - double overall = response.path("summary").path("score").path("overallscore").asDouble(); - - assertThat(fieldscore, is(greaterThan(0.95))); - assertThat(overall, is(greaterThan(0.95))); - - } - - private String getLogLines(String logname) { - return getLogLines(logname, 5000, 30, restTemplate, uri); - } - - public static String getLogLines(String logname, int maxRows, int minRows, RestTemplate restTemplate, URI uri) { - String logLines = restTemplate.getForObject(uri + "/logger/" + logname + "?limit={maxRows}", String.class, maxRows); - assertThat("expecting at least " + minRows + " rows in " + logname, - StringUtils.countMatches(logLines, '\n') + 1, - is(greaterThanOrEqualTo(minRows))); - return logLines; - } - - private JsonNode getCheckerResults(String logtype, String logLines) { - Map<String, String> params = new HashMap<>(); - params.put("format", "raw"); - params.put("type", logtype); - params.put("component", "vid"); - params.put("data", logLines); - - return restTemplate.postForObject(logChecker, params, JsonNode.class); - } -} |