From 5adbf9253697adef9e0b21a1bf3827e80ba88952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jari-Matti=20M=C3=A4kel=C3=A4?= <jmjmak@utu.fi> Date: Mon, 9 Jun 2025 19:13:48 +0300 Subject: [PATCH] Update examples. Add update script for dependencies --- .../fi/utu/tech/powergoblin/api/web/Webserver.kt | 2 ++ stuff/client-library/test.sh | 8 +++++++- stuff/collectd-example/README.md | 4 ++-- stuff/collectd-example/collect.sh | 7 +++++++ stuff/collectd-nvml/README.md | 4 ++-- stuff/collectd-nvml/collect.sh | 7 +++++++ stuff/collectd-rapl/README.md | 4 ++-- stuff/collectd-rapl/collect.sh | 7 +++++++ stuff/fullstack-example/README.md | 4 ++-- stuff/fullstack-example/mscript.sh | 6 ++++++ .../main/java/org/acme/MeasuredHashResource.java | 2 +- .../src/main/java/org/acme/PageResource.java | 10 +++++----- stuff/report-example/test-report.sh | 7 +++++++ update-deps.sh | 14 ++++++++++++++ 14 files changed, 71 insertions(+), 15 deletions(-) create mode 100755 stuff/fullstack-example/mscript.sh create mode 100644 update-deps.sh diff --git a/src/main/java/fi/utu/tech/powergoblin/api/web/Webserver.kt b/src/main/java/fi/utu/tech/powergoblin/api/web/Webserver.kt index c133710..30db0f0 100644 --- a/src/main/java/fi/utu/tech/powergoblin/api/web/Webserver.kt +++ b/src/main/java/fi/utu/tech/powergoblin/api/web/Webserver.kt @@ -16,6 +16,7 @@ import java.nio.file.Files import java.nio.file.Path import java.time.LocalDateTime import java.util.concurrent.ConcurrentLinkedQueue +import java.util.concurrent.Executors import java.util.concurrent.Future import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicInteger @@ -121,6 +122,7 @@ open class SimpleWebServer( IO.printBold("Web [$this] listening at [ http://${it.address}:${it.port} ]") } IO.printBold("") + //server.setExecutor(Executors.newVirtualThreadPerTaskExecutor()) server.createContext("/") { httpExchange: HttpExchange -> if (!active) throw Exception("Server closed the connection") diff --git a/stuff/client-library/test.sh b/stuff/client-library/test.sh index e7a60e9..c0302fa 100755 --- a/stuff/client-library/test.sh +++ b/stuff/client-library/test.sh @@ -1,6 +1,12 @@ #!/bin/bash -set +x +die() { + echo $* + exit 1 +} + +[ -e powergoblin.sh ] || die powergoblin.sh missing + source powergoblin.sh export HOST=localhost:8080 diff --git a/stuff/collectd-example/README.md b/stuff/collectd-example/README.md index 9c83687..a748db6 100644 --- a/stuff/collectd-example/README.md +++ b/stuff/collectd-example/README.md @@ -29,6 +29,6 @@ $ ./collect.sh You will need to customize the script to suit your needs. In the beginning of the file, there are parameters for configuring names, number of runs, and -other settings. The actual code that will be measured is located on lines 28 -and 46. +other settings. The actual code that will be measured is located on lines 35 +and 53. diff --git a/stuff/collectd-example/collect.sh b/stuff/collectd-example/collect.sh index 8d78de9..6bd0c6d 100755 --- a/stuff/collectd-example/collect.sh +++ b/stuff/collectd-example/collect.sh @@ -2,6 +2,13 @@ # You can use this as a template for your measurements. # This depends on the `powergoblin.sh` in `client-library/` +die() { + echo $* + exit 1 +} + +[ -e powergoblin.sh ] || die powergoblin.sh missing + source powergoblin.sh export HOST=localhost:8080 diff --git a/stuff/collectd-nvml/README.md b/stuff/collectd-nvml/README.md index deb451a..3d77dac 100644 --- a/stuff/collectd-nvml/README.md +++ b/stuff/collectd-nvml/README.md @@ -31,6 +31,6 @@ $ ./collect.sh You will need to customize the script to suit your needs. In the beginning of the file, there are parameters for configuring names, number of runs, and -other settings. The actual code that will be measured is located on lines 29 -and 47. +other settings. The actual code that will be measured is located on lines 36 +and 54. diff --git a/stuff/collectd-nvml/collect.sh b/stuff/collectd-nvml/collect.sh index 40cf6de..4e493d6 100755 --- a/stuff/collectd-nvml/collect.sh +++ b/stuff/collectd-nvml/collect.sh @@ -2,6 +2,13 @@ # You can use this as a template for your measurements. # This depends on the `powergoblin.sh` in `client-library/` +die() { + echo $* + exit 1 +} + +[ -e powergoblin.sh ] || die powergoblin.sh missing + source powergoblin.sh export HOST=localhost:8080 diff --git a/stuff/collectd-rapl/README.md b/stuff/collectd-rapl/README.md index edd669f..8196293 100644 --- a/stuff/collectd-rapl/README.md +++ b/stuff/collectd-rapl/README.md @@ -33,6 +33,6 @@ $ ./collect.sh You will need to customize the script to suit your needs. In the beginning of the file, there are parameters for configuring names, number of runs, and -other settings. The actual code that will be measured is located on lines 29 -and 47. +other settings. The actual code that will be measured is located on lines 36 +and 54. diff --git a/stuff/collectd-rapl/collect.sh b/stuff/collectd-rapl/collect.sh index 5a0aae5..37cd780 100755 --- a/stuff/collectd-rapl/collect.sh +++ b/stuff/collectd-rapl/collect.sh @@ -2,6 +2,13 @@ # You can use this as a template for your measurements. # This depends on the `powergoblin.sh` in `client-library/` +die() { + echo $* + exit 1 +} + +[ -e powergoblin.sh ] || die powergoblin.sh missing + source powergoblin.sh export HOST=localhost:8080 diff --git a/stuff/fullstack-example/README.md b/stuff/fullstack-example/README.md index 8dccd05..5e413e7 100644 --- a/stuff/fullstack-example/README.md +++ b/stuff/fullstack-example/README.md @@ -21,8 +21,8 @@ $ mvn io.quarkus.platform:quarkus-maven-plugin:3.23.0:create \ Machines (hostname / IP): * controller: 192.168.1.10 -* sut-frontend: 192.168.1.20 -* sut-backend: 192.168.1.30 +* sut-front: 192.168.1.20 +* sut-back: 192.168.1.30 Preparations (background shell, run on `controller`): diff --git a/stuff/fullstack-example/mscript.sh b/stuff/fullstack-example/mscript.sh new file mode 100755 index 0000000..dc1540d --- /dev/null +++ b/stuff/fullstack-example/mscript.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +export BACKEND=sut-back:8080 +export POWERGOBLIN=controller:8888 +docker run -e POWERGOBLIN=$POWERGOBLIN --network host fullstack-example:latest +python test-backend.py \ No newline at end of file diff --git a/stuff/fullstack-example/src/main/java/org/acme/MeasuredHashResource.java b/stuff/fullstack-example/src/main/java/org/acme/MeasuredHashResource.java index 1606371..f85d3f0 100644 --- a/stuff/fullstack-example/src/main/java/org/acme/MeasuredHashResource.java +++ b/stuff/fullstack-example/src/main/java/org/acme/MeasuredHashResource.java @@ -34,7 +34,7 @@ public class MeasuredHashResource { pg.get("session/latest/measurement/start"); pg.get("session/latest/measurement/rename/Whitebox"); - for (int j=0;j<10;j++) { + for (int j = 0; j < 10; j++) { pg.get("session/latest/run/start"); for (int i = 0; i < 50; i++) diff --git a/stuff/fullstack-example/src/main/java/org/acme/PageResource.java b/stuff/fullstack-example/src/main/java/org/acme/PageResource.java index 7a5ccda..fd9a4e9 100644 --- a/stuff/fullstack-example/src/main/java/org/acme/PageResource.java +++ b/stuff/fullstack-example/src/main/java/org/acme/PageResource.java @@ -10,16 +10,16 @@ import java.nio.charset.StandardCharsets; /** * This page contains Javascript variables that will be extracted * by a Selenium script: - * - * - const banana = 42; - * - const strawberry = 123; - * + * <p> + * - const banana = 42; + * - const strawberry = 123; + * <p> * Various resource information could be obtained with the same technique. */ @Path("/page") public class PageResource { String readPage() { - try(var is = getClass().getResourceAsStream("ipsum.html")) { + try (var is = getClass().getResourceAsStream("ipsum.html")) { return new String(is.readAllBytes(), StandardCharsets.UTF_8); } catch (Exception e) { return "Error reading the resource"; diff --git a/stuff/report-example/test-report.sh b/stuff/report-example/test-report.sh index 657b77f..fe8dd5a 100755 --- a/stuff/report-example/test-report.sh +++ b/stuff/report-example/test-report.sh @@ -3,6 +3,13 @@ # The script should be run on the same system. # Adjust the HOST parameter if necessary +die() { + echo $* + exit 1 +} + +[ -e powergoblin.sh ] || die powergoblin.sh missing + source powergoblin.sh export HOST=localhost:8080 diff --git a/update-deps.sh b/update-deps.sh new file mode 100644 index 0000000..1a0b145 --- /dev/null +++ b/update-deps.sh @@ -0,0 +1,14 @@ +# https://github.com/chartjs/Chart.js/releases +# https://github.com/sgratzl/chartjs-chart-boxplot + +chartjs=4.4.9 +chartjsboxplot=4.4.4 + +wget https://github.com/chartjs/Chart.js/releases/download/v$chartjs/chart.js-$chartjs.tgz +wget https://github.com/sgratzl/chartjs-chart-boxplot/releases/download/v$chartjsboxplot/package.tgz + +tar xvf chart.js-$chartjs.tgz package/dist/chart.umd.js.map package/dist/chart.umd.js --strip-components 2 +mv -v chart.umd.js chart.umd.js.map src/main/resources/fi/utu/tech/powergoblin/web/ + +tar xvf package.tgz package/build/index.umd.min.js package/build/index.umd.min.js.map --strip-components 2 +mv -v index.umd.min.js index.umd.min.js.map src/main/resources/fi/utu/tech/powergoblin/web/ -- GitLab