-
Notifications
You must be signed in to change notification settings - Fork 110
Flaky detect #1420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Flaky detect #1420
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
34c6e31
add option for enabling flakiness detection
man-zhang 1a2365b
add option for enabling flakiness detection
man-zhang c82b7b6
add FlakinessDetector Singleton
man-zhang 16bb348
identify flakiness for Http actions
man-zhang e44d7da
add unit test for set flakiness
man-zhang 9a94fb7
fix a bug
man-zhang 7f074fd
support comment out flaky assertions for Junit
man-zhang 968248e
add test
man-zhang 15cf9e7
update test
man-zhang 4ee3399
add doc
man-zhang 2b393bd
add extra test for list
man-zhang 06a9508
minor
man-zhang 85e5cb3
handle for response in plain text
man-zhang 059bd87
add e2e test
man-zhang 604f5f1
fix the test
man-zhang 00b5e27
fix a bug
man-zhang 23af2a9
rename detectFlakiness to handleFlakiness
man-zhang b8a9348
fix a bug
man-zhang 4139bd0
fix a bug with line sep
man-zhang f278e92
change gson to jackson
man-zhang 6231480
add doc
man-zhang 6437385
Merge branch 'flaky-detect' of https://github.com/WebFuzzing/EvoMaste…
man-zhang cee07da
minor update
man-zhang b77801d
fix the test and modify the assertions
man-zhang b3093e4
Merge branch 'master' into flaky-detect
man-zhang 334a2df
add running example
man-zhang 6101dba
add flakyPhase
man-zhang ab1b531
add derive
man-zhang b4bf238
put back setFlakiness in HttpWsCallResult.kt
man-zhang 4fa39b9
Merge branch 'master' into flaky-detect
man-zhang 79ccad7
resolve conflicts in options.md
man-zhang 09b71c2
clarify
man-zhang 637bba7
handle status
man-zhang c3ed0eb
support flakiness assertion for python
man-zhang cb4ac9f
fix the bugs in module
man-zhang 0b5fd2e
support python output
man-zhang 1e62529
add unint test
man-zhang 585e9d0
use setOption
man-zhang 2e160a1
add bb e2e test
man-zhang d48a7b5
support JS
man-zhang a53fd11
update config
man-zhang 4d9fa6f
add bb e2e tests
man-zhang 892314b
Merge branch 'master' into flaky-detect
man-zhang 569fe7e
add unit test and more doc for flakinessInferenceUtil
man-zhang c0bc11e
Merge branch 'flaky-detect' of https://github.com/WebFuzzing/EvoMaste…
man-zhang 047c2cd
fix a bug
man-zhang 5f24b0e
increase the change to be flaky in example
man-zhang 1a6674c
change the seed
man-zhang 02f35b9
fix tests
man-zhang 14aae4e
add new util method
man-zhang b6fd977
clean code
man-zhang d078dbf
update EMConfig
man-zhang 6181716
use ExecutionPhaseController
man-zhang f239f3b
remove TODO
man-zhang 4193835
fix the test
man-zhang 4717043
Merge branch 'master' into flaky-detect
man-zhang 3ca8611
resolve the conflicts
man-zhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
15 changes: 15 additions & 0 deletions
15
...bb/src/main/kotlin/com/foo/rest/examples/bb/flakinessdetect/FlakinessDetectApplication.kt
This file contains hidden or 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,15 @@ | ||
| package com.foo.rest.examples.bb.flakinessdetect | ||
|
|
||
| import org.springframework.boot.SpringApplication | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication | ||
| import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration | ||
|
|
||
| @SpringBootApplication(exclude = [SecurityAutoConfiguration::class]) | ||
| open class FlakinessDetectApplication { | ||
| companion object { | ||
| @JvmStatic | ||
| fun main(args: Array<String>) { | ||
| SpringApplication.run(FlakinessDetectApplication::class.java, *args) | ||
| } | ||
| } | ||
| } |
95 changes: 95 additions & 0 deletions
95
...g-rest-bb/src/main/kotlin/com/foo/rest/examples/bb/flakinessdetect/FlakinessDetectRest.kt
This file contains hidden or 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,95 @@ | ||
| package com.foo.rest.examples.bb.flakinessdetect | ||
|
|
||
| import org.evomaster.e2etests.utils.CoveredTargets | ||
| import org.h2.util.MathUtils.randomInt | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.PathVariable | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RequestParam | ||
| import org.springframework.web.bind.annotation.RestController | ||
| import java.time.LocalDateTime | ||
| import java.time.format.DateTimeFormatter | ||
| import kotlin.math.max | ||
| import kotlin.math.min | ||
|
|
||
| @RestController | ||
| @RequestMapping(path = ["/api/flakinessdetect"]) | ||
| class FlakinessDetectRest { | ||
|
|
||
| companion object{ | ||
| val formatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSS yyyy-MM-dd EEEE 'Week' ww") | ||
| } | ||
|
|
||
| @GetMapping(path = ["/stringfirst/{n}"]) | ||
| open fun getFirst( @PathVariable("n") n: Int) : ResponseEntity<String> { | ||
| CoveredTargets.cover("First") | ||
| return ResponseEntity.ok(getPartialDate(n)) | ||
| } | ||
|
|
||
| @GetMapping(path = ["/next/{n}"]) | ||
| open fun getNext( @PathVariable("n") n: Int) : ResponseEntity<FlakinessDetectData> { | ||
| CoveredTargets.cover("Next") | ||
| return ResponseEntity.ok(FlakinessDetectData(getPartialDate(n), randomInt(n))) | ||
| } | ||
|
|
||
| @GetMapping(path = ["/multiplelines/{num}"]) | ||
| open fun getMultipleLines( @PathVariable("num") num: Int) : ResponseEntity<FlakinessDetectData> { | ||
|
|
||
| val num = min(20, max(2, randomInt(num))) | ||
|
|
||
| val msg = (1..num).joinToString(System.lineSeparator()) { "LINE $it" } | ||
| CoveredTargets.cover("MultipleLines") | ||
| return ResponseEntity.ok(FlakinessDetectData(msg, num)) | ||
| } | ||
|
|
||
| @GetMapping("/price/estimate") | ||
| fun estimatePrice(@RequestParam base: Int): Map<String, Int> { | ||
| val randomJitter = randomInt(1000) | ||
|
|
||
| val total = base + randomJitter | ||
|
|
||
| CoveredTargets.cover("estimate") | ||
| return mapOf( | ||
| "base" to base, | ||
| "jitter" to randomJitter, | ||
| "total" to total | ||
| ) | ||
| } | ||
|
|
||
| @GetMapping("/calculate/timeago") | ||
| fun getTimeAgo( | ||
| @RequestParam(defaultValue = "0") day: Long, | ||
| @RequestParam(defaultValue = "0") hour: Long, | ||
| @RequestParam(defaultValue = "0") min: Long, | ||
| @RequestParam(defaultValue = "0") sec: Long | ||
| ): ResponseEntity<TimeAgoData> { | ||
|
|
||
| CoveredTargets.cover("TimeAgo") | ||
| val msg = listOf(day to "day", hour to "hour", min to "minute", sec to "second") | ||
| .filter { it.first > 0 } | ||
| .joinToString(", ") { (v, u) -> "$v $u${if (v > 1) "s" else ""}" }.takeIf { it.isNotEmpty() } | ||
| ?.let { "$it ago" } | ||
| ?: "just now" | ||
|
|
||
| val pastDate = LocalDateTime.now() | ||
| .minusDays(day).minusHours(hour).minusMinutes(min).minusSeconds(sec) | ||
|
|
||
| return ResponseEntity.ok(TimeAgoData(msg, pastDate.toString())) | ||
| } | ||
|
|
||
| private fun getPartialDate(n: Int) : String { | ||
| val now = LocalDateTime.now().format(formatter) | ||
| val size = max(12, min(now.toString().length, n)) | ||
|
|
||
| return now.substring(0, size) | ||
| } | ||
| } | ||
|
|
||
| data class FlakinessDetectData( | ||
| val first : String, val next : Int) | ||
|
|
||
| data class TimeAgoData( | ||
| val message: String, | ||
| val calculatedPastTime: String | ||
| ) |
7 changes: 7 additions & 0 deletions
7
...-bb/src/test/kotlin/com/foo/rest/examples/bb/flakinessdetect/FlakinessDetectController.kt
This file contains hidden or 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,7 @@ | ||
| package com.foo.rest.examples.bb.flakinessdetect | ||
|
|
||
| import com.foo.rest.examples.bb.SpringController | ||
|
|
||
|
|
||
|
|
||
| class FlakinessDetectController : SpringController(FlakinessDetectApplication::class.java) |
46 changes: 46 additions & 0 deletions
46
...t/kotlin/org/evomaster/e2etests/spring/rest/bb/flakinessdetect/FlakinessDetectBBEMTest.kt
This file contains hidden or 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,46 @@ | ||
| package org.evomaster.e2etests.spring.rest.bb.flakinessdetect | ||
|
|
||
|
|
||
| import com.foo.rest.examples.bb.flakinessdetect.FlakinessDetectController | ||
| import org.evomaster.core.output.OutputFormat | ||
| import org.evomaster.e2etests.spring.rest.bb.SpringTestBase | ||
| import org.junit.jupiter.api.Assertions.assertTrue | ||
| import org.junit.jupiter.api.BeforeAll | ||
| import org.junit.jupiter.params.ParameterizedTest | ||
| import org.junit.jupiter.params.provider.EnumSource | ||
|
|
||
| class FlakinessDetectBBEMTest : SpringTestBase() { | ||
|
|
||
| companion object { | ||
| init { | ||
| shouldApplyInstrumentation = false | ||
| } | ||
|
|
||
| @BeforeAll | ||
| @JvmStatic | ||
| fun init() { | ||
| initClass(FlakinessDetectController()) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| @ParameterizedTest | ||
| @EnumSource | ||
| fun testBlackBoxOutput(outputFormat: OutputFormat) { | ||
| executeAndEvaluateBBTest( | ||
| outputFormat, | ||
| "flakinessdetect", | ||
| 100, | ||
| 3, | ||
| listOf("TimeAgo", "estimate","MultipleLines","Next","First") | ||
| ){ args: MutableList<String> -> | ||
|
|
||
| setOption(args, "handleFlakiness", "true") | ||
|
|
||
| val solution = initAndRun(args) | ||
|
|
||
| assertTrue(solution.individuals.isNotEmpty()) | ||
|
|
||
| } | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
...lin/com/foo/rest/examples/spring/openapi/v3/flakinessdetect/FlakinessDetectApplication.kt
This file contains hidden or 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,15 @@ | ||
| package com.foo.rest.examples.spring.openapi.v3.flakinessdetect | ||
|
|
||
| import org.springframework.boot.SpringApplication | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication | ||
| import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration | ||
|
|
||
| @SpringBootApplication(exclude = [SecurityAutoConfiguration::class]) | ||
| open class FlakinessDetectApplication { | ||
| companion object { | ||
| @JvmStatic | ||
| fun main(args: Array<String>) { | ||
| SpringApplication.run(FlakinessDetectApplication::class.java, *args) | ||
| } | ||
| } | ||
| } | ||
91 changes: 91 additions & 0 deletions
91
...ain/kotlin/com/foo/rest/examples/spring/openapi/v3/flakinessdetect/FlakinessDetectRest.kt
This file contains hidden or 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,91 @@ | ||
| package com.foo.rest.examples.spring.openapi.v3.flakinessdetect | ||
|
|
||
| import org.h2.util.MathUtils.randomInt | ||
| import org.springframework.http.ResponseEntity | ||
| import org.springframework.web.bind.annotation.GetMapping | ||
| import org.springframework.web.bind.annotation.PathVariable | ||
| import org.springframework.web.bind.annotation.RequestMapping | ||
| import org.springframework.web.bind.annotation.RequestParam | ||
| import org.springframework.web.bind.annotation.RestController | ||
| import java.time.LocalDateTime | ||
| import java.time.format.DateTimeFormatter | ||
| import kotlin.math.max | ||
| import kotlin.math.min | ||
|
|
||
| @RestController | ||
| @RequestMapping(path = ["/api/flakinessdetect"]) | ||
| class FlakinessDetectRest { | ||
|
|
||
| companion object{ | ||
| val formatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSS yyyy-MM-dd EEEE 'Week' ww") | ||
| } | ||
|
|
||
| @GetMapping(path = ["/stringfirst/{n}"]) | ||
| open fun getFirst( @PathVariable("n") n: Int) : ResponseEntity<String> { | ||
|
|
||
| return ResponseEntity.ok(getPartialDate(n)) | ||
| } | ||
|
|
||
| @GetMapping(path = ["/next/{n}"]) | ||
| open fun getNext( @PathVariable("n") n: Int) : ResponseEntity<FlakinessDetectData> { | ||
|
|
||
| return ResponseEntity.ok(FlakinessDetectData(getPartialDate(n), randomInt(n))) | ||
| } | ||
|
|
||
| @GetMapping(path = ["/multiplelines/{num}"]) | ||
| open fun getMultipleLines( @PathVariable("num") num: Int) : ResponseEntity<FlakinessDetectData> { | ||
|
|
||
| val num = min(20, max(2, randomInt(num))) | ||
|
|
||
| val msg = (1..num).joinToString(System.lineSeparator()) { "LINE $it" } | ||
| return ResponseEntity.ok(FlakinessDetectData(msg, num)) | ||
| } | ||
|
|
||
| @GetMapping("/price/estimate") | ||
| fun estimatePrice(@RequestParam base: Int): Map<String, Int> { | ||
| val randomJitter = randomInt(1000) | ||
|
|
||
| val total = base + randomJitter | ||
|
|
||
| return mapOf( | ||
| "base" to base, | ||
| "jitter" to randomJitter, | ||
| "total" to total | ||
| ) | ||
| } | ||
|
|
||
| @GetMapping("/calculate/timeago") | ||
| fun getTimeAgo( | ||
| @RequestParam(defaultValue = "0") day: Long, | ||
| @RequestParam(defaultValue = "0") hour: Long, | ||
| @RequestParam(defaultValue = "0") min: Long, | ||
| @RequestParam(defaultValue = "0") sec: Long | ||
| ): ResponseEntity<TimeAgoData> { | ||
|
|
||
| val msg = listOf(day to "day", hour to "hour", min to "minute", sec to "second") | ||
| .filter { it.first > 0 } | ||
| .joinToString(", ") { (v, u) -> "$v $u${if (v > 1) "s" else ""}" }.takeIf { it.isNotEmpty() } | ||
| ?.let { "$it ago" } | ||
| ?: "just now" | ||
|
|
||
| val pastDate = LocalDateTime.now() | ||
| .minusDays(day).minusHours(hour).minusMinutes(min).minusSeconds(sec) | ||
|
|
||
| return ResponseEntity.ok(TimeAgoData(msg, pastDate.toString())) | ||
| } | ||
|
|
||
| private fun getPartialDate(n: Int) : String { | ||
| val now = LocalDateTime.now().format(formatter) | ||
| val size = max(12, min(now.toString().length, n)) | ||
|
|
||
| return now.substring(0, size) | ||
| } | ||
| } | ||
|
|
||
| data class FlakinessDetectData( | ||
| val first : String, val next : Int) | ||
|
|
||
| data class TimeAgoData( | ||
| val message: String, | ||
| val calculatedPastTime: String | ||
| ) |
5 changes: 5 additions & 0 deletions
5
...tlin/com/foo/rest/examples/spring/openapi/v3/flakinessdetect/FlakinessDetectController.kt
This file contains hidden or 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,5 @@ | ||
| package com.foo.rest.examples.spring.openapi.v3.flakinessdetect | ||
|
|
||
| import com.foo.rest.examples.spring.openapi.v3.SpringController | ||
|
|
||
| class FlakinessDetectController : SpringController(FlakinessDetectApplication::class.java) |
54 changes: 54 additions & 0 deletions
54
...org/evomaster/e2etests/spring/openapi/v3/flakinessdetect/FlakinessDetectBlackboxEMTest.kt
This file contains hidden or 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,54 @@ | ||
| package org.evomaster.e2etests.spring.openapi.v3.flakinessdetect | ||
|
|
||
| import com.foo.rest.examples.spring.openapi.v3.flakinessdetect.FlakinessDetectController | ||
| import org.evomaster.e2etests.spring.openapi.v3.SpringTestBase | ||
| import org.junit.jupiter.api.Assertions.assertTrue | ||
| import org.junit.jupiter.api.BeforeAll | ||
| import org.junit.jupiter.api.Test | ||
| import java.util.function.Predicate | ||
|
|
||
| class FlakinessDetectBlackboxEMTest : SpringTestBase() { | ||
|
|
||
| companion object { | ||
| @BeforeAll | ||
| @JvmStatic | ||
| fun init() { | ||
| initClass(FlakinessDetectController()) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| fun testRunEM() { | ||
| defaultSeed = 123 | ||
|
|
||
| val outputFolder = "FlakinessDetectBlackboxEM" | ||
| val outputClass = "org.foo.FlakinessDetectBlackboxEM" | ||
| val flakyMark = "Flaky" | ||
|
|
||
| runTestHandlingFlakyAndCompilation( | ||
| outputFolder, | ||
| outputClass, | ||
| 100 | ||
| ) { args: MutableList<String> -> | ||
|
|
||
|
|
||
|
|
||
| setOption(args, "handleFlakiness", "true") | ||
|
|
||
| // we may still need to specify info in non bb-e2etest | ||
| setOption(args, "blackBox", "true") | ||
| setOption(args, "bbTargetUrl", baseUrlOfSut) | ||
| setOption(args, "bbSwaggerUrl", "$baseUrlOfSut/v3/api-docs") | ||
|
|
||
|
|
||
| val solution = initAndRun(args) | ||
|
|
||
| assertTrue(solution.individuals.isNotEmpty()) | ||
| assertTextInTests(outputFolder,outputClass,flakyMark) | ||
| assertCountTextInTests(outputFolder,outputClass, | ||
| Predicate { it: String? -> it != null && it.contains(flakyMark) }, 3) | ||
|
|
||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.