Skip to content

Commit

Permalink
management of global wide dependencies related also to performance sy…
Browse files Browse the repository at this point in the history
…stems
  • Loading branch information
Vitor Graziano committed Nov 2, 2022
1 parent 711fe0b commit 0aa5f30
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 31 deletions.
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
<javadoc.plugin.version>3.4.0</javadoc.plugin.version>
<gpg.plugin.version>3.0.1</gpg.plugin.version>
<git.changelog.maven.plugin>1.95.2</git.changelog.maven.plugin>
<okhttp-version>4.10.0</okhttp-version>
<okhttp-mock-version>4.10.0-RC1</okhttp-mock-version>
<gson-version>2.9.1</gson-version>
</properties>

<dependencyManagement>
Expand All @@ -122,6 +125,26 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${okhttp-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>${okhttp-mock-version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
13 changes: 7 additions & 6 deletions system-x/services/horreum/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@
<name>TNB :: System-X :: Services :: Horreum</name>

<properties>
<gson-fire-version>1.8.5</gson-fire-version>
<swagger-core-version>1.6.3</swagger-core-version>
<okhttp-version>4.9.2</okhttp-version>
<gson-version>2.8.8</gson-version>
<jakarta-annotation-version>2.1.1</jakarta-annotation-version>
<threetenbp-version>1.6.0</threetenbp-version>
<google-code-findbugs-jsr305>3.0.2</google-code-findbugs-jsr305>
<okio-jvm-version>3.0.0</okio-jvm-version>
<gson-fire-version>1.8.5</gson-fire-version>
</properties>

<dependencies>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio-jvm</artifactId>
<version>${okio-jvm-version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
Expand All @@ -35,17 +39,14 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>${okhttp-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${okhttp-version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
<dependency>
<groupId>io.gsonfire</groupId>
Expand Down
22 changes: 20 additions & 2 deletions system-x/services/hyperfoil/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
<name>TNB :: System-X :: Services :: Hyperfoil</name>

<properties>
<gson-version>2.9.0</gson-version>
<commons-io-version>2.8.0</commons-io-version>
<okio-jvm-version>3.0.0</okio-jvm-version>
<gson-fire-version>1.8.5</gson-fire-version>
</properties>

Expand All @@ -23,16 +24,33 @@
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
<dependency>
<groupId>io.gsonfire</groupId>
<artifactId>gson-fire</artifactId>
<version>${gson-fire-version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io-version}</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio-jvm</artifactId>
<version>${okio-jvm-version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand All @@ -45,10 +47,31 @@ public HyperfoilValidation(String basePath) {
}

private String msgLogForRun(Run run) {
List<String> errors = run.getErrors();
if (errors != null && errors.size() > 0) {
return run.toString().replaceFirst("errors: \\[.+\\]", String.format("errors: %n%s%s", " ".repeat(8),
String.join(System.lineSeparator() + " ".repeat(8), errors)));
return msgLogForRun(run, null);
}

private String msgLogForRun(Run run, Integer oldErrorsSize) {
List<String> currentErrors = run.getErrors();
if (currentErrors != null && currentErrors.size() > 0) {
if (oldErrorsSize != null) {
currentErrors = currentErrors.subList(oldErrorsSize, currentErrors.size());
}
Map<String, List<String>> em = new HashMap<>();

currentErrors.stream().map(e -> e.split(":", 2)).forEach(es -> {
em.putIfAbsent(es[0], new LinkedList<String>());
em.get(es[0]).add(es[1]);
});
StringBuilder errMsgBuilder = new StringBuilder();
em.forEach((nodeName, errs) -> {
errMsgBuilder.append(" ".repeat(8)).append(nodeName).append(":")
.append(System.lineSeparator()).append(" ".repeat(12))
.append(String.join(System.lineSeparator() + " ".repeat(12), errs))
.append(System.lineSeparator());

});
return run.toString().replaceFirst("errors: \\[.+\\]", String.format("errors: %n%s",
errMsgBuilder.toString()));
} else {
return run.toString();
}
Expand Down Expand Up @@ -88,7 +111,7 @@ public void startAndWaitForBenchmark(String benchmark) {
* Load the benchmark hf.yaml on running hyperfoil server, run the benchmark,
* wait for result and save the report in the target folder
*
* @param benchmark - classpath or http/s endpoint
* @param benchmark - classpath or http/s endpoint
* @param applicationUnderTestEndpoint
* @return an object holding the startTime and endTime of the test
*/
Expand All @@ -107,8 +130,8 @@ public TestResult startAndWaitForBenchmark(String benchmark, String applicationU
* Load the benchmark hf.yaml on running hyperfoil server, run the benchmark,
* wait for result and save the report in the target folder
*
* @param benchmark classpath or http/s endpoint of a benchmark yaml or
* template
* @param benchmark classpath or http/s endpoint of a benchmark yaml or
* template
* @param parameters if not null the parameters will be supplied to the template
* @return an object holding the startTime and endTime of the test
*/
Expand Down Expand Up @@ -149,7 +172,7 @@ private String retrieveBenchmarkFile(String benchmarkUri) throws IOException {
HTTPUtils.Response response = HTTPUtils.getInstance(HTTPUtils.trustAllSslClient()).get(benchmarkUri);
if (response.getResponseCode() != 200) {
throw new RuntimeException(
"Call to " + benchmarkUri + " failed " + response.getResponseCode() + " " + response.getBody());
"Call to " + benchmarkUri + " failed " + response.getResponseCode() + " " + response.getBody());
}
benchmark = response.getBody();
} else {
Expand Down Expand Up @@ -214,7 +237,7 @@ public String addBenchmark(String benchmarkUri, String applicationUnderTestEndpo
((ObjectNode) httpNode).put("host", applicationUnderTestEndpoint);
} else if (httpNode.isArray()) {
throw new RuntimeException(
"Array node detected for http.host, impossible to distinguish which host should be replaced");
"Array node detected for http.host, impossible to distinguish which host should be replaced");
}
}

Expand Down Expand Up @@ -245,10 +268,12 @@ public Run getRun(String runId) {
}

public Run waitForRun(Run run) {
Integer errorsSize = run.getErrors().size();
try {
while (!run.getCompleted()) {
run = getDefaultApi().getRun(run.getId());
LOG.trace(msgLogForRun(run));
LOG.trace(msgLogForRun(run, errorsSize));
errorsSize = run.getErrors().size();
Thread.sleep(WAIT_BENCHMARK_SLEEP_TIME);
}
} catch (ApiException | InterruptedException e) {
Expand Down Expand Up @@ -277,8 +302,8 @@ public Run runBenchmark(String benchmarkName, Map<String, ?> parameters) {
List<String> params = null;
if (parameters != null && parameters.size() > 0) {
params = parameters.entrySet().stream()
.map(en -> String.format("%s=%s", en.getKey(), en.getValue().toString()))
.collect(Collectors.toList());
.map(en -> String.format("%s=%s", en.getKey(), en.getValue().toString()))
.collect(Collectors.toList());
}

return getDefaultApi().startBenchmark(benchmarkName, "TNB - " + benchmarkName, triggerJob, null, params);
Expand Down
7 changes: 1 addition & 6 deletions system-x/services/prometheus-metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@
<artifactId>system-x-prometheus-metrics</artifactId>
<version>1.0-SNAPSHOT</version>
<name>TNB :: System-X :: Services :: Prometheus Metrics</name>

<properties>
<gson-version>2.8.8</gson-version>
</properties>


<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
</dependencies>

Expand Down
6 changes: 1 addition & 5 deletions system-x/services/webhook/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@
<name>TNB :: System-X :: Services :: Webhook</name>
<artifactId>system-x-webhook</artifactId>

<properties>
<gson-version>2.9.0</gson-version>
</properties>


<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson-version}</version>
</dependency>
</dependencies>
</project>

0 comments on commit 0aa5f30

Please sign in to comment.