Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEX-878 Test improvements #339

Merged
merged 1 commit into from
Aug 13, 2020
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
10 changes: 5 additions & 5 deletions Jenkinsfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ pipeline {
}
environment {
SBT_HOME = tool name: 'sbt-1.2.6', type: 'org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation'
SBT_OPTS = '-Xmx2g -XX:ReservedCodeCacheSize=128m -XX:+CMSClassUnloadingEnabled'
SBT_OPTS = '-Xmx2g -XX:ReservedCodeCacheSize=128m'
PATH = "${env.SBT_HOME}/bin:${env.PATH}"
}
stages {
stage('Clean & Compile') {
steps {
stage('Cleanup') {
steps {
sh 'git fetch --tags'
sh 'find ~/.sbt/1.0/staging/*/waves -type d -name target | xargs -I{} rm -rf {}'
sh 'find . -type d -name target | xargs -I{} rm -rf {}'
sh 'sbt "set Global / scalacOptions ++= Seq(\\"-Xfatal-warnings\\", \\"-Ywarn-unused:-imports\\");session save;cleanAll;compile"'
sh 'sbt "cleanAll"'
}
}
stage('Release') {
Expand All @@ -23,7 +23,7 @@ pipeline {
}
}
}

post {
success {
archiveArtifacts artifacts: 'release.tgz', fingerprint: true
Expand Down
27 changes: 11 additions & 16 deletions Jenkinsfile.tests
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,32 @@ pipeline {
PATH = "${env.SBT_HOME}/bin:${env.PATH}"
}
stages {
stage('Cleanup & Compile') {
stage('Cleanup') {
steps {
script {
if (!(BRANCH_NAME ==~ /(DEX\-.*|master|version\-.*)/)) {
catchError(message: 'The branch have an incorrect name. Allowed names: master, version-, DEX-', buildResult: 'UNSTABLE', stageResult: 'UNSTABLE')
}
}
sh 'git fetch --tags'
sh 'docker system prune -f || true'
sh 'docker rmi `docker images --format "{{.Repository}}:{{.Tag}}" | grep "wavesplatform"` || true'
sh 'find ~/.sbt/1.0/staging/*/waves -type d -name target | xargs -I{} rm -rf {}'
sh 'find . -type d \\( -name "test-reports" -o -name "allure-results" -o -name "target" \\) | xargs -I{} rm -rf {}'
sh 'sbt "set Global / scalacOptions ++= Seq(\\"-Xfatal-warnings\\", \\"-Ywarn-unused:-imports\\");session save;cleanAll;compile"'
sh 'find . -type d -name target | xargs -I{} rm -rf {}'
sh 'sbt "cleanAll"'
}
}
stage('Run Unit Tests') {
steps {
sh 'sbt "waves-ext/test;waves-integration/test;dex/test"'
}
}
stage('Build Docker') {
steps {
sh 'docker rmi com.wavesplatform/it com.wavesplatform/node-it com.wavesplatform/dex-it || true'
sh 'sbt dex-it/docker'
}
stage('Build & Run All Tests') {
steps {
sh 'sbt "fullCheck"'
}
}
stage ('Run Integration Tests') {
stage ('Push images') {
steps {
sh 'sbt dex-it/test'
build job: 'Waves.Exchange/Matcher/Push Docker Images', propagate: false, wait: false, parameters: [
[$class: 'StringParameterValue', name: 'BRANCH', value: "${BRANCH_NAME}"]
]
}
}
}
}
post {
Expand Down
16 changes: 6 additions & 10 deletions Jenkinsfile.tests.kafka
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,18 @@ pipeline {
PATH = "${env.SBT_HOME}/bin:${env.PATH}"
}
stages {
stage('Cleanup & Compile') {
stage('Cleanup') {
steps {
sh 'git fetch --tags'
sh 'docker system prune -f || true'
sh 'docker rmi `docker images --format "{{.Repository}}:{{.Tag}}" | grep "wavesplatform"` || true'
sh 'find ~/.sbt/1.0/staging/*/waves -type d -name target | xargs -I{} rm -rf {}'
sh 'find . -type d -name target | xargs -I{} rm -rf {}'
sh 'sbt "set Global / scalacOptions ++= Seq(\\"-Xfatal-warnings\\", \\"-Ywarn-unused:-imports\\");session save;cleanAll;compile"'
sh 'sbt "cleanAll"'
}
}
stage('Run Unit Tests') {
steps {
sh 'sbt "waves-ext/test;waves-integration/test;dex/test"'
}
}
}
stage('Build Docker') {
steps {
sh 'docker rmi com.wavesplatform/it com.wavesplatform/node-it com.wavesplatform/dex-it || true'
steps {
sh 'sbt dex-it/docker'
}
}
Expand Down
27 changes: 7 additions & 20 deletions Jenkinsfile.tests.multiple-versions
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,24 @@ pipeline {
SBT_OPTS = '-Xmx2g -XX:ReservedCodeCacheSize=128m -XX:+CMSClassUnloadingEnabled'
SCALATEST_INCLUDE_TAGS = 'com.wavesplatform.it.tags.DexMultipleVersions'
KAFKA_SERVER = "${KAFKA_SERVER}"
DEX_MULTIPLE_VERSIONS_PREVIOUS_TAG = "${DEX_MULTIPLE_VERSIONS_PREVIOUS_TAG}"
NODE_MULTIPLE_VERSIONS_PREVIOUS_TAG = "${NODE_MULTIPLE_VERSIONS_PREVIOUS_TAG}"
OTHER_DEX_IMAGE = "${OTHER_DEX_IMAGE}"
OTHER_NODE_IMAGE = "${OTHER_NODE_IMAGE}"
PATH = "${env.SBT_HOME}/bin:${env.PATH}"
}
stages {
stage('Cleanup & Compile') {
stage('Cleanup') {
steps {
sh 'git fetch --tags'
sh 'docker system prune -f || true'
sh 'docker rmi `docker images --format "{{.Repository}}:{{.Tag}}" | grep "wavesplatform"` || true'
sh 'find ~/.sbt/1.0/staging/*/waves -type d -name target | xargs -I{} rm -rf {}'
sh 'find . -type d -name target | xargs -I{} rm -rf {}'
sh 'sbt "set Global / scalacOptions ++= Seq(\\"-Xfatal-warnings\\", \\"-Ywarn-unused:-imports\\");session save;cleanAll;compile"'
}
}
stage('Run Unit Tests') {
steps {
sh 'sbt "waves-ext/test;waves-integration/test;dex/test"'
sh 'sbt "cleanAll"'
}
}
stage('Build Docker') {
steps {
sh 'docker rmi com.wavesplatform/it com.wavesplatform/node-it com.wavesplatform/dex-it || true'
sh "docker pull ${REGISTRY}/waves/dex/dex-it:${DEX_MULTIPLE_VERSIONS_PREVIOUS_TAG}"
sh "docker pull ${REGISTRY}/waves/dex/waves-integration-it:${NODE_MULTIPLE_VERSIONS_PREVIOUS_TAG}"
sh '''
IMAGES=`docker image ls | grep "${REGISTRY}/waves/dex/" | awk -v r=${REGISTRY} '{gsub(r "/waves/dex/", "", $1); print $1 ":" $2}'`
for i in $IMAGES
do
docker tag ${REGISTRY}"/waves/dex/"$i "wavesplatform/"$i
done
'''
sh 'sbt dex-it/docker'
sh 'sbt dex-it/docker'
}
}
stage ('Run Integration Tests with multiple versions') {
Expand Down
23 changes: 5 additions & 18 deletions Jenkinsfile.tests.specified-versions
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,19 @@ pipeline {
PATH = "${env.SBT_HOME}/bin:${env.PATH}"
}
stages {
stage('Cleanup & Compile') {
stage('Cleanup') {
steps {
sh 'git fetch --tags'
sh 'docker system prune -f || true'
sh 'docker rmi `docker images --format "{{.Repository}}:{{.Tag}}" | grep "wavesplatform"` || true'
sh 'find ~/.sbt/1.0/staging/*/waves -type d -name target | xargs -I{} rm -rf {}'
sh 'find . -type d -name target | xargs -I{} rm -rf {}'
sh 'sbt "set Global / scalacOptions ++= Seq(\\"-Xfatal-warnings\\", \\"-Ywarn-unused:-imports\\");session save;cleanAll;compile"'
}
}
stage('Run Unit Tests') {
steps {
sh 'sbt "waves-ext/test;waves-integration/test;dex/test"'
sh 'sbt "cleanAll"'
}
}
stage('Build Docker') {
steps {
sh 'docker rmi com.wavesplatform/it com.wavesplatform/node-it com.wavesplatform/dex-it || true'
sh "docker pull ${REGISTRY}/waves/dex/dex-it:${DEX_TAG}"
sh "docker pull ${REGISTRY}/waves/dex/waves-integration-it:${NODE_TAG}"
sh '''
IMAGES=`docker image ls | grep "${REGISTRY}/waves/dex/" | awk -v r=${REGISTRY} '{gsub(r "/waves/dex/", "", $1); print $1 ":" $2}'`
for i in $IMAGES
do
docker tag ${REGISTRY}"/waves/dex/"$i "wavesplatform/"$i
done
'''
sh 'sbt dex-it/docker'
sh 'sbt dex-it/docker'
}
}
stage ('Run Integration Tests with specified versions') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import com.wavesplatform.dex.it.dex.HasDex
import com.wavesplatform.dex.it.docker.{DexContainer, WavesNodeContainer}

trait MultipleVersions extends HasDex with HasWavesNode { self: BaseContainersKit =>
private val dex2Tag = Option(System.getenv("DEX_MULTIPLE_VERSIONS_PREVIOUS_TAG")).getOrElse("latest")
private val node2Tag = Option(System.getenv("NODE_MULTIPLE_VERSIONS_PREVIOUS_TAG")).getOrElse("latest")
private lazy val dex2Image = Option(System.getenv("OTHER_DEX_IMAGE"))
.getOrElse(throw new RuntimeException("Please specify the OTHER_DEX_IMAGE environment variable"))

protected lazy val wavesNode2: WavesNodeContainer = createWavesNode("waves-2", tag = node2Tag, netAlias = None)
private lazy val node2Image = Option(System.getenv("OTHER_NODE_IMAGE"))
.getOrElse(throw new RuntimeException("Please specify the OTHER_NODE_IMAGE environment variable"))

protected lazy val wavesNode2: WavesNodeContainer = createWavesNode("waves-2", image = node2Image, netAlias = None)

protected def dex2SuiteConfig: Config = dexInitialSuiteConfig.withFallback {
ConfigFactory.parseString(
Expand All @@ -19,5 +22,5 @@ trait MultipleVersions extends HasDex with HasWavesNode { self: BaseContainersKi
)
}

protected lazy val dex2: DexContainer = createDex("dex-2", suiteInitialConfig = dex2SuiteConfig, tag = dex2Tag)
protected lazy val dex2: DexContainer = createDex("dex-2", suiteInitialConfig = dex2SuiteConfig, image = dex2Image)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import com.wavesplatform.dex.it.fp.CanExtract
import mouse.any._

trait HasWavesNode { self: BaseContainersKit =>
private val defaultTag = Option(System.getenv("NODE_TAG")).getOrElse("latest")
protected val defaultNodeImage = "wavesplatform/waves-integration-it:latest"
private val nodeImage = Option(System.getenv("NODE_IMAGE")).getOrElse(defaultNodeImage)

protected implicit def toNodeExplicitGetOps[F[_]: Functor: CanExtract](self: NodeApi[F]): NodeApiOps.ExplicitGetNodeApiOps[F] = {
new NodeApiOps.ExplicitGetNodeApiOps[F](self)
Expand All @@ -22,9 +23,9 @@ trait HasWavesNode { self: BaseContainersKit =>
protected def createWavesNode(name: String,
runConfig: Config = wavesNodeRunConfig,
suiteInitialConfig: Config = wavesNodeInitialSuiteConfig,
tag: String = defaultTag,
image: String = nodeImage,
netAlias: Option[String] = Some(WavesNodeContainer.wavesNodeNetAlias)): WavesNodeContainer =
WavesNodeContainer(name, networkName, network, getIp(name), runConfig, suiteInitialConfig, localLogsDir, tag, netAlias) unsafeTap addKnownContainer
WavesNodeContainer(name, networkName, network, getIp(name), runConfig, suiteInitialConfig, localLogsDir, image, netAlias) unsafeTap addKnownContainer

lazy val wavesNode1: WavesNodeContainer = createWavesNode("waves-1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ object GenesisConfigGenerator {
ConfigFactory.parseString(
s"""waves.blockchain.custom {
| address-scheme-character = "${generatorSettings.chainId.toChar}"
| functionality.min-block-time = ${settings.averageBlockDelay.toMillis}ms
| genesis {
| timestamp: ${settings.timestamp}
| signature: ${genesisBlock.signerData.signature}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import org.apache.kafka.clients.admin.{AdminClient, NewTopic}
import scala.jdk.CollectionConverters._

trait HasDex { self: BaseContainersKit =>
private val defaultTag = Option(System.getenv("DEX_TAG")).getOrElse("latest")
protected val defaultDexImage = "wavesplatform/dex-it:latest"
private val dexImage = Option(System.getenv("DEX_IMAGE")).getOrElse(defaultDexImage)

protected implicit def toDexExplicitGetOps[F[_]: CanExtract: Functor](self: DexApi[F]): DexApiOps.ExplicitGetDexApiOps[F] = {
new DexApiOps.ExplicitGetDexApiOps[F](self)
Expand All @@ -41,8 +42,8 @@ trait HasDex { self: BaseContainersKit =>
protected def createDex(name: String,
runConfig: Config = dexRunConfig,
suiteInitialConfig: Config = dexInitialSuiteConfig,
tag: String = defaultTag): DexContainer =
DexContainer(name, networkName, network, getIp(name), runConfig, suiteInitialConfig, localLogsDir, tag) unsafeTap addKnownContainer
image: String = dexImage): DexContainer =
DexContainer(name, networkName, network, getIp(name), runConfig, suiteInitialConfig, localLogsDir, image) unsafeTap addKnownContainer

lazy val dex1: DexContainer = createDex("dex-1")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ object DexContainer extends ScorexLogging {
runConfig: Config,
suiteInitialConfig: Config,
localLogsDir: Path,
tag: String)(implicit
tryHttpBackend: LoggingSttpBackend[Try, Nothing],
futureHttpBackend: LoggingSttpBackend[Future, Nothing],
ec: ExecutionContext): DexContainer = {
image: String)(implicit
tryHttpBackend: LoggingSttpBackend[Try, Nothing],
futureHttpBackend: LoggingSttpBackend[Future, Nothing],
ec: ExecutionContext): DexContainer = {

val underlying = GenericContainer(
dockerImage = s"wavesplatform/dex-it:$tag",
dockerImage = image,
exposedPorts = Seq(restApiPort),
env = getEnv(name),
waitStrategy = ignoreWaitStrategy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ object WavesNodeContainer extends ScorexLogging {
runConfig: Config,
suiteInitialConfig: Config,
localLogsDir: Path,
tag: String,
image: String,
netAlias: Option[String] = Some(wavesNodeNetAlias))(implicit
tryHttpBackend: LoggingSttpBackend[Try, Nothing],
futureHttpBackend: LoggingSttpBackend[Future, Nothing],
ec: ExecutionContext): WavesNodeContainer = {

val underlying = GenericContainer(
dockerImage = s"wavesplatform/waves-integration-it:$tag",
dockerImage = image,
exposedPorts = List(restApiPort, networkPort, dexGrpcExtensionPort),
env = getEnv(name, internalIp),
waitStrategy = ignoreWaitStrategy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MultipleMatchersOrderCancelTestSuite extends MatcherSuiteBase {
val submittedOrders = (1 to 3).map { amt =>
mkOrderDP(acc2, wavesUsdPair, OrderType.BUY, amt.waves, amt)
}
submittedOrders.foreach(placeAndAwaitAtDex(_, Status.Filled, dex2)) // <--
submittedOrders.foreach(placeAndAwaitAtDex(_, Status.Filled, dex2))
submittedOrders.foreach(waitForOrderAtNode(_, dex2.api))

(0 to 2).foreach { i =>
Expand Down