Skip to content

Commit 94e7225

Browse files
committed
fix tests
1 parent ceca7ee commit 94e7225

File tree

7 files changed

+51
-25
lines changed

7 files changed

+51
-25
lines changed

instrumentation/apache-httpasyncclient-4.1/src/test/java/io/opentelemetry/instrumentation/hypertrace/apachehttpasyncclient/ApacheAsyncClientInstrumentationModuleTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,7 @@ public void getJson()
112112
TEST_WRITER.getAttributesMap(responseBodySpan).get("http.response.body").getStringValue());
113113
}
114114

115-
@Test
116-
public void postJson()
117-
throws IOException, TimeoutException, InterruptedException, ExecutionException {
118-
StringEntity entity =
119-
new StringEntity(JSON, ContentType.create(ContentType.APPLICATION_JSON.getMimeType()));
120-
postJsonEntity(entity);
121-
}
122-
123-
@Test
124-
public void postJsonNonRepeatableEntity()
125-
throws IOException, TimeoutException, InterruptedException, ExecutionException {
126-
StringEntity entity = new NonRepeatableStringEntity(JSON);
127-
postJsonEntity(entity);
128-
}
129-
130-
@Disabled("This is flaky !!")
115+
@Disabled("This is flaky!!")
131116
@Test
132117
public void getGzipResponse()
133118
throws ExecutionException, InterruptedException, TimeoutException, IOException {
@@ -172,6 +157,21 @@ public void getGzipResponse()
172157
TEST_WRITER.getAttributesMap(responseBodySpan).get("http.response.body").getStringValue());
173158
}
174159

