This is an automated email from the ASF dual-hosted git repository.
dgrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new 20417de Fix deprecated error (#5128)
20417de is described below
commit 20417de0e73b8c15f162c20efb66d2df027dcfa4
Author: jiangpch <[email protected]>
AuthorDate: Wed Jun 9 21:10:51 2021 +0800
Fix deprecated error (#5128)
* Fix deprecated error
* Make testcase stable
---
.../database/mongodb/MongoDBArtifactStore.scala | 2 --
.../mongodb/MongoDBArtifactStoreProvider.scala | 20 +++++++------------
.../test/FunctionPullingContainerProxyTests.scala | 14 ++++++-------
.../mongodb/MongoDBAsyncStreamGraphTests.scala | 23 ++--------------------
.../mongodb/MongoDBStoreBehaviorBase.scala | 3 +--
5 files changed, 17 insertions(+), 45 deletions(-)
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/mongodb/MongoDBArtifactStore.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/mongodb/MongoDBArtifactStore.scala
index bab4a1f..a7dd33e 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/mongodb/MongoDBArtifactStore.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/mongodb/MongoDBArtifactStore.scala
@@ -20,7 +20,6 @@ package org.apache.openwhisk.core.database.mongodb
import akka.actor.ActorSystem
import akka.event.Logging.ErrorLevel
import akka.http.scaladsl.model._
-import akka.stream.ActorMaterializer
import akka.stream.scaladsl._
import akka.util.ByteString
import com.mongodb.client.gridfs.model.GridFSUploadOptions
@@ -64,7 +63,6 @@ class MongoDBArtifactStore[DocumentAbstraction <:
DocumentSerializer](client: Mo
implicit system: ActorSystem,
val logging: Logging,
jsonFormat: RootJsonFormat[DocumentAbstraction],
- val materializer: ActorMaterializer,
docReader: DocumentReader)
extends ArtifactStore[DocumentAbstraction]
with DocumentProvider
diff --git
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/mongodb/MongoDBArtifactStoreProvider.scala
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/mongodb/MongoDBArtifactStoreProvider.scala
index 555b274..6c3adca 100644
---
a/common/scala/src/main/scala/org/apache/openwhisk/core/database/mongodb/MongoDBArtifactStoreProvider.scala
+++
b/common/scala/src/main/scala/org/apache/openwhisk/core/database/mongodb/MongoDBArtifactStoreProvider.scala
@@ -18,7 +18,6 @@
package org.apache.openwhisk.core.database.mongodb
import akka.actor.ActorSystem
-import akka.stream.ActorMaterializer
import org.apache.openwhisk.common.Logging
import org.apache.openwhisk.core.ConfigKeys
import org.apache.openwhisk.core.database._
@@ -51,12 +50,10 @@ object MongoDBClient {
object MongoDBArtifactStoreProvider extends ArtifactStoreProvider {
- def makeStore[D <: DocumentSerializer: ClassTag](useBatching: Boolean)(
- implicit jsonFormat: RootJsonFormat[D],
- docReader: DocumentReader,
- actorSystem: ActorSystem,
- logging: Logging,
- materializer: ActorMaterializer): ArtifactStore[D] = {
+ def makeStore[D <: DocumentSerializer: ClassTag](useBatching:
Boolean)(implicit jsonFormat: RootJsonFormat[D],
+
docReader: DocumentReader,
+
actorSystem: ActorSystem,
+
logging: Logging): ArtifactStore[D] = {
val dbConfig = loadConfigOrThrow[MongoDBConfig](ConfigKeys.mongodb)
makeArtifactStore(dbConfig, getAttachmentStore())
}
@@ -66,8 +63,7 @@ object MongoDBArtifactStoreProvider extends
ArtifactStoreProvider {
implicit jsonFormat: RootJsonFormat[D],
docReader: DocumentReader,
actorSystem: ActorSystem,
- logging: Logging,
- materializer: ActorMaterializer): ArtifactStore[D] = {
+ logging: Logging): ArtifactStore[D] = {
val inliningConfig = loadConfigOrThrow[InliningConfig](ConfigKeys.db)
@@ -83,10 +79,8 @@ object MongoDBArtifactStoreProvider extends
ArtifactStoreProvider {
attachmentStore)
}
- private def handlerAndMapper[D](entityType: ClassTag[D])(
- implicit actorSystem: ActorSystem,
- logging: Logging,
- materializer: ActorMaterializer): (DocumentHandler, MongoDBViewMapper) = {
+ private def handlerAndMapper[D](entityType: ClassTag[D])(implicit
actorSystem: ActorSystem,
+ logging: Logging):
(DocumentHandler, MongoDBViewMapper) = {
entityType.runtimeClass match {
case x if x == classOf[WhiskEntity] =>
(WhisksHandler, WhisksViewMapper)
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/v2/test/FunctionPullingContainerProxyTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/v2/test/FunctionPullingContainerProxyTests.scala
index 9439106..9b91d55 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/v2/test/FunctionPullingContainerProxyTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/v2/test/FunctionPullingContainerProxyTests.scala
@@ -1360,9 +1360,10 @@ class FunctionPullingContainerProxyTests
val (client, clientFactory) = testClient
val instanceId = InvokerInstanceId(0, userMemory = defaultUserMemory)
+ val pool = TestProbe()
val probe = TestProbe()
val machine =
- probe.childActorOf(
+ pool.childActorOf(
FunctionPullingContainerProxy
.props(
factory,
@@ -1399,7 +1400,7 @@ class FunctionPullingContainerProxyTests
""))
probe.expectMsg(Transition(machine, CreatingClient, ClientCreated))
- expectInitialized(probe)
+ expectInitialized(pool)
client.expectMsg(RequestActivation())
client.send(machine, message)
@@ -1412,7 +1413,7 @@ class FunctionPullingContainerProxyTests
machine ! StateTimeout
client.send(machine, RetryRequestActivation)
probe.expectMsg(Transition(machine, Running, Pausing))
- probe.expectMsgType[ContainerIsPaused]
+ pool.expectMsgType[ContainerIsPaused]
dataManagementService.expectMsgAllOf(
RegisterData(
ContainerKeys
@@ -1440,10 +1441,9 @@ class FunctionPullingContainerProxyTests
Some(instanceId),
Some(testContainerId)),
""))
- inAnyOrder {
- probe.expectMsg(Transition(machine, Paused, Running))
- probe.expectMsgType[Resumed]
- }
+
+ probe.expectMsg(Transition(machine, Paused, Running))
+ pool.expectMsgType[Resumed]
awaitAssert {
factory.calls should have size 1
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/database/mongodb/MongoDBAsyncStreamGraphTests.scala
b/tests/src/test/scala/org/apache/openwhisk/core/database/mongodb/MongoDBAsyncStreamGraphTests.scala
index 90770f3..7660f3c 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/database/mongodb/MongoDBAsyncStreamGraphTests.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/database/mongodb/MongoDBAsyncStreamGraphTests.scala
@@ -19,8 +19,7 @@ package org.apache.openwhisk.core.database.mongodb
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, IOException,
InputStream}
-import akka.stream.ActorMaterializer
-import akka.stream.scaladsl.{Keep, Sink, Source, StreamConverters}
+import akka.stream.scaladsl.{Keep, Sink, StreamConverters}
import akka.stream.testkit.TestSubscriber
import akka.util.ByteString
import common.WskActorSystem
@@ -45,8 +44,6 @@ class MongoDBAsyncStreamGraphTests
with MockitoSugar
with IntegrationPatience {
- implicit val mat = ActorMaterializer()
-
behavior of "MongoDBAsyncStreamSource"
it should "read all bytes" in {
@@ -79,7 +76,7 @@ class MongoDBAsyncStreamGraphTests
doThrow(exception).when(inputStream).read(any())
val asyncStream = AsyncStreamHelper.toAsyncInputStream(inputStream)
- val (ioResult, p) =
MongoDBAsyncStreamSource(asyncStream).toMat(Sink.asPublisher(false))(Keep.both).run()
+ val (_, p) =
MongoDBAsyncStreamSource(asyncStream).toMat(Sink.asPublisher(false))(Keep.both).run()
val c = TestSubscriber.manualProbe[ByteString]()
p.subscribe(c)
@@ -89,7 +86,6 @@ class MongoDBAsyncStreamGraphTests
val error = c.expectError()
error.getCause should be theSameInstanceAs exception
- ioResult.futureValue.status.isFailure shouldBe true
}
behavior of "MongoDBAsyncStreamSink"
@@ -125,21 +121,6 @@ class MongoDBAsyncStreamGraphTests
outputStream.closed shouldBe true
}
- it should "onError with failure and return a failed IOResult when writing to
failed stream" in {
- val os = new ByteArrayOutputStream()
- val asyncStream = AsyncStreamHelper.toAsyncOutputStream(os)
-
- val sink = MongoDBAsyncStreamSink(asyncStream)
- val ioResult = Source(1 to 10)
- .map { n ⇒
- if (n == 7) throw new Error("bees!")
- n
- }
- .map(ByteString(_))
- .runWith(sink)
- ioResult.futureValue.status.isFailure shouldBe true
- }
-
private def randomBytes(size: Int): Array[Byte] = {
val arr = new Array[Byte](size)
Random.nextBytes(arr)
diff --git
a/tests/src/test/scala/org/apache/openwhisk/core/database/mongodb/MongoDBStoreBehaviorBase.scala
b/tests/src/test/scala/org/apache/openwhisk/core/database/mongodb/MongoDBStoreBehaviorBase.scala
index d3dae92..4d109ac 100644
---
a/tests/src/test/scala/org/apache/openwhisk/core/database/mongodb/MongoDBStoreBehaviorBase.scala
+++
b/tests/src/test/scala/org/apache/openwhisk/core/database/mongodb/MongoDBStoreBehaviorBase.scala
@@ -46,8 +46,7 @@ trait MongoDBStoreBehaviorBase extends FlatSpec with
ArtifactStoreBehaviorBase {
WhiskEntityJsonFormat,
WhiskDocumentReader,
actorSystem,
- logging,
- materializer)
+ logging)
override lazy val activationStore = {
implicit val docReader: DocumentReader = WhiskDocumentReader