Skip to content

Commit 88cf528

Browse files
author
Zsofia Borbely
committed
TS-42917 Ensure partition and clusterId are not null
1 parent a51005c commit 88cf528

6 files changed

Lines changed: 12 additions & 7 deletions

File tree

agent/src/main/java/com/teamscale/jacoco/agent/testimpact/CoverageToJsonStrategyBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void testStart(String uniformPath) {
6969
if (availableTests.stream().noneMatch(test -> test.uniformPath.equals(uniformPath))) {
7070
// ensure that we can at least generate a report for the tests that were actually run,
7171
// even if the caller did not provide a list of tests up-front in testRunStart
72-
availableTests.add(new ClusteredTestDetails(uniformPath, uniformPath, null, null, null));
72+
availableTests.add(new ClusteredTestDetails(uniformPath, uniformPath, null, null, agentOptions.getTeamscaleServerOptions().partition));
7373
}
7474
}
7575

impacted-test-engine/src/main/kotlin/com/teamscale/test_impacted/engine/ImpactedTestEngine.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.teamscale.test_impacted.engine
22

33
import com.teamscale.test_impacted.commons.LoggerUtils.createLogger
44
import com.teamscale.test_impacted.engine.options.TestEngineOptionUtils
5+
import jdk.internal.agent.AgentConfigurationError
56
import org.junit.platform.engine.*
67
import org.junit.platform.engine.support.descriptor.EngineDescriptor
78
import java.util.*
@@ -21,6 +22,10 @@ class ImpactedTestEngine : TestEngine {
2122
if (!engineOptions.enabled) {
2223
return EngineDescriptor(uniqueId, ENGINE_NAME)
2324
}
25+
if (engineOptions.partition == null) {
26+
throw AgentConfigurationError("Agent option partition is undefined, but it's a mandatory parameter when executing impacted tests.")
27+
}
28+
2429
val configuration = engineOptions.testEngineConfiguration
2530
val engine = InternalImpactedTestEngine(configuration, engineOptions.partition)
2631

impacted-test-engine/src/main/kotlin/com/teamscale/test_impacted/engine/InternalImpactedTestEngine.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import org.junit.platform.engine.support.descriptor.EngineDescriptor
2525
*/
2626
internal class InternalImpactedTestEngine(
2727
configuration: ImpactedTestEngineConfiguration,
28-
private val partition: String?
28+
private val partition: String
2929
) {
3030
private val testEngineRegistry = configuration.testEngineRegistry
3131
private val testSorter = configuration.testSorter

impacted-test-engine/src/main/kotlin/com/teamscale/test_impacted/test_descriptor/TestDescriptorUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ object TestDescriptorUtils {
9595
/** Returns the [AvailableTests] contained within the root [TestDescriptor]. */
9696
fun getAvailableTests(
9797
rootTestDescriptor: TestDescriptor,
98-
partition: String?
98+
partition: String
9999
): AvailableTests {
100100
val availableTests = AvailableTests()
101101

teamscale-client/src/main/kotlin/com/teamscale/client/ClusteredTestDetails.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ class ClusteredTestDetails @JsonCreator constructor(
3333
*/
3434
@param:JsonProperty(
3535
"partition"
36-
) var partition: String?
36+
) var partition: String
3737
) : TestDetails(uniformPath, sourcePath, content)
3838

teamscale-client/src/main/kotlin/com/teamscale/client/TestWithClusterId.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ class TestWithClusterId @JsonCreator constructor(
1818
/**
1919
* The partition of the test.
2020
*/
21-
@param:JsonProperty("partition") val partition: String?,
21+
@param:JsonProperty("partition") val partition: String,
2222
/**
2323
* A unique identifier for the cluster this test should be prioritized within. May not be null.
2424
*/
25-
@param:JsonProperty("clusterId") val clusterId: String?
25+
@param:JsonProperty("clusterId") val clusterId: String
2626
) {
2727
companion object {
2828
/**
@@ -31,7 +31,7 @@ class TestWithClusterId @JsonCreator constructor(
3131
fun fromClusteredTestDetails(clusteredTestDetails: ClusteredTestDetails) =
3232
TestWithClusterId(
3333
clusteredTestDetails.uniformPath, clusteredTestDetails.content,
34-
clusteredTestDetails.partition, clusteredTestDetails.clusterId
34+
clusteredTestDetails.partition, clusteredTestDetails.clusterId ?: clusteredTestDetails.uniformPath
3535
)
3636
}
3737
}

0 commit comments

Comments
 (0)