160+
@Test
161+
public void postJson()
162+
throws IOException, TimeoutException, InterruptedException, ExecutionException {
163+
StringEntity entity =
164+
new StringEntity(JSON, ContentType.create(ContentType.APPLICATION_JSON.getMimeType()));
165+
postJsonEntity(entity);
166+
}
167+
168+
@Test
169+
public void postJsonNonRepeatableEntity()
170+
throws IOException, TimeoutException, InterruptedException, ExecutionException {
171+
StringEntity entity = new NonRepeatableStringEntity(JSON);
172+
postJsonEntity(entity);
173+
}
174+
175175
public void postJsonEntity(HttpEntity entity)
176176
throws TimeoutException, InterruptedException, IOException, ExecutionException {
177177
HttpPost postRequest = new HttpPost();

instrumentation/netty/netty-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/netty/v4_0/DataCaptureUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
import io.netty.util.Attribute;
2525
import io.netty.util.AttributeKey;
2626
import io.opentelemetry.api.trace.Span;
27-
import java.io.*;
27+
import java.io.ByteArrayInputStream;
28+
import java.io.ByteArrayOutputStream;
29+
import java.io.IOException;
30+
import java.io.InputStreamReader;
31+
import java.io.OutputStreamWriter;
2832
import java.nio.charset.Charset;
2933
import java.util.zip.GZIPInputStream;
3034
import org.hypertrace.agent.core.instrumentation.buffer.BoundedBuffersFactory;

instrumentation/netty/netty-4.0/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/netty/v4_0/client/HttpClientResponseTracingHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
import io.netty.channel.Channel;
2121
import io.netty.channel.ChannelHandlerContext;
2222
import io.netty.channel.ChannelInboundHandlerAdapter;
23-
import io.netty.handler.codec.http.*;
23+
import io.netty.handler.codec.http.HttpContent;
24+
import io.netty.handler.codec.http.HttpMessage;
25+
import io.netty.handler.codec.http.HttpResponse;
26+
import io.netty.handler.codec.http.LastHttpContent;
2427
import io.netty.util.Attribute;
2528
import io.opentelemetry.api.trace.Span;
2629
import io.opentelemetry.api.trace.StatusCode;

instrumentation/netty/netty-4.0/src/test/java/io/opentelemetry/javaagent/instrumentation/hypertrace/netty/v4_0/server/NettyTestServer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@
3131
import io.netty.channel.SimpleChannelInboundHandler;
3232
import io.netty.channel.nio.NioEventLoopGroup;
3333
import io.netty.channel.socket.nio.NioServerSocketChannel;
34-
import io.netty.handler.codec.*;
35-
import io.netty.handler.codec.http.*;
34+
import io.netty.handler.codec.http.DefaultFullHttpResponse;
3635
import io.netty.handler.codec.http.HttpHeaders;
37-
import io.netty.handler.codec.http.HttpHeaders.Names.*;
36+
import io.netty.handler.codec.http.HttpRequest;
37+
import io.netty.handler.codec.http.HttpResponse;
38+
import io.netty.handler.codec.http.HttpResponseStatus;
39+
import io.netty.handler.codec.http.LastHttpContent;
3840
import io.netty.handler.logging.LogLevel;
3941
import io.netty.handler.logging.LoggingHandler;
4042
import io.netty.util.CharsetUtil;

instrumentation/netty/netty-4.1/src/main/java/io/opentelemetry/javaagent/instrumentation/hypertrace/netty/v4_1/DataCaptureUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
import io.netty.util.Attribute;
2626
import io.netty.util.AttributeKey;
2727
import io.opentelemetry.api.trace.Span;
28-
import java.io.*;
28+
import java.io.ByteArrayInputStream;
29+
import java.io.ByteArrayOutputStream;
30+
import java.io.IOException;
31+
import java.io.InputStreamReader;
32+
import java.io.OutputStreamWriter;
2933
import java.nio.charset.Charset;
3034
import java.util.zip.GZIPInputStream;
3135
import org.hypertrace.agent.core.instrumentation.buffer.BoundedBuffersFactory;

instrumentation/netty/netty-4.1/src/test/java/io/opentelemetry/javaagent/instrumentation/hypertrace/netty/v4_1/server/NettyTestServer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@
3131
import io.netty.channel.SimpleChannelInboundHandler;
3232
import io.netty.channel.nio.NioEventLoopGroup;
3333
import io.netty.channel.socket.nio.NioServerSocketChannel;
34-
import io.netty.handler.codec.http.*;
34+
import io.netty.handler.codec.http.DefaultFullHttpResponse;
35+
import io.netty.handler.codec.http.HttpHeaderNames;
36+
import io.netty.handler.codec.http.HttpRequest;
37+
import io.netty.handler.codec.http.HttpResponse;
38+
import io.netty.handler.codec.http.HttpResponseStatus;
39+
import io.netty.handler.codec.http.HttpVersion;
40+
import io.netty.handler.codec.http.LastHttpContent;
3541
import io.netty.handler.logging.LogLevel;
3642
import io.netty.handler.logging.LoggingHandler;
3743
import io.netty.util.CharsetUtil;

instrumentation/vertx/vertx-web-3.0/src/test/java/io/opentelemetry/javaagent/instrumentation/hypertrace/vertx/VertxClientInstrumentationTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ public void postJson_write_end() throws TimeoutException, InterruptedException {
155155
}
156156

157157
@Test
158-
@Disabled("This is flaky")
159158
public void postJson_write_end_string() throws TimeoutException, InterruptedException {
160159
String uri = String.format("http://localhost:%d/echo", testHttpServer.port());
161160

@@ -180,7 +179,15 @@ public void postJson_write_end_string() throws TimeoutException, InterruptedExce
180179
1,
181180
span ->
182181
span.getKind().equals(Span.SpanKind.SPAN_KIND_SERVER)
183-
|| span.getKind().equals(Span.SpanKind.SPAN_KIND_INTERNAL));
182+
|| span.getKind().equals(Span.SpanKind.SPAN_KIND_INTERNAL)
183+
|| span.getAttributesList().stream()
184+
.noneMatch(
185+
keyValue ->
186+
keyValue.getKey().equals("http.response.body")
187+
&& keyValue
188+
.getValue()
189+
.getStringValue()
190+
.contains("write buffer str_encoding end")));
184191
Assertions.assertEquals(1, traces.size(), String.format("was: %d", traces.size()));
185192
Span clientSpan = traces.get(0).get(0);
186193
Assertions.assertEquals(

0 commit comments

Comments
 (0)