lets see
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Torma Kristóf 2020-10-22 19:17:58 +02:00
parent b285769cfd
commit 701412d7c2
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
2 changed files with 24 additions and 23 deletions

View File

@ -15,8 +15,6 @@ fun main(args: Array<String>): Unit = io.ktor.server.tomcat.EngineMain.main(args
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {
runBlocking {
val cachedFile = File("/app/wave.wav").readBytes()
val gson = GsonBuilder().setPrettyPrinting().create()
var startTime : Instant
var elapsed = Duration.ofSeconds(0)
val targetTime = Duration.ofSeconds(System.getenv("WAITTIME").toLong())
@ -30,7 +28,7 @@ fun Application.module(testing: Boolean = false) {
println("Starting benchmark")
startTime = Instant.now()
while(elapsed < targetTime){
uploader.uploadData(currIter, gson, cachedFile)
uploader.uploadData(currIter)
currIter+=1
currTimeStamp = Instant.now()
timestamps[currIter] = currTimeStamp

View File

@ -1,6 +1,7 @@
package com.kmlabz.k8s
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import io.ktor.client.*
import io.ktor.client.engine.apache.*
import io.ktor.client.request.*
@ -8,12 +9,11 @@ import io.ktor.client.request.forms.*
import io.ktor.http.*
import io.ktor.http.content.*
import io.ktor.util.*
import java.io.File
class Uploader(){
@KtorExperimentalAPI
suspend fun uploadData(currIteration: Int, gson: Gson, inputSound: ByteArray) {
HttpClient(Apache).use { client ->
private val gson = GsonBuilder().setPrettyPrinting().create()
private val inputSound = File("/app/wave.wav").readBytes()
val parts: List<PartData> = formData {
val headersBuilder = HeadersBuilder()
headersBuilder[HttpHeaders.ContentType] = "audio/wave"
@ -23,7 +23,7 @@ class Uploader(){
inputSound,
headersBuilder.build()
)
val inputSvcApi = InputSvcApi("2020-02-02T02:02:02", currIteration)
val inputSvcApi = InputSvcApi("2020-02-02T02:02:02", 1)
val jsonHeadersBuilder = HeadersBuilder()
jsonHeadersBuilder[HttpHeaders.ContentType] = "application/json"
this.append(
@ -32,6 +32,9 @@ class Uploader(){
jsonHeadersBuilder.build()
)
}
@KtorExperimentalAPI
suspend fun uploadData(currIteration: Int) {
HttpClient(Apache).use { client ->
client.submitFormWithBinaryData<Unit>(formData = parts) {
url(System.getenv("URL") ?: "https://birb.k8s.kmlabz.com/benchmark")