Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/build.scala_test_for_compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
start_canton_options:
type: string
required: true
with_canton:
type: boolean
required: false
default: true
runs_on:
type: string
required: true
Expand Down Expand Up @@ -94,3 +98,4 @@ jobs:
failure_notifications_invoker_sa: ${{ secrets.FAILURE_NOTIFICATIONS_INVOKER_SA }}
failure_notifications_invoker_url: ${{ secrets.FAILURE_NOTIFICATIONS_INVOKER_URL }}
failure_notifications_slack_channel: ${{ secrets.FAILURE_NOTIFICATIONS_SLACK_CHANNEL }}
with_canton: ${{ inputs.with_canton }}
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,17 @@ jobs:
commit_sha: ${{ inputs.commit_sha }}
secrets: inherit

scala_test_local_net:
uses: ./.github/workflows/build.scala_test_for_compose.yml
with:
runs_on: self-hosted-docker-large
test_names_file: 'test-full-class-names-local-net-based.log'
parallelism: 1
test_name: docker-compose
with_canton: false
start_canton_options: ""
secrets: inherit

scala_test_app_upgrade:
uses: ./.github/workflows/build.scala_test.yml
with:
Expand Down Expand Up @@ -232,6 +243,7 @@ jobs:
- scala_test_frontend_wall_clock_time
- scala_test_frontend_simtime
- scala_test_docker_compose
- scala_test_local_net
- scala_test_app_upgrade
- scala_test_without_canton
- ui_tests
Expand Down
21 changes: 5 additions & 16 deletions .github/workflows/ciupgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,8 @@ on:

jobs:
trigger_ciupgrade:
# TODO(#19109): re-enable ciupgrade
# uses: ./.github/workflows/cluster_tests.yml
# secrets: inherit
# with:
# workflow: deploy_ciupgrade
# sha: ${{ github.sha }}


