Fix grails latestDep test failure (#2547)

* Fix grails3 latestDep test failure

* not found uses sendError
This commit is contained in:
Lauri Tulmin 2021-03-10 20:26:19 +02:00 committed by GitHub
parent f94fabe07f
commit 569b7b5818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 5 deletions

View File

@ -31,8 +31,8 @@ dependencies {
testInstrumentation project(':instrumentation:tomcat-7.0:javaagent')
testInstrumentation project(':instrumentation:spring:spring-webmvc-3.1:javaagent')
testImplementation "org.springframework.boot:spring-boot-autoconfigure:$springBootVersion"
testImplementation "org.springframework.boot:spring-boot-starter-tomcat:$springBootVersion"
testLibrary "org.springframework.boot:spring-boot-autoconfigure:$springBootVersion"
testLibrary "org.springframework.boot:spring-boot-starter-tomcat:$springBootVersion"
testImplementation(project(':testing-common')) {
exclude group: 'org.eclipse.jetty', module: 'jetty-server'

View File

@ -14,4 +14,9 @@ class ErrorController implements Controller {
def index() {
render "Error"
}
@Action
def notFound() {
response.sendError(404, "Not Found")
}
}

View File

@ -59,7 +59,7 @@ class GrailsTest extends HttpServerTest<ConfigurableApplicationContext> implemen
} else if (endpoint == ERROR || endpoint == EXCEPTION) {
return getContextPath() + "/error/index"
} else if (endpoint == NOT_FOUND) {
return getContextPath() + "/error"
return getContextPath() + "/**"
}
return getContextPath() + "/test" + endpoint.path
}
@ -101,7 +101,7 @@ class GrailsTest extends HttpServerTest<ConfigurableApplicationContext> implemen
@Override
int getErrorPageSpansCount(ServerEndpoint endpoint) {
2
endpoint == NOT_FOUND ? 3 : 2
}
@Override
@ -112,7 +112,7 @@ class GrailsTest extends HttpServerTest<ConfigurableApplicationContext> implemen
@Override
void errorPageSpans(TraceAssert trace, int index, Object parent, String method = "GET", ServerEndpoint endpoint) {
forwardSpan(trace, index, trace.span(0))
def errorSpanName = endpoint == NOT_FOUND ? "BasicErrorController.error" : "ErrorController.index"
def errorSpanName = endpoint == NOT_FOUND ? "ErrorController.notFound" : "ErrorController.index"
trace.span(index + 1) {
name errorSpanName
kind INTERNAL
@ -120,6 +120,15 @@ class GrailsTest extends HttpServerTest<ConfigurableApplicationContext> implemen
attributes {
}
}
if (endpoint == NOT_FOUND) {
trace.span(index + 2) {
name ~/\.sendError$/
kind INTERNAL
errored false
attributes {
}
}
}
}
@Override

View File

@ -16,5 +16,6 @@ class UrlMappings {
"/path/$id/param"(controller: 'test', action: 'path')
"500"(controller: 'error')
"404"(controller: 'error', action: 'notFound')
}
}