Skip to content

Commit 5e61d64

Browse files
authored
DEX-958 Prepare release 2.2.4 (#401)
The right Diff for WsAddressChanges
1 parent 50b117b commit 5e61d64

3 files changed

Lines changed: 41 additions & 28 deletions

File tree

dex-it-common/src/main/scala/com/wavesplatform/dex/it/cache/CachedData.scala

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
11
package com.wavesplatform.dex.it.cache
22

3-
import java.util.concurrent.locks.ReentrantReadWriteLock
4-
53
class CachedData[T <: AnyRef](getData: => T) {
64

7-
private val lock = new ReentrantReadWriteLock()
8-
private val read = lock.readLock()
9-
private val write = lock.writeLock()
10-
11-
private var cached = Option.empty[T]
12-
13-
def get(): T =
14-
try {
15-
read.lock()
16-
cached match {
17-
case Some(x) => x
18-
case None =>
19-
val r = getData
20-
cached = Some(r)
21-
r
22-
}
23-
} finally read.unlock()
24-
25-
def invalidate(): Unit =
26-
try {
27-
write.lock()
28-
cached = None
29-
} finally write.unlock()
5+
@volatile private var cached = Option.empty[T]
6+
7+
def get(): T = synchronized {
8+
cached match {
9+
case Some(x) => x
10+
case None =>
11+
val r = getData
12+
cached = Some(r)
13+
r
14+
}
15+
}
16+
17+
def invalidate(): Unit = synchronized {
18+
cached = None
19+
}
3020

3121
}
3222

dex-it-common/src/main/scala/com/wavesplatform/dex/it/docker/BaseContainer.scala

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ abstract class BaseContainer(protected val baseContainerPath: String, private va
134134
}
135135

136136
def connectToNetwork(): Unit = {
137-
invalidateCaches()
138-
139137
dockerClient
140138
.connectToNetworkCmd()
141139
.withContainerId(underlying.containerId)
@@ -147,11 +145,33 @@ abstract class BaseContainer(protected val baseContainerPath: String, private va
147145
)
148146
.exec()
149147

148+
Iterator
149+
.continually {
150+
Thread.sleep(1000)
151+
dockerClient.inspectContainerCmd(underlying.containerId).exec().getNetworkSettings
152+
}
153+
.zipWithIndex
154+
.find { case (ns, attempt) =>
155+
ns.getNetworks.asScala.exists(_._2.getNetworkID == underlying.network.getId) || attempt == 20
156+
}
157+
.fold(log.warn(s"Can't start ${underlying.containerId}"))(_ => ())
158+
159+
invalidateCaches()
150160
waitReady()
151161
}
152162

153163
override def start(): Unit = {
154164
Option(underlying.containerId).fold(super.start())(_ => sendStartCmd())
165+
166+
Iterator
167+
.continually {
168+
Thread.sleep(1000)
169+
dockerClient.inspectContainerCmd(underlying.containerId).exec().getState
170+
}
171+
.zipWithIndex
172+
.find { case (state, attempt) => state.getRunning || attempt == 20 }
173+
.fold(log.warn(s"Can't start ${underlying.containerId}"))(_ => ())
174+
155175
invalidateCaches()
156176
waitReady()
157177
}

dex-it/src/test/scala/com/wavesplatform/it/WsSuiteBase.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.softwaremill.diffx.{Derived, Diff}
55
import com.wavesplatform.dex.api.ws.connection.WsConnection
66
import com.wavesplatform.dex.api.ws.connection.WsConnection.WsRawMessage
77
import com.wavesplatform.dex.api.ws.entities.WsFullOrder
8-
import com.wavesplatform.dex.api.ws.protocol.{WsError, WsPingOrPong, WsServerMessage}
8+
import com.wavesplatform.dex.api.ws.protocol.{WsAddressChanges, WsError, WsPingOrPong, WsServerMessage}
99
import com.wavesplatform.dex.it.api.websockets.HasWebSockets
1010

1111
import scala.concurrent.duration.{DurationInt, FiniteDuration}
@@ -15,6 +15,9 @@ trait WsSuiteBase extends MatcherSuiteBase with HasWebSockets {
1515

1616
implicit protected val wsErrorDiff: Diff[WsError] = Derived[Diff[WsError]].ignore[WsError, Long](_.timestamp)
1717

18+
implicit protected val wsAddressChangesDiff: Diff[WsAddressChanges] =
19+
Derived[Diff[WsAddressChanges]].ignore[WsAddressChanges, Long](_.timestamp)
20+
1821
implicit protected val wsCompleteOrderDiff: Diff[WsFullOrder] =
1922
Derived[Diff[WsFullOrder]].ignore[WsFullOrder, Long](_.timestamp).ignore[WsFullOrder, Long](_.eventTimestamp)
2023

0 commit comments

Comments
 (0)