forked from digital-asset/daml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JSON API: add PruningTest and make it pass (digital-asset#17167)
If the ledger has been pruned more recently that the last cached copy, then attempting to fetch the changes since that last offset will fail, rending the relevant template(s) unqueryable. This PR detects that condition, clears the cache for the relevant template and queries again, which will refresh the cache with a fresh copy of the ACS for that template, and serve the query from that. I also made some usability tweaks around running canton-ee tests, to help improve the dev experience for failures I came across while trying to run them. Specifically * Use `--config=canton-ee` to opt into the tests which require canton-ee * When downloading that EE from artifactory, provide better diagnostics if the required auth isn't set up.
- Loading branch information
1 parent
3e846d9
commit 47d21fe
Showing
14 changed files
with
182 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
ledger-service/http-json/src/it/edition/ee/com/daml/http/PruningTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.http | ||
|
||
final class PruningTest | ||
extends AbstractHttpServiceIntegrationTestFunsCustomToken | ||
with HttpServicePostgresInt { | ||
|
||
override def staticContentConfig: Option[StaticContentConfig] = None | ||
override def useTls = HttpServiceTestFixture.UseTls.Tls | ||
override def wsConfig: Option[WebsocketConfig] = None | ||
|
||
import com.daml.ledger.api.v1.admin.{participant_pruning_service => PruneGrpc} | ||
"fail querying after pruned offset" in withHttpService { fixture => | ||
import scala.concurrent.duration._ | ||
import com.daml.timer.RetryStrategy | ||
for { | ||
(alice, aliceHeaders) <- fixture.getUniquePartyAndAuthHeaders("Alice") | ||
query = jsObject(s"""{"templateIds": ["Iou:Iou"]}""") | ||
|
||
// do query to populate cache | ||
_ <- searchExpectOk(List(), query, fixture, aliceHeaders) | ||
|
||
// perform more actions on the ledger | ||
(offsetBeforeArchive, offsetAfterArchive) <- offsetBeforeAfterArchival( | ||
alice, | ||
fixture, | ||
aliceHeaders, | ||
) | ||
|
||
// prune, at an offset that is later than the last cache refresh. | ||
_ <- RetryStrategy.constant(20, 1.second) { case (_, _) => | ||
for { | ||
// Add artificial ledger activity to advance the safe prune offset. Repeated on failure. | ||
_ <- postCreateCommand(iouCreateCommand(alice), fixture, aliceHeaders) | ||
pruned <- PruneGrpc.ParticipantPruningServiceGrpc | ||
.stub(fixture.client.channel) | ||
.prune( | ||
PruneGrpc.PruneRequest( | ||
pruneUpTo = domain.Offset unwrap offsetAfterArchive, | ||
pruneAllDivulgedContracts = true, | ||
) | ||
) | ||
} yield pruned should ===(PruneGrpc.PruneResponse()) | ||
} | ||
|
||
// now query again to ensure it handles PARTICIPANT_PRUNED_DATA_ACCESSED gracefully | ||
_ <- searchExpectOk(List(), query, fixture, aliceHeaders) | ||
} yield succeed | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.