runs-on: self-hosted-docker-tiny
name: Trigger CIUpgrade deployment
steps:
- name: Trigger CIUpgrade deployment
shell: bash
run: |
echo "CIUpgrade deployments are currently disabled"
exit 0
uses: ./.github/workflows/cluster_tests.yml
secrets: inherit
with:
workflow: deploy_ciupgrade
sha: ${{ github.sha }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package org.lfdecentralizedtrust.splice.integration.tests

import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
import org.lfdecentralizedtrust.splice.util.{FrontendLoginUtil, WalletFrontendTestUtil}

import scala.concurrent.duration.*
import scala.sys.process.*

class LocalNetFrontendIntegrationTest
extends FrontendIntegrationTest("frontend")
with FrontendLoginUtil
with WalletFrontendTestUtil {
override def environmentDefinition: SpliceEnvironmentDefinition =
EnvironmentDefinition.empty(this.getClass.getSimpleName)

override lazy val resetRequiredTopologyState = false

val partyHint = "localnet-localparty-1"

"docker-compose based localnet work" in { implicit env =>
try {
val ret = Seq("build-tools/splice-localnet-compose.sh", "start").!
if (ret != 0) {
fail("Failed to start docker-compose SV and validator")
}

clue("Test validators") {
List(
("app-user", 2000, "app_user"),
("app-provider", 3000, "app_provider"),
).foreach { case (user, port, partyHintPrefix) =>
clue(s"Test $user validator") {
val host = "wallet.localhost"
val url = s"http://$host:$port"
withFrontEnd("frontend") { implicit webDriver =>
eventuallySucceeds()(go to url)
actAndCheck(timeUntilSuccess = 60.seconds)(
s"Login as $user",
login(port, user, host),
)(
s"$user is already onboarded",
_ =>
seleniumText(find(id("logged-in-user"))) should startWith(
s"${partyHintPrefix}_$partyHint"
),
)
// Wait for some traffic to be bought before proceeding so that we don't hit a "traffic below reserved amount" error
waitForTrafficPurchase()
go to url
actAndCheck(
s"Login as $user",
loginOnCurrentPage(port, user, host),
)(
s"$user is already onboarded",
_ =>
seleniumText(find(id("logged-in-user"))) should startWith(
s"${partyHintPrefix}_$partyHint"
),
)
tapAmulets(345.6)
}
}
}

clue("Basic test of SV UIs") {
withFrontEnd("frontend") { implicit webDriver =>
actAndCheck(
"Open the Scan UI",
go to "scan.localhost:4000",
)(
"Open rounds should be listed",
_ => findAll(className("open-mining-round-row")) should have length 2,
)

actAndCheck(timeUntilSuccess = 60.seconds)(
"Login to the wallet as sv",
login(4000, "sv", "wallet.localhost"),
)(
"sv is already onboarded",
_ => seleniumText(find(id("logged-in-user"))) should startWith("sv.sv.ans"),
)

actAndCheck()(
"Login to the SV app as sv",
login(4000, "sv", "sv.localhost"),
)(
"sv is already onboarded, and the app is working",
_ => {
seleniumText(
find(id("svUser")).value
.childElement(className("general-dso-value-name"))
) should be("ledger-api-user")
},
)

}
}
}
} finally {
Seq("build-tools/splice-localnet-compose.sh", "stop", "-D").!
}
}
}
93 changes: 93 additions & 0 deletions build-tools/splice-localnet-compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env bash

# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

set -eou pipefail

# Ensure all background jobs are killed when the script exits
trap 'kill $(jobs -p) 2>/dev/null' EXIT
exec > >(tee -a "${SPLICE_ROOT}/log/console.log") 2>&1

# shellcheck disable=SC1091
source "${TOOLS_LIB}/libcli.source"
SCRIPTNAME=${0##*/}

LOCALNET_DIR="${SPLICE_ROOT}/cluster/compose/localnet"
export LOCALNET_DIR

IMAGE_TAG=$("${SPLICE_ROOT}/build-tools/get-snapshot-version")
export IMAGE_TAG
IMAGE_REPO=""
export IMAGE_REPO

# the port will be assigned by docker
TEST_PORT=""
export TEST_PORT

if [[ $# -lt 1 || $# -gt 2 ]]; then
echo "Usage: $SCRIPTNAME <start|stop> [-D]"
exit 1
fi

ACTION=$1

DOCKER_COMPOSE_CMD=( docker compose
--env-file "$LOCALNET_DIR/compose.env"
--env-file "$LOCALNET_DIR/env/common.env"
--env-file "$LOCALNET_DIR/env/local.env"
-f "$LOCALNET_DIR/compose.yaml"
-f "$LOCALNET_DIR/resource-constraints.yaml"
--profile sv
--profile app-provider
--profile app-user
)

case $ACTION in
start)
if [[ $# -ne 1 ]]; then
echo "Usage: $SCRIPTNAME <start|stop> [-D]"
exit 1
fi
services_to_log=( canton splice postgres nginx )
docker events -f type=container \
-f event=start \
-f event=stop \
-f event=restart \
-f event=kill \
-f event=die \
-f event=destroy \
-f event=health_status \
-f event=oom \
--format '{{.ID}} {{.Time}} {{.Actor.Attributes.name}} {{.Status}}' | while read -r cid time service_name status; do
if [[ -n "$service_name" ]]; then
for svc in "${services_to_log[@]}"; do
if [[ "$svc" == "$service_name" ]]; then
echo "$(date -u -d "@$time" +"%Y-%m-%dT%H:%M:%S") $service_name $status"
if [ "$status" = "start" ]; then
echo " capture logs $service_name"
docker logs -f "$cid" >> "${SPLICE_ROOT}/log/compose-localnet-$service_name.clog" 2>&1 &
fi
break
fi
done
fi
done >> "${SPLICE_ROOT}/log/compose.log" 2>&1 &

"${DOCKER_COMPOSE_CMD[@]}" up -d || _error "Failed to start localnet, please check ${SPLICE_ROOT}/log/console.log for details"
;;
stop)
if [[ $# -eq 2 && $2 == "-D" ]]; then
"${DOCKER_COMPOSE_CMD[@]}" down -v
elif [[ $# -eq 1 ]]; then
"${DOCKER_COMPOSE_CMD[@]}" stop
else
echo "Usage: $SCRIPTNAME <start|stop> [-D]"
exit 1
fi
;;
*)
echo "Invalid action: $ACTION. Use 'start' or 'stop'."
exit 1
;;
esac
7 changes: 7 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,8 @@ printTests := {
name.contains("SvOffboardingIntegrationTest")
def isDockerComposeBasedTest(name: String): Boolean =
name contains "DockerCompose"
def isLocalNetTest(name: String): Boolean =
name contains "LocalNet"
def isCometBftTest(name: String): Boolean =
name contains "CometBft"
def isRecordTimeToleranceTest(name: String): Boolean =
Expand Down Expand Up @@ -1920,6 +1922,11 @@ printTests := {
"test-full-class-names-resource-intensive.log",
(t: String) => isResourceIntensiveTest(t),
),
(
"tests for localnet",
"test-full-class-names-local-net-based.log",
(t: String) => isLocalNetTest(t),
),
(
"tests using docker images",
"test-full-class-names-docker-based.log",
Expand Down
Loading
Loading