diff --git a/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/ArchiverService.kt b/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/ArchiverService.kt index 02722c64..1ec576ba 100644 --- a/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/ArchiverService.kt +++ b/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/ArchiverService.kt @@ -3,16 +3,13 @@ package no.nav.soknad.arkivering.soknadsarkiverer.service import kotlinx.coroutines.* import no.nav.soknad.arkivering.avroschemas.InnsendingMetrics import no.nav.soknad.arkivering.avroschemas.Soknadarkivschema -import no.nav.soknad.arkivering.soknadsarkiverer.Constants import no.nav.soknad.arkivering.soknadsarkiverer.config.ArchivingException import no.nav.soknad.arkivering.soknadsarkiverer.config.ShuttingDownException import no.nav.soknad.arkivering.soknadsarkiverer.kafka.KafkaPublisher import no.nav.soknad.arkivering.soknadsarkiverer.service.arkivservice.JournalpostClientInterface import no.nav.soknad.arkivering.soknadsarkiverer.service.fileservice.* import no.nav.soknad.arkivering.soknadsarkiverer.supervision.ArchivingMetrics -import no.nav.soknad.arkivering.soknadsfillager.model.FileData import org.slf4j.LoggerFactory -import org.slf4j.MDC import org.springframework.stereotype.Service import java.io.PrintWriter import java.io.StringWriter @@ -29,7 +26,7 @@ class ArchiverService(private val filestorageService: FileserviceInterface, try { val startTime = System.currentTimeMillis() val journalpostId = journalpostClient.opprettJournalpost(key, data, files) - createMetric(key, "send files to archive", startTime) + createMetricAndPublishOnKafka(key, "send files to archive", startTime) logger.info("$key: Opprettet journalpostId=$journalpostId for behandlingsid=${data.behandlingsid}") createMessage(key, "**Archiving: OK. journalpostId=$journalpostId") @@ -47,7 +44,13 @@ class ArchiverService(private val filestorageService: FileserviceInterface, return try { val startTime = System.currentTimeMillis() val files = makeParallelCallsToFetchFiles(key, data) - createMetric(key, "get files from filestorage", startTime) + + createMetricAndPublishOnKafka(key, "get files from filestorage", startTime) + files.filter{it.content != null}.forEach { + metrics.setFileFetchSizeHistogram(it.content!!.size.toDouble(), data.arkivtema) + metrics.setFileFetchSize(it.content.size.toDouble()) + } + files } catch (e: ShuttingDownException) { @@ -79,10 +82,11 @@ class ArchiverService(private val filestorageService: FileserviceInterface, val okResponse = responses.firstOrNull { it.status == ResponseStatus.Ok.value } if (okResponse != null) { metrics.incGetFilestorageSuccesses() - if (okResponse.files != null) + if (okResponse.files != null) { return okResponse.files - else + } else { return listOf() + } } val deletedResponse = responses.firstOrNull { it.status == "deleted" } @@ -109,7 +113,7 @@ class ArchiverService(private val filestorageService: FileserviceInterface, try { val startTime = System.currentTimeMillis() filestorageService.deleteFilesFromFilestorage(key, data) - createMetric(key, "delete files from filestorage", startTime) + createMetricAndPublishOnKafka(key, "delete files from filestorage", startTime) createMessage(key, "ok") } catch (e: ShuttingDownException) { @@ -127,7 +131,7 @@ class ArchiverService(private val filestorageService: FileserviceInterface, kafkaPublisher.putMessageOnTopic(key, message) } - private fun createMetric(key: String, message: String, startTime: Long) { + private fun createMetricAndPublishOnKafka(key: String, message: String, startTime: Long) { val duration = System.currentTimeMillis() - startTime val metrics = InnsendingMetrics("soknadsarkiverer", message, startTime, duration) kafkaPublisher.putMetricOnTopic(key, metrics) diff --git a/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/TaskListService.kt b/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/TaskListService.kt index b467d935..1e1021d7 100644 --- a/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/TaskListService.kt +++ b/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/TaskListService.kt @@ -310,7 +310,7 @@ open class TaskListService( MDC.clear() metrics.endTimer(timer) metrics.endHistogramTimer(histogram) - metrics.numberOfAttachmentHistogramSet( + metrics.setNumberOfAttachmentHistogram( soknadarkivschema.mottatteDokumenter.size.toDouble(), soknadarkivschema.arkivtema ) diff --git a/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/arkivservice/JournalpostClient.kt b/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/arkivservice/JournalpostClient.kt index 2bf042bf..139cac92 100644 --- a/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/arkivservice/JournalpostClient.kt +++ b/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/arkivservice/JournalpostClient.kt @@ -9,7 +9,6 @@ import no.nav.soknad.arkivering.soknadsarkiverer.service.arkivservice.api.Oppret import no.nav.soknad.arkivering.soknadsarkiverer.service.arkivservice.converter.createOpprettJournalpostRequest import no.nav.soknad.arkivering.soknadsarkiverer.service.fileservice.FileInfo import no.nav.soknad.arkivering.soknadsarkiverer.supervision.ArchivingMetrics -import no.nav.soknad.arkivering.soknadsfillager.model.FileData import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Value @@ -32,7 +31,7 @@ class JournalpostClient(@Value("\${joark.host}") private val joarkHost: String, val bidClient: WebClient = webClient.mutate().defaultHeader(NAV_CONSUMER_ID, "dialogstyring-bidrag").build() override fun opprettJournalpost(key: String, soknadarkivschema: Soknadarkivschema, attachedFiles: List): String { - val timer = metrics.joarkLatencyStart() + val timer = metrics.startJoarkLatency() try { logger.info("$key: About to create journalpost for behandlingsId: '${soknadarkivschema.behandlingsid}'") val request = createOpprettJournalpostRequest(soknadarkivschema, attachedFiles) diff --git a/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/supervision/ArchivingMetrics.kt b/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/supervision/ArchivingMetrics.kt index 0023017d..fcaf9c23 100644 --- a/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/supervision/ArchivingMetrics.kt +++ b/arkiverer/src/main/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/supervision/ArchivingMetrics.kt @@ -45,6 +45,11 @@ class ArchivingMetrics(private val registry: CollectorRegistry) { private val SUMMARY_FILESTORAGE_DEL_LATENCY = "latency_filestorage_del_operations" private val SUMMARY_FILESTORAGE_DEL_LATENCY_DESC = "Latency for deleting from filestorage" + private val SUMMARY_FILE_FETCH_SIZE = "file_fetch_size" + private val SUMMARY_FILE_FETCH_SIZE_DESC = "Size of fetched file" + private val HISTOGRAM_FILE_FETCH_SIZE = "file_fetch_size_distribution" + private val HISTOGRAM_FILE_FETCH_SIZE_DESC = "Distribution of sizes of fetched files" + private val COUNTER_JOARK_SUCCESS = "counter_joark_success" private val COUNTER_JOARK_SUCCESS_DESC = "Number of successes when sending to Joark" @@ -67,10 +72,12 @@ class ArchivingMetrics(private val registry: CollectorRegistry) { private val filestorageDelErrorCounter: Counter = registerCounter(COUNTER_FILESTORAGE_DEL_ERROR, COUNTER_FILESTORAGE_DEL_ERROR_DESC) private val filestorageGetLatencySummary = registerSummary(SUMMARY_FILESTORAGE_GET_LATENCY, SUMMARY_FILESTORAGE_GET_LATENCY_DESC) private val filestorageDelLatencySummary = registerSummary(SUMMARY_FILESTORAGE_DEL_LATENCY, SUMMARY_FILESTORAGE_DEL_LATENCY_DESC) + private val filefetchSizeSummary = registerSummary(SUMMARY_FILE_FETCH_SIZE, SUMMARY_FILE_FETCH_SIZE_DESC) + private val filefetchSizeHistogram = registerFileSizeHistogram(HISTOGRAM_FILE_FETCH_SIZE, HISTOGRAM_FILE_FETCH_SIZE_DESC) private val joarkSuccessCounter: Counter = registerCounter(COUNTER_JOARK_SUCCESS, COUNTER_JOARK_SUCCESS_DESC) private val joarkErrorCounter: Counter = registerCounter(COUNTER_JOARK_ERROR, COUNTER_JOARK_ERROR_DESC) private val joarkLatencySummary = registerSummary(SUMMARY_JOARK_LATENCY, SUMMARY_JOARK_LATENCY_DESC) - private val archivingLatencyHistogram = registerHistogram(HISTOGRAM_ARCHIVING_LATENCY, HISTORGRAM_ARCHIVING_LATENCY_DESC) + private val archivingLatencyHistogram = registerLatencyHistogram(HISTOGRAM_ARCHIVING_LATENCY, HISTORGRAM_ARCHIVING_LATENCY_DESC) private val HISTOGRAM_ATTACHMENT_NUMBER = "histogram_attachment_number" private val HISTOGRAM_ATTACHMENT_NUMBER_DESC = "Histogram for number of attachment per application" @@ -106,16 +113,41 @@ class ArchivingMetrics(private val registry: CollectorRegistry) { .labelNames(APP_LABEL) .register(registry) - private fun registerHistogram(name: String, help: String): Histogram = + private fun registerLatencyHistogram(name: String, help: String): Histogram = Histogram .build() .namespace(SOKNAD_NAMESPACE) .name(name) .help(help) - .buckets(0.1, 0.2, 0.4, 0.8, 1.6, 3.2, 6.4, 12.8, 25.6, 51.2, 100.2) + .buckets(0.1, 0.2, 0.4, 0.8, 1.6, 3.2, 6.4, 12.8, 25.6, 51.2, 100.2, 240.0) .labelNames(TEMA_LABEL) .register(registry) + private fun registerFileSizeHistogram(name: String, help: String): Histogram { + val kB = 1024.0 + val mB = kB * kB + return Histogram + .build() + .namespace(SOKNAD_NAMESPACE) + .name(name) + .help(help) + .buckets( + kB, + 10 * kB, + 50 * kB, + 100 * kB, + 500 * kB, + mB, + 2 * mB, + 5 * mB, + 25 * mB, + 50 * mB, + 150 * mB + ) + .labelNames(TEMA_LABEL) + .register(registry) + } + private fun registerAttachmentNumberHistogram(name: String, help: String): Histogram = Histogram .build() @@ -156,9 +188,15 @@ class ArchivingMetrics(private val registry: CollectorRegistry) { fun archivingLatencyStart(): Summary.Timer = archivingLatencySummary.labels(APP).startTimer() fun filestorageGetLatencyStart(): Summary.Timer = filestorageGetLatencySummary.labels(APP).startTimer() fun filestorageDelLatencyStart(): Summary.Timer = filestorageDelLatencySummary.labels(APP).startTimer() - fun joarkLatencyStart(): Summary.Timer = joarkLatencySummary.labels(APP).startTimer() + fun startJoarkLatency(): Summary.Timer = joarkLatencySummary.labels(APP).startTimer() + fun getJoarkLatency(): Summary.Child.Value = joarkLatencySummary.labels(APP).get() fun archivingLatencyHistogramStart(tema: String): Histogram.Timer = archivingLatencyHistogram.labels(tema).startTimer() - fun numberOfAttachmentHistogramSet(number: Double, tema: String) = numberOfAttachmentHistogram.labels(tema).observe(number) + fun setNumberOfAttachmentHistogram(number: Double, tema: String) = numberOfAttachmentHistogram.labels(tema).observe(number) + fun getNumberOfAttachmentHistogram(tema: String) = numberOfAttachmentHistogram.labels(tema).get() + fun setFileFetchSize(size: Double) = filefetchSizeSummary.labels(APP).observe(size) + fun getFileFetchSize() = filefetchSizeSummary.labels(APP).get() + fun setFileFetchSizeHistogram(size: Double, tema: String) = filefetchSizeHistogram.labels(tema).observe(size) + fun getFileFetchSizeHistogram(tema: String) = filefetchSizeHistogram.labels(tema).get() fun endTimer(timer: Summary.Timer) { timer.observeDuration() @@ -184,5 +222,6 @@ class ArchivingMetrics(private val registry: CollectorRegistry) { registry.unregister(taskGauge) registry.unregister(upOrDownGauge) registry.unregister(numberOfAttachmentHistogram) + registry.unregister(filefetchSizeSummary) } } diff --git a/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/ArchiverServiceTests.kt b/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/ArchiverServiceTests.kt index db62af70..bc060eaa 100644 --- a/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/ArchiverServiceTests.kt +++ b/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/service/ArchiverServiceTests.kt @@ -2,9 +2,8 @@ package no.nav.soknad.arkivering.soknadsarkiverer.service import io.mockk.* import io.prometheus.client.CollectorRegistry -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch +import kotlinx.coroutines.* +import no.nav.soknad.arkivering.soknadsarkiverer.SoknadsarkivererApplication import no.nav.soknad.arkivering.soknadsarkiverer.config.ArchivingException import no.nav.soknad.arkivering.soknadsarkiverer.kafka.KafkaPublisher import no.nav.soknad.arkivering.soknadsarkiverer.service.arkivservice.JournalpostClientInterface @@ -18,11 +17,15 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.boot.test.mock.mockito.MockBean import java.time.OffsetDateTime.now import java.util.* class ArchiverServiceTests { + private lateinit var metrics: ArchivingMetrics + private val filestorage = mockk().also { every { it.getFilesFromFilestorage(any(), any()) } returns FetchFileResponse(status = "ok", @@ -68,8 +71,6 @@ class ArchiverServiceTests { private val journalpostClient = mockk().also { every { it.opprettJournalpost(any(), any(), any()) } returns UUID.randomUUID().toString() } - @Autowired - private lateinit var metrics: ArchivingMetrics private val kafkaPublisher = mockk().also { every { it.putMetricOnTopic(any(), any(), any()) } just Runs @@ -104,6 +105,38 @@ class ArchiverServiceTests { private val journalpostClient2 = mockk().also { every { it.opprettJournalpost(any(), any(), capture(filer)) } returns UUID.randomUUID().toString() } + + @Test + fun `Fetch file metrics test`() { + archiverService = ArchiverService(filestorageNotFound, innsendingApi, journalpostClient2, metrics, kafkaPublisher) + val key = UUID.randomUUID().toString() + val tema = "AAP" + val soknadschema = + createSoknadarkivschema(behandlingsId = key, + tema = tema, + fileIds = listOf( + UUID.randomUUID().toString(), + UUID.randomUUID().toString(), + UUID.randomUUID().toString(), + UUID.randomUUID().toString(), + UUID.randomUUID().toString(), + UUID.randomUUID().toString(), + UUID.randomUUID().toString(), + UUID.randomUUID().toString() + )) + + runBlocking { + archiverService.fetchFiles(key, soknadschema) + + val fetchObservation = metrics.getFileFetchSize() + assertTrue(fetchObservation != null) + assertEquals(7.0, fetchObservation.quantiles[0.99]!!) + val fetchFileHistogram = metrics.getFileFetchSizeHistogram(tema) + assertTrue(fetchFileHistogram != null) + assertEquals("content".length.toDouble(), fetchFileHistogram.sum) + } + } + @Test fun `Archiving succeeds when all is up and running`() { archiverService = ArchiverService(filestorageNotFound, innsendingApi, journalpostClient2, metrics, kafkaPublisher) @@ -118,7 +151,6 @@ class ArchiverServiceTests { verify(exactly = 1) { journalpostClient2.opprettJournalpost(eq(key), eq(soknadschema), any()) } assertTrue(filer.isCaptured) assertEquals(soknadschema.mottatteDokumenter.first().mottatteVarianter.size, filer.captured.size) - } } diff --git a/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/supervision/ArchivingMetricsTests.kt b/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/supervision/ArchivingMetricsTests.kt new file mode 100644 index 00000000..2208ac6e --- /dev/null +++ b/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/supervision/ArchivingMetricsTests.kt @@ -0,0 +1,149 @@ +package no.nav.soknad.arkivering.soknadsarkiverer.supervision + +import io.prometheus.client.CollectorRegistry +import io.prometheus.client.Histogram +import io.prometheus.client.Summary +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test + +class ArchivingMetricsTests { + + private lateinit var metrics: ArchivingMetrics + + @BeforeEach + fun setup() { + metrics = ArchivingMetrics(CollectorRegistry()) + } + + @Test + fun `test of counter`() { + val noOfsucesses = 10 + repeat(noOfsucesses) { + metrics.incJoarkSuccesses() + } + assertEquals(noOfsucesses.toDouble(), metrics.getJoarkSuccesses()) + assertEquals(0.0, metrics.getJoarkErrors()) + } + + @Test + fun `test of gauge`() { + repeat(3) { + metrics.addTask() + } + repeat(2) { + metrics.removeTask() + } + + assertEquals(1.0, metrics.getTasks()) + } + + @Test + fun `test of numberOfAttachmentsHistogram`() { + val temaer = listOf("AAP", "TSO", "SYK") + val numberOfAttachments = listOf( + 2, // 1 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 15 + 5, 5, 5, 5, 5, // 5 + 7, 7, 7, 7, // 4 + 13, 13, 13, 13, 13, // 5 + 21, 21, 21, 21, // 4 + 34, // 1 + 40 // 1 + ) + numberOfAttachments.forEach { metrics.setNumberOfAttachmentHistogram(it.toDouble(), temaer.random()) } + val observations = mutableListOf() + temaer.forEach { observations.add(metrics.getNumberOfAttachmentHistogram(it)) } + + assertTrue(observations.isNotEmpty()) + assertEquals(numberOfAttachments.size.toDouble(), observations.sumOf { it.buckets.last() }) + assertEquals(1.0, observations.sumOf { it.buckets.first() }) + } + + @Test + fun `test of filesizeHistogram`() { + val temaer = listOf("AAP", "TSO", "SYK") + val fileSizes = listOf( + 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, // 15 + 10*1024, 10*1024, 10*1024, 10*1024, 10*1024, // 5 + 100*1024, 100*1024, 100*1024, 100*1024, // 4 + 1024*1024, 1024*1024, 1024*1024, 1024*1024, 1024*1024, // 5 + 10*1024*1024, 10*1024*1024, 10*1024*1024, 10*1024*1024, // 4 + 50*1024*1024, 50*1024*1024, // 2 + 100*1024*1024, // 1 + 150*1024*1024, // 1 + 200*1024*1024 + ) + fileSizes.forEach { metrics.setFileFetchSizeHistogram(it.toDouble(), temaer.random()) } + val observations = mutableListOf() + temaer.forEach { observations.add(metrics.getFileFetchSizeHistogram(it)) } + + assertTrue(observations.isNotEmpty()) + assertEquals(fileSizes.size.toDouble(), observations.sumOf { it.buckets.last() }) + assertEquals(15.0, observations.sumOf { it.buckets.first() }) + } + + @Test + fun `test of filSizeSummary`() { + val fileSizes = listOf( + 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, // 15 + 10 * 1024, 10 * 1024, 10 * 1024, 10 * 1024, 10 * 1024, // 5 + 100 * 1024, 100 * 1024, 100 * 1024, 100 * 1024, // 4 + 1024 * 1024, 1024 * 1024, 1024 * 1024, 1024 * 1024, 1024 * 1024, // 5 + 10 * 1024 * 1024, 10 * 1024 * 1024, 10 * 1024 * 1024, 10 * 1024 * 1024, // 4 + 50 * 1024 * 1024, 50 * 1024 * 1024, // 2 + 100 * 1024 * 1024, // 1 + 150 * 1024 * 1024, // 1 + 200 * 1024 * 1024 + ) + fileSizes.forEach { metrics.setFileFetchSize(it.toDouble()) } + val observations = metrics.getFileFetchSize() + + assertTrue(observations != null) + assertEquals(fileSizes.size.toDouble(), observations.count) + assertEquals(200 * 1024 * 1024.0, observations.quantiles[0.99]) + } + + @Test + fun `test av joarkLatencySummary`() { + val latencies = mapOf( + 10L to 1, // 1 + 100L to 10, // 10 + 500L to 3, // 5 + 1000L to 2, // 3 + 10000L to 1 // 1 + ) + val timers = mutableListOf () + latencies.keys.forEach { repeat(latencies[it]!!) {timers.add(metrics.startJoarkLatency()) }} + + var nextTimer = 0 + var sleepTime = 10L + nextTimer = sleepAndSetEndTimer(sleepTime = sleepTime, startIndex = nextTimer, latencyIndex = 10L, latencies = latencies, timers = timers) + sleepTime = 100L-sleepTime + nextTimer = sleepAndSetEndTimer(sleepTime = sleepTime, startIndex = nextTimer, latencyIndex = 100L, latencies = latencies, timers = timers) + sleepTime = 500L-sleepTime + nextTimer = sleepAndSetEndTimer(sleepTime = sleepTime, startIndex = nextTimer, latencyIndex = 500L, latencies = latencies, timers = timers) + sleepTime = 1000L-sleepTime + nextTimer = sleepAndSetEndTimer(sleepTime = sleepTime, startIndex = nextTimer, latencyIndex = 1000L, latencies = latencies, timers = timers) + sleepTime = 10000L-sleepTime + nextTimer = sleepAndSetEndTimer(sleepTime = sleepTime, startIndex = nextTimer, latencyIndex = 10000L, latencies = latencies, timers = timers) + + val observations = metrics.getJoarkLatency() + assertEquals(latencies.values.sum().toDouble(), observations.count) + assertTrue(observations.quantiles[0.5]!! > 0.1) + assertTrue(observations.quantiles[0.9]!! > 1.0) + assertTrue(observations.quantiles[0.99]!! > 10.0) + + } + + private fun sleepAndSetEndTimer(sleepTime: Long, startIndex: Int, latencyIndex: Long, latencies: Map, timers: List ): Int { + Thread.sleep(sleepTime) + var nextTimer = startIndex + repeat(latencies[latencyIndex]!!) { + metrics.endTimer(timers[nextTimer]) + nextTimer++ + } + return nextTimer + } +} diff --git a/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/utils/Builders.kt b/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/utils/Builders.kt index 2ea03515..6a017bce 100644 --- a/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/utils/Builders.kt +++ b/arkiverer/src/test/kotlin/no/nav/soknad/arkivering/soknadsarkiverer/utils/Builders.kt @@ -56,13 +56,15 @@ class MottattVariantBuilder { } fun createSoknadarkivschema(fileId: String = UUID.randomUUID().toString(), behandlingsId: String = UUID.randomUUID().toString()) = createSoknadarkivschema(listOf(fileId), behandlingsId) +fun createSoknadarkivschema(behandlingsId: String = UUID.randomUUID().toString(), tema: String, fileIds: List = listOf(UUID.randomUUID().toString()), ) = createSoknadarkivschema(fileIds, behandlingsId, tema) -fun createSoknadarkivschema(fileIds: List, behandlingsId: String = UUID.randomUUID().toString()) = +fun createSoknadarkivschema(fileIds: List, variantformat: String = "ARKIV",behandlingsId: String = UUID.randomUUID().toString(), tema: String = "AAP") = SoknadarkivschemaBuilder() .withBehandlingsid(behandlingsId) + .withArkivtema(tema) .withMottatteDokumenter(MottattDokumentBuilder() .withMottatteVarianter( - fileIds.map { MottattVariantBuilder().withUuid(it).build() } + fileIds.map { MottattVariantBuilder().withUuid(it).withVariantformat(variantformat).build() } ) .build()) .build()