Merge pull request #594 from DataDog/mar-kolya/es-tests-stability
Improve stability of ES tests by avoiding unpredictable spans
This commit is contained in:
commit
6f61ddc67d
|
@ -1,6 +1,7 @@
|
||||||
package springdata
|
package springdata
|
||||||
|
|
||||||
import com.anotherchrisberry.spock.extensions.retry.RetryOnFailure
|
import com.anotherchrisberry.spock.extensions.retry.RetryOnFailure
|
||||||
|
import com.google.common.collect.ImmutableSet
|
||||||
import datadog.trace.agent.test.AgentTestRunner
|
import datadog.trace.agent.test.AgentTestRunner
|
||||||
import datadog.trace.agent.test.TestUtils
|
import datadog.trace.agent.test.TestUtils
|
||||||
import datadog.trace.api.DDSpanTypes
|
import datadog.trace.api.DDSpanTypes
|
||||||
|
@ -32,6 +33,11 @@ import static org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING
|
||||||
class Elasticsearch53SpringTemplateTest extends AgentTestRunner {
|
class Elasticsearch53SpringTemplateTest extends AgentTestRunner {
|
||||||
public static final long TIMEOUT = 10000; // 10 seconds
|
public static final long TIMEOUT = 10000; // 10 seconds
|
||||||
|
|
||||||
|
// Some ES actions are not caused by clients and seem to just happen from time to time.
|
||||||
|
// We will just ignore these actions in traces.
|
||||||
|
// TODO: check if other ES tests need this protection and potentially pull this into global class
|
||||||
|
public static final Set<String> IGNORED_ACTIONS = ImmutableSet.of("NodesStatsAction", "IndicesStatsAction")
|
||||||
|
|
||||||
@Shared
|
@Shared
|
||||||
int httpPort
|
int httpPort
|
||||||
@Shared
|
@Shared
|
||||||
|
@ -145,6 +151,9 @@ class Elasticsearch53SpringTemplateTest extends AgentTestRunner {
|
||||||
template.queryForList(query, Doc) == [new Doc()]
|
template.queryForList(query, Doc) == [new Doc()]
|
||||||
|
|
||||||
and:
|
and:
|
||||||
|
// FIXME: it looks like proper approach is to provide TEST_WRITER with an API to filter traces as they are written
|
||||||
|
TEST_WRITER.waitForTraces(7)
|
||||||
|
filterIgnoredActions()
|
||||||
// IndexAction and PutMappingAction run in separate threads and order in which
|
// IndexAction and PutMappingAction run in separate threads and order in which
|
||||||
// these spans are closed is not defined. So we force the order if it is wrong.
|
// these spans are closed is not defined. So we force the order if it is wrong.
|
||||||
if (TEST_WRITER[3][0].resourceName == "IndexAction") {
|
if (TEST_WRITER[3][0].resourceName == "IndexAction") {
|
||||||
|
@ -152,6 +161,7 @@ class Elasticsearch53SpringTemplateTest extends AgentTestRunner {
|
||||||
TEST_WRITER[3] = TEST_WRITER[4]
|
TEST_WRITER[3] = TEST_WRITER[4]
|
||||||
TEST_WRITER[4] = tmp
|
TEST_WRITER[4] = tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
assertTraces(7) {
|
assertTraces(7) {
|
||||||
trace(0, 1) {
|
trace(0, 1) {
|
||||||
span(0) {
|
span(0) {
|
||||||
|
@ -368,4 +378,12 @@ class Elasticsearch53SpringTemplateTest extends AgentTestRunner {
|
||||||
where:
|
where:
|
||||||
indexName = "test-index-extract"
|
indexName = "test-index-extract"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void filterIgnoredActions() {
|
||||||
|
for (int i = 0; i < TEST_WRITER.size(); i++) {
|
||||||
|
if (IGNORED_ACTIONS.contains(TEST_WRITER[i][0].getResourceName())) {
|
||||||
|
TEST_WRITER.remove(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue