Skip to content

Commit

Permalink
Updated package versions, updated web server tests. (#207)
Browse files Browse the repository at this point in the history
* Updated all package versions including kotlin. Updated all web-server tests to run.

* Changed the java version of the tests. OpenDC now only supports java 19.

* small update

* test update

* new update

* updated docker version to 19

* updated docker version to 19
  • Loading branch information
DanteNiewenhuis authored Mar 5, 2024
1 parent d28002a commit 5864cbc
Show file tree
Hide file tree
Showing 383 changed files with 8,252 additions and 6,850 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
strategy:
matrix:
os: [ ubuntu-22.04 ]
java: [ 17, 19 ]
java: [ 19 ]
include:
- os: windows-2022
java: 17
java: 19
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
java-version: 19
- name: Prepare
id: prep
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 17
java-version: 19
- name: Publish with Gradle
uses: gradle/gradle-build-action@v2
with:
Expand Down
1 change: 0 additions & 1 deletion buildSrc/src/main/kotlin/spotless-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ spotless {
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
kotlin {
ktlint()
.setUseExperimental(false)
trimTrailingWhitespace()
endWithNewline()

Expand Down
46 changes: 24 additions & 22 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
[versions]
calcite = "1.34.0"
calcite = "1.36.0"
clikt = "3.5.2"
commons-math3 = "3.6.1"
dokka = "1.8.10"
dokka = "1.9.10"
gradle-node = "3.5.1"
hadoop = "3.3.5"
hypersistence-utils = "3.2.0"
jackson = "2.14.2"
hadoop = "3.3.6"
hypersistence-utils = "3.7.3"
jackson = "2.16.1"
jandex-gradle = "1.1.0"
java = "17"
jline = "3.23.0"
java = "19"
jline = "3.25.1"
jmh-gradle = "0.7.0"
jakarta-validation = "2.0.2"
junit-jupiter = "5.9.1"
kotlin = "1.8.10"
jakarta = "3.0.2"
junit-jupiter = "5.10.2"
kotlin = "1.9.22"
kotlin-logging = "3.0.5"
kotlinx-coroutines = "1.6.4"
log4j = "2.20.0"
microprofile-openapi = "3.0"
microprofile-config = "3.0.1"
mockk = "1.13.4"
kotlinx-coroutines = "1.8.0"
log4j = "2.23.0"
microprofile-openapi = "3.1"
microprofile-config = "3.1"
mockk = "1.13.9"
node = "18.15.0"
parquet = "1.12.3"
progressbar = "0.9.5"
quarkus = "2.16.5.Final"
sentry = "6.16.0"
parquet = "1.13.1"
progressbar = "0.10.0"
quarkus = "3.8.0"
sentry = "7.4.0"
slf4j = "2.0.7"
spotless = "6.12.0"
spotless = "6.25.0"

[libraries]
# Kotlin
Expand All @@ -36,6 +36,7 @@ kotlin-noarg = { module = "org.jetbrains.kotlin:kotlin-noarg", version.ref = "ko
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }

# Logging
#kotlin-logging = { module = "io.github.oshai:kotlin-logging-jvm", version.ref = "kotlin-logging" }
kotlin-logging = { module = "io.github.microutils:kotlin-logging", version.ref = "kotlin-logging" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4j" }
Expand Down Expand Up @@ -84,7 +85,7 @@ quarkus-hibernate-validator = { module = "io.quarkus:quarkus-hibernate-validator
quarkus-jdbc-h2 = { module = "io.quarkus:quarkus-jdbc-h2" }
quarkus-jdbc-postgresql = { module = "io.quarkus:quarkus-jdbc-postgresql" }
quarkus-flyway = { module = "io.quarkus:quarkus-flyway" }
hypersistence-utils-hibernate = { module = "io.hypersistence:hypersistence-utils-hibernate-55", version.ref = "hypersistence-utils" }
hypersistence-utils-hibernate = { module = "io.hypersistence:hypersistence-utils-hibernate-60", version.ref = "hypersistence-utils" }

# Quarkus (Testing)
quarkus-junit5-core = { module = "io.quarkus:quarkus-junit5" }
Expand All @@ -98,7 +99,8 @@ calcite-core = { module = "org.apache.calcite:calcite-core", version.ref = "calc
jline = { module = "org.jline:jline", version.ref = "jline" }

# Other
jakarta-validation = { module = "jakarta.validation:jakarta.validation-api", version.ref = "jakarta-validation" }
jakarta-validation = { module = "jakarta.validation:jakarta.validation-api", version.ref = "jakarta" }
jakarta-ws-rs = { module = "jakarta.ws.rs:jakarta.ws.rs-api", version.ref = "jakarta" }
hadoop-common = { module = "org.apache.hadoop:hadoop-common", version.ref = "hadoop" }
hadoop-mapreduce-client-core = { module = "org.apache.hadoop:hadoop-mapreduce-client-core", version.ref = "hadoop" }
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
Expand Down
2 changes: 1 addition & 1 deletion opendc-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
group = "org.opendc"
description = "Common functionality used across OpenDC modules"

/* Build configuration */
// Build configuration
plugins {
`kotlin-library-conventions`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,33 @@ import kotlin.coroutines.CoroutineContext
*/
@OptIn(InternalCoroutinesApi::class)
internal class DispatcherCoroutineDispatcher(private val dispatcher: Dispatcher) : CoroutineDispatcher(), Delay, DispatcherProvider {
override fun dispatch(context: CoroutineContext, block: Runnable) {
override fun dispatch(
context: CoroutineContext,
block: Runnable,
) {
block.run()
}

override fun dispatchYield(context: CoroutineContext, block: Runnable) {
override fun dispatchYield(
context: CoroutineContext,
block: Runnable,
) {
dispatcher.schedule(block)
}

@OptIn(ExperimentalCoroutinesApi::class)
override fun scheduleResumeAfterDelay(timeMillis: Long, continuation: CancellableContinuation<Unit>) {
override fun scheduleResumeAfterDelay(
timeMillis: Long,
continuation: CancellableContinuation<Unit>,
) {
dispatcher.schedule(timeMillis, CancellableContinuationRunnable(continuation) { resumeUndispatched(Unit) })
}

override fun invokeOnTimeout(timeMillis: Long, block: Runnable, context: CoroutineContext): DisposableHandle {
override fun invokeOnTimeout(
timeMillis: Long,
block: Runnable,
context: CoroutineContext,
): DisposableHandle {
val handle = dispatcher.scheduleCancellable(timeMillis, block)
return DisposableHandle { handle.cancel() }
}
Expand All @@ -67,7 +80,7 @@ internal class DispatcherCoroutineDispatcher(private val dispatcher: Dispatcher)
*/
private class CancellableContinuationRunnable<T>(
@JvmField val continuation: CancellableContinuation<T>,
private val block: CancellableContinuation<T>.() -> Unit
private val block: CancellableContinuation<T>.() -> Unit,
) : Runnable {
override fun run() = continuation.block()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,44 +36,46 @@ import org.opendc.simulator.kotlin.runSimulation
* Test suite for [DispatcherCoroutineDispatcher].
*/
class DispatcherCoroutineDispatcherTest {

/**
* Tests if a dispatcher yields the correct time
*/
@Test
fun testYield() = runSimulation {
withContext(dispatcher.asCoroutineDispatcher()) {
val startTime = dispatcher.currentTime
yield()
assertEquals(startTime, dispatcher.currentTime)
fun testYield() =
runSimulation {
withContext(dispatcher.asCoroutineDispatcher()) {
val startTime = dispatcher.currentTime
yield()
assertEquals(startTime, dispatcher.currentTime)
}
}
}

/**
* Tests if a dispatcher correctly delays
*/
@Test
fun testDelay() = runSimulation {
withContext(dispatcher.asCoroutineDispatcher()) {
val startTime = dispatcher.currentTime
delay(10)
assertEquals(startTime + 10, dispatcher.currentTime)
fun testDelay() =
runSimulation {
withContext(dispatcher.asCoroutineDispatcher()) {
val startTime = dispatcher.currentTime
delay(10)
assertEquals(startTime + 10, dispatcher.currentTime)
}
}
}

/**
* Tests if a dispatcher correctly times out
*/
@Test
fun testTimeout() = runSimulation {
withContext(dispatcher.asCoroutineDispatcher()) {
assertThrows<TimeoutCancellationException> {
withTimeout(10) {
delay(1000)
fun testTimeout() =
runSimulation {
withContext(dispatcher.asCoroutineDispatcher()) {
assertThrows<TimeoutCancellationException> {
withTimeout(10) {
delay(1000)
}
}
}

assertEquals(10, dispatcher.currentTime)
assertEquals(10, dispatcher.currentTime)
}
}
}
}
35 changes: 20 additions & 15 deletions opendc-common/src/test/kotlin/org/opendc/common/util/PacerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ class PacerTest {
var count = 0

runSimulation {
val pacer = Pacer(dispatcher, /*quantum*/ 100) {
count++
}
val pacer =
Pacer(dispatcher, 100) {
count++
}

pacer.enqueue()
}
Expand All @@ -54,9 +55,10 @@ class PacerTest {
var count = 0

runSimulation {
val pacer = Pacer(dispatcher, /*quantum*/ 100) {
count++
}
val pacer =
Pacer(dispatcher, 100) {
count++
}

pacer.enqueue()
pacer.enqueue()
Expand All @@ -72,9 +74,10 @@ class PacerTest {
var count = 0

runSimulation {
val pacer = Pacer(dispatcher, /*quantum*/ 100) {
count++
}
val pacer =
Pacer(dispatcher, 100) {
count++
}

pacer.enqueue()
pacer.cancel()
Expand All @@ -90,9 +93,10 @@ class PacerTest {
var count = 0

runSimulation {
val pacer = Pacer(dispatcher, /*quantum*/ 100) {
count++
}
val pacer =
Pacer(dispatcher, 100) {
count++
}

assertFalse(pacer.isPending)
assertDoesNotThrow { pacer.cancel() }
Expand All @@ -108,9 +112,10 @@ class PacerTest {
var count = 0

runSimulation {
val pacer = Pacer(dispatcher, /*quantum*/ 100) {
count++
}
val pacer =
Pacer(dispatcher, 100) {
count++
}

pacer.enqueue()
delay(100)
Expand Down
2 changes: 1 addition & 1 deletion opendc-compute/opendc-compute-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

description = "API interface for the OpenDC Compute service"

/* Build configuration */
// Build configuration
plugins {
`kotlin-library-conventions`
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public interface ComputeClient : AutoCloseable {
cpuCount: Int,
memorySize: Long,
labels: Map<String, String> = emptyMap(),
meta: Map<String, Any> = emptyMap()
meta: Map<String, Any> = emptyMap(),
): Flavor

/**
Expand All @@ -79,7 +79,7 @@ public interface ComputeClient : AutoCloseable {
public fun newImage(
name: String,
labels: Map<String, String> = emptyMap(),
meta: Map<String, Any> = emptyMap()
meta: Map<String, Any> = emptyMap(),
): Image

/**
Expand Down Expand Up @@ -110,7 +110,7 @@ public interface ComputeClient : AutoCloseable {
flavor: Flavor,
labels: Map<String, String> = emptyMap(),
meta: Map<String, Any> = emptyMap(),
start: Boolean = true
start: Boolean = true,
): Server

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ package org.opendc.compute.api
* This exception is thrown to indicate that the compute service does not have enough capacity at the moment to
* fulfill a launch request.
*/
public class InsufficientServerCapacityException(override val cause: Throwable? = null) : Exception("There was insufficient capacity available to satisfy the launch request")
public class InsufficientServerCapacityException(
override val cause: Throwable? = null,
) : Exception("There was insufficient capacity available to satisfy the launch request")
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ public enum class ServerState {
/**
* The server has been deleted and cannot be started later on.
*/
DELETED
DELETED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ public interface ServerWatcher {
* @param server The server whose state has changed.
* @param newState The new state of the server.
*/
public fun onStateChanged(server: Server, newState: ServerState) {}
public fun onStateChanged(
server: Server,
newState: ServerState,
) {}
}
3 changes: 2 additions & 1 deletion opendc-compute/opendc-compute-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

description = "OpenDC Compute Service implementation"

/* Build configuration */
// Build configuration
plugins {
`kotlin-library-conventions`
}
Expand All @@ -33,6 +33,7 @@ dependencies {
implementation(libs.kotlin.logging)

testImplementation(projects.opendcSimulator.opendcSimulatorCore)
testImplementation(libs.log4j.slf4j)
testRuntimeOnly(libs.log4j.core)
testRuntimeOnly(libs.log4j.slf4j)
}
Loading

0 comments on commit 5864cbc

Please sign in to comment.