-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5579895
commit 1f80e95
Showing
4 changed files
with
67 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 0 additions & 68 deletions
68
...ine/src/main/java/com/teamscale/test_impacted/engine/executor/TeamscaleAgentNotifier.java
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
...ine/src/main/kotlin/com/teamscale/test_impacted/engine/executor/TeamscaleAgentNotifier.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.teamscale.test_impacted.engine.executor | ||
|
||
import com.teamscale.report.testwise.model.TestExecution | ||
import com.teamscale.test_impacted.commons.LoggerUtils.createLogger | ||
import com.teamscale.tia.client.ITestwiseCoverageAgentApi | ||
import com.teamscale.tia.client.UrlUtils.encodeUrl | ||
import java.io.IOException | ||
import java.util.logging.Level | ||
|
||
/** Communicates test start and end to the agent and the end of the overall test execution. */ | ||
open class TeamscaleAgentNotifier( | ||
/** A list of API services to signal test start and end to the agent. */ | ||
private val testwiseCoverageAgentApis: List<ITestwiseCoverageAgentApi>, | ||
/** | ||
* Whether only a part of the tests is being executed (`true`) or whether all tests are executed | ||
* (`false`). | ||
*/ | ||
private val partial: Boolean | ||
) { | ||
private val logger = createLogger() | ||
|
||
/** Reports the start of a test to the Teamscale JaCoCo agent. */ | ||
open fun startTest(testUniformPath: String) { | ||
try { | ||
testwiseCoverageAgentApis.forEach { apiService -> | ||
apiService.testStarted(testUniformPath.encodeUrl()).execute() | ||
} | ||
} catch (e: IOException) { | ||
logger.log( | ||
Level.SEVERE, e | ||
) { "Error while calling service api." } | ||
} | ||
} | ||
|
||
/** Reports the end of a test to the Teamscale JaCoCo agent. */ | ||
open fun endTest(testUniformPath: String, testExecution: TestExecution?) { | ||
try { | ||
testwiseCoverageAgentApis.forEach { apiService -> | ||
val url = testUniformPath.encodeUrl() | ||
if (testExecution == null) { | ||
apiService.testFinished(url).execute() | ||
} else { | ||
apiService.testFinished(url, testExecution).execute() | ||
} | ||
} | ||
} catch (e: IOException) { | ||
logger.log( | ||
Level.SEVERE, e | ||
) { "Error contacting test wise coverage agent." } | ||
} | ||
} | ||
|
||
/** Reports the end of the test run to the Teamscale JaCoCo agent. */ | ||
open fun testRunEnded() { | ||
try { | ||
testwiseCoverageAgentApis.forEach { apiService -> | ||
apiService.testRunFinished(partial).execute() | ||
} | ||
} catch (e: IOException) { | ||
logger.log( | ||
Level.SEVERE, e | ||
) { "Error contacting test wise coverage agent." } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters