Compare commits
19 Commits
0638b7a116
...
master
Author | SHA1 | Date | |
---|---|---|---|
ff98587aeb | |||
2eaa6de91f
|
|||
c0066bb414
|
|||
215bb0ed13
|
|||
567f8a8d24
|
|||
9663660519
|
|||
f3d339a4a6
|
|||
a212aa300c
|
|||
a4c9bd854e
|
|||
701412d7c2
|
|||
b285769cfd
|
|||
233b706d29
|
|||
afdd1ee4eb
|
|||
d81339b851
|
|||
89504a99ca
|
|||
4d0920c40f
|
|||
c05aabf185
|
|||
5962a477f4
|
|||
144452a768
|
20
.drone.yml
20
.drone.yml
@ -3,14 +3,6 @@ type: docker
|
|||||||
name: default
|
name: default
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: code-analysis
|
|
||||||
image: aosapps/drone-sonar-plugin
|
|
||||||
settings:
|
|
||||||
sonar_host:
|
|
||||||
from_secret: SONAR_HOST
|
|
||||||
sonar_token:
|
|
||||||
from_secret: SONAR_CODE
|
|
||||||
|
|
||||||
- name: build_application
|
- name: build_application
|
||||||
image: openjdk:11-jdk
|
image: openjdk:11-jdk
|
||||||
commands:
|
commands:
|
||||||
@ -30,6 +22,18 @@ steps:
|
|||||||
- latest
|
- latest
|
||||||
- ${DRONE_BUILD_NUMBER}
|
- ${DRONE_BUILD_NUMBER}
|
||||||
|
|
||||||
|
- name: dockerhub
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: birbnetes/${DRONE_REPO_NAME}
|
||||||
|
username:
|
||||||
|
from_secret: DOCKERHUB_USER
|
||||||
|
password:
|
||||||
|
from_secret: DOCKERHUB_PASSWORD
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- ${DRONE_BUILD_NUMBER}
|
||||||
|
|
||||||
- name: ms-teams
|
- name: ms-teams
|
||||||
image: kuperiu/drone-teams
|
image: kuperiu/drone-teams
|
||||||
settings:
|
settings:
|
||||||
|
@ -9,7 +9,7 @@ RUN chown -R $APPLICATION_USER /app
|
|||||||
USER $APPLICATION_USER
|
USER $APPLICATION_USER
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY ./build/libs/birb-integrated-bench.jar /app/birb-integrated-bench.jar
|
|
||||||
COPY ./wave.wav /app/wave.wav
|
COPY ./wave.wav /app/wave.wav
|
||||||
|
COPY ./build/libs/birb-integrated-bench.jar /app/birb-integrated-bench.jar
|
||||||
|
|
||||||
CMD ["java", "-server", "-XX:+UnlockExperimentalVMOptions", "-XX:InitialRAMFraction=2", "-XX:MinRAMFraction=2", "-XX:MaxRAMFraction=2", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=100", "-XX:+UseStringDeduplication", "-jar", "birb-integrated-bench.jar"]
|
CMD ["java", "-server", "-XX:+UnlockExperimentalVMOptions", "-XX:InitialRAMFraction=2", "-XX:MinRAMFraction=2", "-XX:MaxRAMFraction=2", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=100", "-XX:+UseStringDeduplication", "-jar", "birb-integrated-bench.jar"]
|
@ -28,7 +28,7 @@ apply plugin: 'application'
|
|||||||
|
|
||||||
group 'com.kmlabz.k8s'
|
group 'com.kmlabz.k8s'
|
||||||
version '0.0.1'
|
version '0.0.1'
|
||||||
mainClassName = "io.ktor.server.jetty.EngineMain"
|
mainClassName = "io.ktor.server.tomcat.EngineMain"
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main.kotlin.srcDirs = main.java.srcDirs = ['src']
|
main.kotlin.srcDirs = main.java.srcDirs = ['src']
|
||||||
@ -44,11 +44,11 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
implementation "io.ktor:ktor-server-jetty:$ktor_version"
|
implementation "io.ktor:ktor-server-tomcat:$ktor_version"
|
||||||
implementation "ch.qos.logback:logback-classic:$logback_version"
|
implementation "ch.qos.logback:logback-classic:$logback_version"
|
||||||
implementation "io.ktor:ktor-client-core:$ktor_version"
|
implementation "io.ktor:ktor-client-core:$ktor_version"
|
||||||
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
|
implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
|
||||||
implementation "io.ktor:ktor-client-jetty:$ktor_version"
|
implementation "io.ktor:ktor-client-apache:$ktor_version"
|
||||||
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
|
implementation "io.ktor:ktor-client-json-jvm:$ktor_version"
|
||||||
implementation "io.ktor:ktor-client-gson:$ktor_version"
|
implementation "io.ktor:ktor-client-gson:$ktor_version"
|
||||||
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
|
||||||
|
@ -1,64 +1,54 @@
|
|||||||
package com.kmlabz.k8s
|
package com.kmlabz.k8s
|
||||||
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.GsonBuilder
|
|
||||||
import io.ktor.application.*
|
import io.ktor.application.*
|
||||||
import io.ktor.client.*
|
|
||||||
import io.ktor.client.engine.jetty.*
|
|
||||||
import io.ktor.client.features.json.*
|
|
||||||
import io.ktor.client.request.*
|
|
||||||
import io.ktor.client.request.forms.*
|
|
||||||
import io.ktor.http.*
|
|
||||||
import io.ktor.http.content.*
|
|
||||||
import io.ktor.util.*
|
import io.ktor.util.*
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import java.io.File
|
import java.time.Duration
|
||||||
|
import java.time.Instant
|
||||||
|
import java.util.*
|
||||||
|
import kotlin.collections.LinkedHashMap
|
||||||
|
|
||||||
fun main(args: Array<String>): Unit = io.ktor.server.jetty.EngineMain.main(args)
|
fun main(args: Array<String>): Unit = io.ktor.server.tomcat.EngineMain.main(args)
|
||||||
|
|
||||||
@KtorExperimentalAPI
|
@KtorExperimentalAPI
|
||||||
@Suppress("unused") // Referenced in application.conf
|
@Suppress("unused")
|
||||||
@kotlin.jvm.JvmOverloads
|
@kotlin.jvm.JvmOverloads
|
||||||
fun Application.module(testing: Boolean = false) {
|
fun Application.module(testing: Boolean = false) {
|
||||||
val client = HttpClient(Jetty) {
|
|
||||||
install(JsonFeature) {
|
|
||||||
serializer = GsonSerializer()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
runBlocking {
|
runBlocking {
|
||||||
val cachedFile = File("/app/wave.wav").readBytes()
|
var startTime: Instant
|
||||||
val gson = GsonBuilder().setPrettyPrinting().create()
|
var currTimeStamp: Instant
|
||||||
uploadData(1, gson, cachedFile)
|
var elapsed = Duration.ZERO
|
||||||
|
val targetTime = Duration.ofSeconds(System.getenv("WAITTIME").toLong())
|
||||||
|
var currIter = 0
|
||||||
|
val timestamps = LinkedHashMap<Int, Instant>()
|
||||||
|
val uploaders = LinkedList<Uploader>()
|
||||||
|
val processResults = ProcessResults()
|
||||||
|
var currUploader: Uploader
|
||||||
|
environment.monitor.subscribe(ApplicationStarted) {
|
||||||
|
GlobalScope.launch {
|
||||||
|
println("Starting benchmark setup")
|
||||||
|
startTime = Instant.now()
|
||||||
|
while (elapsed < targetTime) {
|
||||||
|
currIter += 1
|
||||||
|
currUploader = Uploader()
|
||||||
|
currUploader.currIteration = currIter
|
||||||
|
currUploader.buildRequest()
|
||||||
|
uploaders.add(currUploader)
|
||||||
|
currTimeStamp = Instant.now()
|
||||||
|
elapsed = Duration.between(startTime, currTimeStamp)
|
||||||
}
|
}
|
||||||
|
println("Starting benchmark")
|
||||||
}
|
for (uploader in uploaders) {
|
||||||
|
uploader.sendRequest()
|
||||||
@KtorExperimentalAPI
|
}
|
||||||
suspend fun uploadData(currIteration: Int, gson: Gson, inputSound: ByteArray) {
|
println("Data scrubbing")
|
||||||
HttpClient(Jetty).use { client ->
|
for (uploader in uploaders) {
|
||||||
val parts: List<PartData> = formData {
|
timestamps[uploader.currIteration] = uploader.respInstant
|
||||||
val headersBuilder = HeadersBuilder()
|
}
|
||||||
headersBuilder[HttpHeaders.ContentType] = "audio/wave"
|
println("Benchmark ended")
|
||||||
headersBuilder[HttpHeaders.ContentDisposition] = "filename=csirip.wav"
|
processResults.mapToProcess = timestamps
|
||||||
this.append(
|
processResults.process()
|
||||||
"file",
|
|
||||||
inputSound,
|
|
||||||
headersBuilder.build()
|
|
||||||
)
|
|
||||||
val inputSvcApi = InputSvcApi("2020-02-02T02:02:02", currIteration)
|
|
||||||
val jsonHeadersBuilder = HeadersBuilder()
|
|
||||||
jsonHeadersBuilder[HttpHeaders.ContentType] = "application/json"
|
|
||||||
this.append(
|
|
||||||
"description",
|
|
||||||
gson.toJson(inputSvcApi),
|
|
||||||
jsonHeadersBuilder.build()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client.submitFormWithBinaryData<Unit>(formData = parts) {
|
|
||||||
url("https://birb.k8s.kmlabz.com/benchmark")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data class InputSvcApi(val date: String, val device_id: Int)
|
|
3
src/InputSvcApi.kt
Normal file
3
src/InputSvcApi.kt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package com.kmlabz.k8s
|
||||||
|
|
||||||
|
data class InputSvcApi(val date: String, val device_id: Int)
|
20
src/ProcessResults.kt
Normal file
20
src/ProcessResults.kt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package com.kmlabz.k8s
|
||||||
|
|
||||||
|
import java.time.Instant
|
||||||
|
import java.time.ZoneId
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
|
class ProcessResults {
|
||||||
|
var mapToProcess = LinkedHashMap<Int, Instant>()
|
||||||
|
private var formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss_SSS")
|
||||||
|
.withZone(ZoneId.systemDefault())
|
||||||
|
|
||||||
|
|
||||||
|
fun process() {
|
||||||
|
println("Start processing results")
|
||||||
|
for ((id, instant) in this.mapToProcess) {
|
||||||
|
val currInstantString = formatter.format(instant)
|
||||||
|
println("$id, $currInstantString")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
src/Uploader.kt
Normal file
50
src/Uploader.kt
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package com.kmlabz.k8s
|
||||||
|
|
||||||
|
import com.google.gson.GsonBuilder
|
||||||
|
import io.ktor.client.*
|
||||||
|
import io.ktor.client.engine.apache.*
|
||||||
|
import io.ktor.client.request.*
|
||||||
|
import io.ktor.client.request.forms.*
|
||||||
|
import io.ktor.http.*
|
||||||
|
import io.ktor.http.content.*
|
||||||
|
import io.ktor.util.*
|
||||||
|
import java.io.File
|
||||||
|
import java.time.Instant
|
||||||
|
|
||||||
|
class Uploader{
|
||||||
|
private val gson = GsonBuilder().setPrettyPrinting().create()
|
||||||
|
private val inputSound = File("/app/wave.wav").readBytes()
|
||||||
|
private lateinit var parts: List<PartData>
|
||||||
|
var respInstant: Instant = Instant.now()
|
||||||
|
var currIteration: Int = 0
|
||||||
|
fun buildRequest() {
|
||||||
|
parts = formData {
|
||||||
|
val headersBuilder = HeadersBuilder()
|
||||||
|
headersBuilder[HttpHeaders.ContentType] = "audio/wave"
|
||||||
|
headersBuilder[HttpHeaders.ContentDisposition] = "filename=csirip.wav"
|
||||||
|
this.append(
|
||||||
|
"file",
|
||||||
|
inputSound,
|
||||||
|
headersBuilder.build()
|
||||||
|
)
|
||||||
|
val inputSvcApi = InputSvcApi("2020-02-02T02:02:02", currIteration)
|
||||||
|
val jsonHeadersBuilder = HeadersBuilder()
|
||||||
|
jsonHeadersBuilder[HttpHeaders.ContentType] = "application/json"
|
||||||
|
this.append(
|
||||||
|
"description",
|
||||||
|
gson.toJson(inputSvcApi),
|
||||||
|
jsonHeadersBuilder.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@KtorExperimentalAPI
|
||||||
|
suspend fun sendRequest() {
|
||||||
|
HttpClient(Apache).use { client ->
|
||||||
|
client.submitFormWithBinaryData<Unit>(formData = parts) {
|
||||||
|
url(System.getenv("URL") ?: "https://birb.k8s.kmlabz.com/benchmark")
|
||||||
|
}
|
||||||
|
respInstant = Instant.now()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user