-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JSON-API] Migrating tests to use sandbox next (#11034)
* Changes to use sandbox next for our integration tests CHANGELOG_BEGIN CHANGELOG_END * remove sandbox classic dependency for HttpServiceTestFixture and perf tests * rely on sandbox next fixture test class * add missing dependencies for http-json-oracle * changes based on code review comments * Add tag to skip test case for scala_2_12 and also add a jdbc backend for sandbox spun up for perf tests * Reduce size of contracts for archiving test
- Loading branch information
1 parent
ffc8d68
commit d3e6f16
Showing
11 changed files
with
521 additions
and
246 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
78 changes: 78 additions & 0 deletions
78
ledger-service/http-json-testing/src/main/scala/com/daml/http/util/SandboxTestLedger.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,78 @@ | ||
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.http.util | ||
|
||
import com.daml.grpc.adapter.ExecutionSequencerFactory | ||
import com.daml.http.HttpServiceTestFixture.{UseTls, clientTlsConfig, serverTlsConfig} | ||
import com.daml.ledger.api.domain.LedgerId | ||
import com.daml.ledger.client.configuration.{ | ||
CommandClientConfiguration, | ||
LedgerClientConfiguration, | ||
LedgerIdRequirement, | ||
} | ||
import com.daml.ports.Port | ||
import com.daml.ledger.client.withoutledgerid.{LedgerClient => DamlLedgerClient} | ||
import com.daml.platform.apiserver.SeedService.Seeding | ||
import com.daml.platform.common.LedgerIdMode | ||
import com.daml.platform.sandbox.config.SandboxConfig | ||
import com.daml.platform.sandboxnext.SandboxNextFixture | ||
import com.daml.platform.services.time.TimeProviderType | ||
import org.scalatest.Suite | ||
|
||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
trait SandboxTestLedger extends SandboxNextFixture { | ||
self: Suite => | ||
|
||
protected def testId: String | ||
|
||
def useTls: UseTls | ||
|
||
def ledgerId = LedgerId(testId) | ||
|
||
override protected def config: SandboxConfig = SandboxConfig.defaultConfig.copy( | ||
port = Port.Dynamic, | ||
damlPackages = packageFiles, | ||
timeProviderType = Some(TimeProviderType.WallClock), | ||
tlsConfig = if (useTls) Some(serverTlsConfig) else None, | ||
ledgerIdMode = LedgerIdMode.Static(ledgerId), | ||
authService = authService, | ||
scenario = scenario, | ||
engineMode = SandboxConfig.EngineMode.Dev, | ||
seeding = Some(Seeding.Weak), | ||
) | ||
|
||
def clientCfg(token: Option[String], testName: String): LedgerClientConfiguration = | ||
LedgerClientConfiguration( | ||
applicationId = testName, | ||
ledgerIdRequirement = LedgerIdRequirement.none, | ||
commandClient = CommandClientConfiguration.default, | ||
sslContext = if (useTls) clientTlsConfig.client() else None, | ||
token = token, | ||
) | ||
|
||
def usingLedger[A](testName: String, token: Option[String] = None)( | ||
testFn: (Port, DamlLedgerClient, LedgerId) => Future[A] | ||
)(implicit | ||
esf: ExecutionSequencerFactory, | ||
ec: ExecutionContext, | ||
): Future[A] = { | ||
|
||
val clientF: Future[DamlLedgerClient] = for { | ||
ledgerPort <- Future(serverPort) | ||
} yield DamlLedgerClient.singleHost( | ||
"localhost", | ||
ledgerPort.value, | ||
clientCfg(token, testName), | ||
)(ec, esf) | ||
|
||
val fa: Future[A] = for { | ||
ledgerPort <- Future(serverPort) | ||
client <- clientF | ||
a <- testFn(ledgerPort, client, ledgerId) | ||
} yield a | ||
|
||
fa | ||
} | ||
} |
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
Oops, something went wrong.