Skip to content

Commit 3689e11

Browse files
committed
Stable test names in Mongo instrumentation tests
1 parent 92a664b commit 3689e11

8 files changed

Lines changed: 72 additions & 192 deletions

File tree

dd-java-agent/instrumentation/mongo/driver-3.1-core-test/src/test/groovy/MongoCore31ClientTest.groovy

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ abstract class MongoCore31ClientTest extends MongoBaseTest {
4747
client = null
4848
}
4949

50-
def "test create collection"() {
50+
def "test create collection with renameService=#renameService"() {
5151
setup:
52+
String collectionName = randomCollectionName()
5253
MongoDatabase db = client.getDatabase(databaseName)
5354
injectSysConfig(DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "$renameService")
5455

@@ -63,12 +64,12 @@ abstract class MongoCore31ClientTest extends MongoBaseTest {
6364
}
6465

6566
where:
66-
collectionName = randomCollectionName()
6767
renameService << [false, true]
6868
}
6969

7070
def "test create collection no description"() {
7171
setup:
72+
String collectionName = randomCollectionName()
7273
MongoDatabase db = new MongoClient("localhost", port).getDatabase(databaseName)
7374

7475
when:
@@ -80,13 +81,11 @@ abstract class MongoCore31ClientTest extends MongoBaseTest {
8081
mongoSpan(it, 0, "create","{\"create\":\"$collectionName\",\"capped\":\"?\"}", false, databaseName)
8182
}
8283
}
83-
84-
where:
85-
collectionName = randomCollectionName()
8684
}
8785

8886
def "test get collection"() {
8987
setup:
88+
String collectionName = randomCollectionName()
9089
MongoDatabase db = client.getDatabase(databaseName)
9190

9291
when:
@@ -99,13 +98,11 @@ abstract class MongoCore31ClientTest extends MongoBaseTest {
9998
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
10099
}
101100
}
102-
103-
where:
104-
collectionName = randomCollectionName()
105101
}
106102

107103
def "test insert"() {
108104
setup:
105+
String collectionName = randomCollectionName()
109106
DDSpan setupSpan = null
110107
MongoCollection<Document> collection = runUnderTrace("setup") {
111108
setupSpan = activeSpan() as DDSpan
@@ -129,13 +126,11 @@ abstract class MongoCore31ClientTest extends MongoBaseTest {
129126
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
130127
}
131128
}
132-
133-
where:
134-
collectionName = randomCollectionName()
135129
}
136130

137131
def "test update"() {
138132
setup:
133+
String collectionName = randomCollectionName()
139134
DDSpan setupSpan = null
140135
MongoCollection<Document> collection = runUnderTrace("setup") {
141136
setupSpan = activeSpan() as DDSpan
@@ -164,13 +159,11 @@ abstract class MongoCore31ClientTest extends MongoBaseTest {
164159
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
165160
}
166161
}
167-
168-
where:
169-
collectionName = randomCollectionName()
170162
}
171163

172164
def "test delete"() {
173165
setup:
166+
String collectionName = randomCollectionName()
174167
DDSpan setupSpan = null
175168
MongoCollection<Document> collection = runUnderTrace("setup") {
176169
setupSpan = activeSpan() as DDSpan
@@ -197,13 +190,11 @@ abstract class MongoCore31ClientTest extends MongoBaseTest {
197190
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
198191
}
199192
}
200-
201-
where:
202-
collectionName = randomCollectionName()
203193
}
204194

