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

Fix deprecated error #5128

Merged
merged 2 commits into from
Jun 9, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down Expand Up @@ -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] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we don't need a materializer at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems yes

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())
}
Expand All @@ -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)

Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1399,7 +1400,7 @@ class FunctionPullingContainerProxyTests
""))

probe.expectMsg(Transition(machine, CreatingClient, ClientCreated))
expectInitialized(probe)
expectInitialized(pool)
client.expectMsg(RequestActivation())
client.send(machine, message)

Expand All @@ -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
Expand Down Expand Up @@ -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]
Copy link
Contributor

@ningyougang ningyougang Jun 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea for using separate probe object


awaitAssert {
factory.calls should have size 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,8 +44,6 @@ class MongoDBAsyncStreamGraphTests
with MockitoSugar
with IntegrationPatience {

implicit val mat = ActorMaterializer()

behavior of "MongoDBAsyncStreamSource"

it should "read all bytes" in {
Expand Down Expand Up @@ -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)

Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down