Some assertions refactoring (#6618)
This commit is contained in:
parent
14b4b3ba07
commit
c0b0722699
|
@ -209,12 +209,8 @@ public abstract class AbstractGraphqlTest {
|
||||||
assertThat(attrs)
|
assertThat(attrs)
|
||||||
.containsEntry("exception.type", "InvalidSyntax");
|
.containsEntry("exception.type", "InvalidSyntax");
|
||||||
String message =
|
String message =
|
||||||
String.valueOf(
|
attrs.get(
|
||||||
attrs
|
AttributeKey.stringKey("exception.message"));
|
||||||
.asMap()
|
|
||||||
.get(
|
|
||||||
AttributeKey.stringKey(
|
|
||||||
"exception.message")));
|
|
||||||
assertThat(message).startsWith("Invalid Syntax");
|
assertThat(message).startsWith("Invalid Syntax");
|
||||||
}))));
|
}))));
|
||||||
}
|
}
|
||||||
|
@ -256,12 +252,8 @@ public abstract class AbstractGraphqlTest {
|
||||||
.containsEntry(
|
.containsEntry(
|
||||||
"exception.type", "ValidationError");
|
"exception.type", "ValidationError");
|
||||||
String message =
|
String message =
|
||||||
String.valueOf(
|
attrs.get(
|
||||||
attrs
|
AttributeKey.stringKey("exception.message"));
|
||||||
.asMap()
|
|
||||||
.get(
|
|
||||||
AttributeKey.stringKey(
|
|
||||||
"exception.message")));
|
|
||||||
assertThat(message)
|
assertThat(message)
|
||||||
.startsWith(
|
.startsWith(
|
||||||
"Validation error of type FieldUndefined");
|
"Validation error of type FieldUndefined");
|
||||||
|
|
|
@ -921,10 +921,10 @@ public abstract class AbstractHttpClientTest<REQUEST> {
|
||||||
if (uri.getPort() == PortUtils.UNUSABLE_PORT || uri.getHost().equals("192.0.2.1")) {
|
if (uri.getPort() == PortUtils.UNUSABLE_PORT || uri.getHost().equals("192.0.2.1")) {
|
||||||
// TODO: net.peer.name and net.peer.port should always be populated from the URI or
|
// TODO: net.peer.name and net.peer.port should always be populated from the URI or
|
||||||
// the Host header, verify these assertions below
|
// the Host header, verify these assertions below
|
||||||
if (attrs.asMap().containsKey(SemanticAttributes.NET_PEER_NAME)) {
|
if (attrs.get(SemanticAttributes.NET_PEER_NAME) != null) {
|
||||||
assertThat(attrs).containsEntry(SemanticAttributes.NET_PEER_NAME, uri.getHost());
|
assertThat(attrs).containsEntry(SemanticAttributes.NET_PEER_NAME, uri.getHost());
|
||||||
}
|
}
|
||||||
if (attrs.asMap().containsKey(SemanticAttributes.NET_PEER_PORT)) {
|
if (attrs.get(SemanticAttributes.NET_PEER_PORT) != null) {
|
||||||
if (uri.getPort() > 0) {
|
if (uri.getPort() > 0) {
|
||||||
assertThat(attrs)
|
assertThat(attrs)
|
||||||
.containsEntry(SemanticAttributes.NET_PEER_PORT, (long) uri.getPort());
|
.containsEntry(SemanticAttributes.NET_PEER_PORT, (long) uri.getPort());
|
||||||
|
@ -945,13 +945,12 @@ public abstract class AbstractHttpClientTest<REQUEST> {
|
||||||
|
|
||||||
// In these cases the peer connection is not established, so the HTTP client should
|
// In these cases the peer connection is not established, so the HTTP client should
|
||||||
// not report any socket-level attributes
|
// not report any socket-level attributes
|
||||||
// TODO https://github.com/open-telemetry/opentelemetry-java/pull/4723
|
assertThat(attrs)
|
||||||
assertThat(attrs.asMap())
|
.doesNotContainKey("net.sock.family")
|
||||||
.doesNotContainKey(AttributeKey.stringKey("net.sock.family"))
|
|
||||||
// TODO netty sometimes reports net.sock.peer.addr in connection error test
|
// TODO netty sometimes reports net.sock.peer.addr in connection error test
|
||||||
// .doesNotContainKey(AttributeKey.stringKey("net.sock.peer.addr"))
|
// .doesNotContainKey("net.sock.peer.addr")
|
||||||
.doesNotContainKey(AttributeKey.stringKey("net.sock.peer.name"))
|
.doesNotContainKey("net.sock.peer.name")
|
||||||
.doesNotContainKey(AttributeKey.stringKey("net.sock.peer.port"));
|
.doesNotContainKey("net.sock.peer.port");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (httpClientAttributes.contains(SemanticAttributes.NET_PEER_NAME)) {
|
if (httpClientAttributes.contains(SemanticAttributes.NET_PEER_NAME)) {
|
||||||
|
@ -962,11 +961,11 @@ public abstract class AbstractHttpClientTest<REQUEST> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move to test knob rather than always treating as optional
|
// TODO: Move to test knob rather than always treating as optional
|
||||||
if (attrs.asMap().containsKey(AttributeKey.stringKey("net.sock.peer.addr"))) {
|
if (attrs.get(AttributeKey.stringKey("net.sock.peer.addr")) != null) {
|
||||||
assertThat(attrs)
|
assertThat(attrs)
|
||||||
.containsEntry(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1");
|
.containsEntry(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1");
|
||||||
}
|
}
|
||||||
if (attrs.asMap().containsKey(AttributeKey.stringKey("net.sock.peer.port"))) {
|
if (attrs.get(AttributeKey.stringKey("net.sock.peer.port")) != null) {
|
||||||
assertThat(attrs)
|
assertThat(attrs)
|
||||||
.containsEntry(
|
.containsEntry(
|
||||||
AttributeKey.longKey("net.sock.peer.port"),
|
AttributeKey.longKey("net.sock.peer.port"),
|
||||||
|
|
Loading…
Reference in New Issue