Skip to content

Commit

Permalink
Fix once and for all the logging.
Browse files Browse the repository at this point in the history
Reduce parallelism
  • Loading branch information
slinkydeveloper committed Aug 6, 2024
1 parent daa5d2c commit bf07e17
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
41 changes: 21 additions & 20 deletions src/main/kotlin/dev/restate/sdktesting/infra/RestateDeployer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import java.nio.file.Path
import java.util.concurrent.TimeUnit
import org.apache.logging.log4j.LogManager
import org.junit.jupiter.api.extension.ExtensionContext
import org.junit.jupiter.api.fail
import org.rnorth.ducttape.unreliables.Unreliables
import org.testcontainers.containers.*
import org.testcontainers.containers.wait.strategy.Wait
Expand Down Expand Up @@ -295,26 +294,28 @@ private constructor(
waitRuntimeIngressHealthy()
}

fun discoverDeployment(client: DeploymentApi, spec: ServiceSpec) {
Unreliables.retryUntilSuccess(5, TimeUnit.SECONDS) {
val url = spec.getEndpointUrl(config)
if (spec.skipRegistration) {
LOG.debug("Skipping registration for endpoint {}", url)
return@retryUntilSuccess
}

val request =
RegisterDeploymentRequest(
RegisterDeploymentRequestAnyOf().uri(url.toString()).force(false))
try {
val response = client.createDeployment(request)
LOG.debug("Successfully executed discovery for endpoint {}. Result: {}", url, response)
} catch (e: ApiException) {
fail(
"Error when discovering endpoint $url, got status code ${e.code} with body: ${e.responseBody}",
e)
}
private fun discoverDeployment(client: DeploymentApi, spec: ServiceSpec) {
val url = spec.getEndpointUrl(config)
if (spec.skipRegistration) {
LOG.debug("Skipping registration for endpoint {}", url)
return
}
val request =
RegisterDeploymentRequest(RegisterDeploymentRequestAnyOf().uri(url.toString()).force(false))

val response =
Unreliables.retryUntilSuccess(20, TimeUnit.SECONDS) {
try {
return@retryUntilSuccess client.createDeployment(request)
} catch (e: ApiException) {
Thread.sleep(30)
throw IllegalStateException(
"Error when discovering endpoint $url, got status code ${e.code} with body: ${e.responseBody}",
e)
}
}

LOG.debug("Successfully executed discovery for endpoint {}. Result: {}", url, response)
}

private fun writeEnvironmentReport(testReportDir: String) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/dev/restate/sdktesting/junit/TestSuite.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class TestSuite(
"""
.trimMargin())

// Apply additional runtime envs
registerGlobalConfig(getGlobalConfig().copy(additionalRuntimeEnvs = additionalEnvs))

// Prepare Log4j2 configuration
val log4j2Configuration = prepareLog4j2Config(reportDir, printToStdout)
Configurator.reconfigure(log4j2Configuration)

// Apply additional runtime envs
registerGlobalConfig(getGlobalConfig().copy(additionalRuntimeEnvs = additionalEnvs))

// Prepare launch request
val request =
LauncherDiscoveryRequestBuilder.request()
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/dev/restate/sdktesting/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class RestateSdkTestSuite : CliktCommand() {
override fun run() {
// Disable log4j2 JMX, this prevents reconfiguration
System.setProperty("log4j2.disable.jmx", "true")
// This is hours of debugging, don't touch it
// tl;dr this makes sure a single log4j2 configuration exists for the whole JVM,
// important to make Configurator.reconfigure work
System.setProperty(
"log4j2.contextSelector", "org.apache.logging.log4j.core.selector.BasicContextSelector")
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/junit-platform.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ junit.jupiter.execution.parallel.mode.default=same_thread
# junit.jupiter.execution.parallel.mode.classes.default=concurrent
# Automatically adjust parallelism based on available cpu/processor cores
junit.jupiter.execution.parallel.config.strategy=dynamic
junit.jupiter.execution.parallel.config.dynamic.factor=1.5
junit.jupiter.execution.parallel.config.dynamic.factor=1.0

0 comments on commit bf07e17

Please sign in to comment.