-
Notifications
You must be signed in to change notification settings - Fork 864
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decode resource attributes specified via otel.resource.attributes (#4756
- Loading branch information
Showing
6 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...igure/src/test/java/io/opentelemetry/sdk/autoconfigure/ResourceConfigurationFuzzTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.autoconfigure; | ||
|
||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; | ||
import static java.util.Collections.singletonMap; | ||
|
||
import edu.berkeley.cs.jqf.fuzz.Fuzz; | ||
import edu.berkeley.cs.jqf.fuzz.JQF; | ||
import edu.berkeley.cs.jqf.fuzz.junit.GuidedFuzzing; | ||
import edu.berkeley.cs.jqf.fuzz.random.NoGuidance; | ||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.api.internal.PercentEscaper; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.runner.Result; | ||
import org.junit.runner.RunWith; | ||
|
||
@SuppressWarnings("SystemOut") | ||
class ResourceConfigurationFuzzTest { | ||
|
||
@RunWith(JQF.class) | ||
public static class TestCases { | ||
|
||
private static final PercentEscaper escaper = PercentEscaper.create(); | ||
|
||
@Fuzz | ||
public void getAttributesWithRandomValues(String value1, String value2) { | ||
Attributes attributes = | ||
ResourceConfiguration.getAttributes( | ||
DefaultConfigProperties.createForTest( | ||
singletonMap( | ||
ResourceConfiguration.ATTRIBUTE_PROPERTY, | ||
"key1=" + escaper.escape(value1) + ",key2=" + escaper.escape(value2)))); | ||
|
||
assertThat(attributes).hasSize(2).containsEntry("key1", value1).containsEntry("key2", value2); | ||
} | ||
} | ||
|
||
// driver methods to avoid having to use the vintage junit engine, and to enable increasing the | ||
// number of iterations: | ||
|
||
@Test | ||
void getAttributesWithFuzzing() { | ||
Result result = | ||
GuidedFuzzing.run( | ||
TestCases.class, | ||
"getAttributesWithRandomValues", | ||
new NoGuidance(10000, System.out), | ||
System.out); | ||
assertThat(result.wasSuccessful()).isTrue(); | ||
} | ||
} |