Skip to content

Commit 20417de

Browse files
Fix deprecated error (#5128)
* Fix deprecated error * Make testcase stable
1 parent 9279626 commit 20417de

File tree

5 files changed

+17
-45
lines changed

5 files changed

+17
-45
lines changed

common/scala/src/main/scala/org/apache/openwhisk/core/database/mongodb/MongoDBArtifactStore.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package org.apache.openwhisk.core.database.mongodb
2020
import akka.actor.ActorSystem
2121
import akka.event.Logging.ErrorLevel
2222
import akka.http.scaladsl.model._
23-
import akka.stream.ActorMaterializer
2423
import akka.stream.scaladsl._
2524
import akka.util.ByteString
2625
import com.mongodb.client.gridfs.model.GridFSUploadOptions
@@ -64,7 +63,6 @@ class MongoDBArtifactStore[DocumentAbstraction <: DocumentSerializer](client: Mo
6463
implicit system: ActorSystem,
6564
val logging: Logging,
6665
jsonFormat: RootJsonFormat[DocumentAbstraction],
67-
val materializer: ActorMaterializer,
6866
docReader: DocumentReader)
6967
extends ArtifactStore[DocumentAbstraction]
7068
with DocumentProvider

common/scala/src/main/scala/org/apache/openwhisk/core/database/mongodb/MongoDBArtifactStoreProvider.scala

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.openwhisk.core.database.mongodb
1919

2020
import akka.actor.ActorSystem
21-
import akka.stream.ActorMaterializer
2221
import org.apache.openwhisk.common.Logging
2322
import org.apache.openwhisk.core.ConfigKeys
2423
import org.apache.openwhisk.core.database._
@@ -51,12 +50,10 @@ object MongoDBClient {
5150

5251
object MongoDBArtifactStoreProvider extends ArtifactStoreProvider {
5352

54-
def makeStore[D <: DocumentSerializer: ClassTag](useBatching: Boolean)(
55-
implicit jsonFormat: RootJsonFormat[D],
56-
docReader: DocumentReader,
57-
actorSystem: ActorSystem,
58-
logging: Logging,
59-
materializer: ActorMaterializer): ArtifactStore[D] = {
53+
def makeStore[D <: DocumentSerializer: ClassTag](useBatching: Boolean)(implicit jsonFormat: RootJsonFormat[D],
54+
docReader: DocumentReader,
55+
actorSystem: ActorSystem,
56+
logging: Logging): ArtifactStore[D] = {
6057
val dbConfig = loadConfigOrThrow[MongoDBConfig](ConfigKeys.mongodb)
6158
makeArtifactStore(dbConfig, getAttachmentStore())
6259
}
@@ -66,8 +63,7 @@ object MongoDBArtifactStoreProvider extends ArtifactStoreProvider {
6663
implicit jsonFormat: RootJsonFormat[D],
6764
docReader: DocumentReader,
6865
actorSystem: ActorSystem,
69-
logging: Logging,
70-
materializer: ActorMaterializer): ArtifactStore[D] = {
66+
logging: Logging): ArtifactStore[D] = {
7167

7268
val inliningConfig = loadConfigOrThrow[InliningConfig](ConfigKeys.db)
7369

@@ -83,10 +79,8 @@ object MongoDBArtifactStoreProvider extends ArtifactStoreProvider {
8379
attachmentStore)
8480
}
8581

86-
private def handlerAndMapper[D](entityType: ClassTag[D])(
87-
implicit actorSystem: ActorSystem,
88-
logging: Logging,
89-
materializer: ActorMaterializer): (DocumentHandler, MongoDBViewMapper) = {
82+
private def handlerAndMapper[D](entityType: ClassTag[D])(implicit actorSystem: ActorSystem,
83+
logging: Logging): (DocumentHandler, MongoDBViewMapper) = {
9084
entityType.runtimeClass match {
9185
case x if x == classOf[WhiskEntity] =>
9286
(WhisksHandler, WhisksViewMapper)

tests/src/test/scala/org/apache/openwhisk/core/containerpool/v2/test/FunctionPullingContainerProxyTests.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,9 +1360,10 @@ class FunctionPullingContainerProxyTests
13601360
val (client, clientFactory) = testClient
13611361
val instanceId = InvokerInstanceId(0, userMemory = defaultUserMemory)
13621362

1363+
val pool = TestProbe()
13631364
val probe = TestProbe()
13641365
val machine =
1365-
probe.childActorOf(
1366+
pool.childActorOf(
13661367
FunctionPullingContainerProxy
13671368
.props(
13681369
factory,
@@ -1399,7 +1400,7 @@ class FunctionPullingContainerProxyTests
13991400
""))
14001401

14011402
probe.expectMsg(Transition(machine, CreatingClient, ClientCreated))
1402-
expectInitialized(probe)
1403+
expectInitialized(pool)
14031404
client.expectMsg(RequestActivation())
14041405
client.send(machine, message)
14051406

@@ -1412,7 +1413,7 @@ class FunctionPullingContainerProxyTests
14121413
machine ! StateTimeout
14131414
client.send(machine, RetryRequestActivation)
14141415
probe.expectMsg(Transition(machine, Running, Pausing))
1415-
probe.expectMsgType[ContainerIsPaused]
1416+
pool.expectMsgType[ContainerIsPaused]
14161417
dataManagementService.expectMsgAllOf(
14171418
RegisterData(
14181419
ContainerKeys
@@ -1440,10 +1441,9 @@ class FunctionPullingContainerProxyTests
14401441
Some(instanceId),
14411442
Some(testContainerId)),
14421443
""))
1443-
inAnyOrder {
1444-
probe.expectMsg(Transition(machine, Paused, Running))
1445-
probe.expectMsgType[Resumed]
1446-
}
1444+
1445+
probe.expectMsg(Transition(machine, Paused, Running))
1446+
pool.expectMsgType[Resumed]
14471447

14481448
awaitAssert {
14491449
factory.calls should have size 1

tests/src/test/scala/org/apache/openwhisk/core/database/mongodb/MongoDBAsyncStreamGraphTests.scala

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ package org.apache.openwhisk.core.database.mongodb
1919

2020
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, IOException, InputStream}
2121

22-
import akka.stream.ActorMaterializer
23-
import akka.stream.scaladsl.{Keep, Sink, Source, StreamConverters}
22+
import akka.stream.scaladsl.{Keep, Sink, StreamConverters}
2423
import akka.stream.testkit.TestSubscriber
2524
import akka.util.ByteString
2625
import common.WskActorSystem
@@ -45,8 +44,6 @@ class MongoDBAsyncStreamGraphTests
4544
with MockitoSugar
4645
with IntegrationPatience {
4746

48-
implicit val mat = ActorMaterializer()
49-
5047
behavior of "MongoDBAsyncStreamSource"
5148

5249
it should "read all bytes" in {
@@ -79,7 +76,7 @@ class MongoDBAsyncStreamGraphTests
7976
doThrow(exception).when(inputStream).read(any())
8077
val asyncStream = AsyncStreamHelper.toAsyncInputStream(inputStream)
8178

82-
val (ioResult, p) = MongoDBAsyncStreamSource(asyncStream).toMat(Sink.asPublisher(false))(Keep.both).run()
79+
val (_, p) = MongoDBAsyncStreamSource(asyncStream).toMat(Sink.asPublisher(false))(Keep.both).run()
8380
val c = TestSubscriber.manualProbe[ByteString]()
8481
p.subscribe(c)
8582

@@ -89,7 +86,6 @@ class MongoDBAsyncStreamGraphTests
8986
val error = c.expectError()
9087
error.getCause should be theSameInstanceAs exception
9188

92-
ioResult.futureValue.status.isFailure shouldBe true
9389
}
9490

9591
behavior of "MongoDBAsyncStreamSink"
@@ -125,21 +121,6 @@ class MongoDBAsyncStreamGraphTests
125121
outputStream.closed shouldBe true
126122
}
127123

128-
it should "onError with failure and return a failed IOResult when writing to failed stream" in {
129-
val os = new ByteArrayOutputStream()
130-
val asyncStream = AsyncStreamHelper.toAsyncOutputStream(os)
131-
132-
val sink = MongoDBAsyncStreamSink(asyncStream)
133-
val ioResult = Source(1 to 10)
134-
.map { n
135-
if (n == 7) throw new Error("bees!")
136-
n
137-
}
138-
.map(ByteString(_))
139-
.runWith(sink)
140-
ioResult.futureValue.status.isFailure shouldBe true
141-
}
142-
143124
private def randomBytes(size: Int): Array[Byte] = {
144125
val arr = new Array[Byte](size)
145126
Random.nextBytes(arr)

tests/src/test/scala/org/apache/openwhisk/core/database/mongodb/MongoDBStoreBehaviorBase.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ trait MongoDBStoreBehaviorBase extends FlatSpec with ArtifactStoreBehaviorBase {
4646
WhiskEntityJsonFormat,
4747
WhiskDocumentReader,
4848
actorSystem,
49-
logging,
50-
materializer)
49+
logging)
5150

5251
override lazy val activationStore = {
5352
implicit val docReader: DocumentReader = WhiskDocumentReader

0 commit comments

Comments
 (0)