Skip to content

Commit e492dd9

Browse files
canton-network-daDA Automation
and
DA Automation
authored
Update Splice from CCI (#313)
Signed-off-by: DA Automation <[email protected]> Co-authored-by: DA Automation <[email protected]>
1 parent b7f7b8d commit e492dd9

File tree

8 files changed

+50
-34
lines changed

8 files changed

+50
-34
lines changed

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/runbook/ValidatorPreflightIntegrationTest.scala

+17-8
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ import com.daml.nonempty.NonEmpty
1111
import com.digitalasset.canton.integration.BaseEnvironmentDefinition
1212
import com.digitalasset.canton.networking.Endpoint
1313
import com.digitalasset.canton.topology.PartyId
14+
import com.digitalasset.canton.tracing.TraceContext
1415
import org.lfdecentralizedtrust.splice.util.Auth0Util.WithAuth0Support
1516

1617
import java.net.URI
1718
import scala.collection.mutable
1819
import scala.concurrent.duration.*
1920
import scala.jdk.CollectionConverters.MapHasAsScala
2021
import scala.jdk.OptionConverters.RichOptional
22+
import scala.util.control.NonFatal
2123

2224
/** Base for preflight tests running against a deployed validator
2325
*/
@@ -59,22 +61,29 @@ abstract class ValidatorPreflightIntegrationTestBase
5961
override def beforeEach() = {
6062
super.beforeEach();
6163

62-
def addUser(name: String) = {
64+
def addUser(name: String)(implicit traceContext: TraceContext) = {
6365
val user = auth0.createUser()
64-
logger.debug(
65-
s"Created user $name: email ${user.email}, password ${user.password}, id: ${user.id}"
66-
)
6766
auth0Users += (name -> user)
6867
}
6968

70-
addUser("alice-validator")
71-
addUser("bob-validator")
72-
addUser("charlie-validator")
69+
TraceContext.withNewTraceContext(implicit traceContext => {
70+
try {
71+
addUser("alice-validator")
72+
addUser("bob-validator")
73+
addUser("charlie-validator")
74+
} catch {
75+
case NonFatal(e) =>
76+
// Logging the error, as an exception in this method will abort the test suite with no log output.
77+
logger.error("addUser {alice,bob,charlie}-validator beforeEach failed", e)
78+
throw e
79+
}
80+
})
7381
}
7482

7583
override def afterEach() = {
7684
try super.afterEach()
77-
finally auth0Users.values.map(user => user.close)
85+
finally
86+
auth0Users.values.foreach(user => user.close())
7887
}
7988

8089
override def beforeAll() = {

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/util/Auth0Util.scala

+24-14
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Auth0Util(
3838
private val auth = new AuthAPI(domain, managementApiClientId, managementApiClientSecret)
3939
val api = new ManagementAPI(domain, requestManagementAPIToken())
4040

41-
def createUser(): Auth0User = {
41+
def createUser()(implicit tc: TraceContext): Auth0User = {
4242
val user = new User()
4343
val rand = new scala.util.Random
4444
val password = s"${rand.alphanumeric.take(20).mkString}${rand.nextInt()}"
@@ -48,11 +48,16 @@ class Auth0Util(
4848
user.setEmail(email)
4949
user.setVerifyEmail(false) // avoid auth0 trying to send mails
5050
user.setConnection("Username-Password-Authentication")
51+
logger.debug(s"Creating user with username $username email $email and password $password")
5152
val id = executeManagementApiRequest(api.users().create(user)).getId
53+
logger.debug(s"Created user ${email} with password ${password} (id: ${id})")
5254
new Auth0User(id, email, password, this)
5355
}
5456

5557
def deleteUser(id: String): Unit = {
58+
// Called from AutoCloseable.close, which doesn't propagate the trace context
59+
implicit val traceContext: TraceContext = TraceContext.empty
60+
logger.debug(s"Deleting user with id: ${id}")
5661
executeManagementApiRequest(api.users.delete(id))
5762
}
5863

@@ -70,7 +75,9 @@ class Auth0Util(
7075
auth.requestToken(s"${domain}/api/v2/").execute().getAccessToken()
7176
}
7277

73-
private def executeManagementApiRequest[T](req: com.auth0.net.Request[T]) =
78+
private def executeManagementApiRequest[T](
79+
req: com.auth0.net.Request[T]
80+
)(implicit traceContext: TraceContext) =
7481
retry.retryAuth0CallsForTests {
7582
// Auth0 management API calls are rate limited, with limits much lower than
7683
// the rate limits for the auth API calls.
@@ -85,7 +92,7 @@ class Auth0Util(
8592
object Auth0Util {
8693

8794
trait Auth0Retry {
88-
def retryAuth0CallsForTests[T](f: => T): T
95+
def retryAuth0CallsForTests[T](f: => T)(implicit traceContext: TraceContext): T
8996
}
9097

9198
trait WithAuth0Support {
@@ -115,19 +122,22 @@ object Auth0Util {
115122
clientSecret,
116123
loggerFactory,
117124
new Auth0Retry {
118-
def handleExceptions(e: Throwable): Nothing = e match {
119-
case auth0Exception: Auth0Exception => {
120-
logger.debug("Auth0 exception raised, triggering retry...")
121-
fail(auth0Exception)
122-
}
123-
case ioException: java.io.IOException => {
124-
logger.debug("IOException raised, triggering retry...")
125-
fail(ioException)
125+
def handleExceptions(e: Throwable)(implicit traceContext: TraceContext): Nothing =
126+
e match {
127+
case auth0Exception: Auth0Exception => {
128+
logger.debug("Auth0 exception raised, triggering retry...", auth0Exception)
129+
fail(auth0Exception)
130+
}
131+
case ioException: java.io.IOException => {
132+
logger.debug("IOException raised, triggering retry...", ioException)
133+
fail(ioException)
134+
}
135+
case ex: Throwable => throw ex // throw anything else
126136
}
127-
case ex: Throwable => throw ex // throw anything else
128-
}
129137

130-
override def retryAuth0CallsForTests[T](f: => T): T = {
138+
override def retryAuth0CallsForTests[T](
139+
f: => T
140+
)(implicit traceContext: TraceContext): T = {
131141
eventually() {
132142
try {
133143
f

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/util/FrontendLoginUtil.scala

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ trait FrontendLoginUtil extends WithAuth0Support { self: FrontendTestCommon =>
8383
)(implicit env: SpliceTests.SpliceTestConsoleEnvironment): A = {
8484
val auth0 = auth0UtilFromEnvVars("test")
8585
Using.resource(auth0.createUser()) { user =>
86-
logger.debug(s"Created user ${user.email} with password ${user.password} (id: ${user.id})")
8786
if (!onboardThroughWalletUI) {
8887
aliceValidatorBackend.onboardUser(user.id)
8988
}

apps/common/frontend/src/config/schema/auth.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ enum Algorithm {
88
}
99

1010
const tokenRequestSchema = z.object({
11-
token_audience: z.string().url(), // Request an access token from IAM provider with this audience
11+
token_audience: z.string(), // Request an access token from IAM provider with this audience
1212
token_scope: z.string().optional(), // Request an access token from IAM provider with this scope
1313
});
1414

apps/tools/src/main/scala/org/lfdecentralizedtrust/splice/Auth0TestUserCleaner.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ object Auth0TestUserCleaner {
7171
}
7272

7373
// Super simple retrier
74-
def retryAuth0Calls[T](f: => T, retryCount: Int = 10): T = {
74+
def retryAuth0Calls[T](f: => T, retryCount: Int = 10)(implicit traceContext: TraceContext): T = {
7575
if (retryCount <= 0) {
7676
throw new Error("Auth0 retry count exhausted")
7777
}
@@ -101,7 +101,8 @@ object Auth0TestUserCleaner {
101101
clientSecret,
102102
loggerFactory,
103103
new Auth0Util.Auth0Retry {
104-
override def retryAuth0CallsForTests[T](f: => T): T = retryAuth0Calls(f)
104+
override def retryAuth0CallsForTests[T](f: => T)(implicit tc: TraceContext): T =
105+
retryAuth0Calls(f)
105106
},
106107
)
107108

cluster/pulumi/infra/grafana-dashboards/canton-network/history-backfilling.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -641,14 +641,14 @@
641641
"type": "prometheus",
642642
"uid": "prometheus"
643643
},
644-
"definition": "label_values(splice_history_backfilling_latest_record_time,namespace)",
644+
"definition": "label_values(splice_history_backfilling_complete,namespace)",
645645
"includeAll": true,
646646
"multi": true,
647647
"name": "namespace",
648648
"options": [],
649649
"query": {
650650
"qryType": 1,
651-
"query": "label_values(splice_history_backfilling_latest_record_time,namespace)",
651+
"query": "label_values(splice_history_backfilling_complete,namespace)",
652652
"refId": "PrometheusVariableQueryEditor-VariableQuery"
653653
},
654654
"refresh": 1,
@@ -664,14 +664,14 @@
664664
"type": "prometheus",
665665
"uid": "prometheus"
666666
},
667-
"definition": "label_values(splice_history_backfilling_transaction_count,migration)",
667+
"definition": "label_values(splice_history_backfilling_complete,migration)",
668668
"includeAll": true,
669669
"multi": true,
670670
"name": "migration",
671671
"options": [],
672672
"query": {
673673
"qryType": 1,
674-
"query": "label_values(splice_history_backfilling_transaction_count,migration)",
674+
"query": "label_values(splice_history_backfilling_complete,migration)",
675675
"refId": "PrometheusVariableQueryEditor-VariableQuery"
676676
},
677677
"refresh": 1,

nix/shell.nix

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ in pkgs.mkShell {
8686
python3Packages.sphinx-autobuild
8787
python3Packages.waitress
8888
python3.pkgs.sphinx-reredirects
89+
redocly
8990
ripgrep
9091
rsync
9192
sbt

project/ignore-patterns/canton_network_test_log.ignore.txt

-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ LogReporter - Aborted test suite
1515
Trying to gather entropy from the underlying operating system to initialized the contract ID seeding, but the entropy pool seems empty.
1616
In CI environments environment consider using the "testing-weak" mode, that may produce insecure contract IDs but does not block on startup.
1717

18-
# Ignore generic http 400/500 response errors as they are often benign.
19-
# TODO (#1734): consider implementing a more fine-granular ignore
20-
.*Http response at 400 or 500 level.*
21-
2218
# We use self-signed ledger API tokens for tests
2319
HMAC256 JWT Validator is NOT recommended for production environments
2420

0 commit comments

Comments
 (0)