From ad5445e25e920c5ff68cf58b3733666dbeeeb44e Mon Sep 17 00:00:00 2001 From: Corneil du Plessis Date: Thu, 17 Nov 2022 21:53:41 +0200 Subject: [PATCH] [GitHub Actions] Tune thread count for Maven and surefire plugin forks. Increase runners with 10% more than requested. --- .github/actions/increase-runners/action.yml | 5 +- .github/actions/scale-runners-up/action.yml | 5 +- .github/workflows/ci-pr.yml | 2 +- .github/workflows/common.yml | 2 +- build-folder.sh | 4 +- .../websocket/WebsocketConsumerTests.java | 57 +++++-------------- stream-applications-build/pom.xml | 3 + 7 files changed, 27 insertions(+), 51 deletions(-) diff --git a/.github/actions/increase-runners/action.yml b/.github/actions/increase-runners/action.yml index e31234c4..a50bcab1 100644 --- a/.github/actions/increase-runners/action.yml +++ b/.github/actions/increase-runners/action.yml @@ -16,5 +16,6 @@ runs: shell: bash run: | source ./scripts/kubeconfig-runners.sh - ./scripts/increase-runners.sh ${{ inputs.inc }} ${{ inputs.max }} - echo "::notice ::Increased runners with ${{ inputs.inc }}" + INC=$((11 * ${{ inputs.inc }} / 10)) + ./scripts/increase-runners.sh $INC ${{ inputs.max }} + echo "::notice ::Increased runners with $INC" diff --git a/.github/actions/scale-runners-up/action.yml b/.github/actions/scale-runners-up/action.yml index d8ec9876..215650a0 100644 --- a/.github/actions/scale-runners-up/action.yml +++ b/.github/actions/scale-runners-up/action.yml @@ -82,8 +82,9 @@ runs: echo "::notice ::Scaling stream-apps-gh-runners to ${{ inputs.max_parallel }} pods" source ./scripts/kubeconfig-runners.sh IDLE=$(./scripts/count-runners-idle.sh runners-stream-ci) - if ((IDLE < ${{ inputs.max_parallel }})); then - REQUEST=$((${{ inputs.max_parallel }} - IDLE)) + INC=$((11 * ${{ inputs.max_parallel }} / 10)) + if ((IDLE < INC)); then + REQUEST=$((INC - IDLE)) echo "::info Requesting $REQUEST runners with $IDLE idle" ./scripts/scale-cluster-pods.sh stream-apps-gh-runners $REQUEST --add 1 else diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index 275351f5..b3dbb654 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -53,7 +53,7 @@ jobs: VERBOSE: ${{ github.debug && 'true' || '' }} run: | BUILD_DIR=$(realpath $MAIN_PATH) - MAVEN_OPT="-U -B -T 1C -s $ROOT_DIR/.settings.xml ${{ inputs.verbose && '--debug' || '' }}" + MAVEN_OPT="-U -B -T 0.3C -s $ROOT_DIR/.settings.xml ${{ inputs.verbose && '--debug' || '' }}" echo "::notice ::building - stream-applications-build" set +e $BUILD_DIR/build-folder.sh stream-applications-build install -DskipTests diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index b6526791..360f854a 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -203,7 +203,7 @@ jobs: CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} run: | ROOT_DIR=$(realpath $PWD) - MAVEN_OPT="-U -B -T 1C -s $ROOT_DIR/.settings.xml ${{ inputs.verbose && '--debug' || '' }}" + MAVEN_OPT="-U -B -T 0.3C -s $ROOT_DIR/.settings.xml ${{ inputs.verbose && '--debug' || '' }}" pushd stream-applications > /dev/null echo "::notice ::building - stream-applications-build,functions,applications/stream-applications-core" set -e diff --git a/build-folder.sh b/build-folder.sh index ebd41f78..dfaa4b58 100755 --- a/build-folder.sh +++ b/build-folder.sh @@ -23,9 +23,9 @@ elif [ "$VERBOSE" == "false" ]; then MAVEN_OPTS="-q" fi if [ "$MAVEN_OPTS" == "" ]; then - MAVEN_OPTS="-s ./.settings.xml -B -T 1C" + MAVEN_OPTS="-s ./.settings.xml -B -T 0.3C" else - MAVEN_OPTS="$MAVEN_OPTS -s ./.settings.xml -B -T 1C" + MAVEN_OPTS="$MAVEN_OPTS -s ./.settings.xml -B -T 0.3C" fi if [ "$1" == "" ]; then diff --git a/functions/consumer/websocket-consumer/src/test/java/org/springframework/cloud/fn/consumer/websocket/WebsocketConsumerTests.java b/functions/consumer/websocket-consumer/src/test/java/org/springframework/cloud/fn/consumer/websocket/WebsocketConsumerTests.java index 0f03be26..07bcf7c0 100644 --- a/functions/consumer/websocket-consumer/src/test/java/org/springframework/cloud/fn/consumer/websocket/WebsocketConsumerTests.java +++ b/functions/consumer/websocket-consumer/src/test/java/org/springframework/cloud/fn/consumer/websocket/WebsocketConsumerTests.java @@ -16,14 +16,12 @@ package org.springframework.cloud.fn.consumer.websocket; -import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.function.Consumer; -import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -82,22 +80,13 @@ public class WebsocketConsumerTests { @Timeout(TIMEOUT) public void testMultipleMessageSingleSubscriber() throws Exception { WebsocketConsumerClientHandler handler = new WebsocketConsumerClientHandler("handler_0", MESSAGE_COUNT, TIMEOUT); - try (WebSocketSession session = doHandshake(handler)) { - assertThat(session.isOpen()); - List messagesToSend = submitMultipleMessages(MESSAGE_COUNT); - List received = new ArrayList<>(); - Awaitility.await() - .atMost(Duration.ofSeconds(10)) - .until(() -> { - handler.await(); - received.addAll(handler.getReceivedMessages()); - return received.size() == MESSAGE_COUNT; - } - ); + doHandshake(handler); - assertThat(received.size()).isEqualTo(MESSAGE_COUNT); - messagesToSend.forEach(s -> assertThat(received.contains(s)).isTrue()); - } + List messagesToSend = submitMultipleMessages(MESSAGE_COUNT); + handler.await(); + + assertThat(handler.getReceivedMessages().size()).isEqualTo(MESSAGE_COUNT); + messagesToSend.forEach(s -> assertThat(handler.getReceivedMessages().contains(s)).isTrue()); } @Test @@ -110,25 +99,13 @@ public class WebsocketConsumerTests { // submit a single message String payload = UUID.randomUUID().toString(); websocketConsumer.accept(MessageBuilder.withPayload(payload).build()); - List responses = new ArrayList<>(); + // await completion on each handler for (WebsocketConsumerClientHandler handler : handlers) { - Awaitility.await() - .atMost(Duration.ofSeconds(5)) - .until(() -> { - handler.await(); - if (!handler.getReceivedMessages().isEmpty()) { - responses.add(handler.getReceivedMessages().get(0)); - } - return !handler.getReceivedMessages().isEmpty(); - }); - + handler.await(); + assertThat(handler.getReceivedMessages().size()).isEqualTo(1); + assertThat(handler.getReceivedMessages().get(0)).isEqualTo(payload); } - assertThat(responses.size()).isEqualTo(handlers.size()); - responses.forEach(s -> { - assertThat(s).isEqualTo(payload); - }); - } @Test @@ -143,22 +120,16 @@ public class WebsocketConsumerTests { // wait on each handle for (WebsocketConsumerClientHandler handler : handlers) { - Awaitility.await() - .atMost(Duration.ofSeconds(5)) - .until(() -> { - handler.await(); - if (handler.getReceivedMessages().size() == messagesReceived.size()) { - return handler.getReceivedMessages().equals(messagesReceived); - } - return false; - }); + handler.await(); + assertThat(handler.getReceivedMessages().size()).isEqualTo(messagesReceived.size()); + assertThat(handler.getReceivedMessages()).isEqualTo(messagesReceived); } } private WebSocketSession doHandshake(WebsocketConsumerClientHandler handler) throws InterruptedException, ExecutionException { String wsEndpoint = "ws://localhost:" + this.consumerServer.getPort() + this.properties.getPath(); - return new StandardWebSocketClient().execute(handler, wsEndpoint).get(); + return new StandardWebSocketClient().doHandshake(handler, wsEndpoint).get(); } private List submitMultipleMessages(int messageCount) { diff --git a/stream-applications-build/pom.xml b/stream-applications-build/pom.xml index f9311f52..88f35405 100644 --- a/stream-applications-build/pom.xml +++ b/stream-applications-build/pom.xml @@ -149,6 +149,7 @@ ${maven-surefire-plugin.version} classes + 0.3C true @@ -326,6 +327,7 @@ ${maven-surefire-plugin.version} classes + 0.3C integration @@ -342,6 +344,7 @@ ${maven-surefire-plugin.version} classes + 0.3C integration