diff options
Diffstat (limited to 'sources/hv-collector-ct')
2 files changed, 15 insertions, 10 deletions
diff --git a/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/PerformanceSpecification.kt b/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/PerformanceSpecification.kt index ef4ce967..dc5fe60b 100644 --- a/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/PerformanceSpecification.kt +++ b/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/PerformanceSpecification.kt @@ -31,11 +31,13 @@ import org.jetbrains.spek.api.dsl.describe import org.jetbrains.spek.api.dsl.it import org.onap.dcae.collectors.veshv.domain.VesEventDomain.PERF3GPP import org.onap.dcae.collectors.veshv.domain.WireFrameEncoder +import org.onap.dcae.collectors.veshv.domain.WireFrameMessage +import org.onap.dcae.collectors.veshv.tests.component.Sut.Companion.MAX_PAYLOAD_SIZE_BYTES import org.onap.dcae.collectors.veshv.tests.fakes.CountingSink import org.onap.dcae.collectors.veshv.tests.fakes.basicConfiguration import org.onap.dcae.collectors.veshv.tests.utils.commonHeader -import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageParameters -import org.onap.dcae.collectors.veshv.ves.message.generator.api.MessageType.VALID +import org.onap.dcae.collectors.veshv.ves.message.generator.api.VesEventParameters +import org.onap.dcae.collectors.veshv.ves.message.generator.api.VesEventType import org.onap.dcae.collectors.veshv.ves.message.generator.factory.MessageGeneratorFactory import reactor.core.publisher.Flux import reactor.math.sum @@ -61,9 +63,9 @@ object PerformanceSpecification : Spek({ val runs = 4 val timeout = Duration.ofMinutes((1 + (runs / 2)).toLong()) - val params = MessageParameters( + val params = VesEventParameters( commonEventHeader = commonHeader(PERF3GPP), - messageType = VALID, + messageType = VesEventType.VALID, amount = numMessages ) @@ -91,9 +93,9 @@ object PerformanceSpecification : Spek({ val numMessages: Long = 100_000 val timeout = Duration.ofSeconds(30) - val params = MessageParameters( + val params = VesEventParameters( commonEventHeader = commonHeader(PERF3GPP), - messageType = VALID, + messageType = VesEventType.VALID, amount = numMessages ) @@ -158,8 +160,9 @@ object PerformanceSpecification : Spek({ private const val ONE_MILION = 1_000_000.0 - private val rand = Random() +private val generatorsFactory = MessageGeneratorFactory(MAX_PAYLOAD_SIZE_BYTES) + private fun randomByteArray(size: Int): ByteArray { val bytes = ByteArray(size) rand.nextBytes(bytes) @@ -171,10 +174,11 @@ fun dropWhenIndex(predicate: (Long) -> Boolean, stream: Flux<ByteBuf>): Flux<Byt .filter { predicate(it.t1) } .map { it.t2 } -private fun generateDataStream(alloc: ByteBufAllocator, params: MessageParameters): Flux<ByteBuf> = +private fun generateDataStream(alloc: ByteBufAllocator, params: VesEventParameters): Flux<ByteBuf> = WireFrameEncoder(alloc).let { encoder -> - MessageGeneratorFactory.create(Sut.MAX_PAYLOAD_SIZE_BYTES) - .createMessageFlux(listOf(params)) + generatorsFactory.createVesEventGenerator() + .createMessageFlux(params) + .map { WireFrameMessage(it.toByteArray()) } .map(encoder::encode) .transform { simulateRemoteTcp(alloc, 1000, it) } } diff --git a/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/Sut.kt b/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/Sut.kt index 30661e84..ed79e3e2 100644 --- a/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/Sut.kt +++ b/sources/hv-collector-ct/src/test/kotlin/org/onap/dcae/collectors/veshv/tests/component/Sut.kt @@ -69,6 +69,7 @@ class Sut(sink: Sink = StoringSink()): AutoCloseable { } } + class DummySinkProvider(private val sink: Sink) : SinkProvider { private val active = AtomicBoolean(true) |