Add some simplistic fuzz-based tests for the 2 built-in W3C propagators. (#1926)
* Add some simplistic fuzz-based tests for the 2 built-in propagators. * remove unused gradle plugin
This commit is contained in:
parent
03ddfae0c4
commit
338acd4816
|
|
@ -15,6 +15,8 @@ dependencies {
|
|||
annotationProcessor libraries.auto_value
|
||||
|
||||
signature "net.sf.androidscents.signature:android-api-level-24:7.0_r2@signature"
|
||||
|
||||
testImplementation libraries.jqf
|
||||
}
|
||||
|
||||
javadoc {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.api.baggage.propagation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import edu.berkeley.cs.jqf.fuzz.Fuzz;
|
||||
import edu.berkeley.cs.jqf.fuzz.JQF;
|
||||
import io.opentelemetry.context.Context;
|
||||
import java.util.Map;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(JQF.class)
|
||||
@SuppressWarnings("JavadocMethod")
|
||||
public class W3CBaggagePropagatorFuzzTest {
|
||||
private final W3CBaggagePropagator baggagePropagator = W3CBaggagePropagator.getInstance();
|
||||
|
||||
@Fuzz
|
||||
public void safeForRandomInputs(String baggage) {
|
||||
Context context =
|
||||
baggagePropagator.extract(Context.root(), ImmutableMap.of("baggage", baggage), Map::get);
|
||||
assertThat(context).isNotNull();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.api.trace.propagation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import edu.berkeley.cs.jqf.fuzz.Fuzz;
|
||||
import edu.berkeley.cs.jqf.fuzz.JQF;
|
||||
import io.opentelemetry.context.Context;
|
||||
import java.util.Map;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(JQF.class)
|
||||
@SuppressWarnings("JavadocMethod")
|
||||
public class HttpTraceContextFuzzTest {
|
||||
private final HttpTraceContext httpTraceContext = HttpTraceContext.getInstance();
|
||||
|
||||
@Fuzz
|
||||
public void safeForRandomInputs(String traceParentHeader, String traceStateHeader) {
|
||||
Context context =
|
||||
httpTraceContext.extract(
|
||||
Context.root(),
|
||||
ImmutableMap.of("traceparent", traceParentHeader, "tracestate", traceStateHeader),
|
||||
Map::get);
|
||||
assertThat(context).isNotNull();
|
||||
}
|
||||
}
|
||||
|
|
@ -332,7 +332,8 @@ configure(opentelemetryProjects) {
|
|||
rest_assured : 'io.rest-assured:rest-assured:4.2.0',
|
||||
jaeger_client : 'io.jaegertracing:jaeger-client:1.2.0', // Jaeger Client
|
||||
zipkin_junit : "io.zipkin.zipkin2:zipkin-junit:${zipkinVersion}", // Zipkin JUnit rule
|
||||
archunit : 'com.tngtech.archunit:archunit-junit4:0.13.1' //Architectural constraints
|
||||
archunit : 'com.tngtech.archunit:archunit-junit4:0.13.1', //Architectural constraints
|
||||
jqf : 'edu.berkeley.cs.jqf:jqf-fuzz:1.6' // fuzz testing
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue