-
Notifications
You must be signed in to change notification settings - Fork 103
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
base: master
Are you sure you want to change the base?
Flaky detect #1420
Changes from all commits
34c6e31
1a2365b
c82b7b6
16bb348
e44d7da
9a94fb7
7f074fd
968248e
15cf9e7
4ee3399
2b393bd
06a9508
85e5cb3
059bd87
604f5f1
00b5e27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| 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.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))) | ||
| } | ||
|
|
||
|
|
||
| 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) |
| 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) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| 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 | ||
| import org.junit.jupiter.api.Assertions.assertTrue | ||
| import org.junit.jupiter.api.BeforeAll | ||
| import org.junit.jupiter.api.Test | ||
| import java.nio.file.Files | ||
| import java.nio.file.Paths | ||
|
|
||
| class FlakinessDetectEMTest : SpringTestBase() { | ||
|
|
||
| companion object { | ||
| @BeforeAll | ||
| @JvmStatic | ||
| fun init() { | ||
| initClass(FlakinessDetectController()) | ||
| } | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| fun testRunEM() { | ||
| runTestHandlingFlakyAndCompilation( | ||
| "FlakinessDetectEM", | ||
| "org.foo.FlakinessDetectEM", | ||
| 5 | ||
| ) { args: MutableList<String> -> | ||
|
|
||
| val executedMainActionToFile = "target/em-tests/FlakinessDetectEM/org/foo/FlakinessDetectEM.kt" | ||
|
|
||
| args.add("--minimize") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for new E2E tests, should use |
||
| args.add("true") | ||
| args.add("--detectFlakiness") | ||
| args.add("true") | ||
|
|
||
|
|
||
| val solution = initAndRun(args) | ||
|
|
||
| val size = Files.readAllLines(Paths.get(executedMainActionToFile)).count { !it.contains("Flaky") && it.isNotBlank() } | ||
| assertTrue(size >= 3) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2474,6 +2474,10 @@ class EMConfig { | |
| RANDOM | ||
| } | ||
|
|
||
| @Experimental | ||
| @Cfg("Specify whether to detect flaky assertions during post handling of fuzzing.") | ||
| var detectFlakiness = false | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not only detect, but also handle, isn't it? maybe rename into |
||
|
|
||
| @Experimental | ||
| @Cfg("Specify a method to select the first external service spoof IP address.") | ||
| var externalServiceIPSelectionStrategy = ExternalServiceIPSelectionStrategy.NONE | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,6 +75,14 @@ class Lines(val format: OutputFormat) { | |
| buffer[buffer.lastIndex] = buffer.last().replace(regex, replacement) | ||
| } | ||
|
|
||
| fun replaceFirstInCurrent(regex: Regex, replacement: String){ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add JavaDoc |
||
| if(buffer.isEmpty()){ | ||
| return | ||
| } | ||
|
|
||
| buffer[buffer.lastIndex] = buffer.last().replaceFirst(regex, replacement) | ||
| } | ||
|
|
||
| /** | ||
| * Is the current line just a comment // without any statement? | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when dealing with PR where test output code is changed/upgraded, should also have 1 BB test under
core-tests/e2e-tests/spring/spring-rest-bb, as those automatically check all output formats (eg Python and JS)