205195
def "test error"() {
206196
setup:
197+
String collectionName = randomCollectionName()
207198
DDSpan setupSpan = null
208199
MongoCollection<Document> collection = runUnderTrace("setup") {
209200
setupSpan = activeSpan() as DDSpan
@@ -221,13 +212,11 @@ abstract class MongoCore31ClientTest extends MongoBaseTest {
221212
thrown(IllegalArgumentException)
222213
// Unfortunately not caught by our instrumentation.
223214
assertTraces(0) {}
224-
225-
where:
226-
collectionName = randomCollectionName()
227215
}
228216

229217
def "test client failure"() {
230218
setup:
219+
String collectionName = randomCollectionName()
231220
def options = MongoClientOptions.builder().serverSelectionTimeout(10).build()
232221
def client = new MongoClient(new ServerAddress("localhost", UNUSABLE_PORT), [], options)
233222

@@ -239,9 +228,6 @@ abstract class MongoCore31ClientTest extends MongoBaseTest {
239228
thrown(MongoTimeoutException)
240229
// Unfortunately not caught by our instrumentation.
241230
assertTraces(0) {}
242-
243-
where:
244-
collectionName = randomCollectionName()
245231
}
246232
}
247233

dd-java-agent/instrumentation/mongo/driver-3.1/src/test/groovy/MongoJava31ClientTest.groovy

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ abstract class MongoJava31ClientTest extends MongoBaseTest {
4949
client = null
5050
}
5151

52-
def "test create collection"() {
52+
def "test create collection with renameService=#renameService"() {
5353
setup:
54+
String collectionName = randomCollectionName()
5455
MongoDatabase db = client.getDatabase(databaseName)
5556
injectSysConfig(DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "$renameService")
5657

@@ -65,12 +66,12 @@ abstract class MongoJava31ClientTest extends MongoBaseTest {
6566
}
6667

6768
where:
68-
collectionName = randomCollectionName()
6969
renameService << [false, true]
7070
}
7171

7272
def "test create collection no description"() {
7373
setup:
74+
String collectionName = randomCollectionName()
7475
MongoDatabase db = new MongoClient("localhost", port).getDatabase(databaseName)
7576

7677
when:
@@ -82,13 +83,11 @@ abstract class MongoJava31ClientTest extends MongoBaseTest {
8283
mongoSpan(it, 0, "create", "{\"create\":\"$collectionName\",\"capped\":\"?\"}", false, databaseName)
8384
}
8485
}
85-
86-
where:
87-
collectionName = randomCollectionName()
8886
}
8987

9088
def "test get collection"() {
9189
setup:
90+
String collectionName = randomCollectionName()
9291
MongoDatabase db = client.getDatabase(databaseName)
9392

9493
when:
@@ -101,13 +100,11 @@ abstract class MongoJava31ClientTest extends MongoBaseTest {
101100
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
102101
}
103102
}
104-
105-
where:
106-
collectionName = randomCollectionName()
107103
}
108104

109105
def "test insert"() {
110106
setup:
107+
String collectionName = randomCollectionName()
111108
DDSpan setupSpan = null
112109
MongoCollection<Document> collection = runUnderTrace("setup") {
113110
setupSpan = activeSpan() as DDSpan
@@ -131,13 +128,11 @@ abstract class MongoJava31ClientTest extends MongoBaseTest {
131128
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
132129
}
133130
}
134-
135-
where:
136-
collectionName = randomCollectionName()
137131
}
138132

139133
def "test update"() {
140134
setup:
135+
String collectionName = randomCollectionName()
141136
DDSpan setupSpan = null
142137
MongoCollection<Document> collection = runUnderTrace("setup") {
143138
setupSpan = activeSpan() as DDSpan
@@ -166,13 +161,11 @@ abstract class MongoJava31ClientTest extends MongoBaseTest {
166161
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
167162
}
168163
}
169-
170-
where:
171-
collectionName = randomCollectionName()
172164
}
173165

174166
def "test delete"() {
175167
setup:
168+
String collectionName = randomCollectionName()
176169
DDSpan setupSpan = null
177170
MongoCollection<Document> collection = runUnderTrace("setup") {
178171
setupSpan = activeSpan() as DDSpan
@@ -199,13 +192,11 @@ abstract class MongoJava31ClientTest extends MongoBaseTest {
199192
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
200193
}
201194
}
202-
203-
where:
204-
collectionName = randomCollectionName()
205195
}
206196

207197
def "test error"() {
208198
setup:
199+
String collectionName = randomCollectionName()
209200
DDSpan setupSpan = null
210201
MongoCollection<Document> collection = runUnderTrace("setup") {
211202
setupSpan = activeSpan() as DDSpan
@@ -223,13 +214,11 @@ abstract class MongoJava31ClientTest extends MongoBaseTest {
223214
thrown(IllegalArgumentException)
224215
// Unfortunately not caught by our instrumentation.
225216
assertTraces(0) {}
226-
227-
where:
228-
collectionName = randomCollectionName()
229217
}
230218

231219
def "test client failure"() {
232220
setup:
221+
String collectionName = randomCollectionName()
233222
def options = MongoClientOptions.builder().serverSelectionTimeout(10).build()
234223
def client = new MongoClient(new ServerAddress("localhost", UNUSABLE_PORT), [], options)
235224

@@ -241,9 +230,6 @@ abstract class MongoJava31ClientTest extends MongoBaseTest {
241230
thrown(MongoTimeoutException)
242231
// Unfortunately not caught by our instrumentation.
243232
assertTraces(0) {}
244-
245-
where:
246-
collectionName = randomCollectionName()
247233
}
248234
}
249235

dd-java-agent/instrumentation/mongo/driver-3.10-sync-test/src/test/groovy/MongoSyncClientTest.groovy

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ abstract class MongoSyncClientTest extends MongoBaseTest {
2828
client = null
2929
}
3030

31-
def "test create collection"() {
31+
def "test create collection with renameService=#renameService"() {
3232
setup:
33+
String collectionName = randomCollectionName()
3334
MongoDatabase db = client.getDatabase(databaseName)
3435
injectSysConfig(DB_CLIENT_HOST_SPLIT_BY_INSTANCE, "$renameService")
3536

@@ -45,12 +46,12 @@ abstract class MongoSyncClientTest extends MongoBaseTest {
4546
}
4647

4748
where:
48-
collectionName = randomCollectionName()
4949
renameService << [false, true]
5050
}
5151

5252
def "test create collection no description"() {
5353
setup:
54+
String collectionName = randomCollectionName()
5455
MongoDatabase db = MongoClients.create("mongodb://localhost:$port").getDatabase(databaseName)
5556

5657
when:
@@ -62,13 +63,11 @@ abstract class MongoSyncClientTest extends MongoBaseTest {
6263
mongoSpan(it, 0, "create", "{\"create\":\"$collectionName\",\"capped\":\"?\"}", false, databaseName)
6364
}
6465
}
65-
66-
where:
67-
collectionName = randomCollectionName()
6866
}
6967

7068
def "test get collection"() {
7169
setup:
70+
String collectionName = randomCollectionName()
7271
MongoDatabase db = client.getDatabase(databaseName)
7372

7473
when:
@@ -81,13 +80,11 @@ abstract class MongoSyncClientTest extends MongoBaseTest {
8180
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
8281
}
8382
}
84-
85-
where:
86-
collectionName = randomCollectionName()
8783
}
8884

8985
def "test insert"() {
9086
setup:
87+
String collectionName = randomCollectionName()
9188
DDSpan setupSpan = null
9289
MongoCollection<Document> collection = runUnderTrace("setup") {
9390
setupSpan = activeSpan() as DDSpan
@@ -113,13 +110,11 @@ abstract class MongoSyncClientTest extends MongoBaseTest {
113110
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
114111
}
115112
}
116-
117-
where:
118-
collectionName = randomCollectionName()
119113
}
120114

121115
def "test update"() {
122116
setup:
117+
String collectionName = randomCollectionName()
123118
DDSpan setupSpan = null
124119
MongoCollection<Document> collection = runUnderTrace("setup") {
125120
setupSpan = activeSpan() as DDSpan
@@ -150,13 +145,11 @@ abstract class MongoSyncClientTest extends MongoBaseTest {
150145
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
151146
}
152147
}
153-
154-
where:
155-
collectionName = randomCollectionName()
156148
}
157149

158150
def "test delete"() {
159151
setup:
152+
String collectionName = randomCollectionName()
160153
DDSpan setupSpan = null
161154
MongoCollection<Document> collection = runUnderTrace("setup") {
162155
setupSpan = activeSpan() as DDSpan
@@ -185,13 +178,11 @@ abstract class MongoSyncClientTest extends MongoBaseTest {
185178
mongoSpan(it, 0, "count", "{\"count\":\"$collectionName\",\"query\":{}}")
186179
}
187180
}
188-
189-
where:
190-
collectionName = randomCollectionName()
191181
}
192182

193183
def "test error"() {
194184
setup:
185+
String collectionName = randomCollectionName()
195186
DDSpan setupSpan = null
196187
MongoCollection<Document> collection = runUnderTrace("setup") {
197188
setupSpan = activeSpan() as DDSpan
@@ -209,13 +200,11 @@ abstract class MongoSyncClientTest extends MongoBaseTest {
209200
thrown(IllegalArgumentException)
210201
// Unfortunately not caught by our instrumentation.
211202
assertTraces(0) {}
212-
213-
where:
214-
collectionName = randomCollectionName()
215203
}
216204

217205
def "test client failure"() {
218206
setup:
207+
String collectionName = randomCollectionName()
219208
def client = MongoClients.create("mongodb://localhost:$UNUSABLE_PORT/?serverselectiontimeoutms=10")
220209

221210
when:
@@ -226,9 +215,6 @@ abstract class MongoSyncClientTest extends MongoBaseTest {
226215
thrown(MongoTimeoutException)
227216
// Unfortunately not caught by our instrumentation.
228217
assertTraces(0) {}
229-
230-
where:
231-
collectionName = randomCollectionName()
232218
}
233219
}
234220

0 commit comments

Comments
 (0)