Skip to content

Commit 3a589b8

Browse files
committed
fix: skip ordering-dependent max files limit test for Vert.x HashSet
fileUploads() returns a HashSet in Vert.x so iteration order is JVM- version-dependent. Add testBodyFilesContentOrdering() flag (defaults true) to HttpServerTest to allow skipping the specific-file assertion. Vert.x subclasses return false and add a count-based test instead.
1 parent 0e08e82 commit 3a589b8

5 files changed

Lines changed: 34 additions & 9 deletions

File tree

dd-java-agent/instrumentation-testing/src/main/groovy/datadog/trace/agent/test/base/HttpServerTest.groovy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
387387
false
388388
}
389389

390+
/** Override to false when the multipart implementation uses a set with non-deterministic ordering (e.g. HashSet). */
391+
boolean testBodyFilesContentOrdering() {
392+
true
393+
}
394+
390395
boolean testBodyJson() {
391396
false
392397
}
@@ -1767,7 +1772,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
17671772

17681773
def 'test instrumentation gateway file upload content max files limit'() {
17691774
setup:
1770-
assumeTrue(testBodyFilesContent())
1775+
assumeTrue(testBodyFilesContent() && testBodyFilesContentOrdering())
17711776
def maxFilesToInspect = Config.get().getAppSecMaxFileContentCount()
17721777
def bodyBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM)
17731778
(1..maxFilesToInspect + 1).each {

dd-java-agent/instrumentation/vertx/vertx-web/vertx-web-3.4/src/test/groovy/server/VertxHttpServerForkedTest.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,13 @@ class VertxHttpServerForkedTest extends HttpServerTest<Vertx> {
9898
true
9999
}
100100

101-
// fileUploads() returns a HashSet in Vert.x: override to verify count instead of which specific file is last
102-
def 'test instrumentation gateway file upload content max files limit'() {
101+
@Override
102+
boolean testBodyFilesContentOrdering() {
103+
false
104+
}
105+
106+
// fileUploads() returns a HashSet in Vert.x: check count instead of which specific file is excluded
107+
def 'test instrumentation gateway file upload content max files limit count'() {
103108
setup:
104109
assumeTrue(testBodyFilesContent())
105110
def maxFilesToInspect = Config.get().getAppSecMaxFileContentCount()

dd-java-agent/instrumentation/vertx/vertx-web/vertx-web-4.0/src/latestDepTest/groovy/server/VertxHttpServerForkedTest.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,13 @@ class VertxHttpServerForkedTest extends HttpServerTest<Vertx> {
9393
true
9494
}
9595

96-
// fileUploads() returns a HashSet in Vert.x: override to verify count instead of which specific file is last
97-
def 'test instrumentation gateway file upload content max files limit'() {
96+
@Override
97+
boolean testBodyFilesContentOrdering() {
98+
false
99+
}
100+
101+
// fileUploads() returns a HashSet in Vert.x: check count instead of which specific file is excluded
102+
def 'test instrumentation gateway file upload content max files limit count'() {
98103
setup:
99104
assumeTrue(testBodyFilesContent())
100105
def maxFilesToInspect = Config.get().getAppSecMaxFileContentCount()

dd-java-agent/instrumentation/vertx/vertx-web/vertx-web-4.0/src/test/groovy/server/VertxHttpServerForkedTest.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@ class VertxHttpServerForkedTest extends HttpServerTest<Vertx> {
9494
true
9595
}
9696

97-
// fileUploads() returns a HashSet in Vert.x: override to verify count instead of which specific file is last
98-
def 'test instrumentation gateway file upload content max files limit'() {
97+
@Override
98+
boolean testBodyFilesContentOrdering() {
99+
false
100+
}
101+
102+
// fileUploads() returns a HashSet in Vert.x: check count instead of which specific file is excluded
103+
def 'test instrumentation gateway file upload content max files limit count'() {
99104
setup:
100105
assumeTrue(testBodyFilesContent())
101106
def maxFilesToInspect = Config.get().getAppSecMaxFileContentCount()

dd-java-agent/instrumentation/vertx/vertx-web/vertx-web-5.0/src/test/groovy/server/VertxHttpServerForkedTest.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,13 @@ class VertxHttpServerForkedTest extends HttpServerTest<Vertx> {
9898
true
9999
}
100100

101-
// fileUploads() returns a HashSet in Vert.x: override to verify count instead of which specific file is last
102-
def 'test instrumentation gateway file upload content max files limit'() {
101+
@Override
102+
boolean testBodyFilesContentOrdering() {
103+
false
104+
}
105+
106+
// fileUploads() returns a HashSet in Vert.x: check count instead of which specific file is excluded
107+
def 'test instrumentation gateway file upload content max files limit count'() {
103108
setup:
104109
assumeTrue(testBodyFilesContent())
105110
def maxFilesToInspect = Config.get().getAppSecMaxFileContentCount()

0 commit comments

Comments
 (0)