@@ -109,7 +109,7 @@ class AkkaContainerClientTests
109109
110110 it should " not wait longer than set timeout" in {
111111 val timeout = 5 .seconds
112- val connection = new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout, 1 .B , 100 )
112+ val connection = new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout, 1 .B , 1 . B , 100 )
113113 testHang = timeout * 2
114114 val start = Instant .now()
115115 val result = Await .result(connection.post(" /init" , JsObject .empty, retry = true ), 10 .seconds)
@@ -123,15 +123,15 @@ class AkkaContainerClientTests
123123
124124 it should " handle empty entity response" in {
125125 val timeout = 5 .seconds
126- val connection = new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout, 1 .B , 100 )
126+ val connection = new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout, 1 .B , 1 . B , 100 )
127127 testStatusCode = 204
128128 val result = Await .result(connection.post(" /init" , JsObject .empty, retry = true ), 10 .seconds)
129129 result shouldBe Left (NoResponseReceived ())
130130 }
131131
132132 it should " retry till timeout on StreamTcpException" in {
133133 val timeout = 5 .seconds
134- val connection = new AkkaContainerClient (" 0.0.0.0" , 12345 , timeout, 1 .B , 100 )
134+ val connection = new AkkaContainerClient (" 0.0.0.0" , 12345 , timeout, 1 .B , 1 . B , 100 )
135135 val start = Instant .now()
136136 val result = Await .result(connection.post(" /init" , JsObject .empty, retry = true ), 10 .seconds)
137137 val end = Instant .now()
@@ -146,7 +146,7 @@ class AkkaContainerClientTests
146146
147147 it should " throw ContainerHealthError on HttpHostConnectException if reschedule==true" in {
148148 val timeout = 5 .seconds
149- val connection = new AkkaContainerClient (" 0.0.0.0" , 12345 , timeout, 1 .B , 100 )
149+ val connection = new AkkaContainerClient (" 0.0.0.0" , 12345 , timeout, 1 .B , 1 . B , 100 )
150150 assertThrows[ContainerHealthError ] {
151151 Await .result(connection.post(" /run" , JsObject .empty, retry = false , reschedule = true ), 10 .seconds)
152152 }
@@ -156,7 +156,7 @@ class AkkaContainerClientTests
156156 val timeout = 5 .seconds
157157 val retryInterval = 500 .milliseconds
158158 val connection =
159- new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout, 1 .B , 100 , retryInterval)
159+ new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout, 1 .B , 1 . B , 100 , retryInterval)
160160 val start = Instant .now()
161161 testConnectionFailCount = 5
162162 testResponse = " "
@@ -173,7 +173,7 @@ class AkkaContainerClientTests
173173
174174 it should " not truncate responses within limit" in {
175175 val timeout = 1 .minute.toMillis
176- val connection = new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout.millis, 50 .B , 100 )
176+ val connection = new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout.millis, 50 .B , 50 . B , 100 )
177177 Seq (true , false ).foreach { success =>
178178 Seq (null , " " , " abc" , """ {"a":"B"}""" , """ ["a", "b"]""" ).foreach { r =>
179179 testStatusCode = if (success) 200 else 500
@@ -188,15 +188,17 @@ class AkkaContainerClientTests
188188
189189 it should " truncate responses that exceed limit" in {
190190 val timeout = 1 .minute.toMillis
191- val limit = 1 .B
192- val connection = new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout.millis, limit, 100 )
191+ val limit = 2 .B
192+ val truncationLimit = 1 .B
193+ val connection =
194+ new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout.millis, limit, truncationLimit, 100 )
193195 Seq (true , false ).foreach { success =>
194196 Seq (" abc" , """ {"a":"B"}""" , """ ["a", "b"]""" ).foreach { r =>
195197 testStatusCode = if (success) 200 else 500
196198 testResponse = r
197199 val result = Await .result(connection.post(" /init" , JsObject .empty, retry = true ), 10 .seconds)
198200 result shouldBe Right {
199- ContainerResponse (okStatus = success, r.take(limit .toBytes.toInt), Some ((r.length.B , limit)))
201+ ContainerResponse (okStatus = success, r.take(truncationLimit .toBytes.toInt), Some ((r.length.B , limit)))
200202 }
201203 }
202204 }
@@ -207,15 +209,20 @@ class AkkaContainerClientTests
207209 // use a limit large enough to not fit into a single ByteString as response entity is parsed into multiple ByteStrings
208210 // seems like this varies, but often is ~64k or ~128k
209211 val limit = 300 .KB
210- val connection = new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout.millis, limit, 100 )
212+ val truncationLimit = 299 .B
213+ val connection =
214+ new AkkaContainerClient (httpHost.getHostName, httpHost.getPort, timeout.millis, limit, truncationLimit, 100 )
211215 Seq (true , false ).foreach { success =>
212216 // Generate a response that's 1MB
213217 val response = " 0" * 1024 * 1024
214218 testStatusCode = if (success) 200 else 500
215219 testResponse = response
216220 val result = Await .result(connection.post(" /init" , JsObject .empty, retry = true ), 10 .seconds)
217221 result shouldBe Right {
218- ContainerResponse (okStatus = success, response.take(limit.toBytes.toInt), Some ((response.length.B , limit)))
222+ ContainerResponse (
223+ okStatus = success,
224+ response.take(truncationLimit.toBytes.toInt),
225+ Some ((response.length.B , limit)))
219226 }
220227
221228 }
0 commit comments