Skip to content

Commit

Permalink
Update Splice from CCI (#169)
Browse files Browse the repository at this point in the history
Signed-off-by: DA Automation <[email protected]>
Co-authored-by: DA Automation <[email protected]>
  • Loading branch information
canton-network-da and DA Automation authored Jan 8, 2025
1 parent 569c0d1 commit 08fc692
Show file tree
Hide file tree
Showing 47 changed files with 598 additions and 577 deletions.
11 changes: 11 additions & 0 deletions apps/app/src/test/resources/include/upgrade-databases.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
canton.sv-apps.sv1.storage.config.properties.databaseName = sv1node
canton.sv-apps.sv2.storage.config.properties.databaseName = sv2node
canton.sv-apps.sv3.storage.config.properties.databaseName = sv3node
canton.scan-apps.sv1Scan.storage.config.properties.databaseName = sv1node
canton.scan-apps.sv2Scan.storage.config.properties.databaseName = sv2node
canton.validator-apps.sv1Validator.storage.config.properties.databaseName = sv1node
canton.validator-apps.sv2Validator.storage.config.properties.databaseName = sv2node
canton.validator-apps.sv3Validator.storage.config.properties.databaseName = sv3node
canton.splitwell-apps.providerSplitwellBackend.storage.config.properties.databaseName = bobsplitwellvalidators
canton.validator-apps.bobValidator.storage.config.properties.databaseName = bobsplitwellvalidators
canton.validator-apps.splitwellValidator.storage.config.properties.databaseName = bobsplitwellvalidators
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ _splitwellUpgradeMediator_client {
canton {
parameters {
clock.type = sim-clock
timeouts.processing.sequenced-event-processing-bound = 365.days
}
participants {
sv1Participant = ${_participant_template} ${_sv1Participant_client} ${_autoInit_enabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import org.lfdecentralizedtrust.splice.integration.tests.AppUpgradeIntegrationTe
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.IntegrationTest
import org.lfdecentralizedtrust.splice.splitwell.admin.api.client.commands.HttpSplitwellAppClient
import org.lfdecentralizedtrust.splice.util.{ProcessTestUtil, SplitwellTestUtil, WalletTestUtil}
import org.lfdecentralizedtrust.splice.util.{
PostgresAroundEach,
ProcessTestUtil,
SplitwellTestUtil,
WalletTestUtil,
}

import java.nio.file.{Path, Paths}
import better.files.*
Expand All @@ -30,6 +35,7 @@ import scala.concurrent.duration.*

class AppUpgradeIntegrationTest
extends IntegrationTest
with PostgresAroundEach
with ProcessTestUtil
with SplitwellTestUtil
with WalletTestUtil {
Expand All @@ -39,18 +45,33 @@ class AppUpgradeIntegrationTest
private val splitwellDarPathCurrent =
"daml/splitwell/src/main/resources/dar/splitwell-current.dar"

// We need to split DBs as we upgrade the nodes independently. Otherwise, the first node runs the DB migrations
// and the nodes that have not yet been upgraded will fail if the DB schema is not backwards compatible.
override def usesDbs: IndexedSeq[String] = IndexedSeq(
"sv1node",
"sv2node",
"sv3node",
"bobsplitwellvalidators",
)

override def environmentDefinition
: org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition =
EnvironmentDefinition
.simpleTopology4Svs(this.getClass.getSimpleName)
.fromResources(
Seq("simple-topology.conf", "include/upgrade-databases.conf"),
this.getClass.getSimpleName,
)
.withAllocatedUsers()
.withInitializedNodes()
.withTrafficTopupsEnabled
.withManualStart
// TODO(#8300) Consider removing this once domain config updates are less disruptive, particularly
// to the tests after SVs 2 and 3 have been upgraded
.withSequencerConnectionsFromScanDisabled()
.addConfigTransform((_, config) => {
.addConfigTransforms((_, config) =>
// Makes the test a bit faster and easier to debug. See #11488
ConfigTransforms.useDecentralizedSynchronizerSplitwell()(config)
})
)
.addConfigTransform((_, config) => {
config
.focus(_.validatorApps)
Expand Down Expand Up @@ -85,12 +106,29 @@ class AppUpgradeIntegrationTest
AppUpgradeIntegrationTest.MultiProcessResource("forUpgrade", loggerFactory)
)(spliceProcs => {
// Do not start the old sv4 backend nor alice's validators, they will join only after upgrade
Seq("sv1-node", "sv2-node", "sv3-node", "bobSplitwellValidators").foreach(conf => {
Seq(
("sv1-node", Seq("sv-apps.sv1", "scan-apps.sv1Scan", "validator-apps.sv1Validator")),
("sv2-node", Seq("sv-apps.sv2", "scan-apps.sv2Scan", "validator-apps.sv2Validator")),
("sv3-node", Seq("sv-apps.sv3", "validator-apps.sv3Validator")),
(
"bobSplitwellValidators",
Seq(
"splitwell-apps.providerSplitwellBackend",
"validator-apps.bobValidator",
"validator-apps.splitwellValidator",
),
),
).foreach { case (conf, apps) =>
val version = getBaseVersion()
val bundledConfig = getConfigFileFromBundle(version, conf)
val inputConfig = generateConfig(bundledConfig, version, testId)
val suffix = apps
.map(app =>
s"canton.$app.storage.config.properties.databaseName = ${conf.replace("-", "").toLowerCase}"
)
.mkString("\n")
val inputConfig = generateConfig(bundledConfig, version, testId, Some(suffix))
spliceProcs.startBundledSplice(conf, inputConfig)
})
}

eventually(5.minute) {
Seq("sv1", "sv2", "sv3").foreach(sv => {
Expand Down Expand Up @@ -571,7 +609,12 @@ object AppUpgradeIntegrationTest {
BuildInfo.compatibleVersion
}

def generateConfig(sourceConfig: Path, version: String, testId: String): Path = {
def generateConfig(
sourceConfig: Path,
version: String,
testId: String,
suffix: Option[String],
): Path = {
val bundle = bundleDir(version)
val classpath = bundle.resolve("lib/splice-node.jar")
val transformConfig = bundle.resolve("testResources/transform-config.sc")
Expand All @@ -593,6 +636,7 @@ object AppUpgradeIntegrationTest {
if (result != 0) {
throw new RuntimeException(s"Command $cmd returned: $result")
}
suffix.foreach(s => File(generatedPath).appendLine().append(s))
generatedPath
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import scala.concurrent.{ExecutionContext, Future}
import scala.jdk.CollectionConverters.*
import scala.jdk.OptionConverters.*

class SoftDomainMigrationTopologySetupIntegrationTest
class SoftDomainMigrationIntegrationTest
extends IntegrationTest
with ConfigScheduleUtil
with SplitwellTestUtil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ class UpdateHistoryIntegrationTest
ledgerBeginAlice,
)
}

eventually() {
checkUpdateHistoryMetrics(sv1ScanBackend, sv1ScanBackend.participantClient, dsoParty)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package org.lfdecentralizedtrust.splice.integration.tests

import org.lfdecentralizedtrust.splice.environment.SpliceMetrics.MetricsPrefix
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.IntegrationTestWithSharedEnvironment
import org.lfdecentralizedtrust.splice.util.{WalletTestUtil}
Expand All @@ -25,7 +26,7 @@ class WalletMetricsTest
val aliceUserParty = onboardWalletUser(aliceWalletClient, aliceValidatorBackend)
val before = aliceValidatorBackend.metrics
.get(
"cn.wallet.unlocked-amulet-balance",
s"$MetricsPrefix.wallet.unlocked-amulet-balance",
Map("owner" -> aliceUserParty.toString),
)
.select[MetricValue.DoublePoint]
Expand All @@ -39,7 +40,10 @@ class WalletMetricsTest
"metrics update to reflect new coins",
_ => {
val after = aliceValidatorBackend.metrics
.get("cn.wallet.unlocked-amulet-balance", Map("owner" -> aliceUserParty.toString))
.get(
s"$MetricsPrefix.wallet.unlocked-amulet-balance",
Map("owner" -> aliceUserParty.toString),
)
.select[MetricValue.DoublePoint]
.value
.value
Expand Down Expand Up @@ -72,7 +76,7 @@ class WalletMetricsTest
clue(s"$triggerName should report polling iterations correctly") {
aliceValidatorBackend.metrics
.get(
"cn.trigger.iterations",
s"$MetricsPrefix.trigger.iterations",
Map(
"trigger_name" -> triggerName,
"party" -> aliceUserParty.toString,
Expand All @@ -94,7 +98,7 @@ class WalletMetricsTest
clue(s"$triggerName should report task completions correctly") {
aliceValidatorBackend.metrics
.get(
"cn.trigger.completed",
s"$MetricsPrefix.trigger.completed",
Map(
"trigger_name" -> triggerName,
"party" -> aliceUserParty.toString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.lfdecentralizedtrust.splice.console.{
ScanAppClientReference,
SvAppBackendReference,
}
import org.lfdecentralizedtrust.splice.environment.SpliceMetrics.MetricsPrefix
import org.lfdecentralizedtrust.splice.environment.ledger.api.LedgerClient.GetTreeUpdatesResponse
import org.lfdecentralizedtrust.splice.environment.ledger.api.ReassignmentEvent.{Assign, Unassign}
import org.lfdecentralizedtrust.splice.environment.ledger.api.{
Expand Down Expand Up @@ -35,6 +36,8 @@ import com.digitalasset.canton.admin.api.client.commands.LedgerApiCommands.Updat
TransactionTreeWrapper,
UnassignedWrapper,
}
import com.digitalasset.canton.console.LocalInstanceReference
import com.digitalasset.canton.metrics.MetricValue
import com.digitalasset.canton.topology.{DomainId, PartyId}
import org.scalatest.Assertion

Expand Down Expand Up @@ -214,6 +217,27 @@ trait UpdateHistoryTestUtil extends TestCommon {
succeed
}

def checkUpdateHistoryMetrics(
node: LocalInstanceReference,
participant: ParticipantClientReference,
party: PartyId,
): Assertion = {
val expected = updateHistoryFromParticipant(0, party, participant).size

def getValue(metric: String): Long =
node.metrics.list(metric).get(metric) match {
case None => 0
case Some(_) => node.metrics.get(metric).select[MetricValue.LongPoint].value.value
}

val totalMetrics = Seq("transactions", "assignments", "unassignments")
.map(m => s"$MetricsPrefix.history.updates.$m")
.map(getValue(_))
.reduce(_ + _)

totalMetrics should equal(expected)
}

// Minimal, human-readable description of an update
def shortDebugDescription(e: definitions.TreeEvent): String = e match {
case definitions.TreeEvent.members.CreatedEvent(http) =>
Expand Down
Loading

0 comments on commit 08fc692

Please sign in to comment.