File tree Expand file tree Collapse file tree 3 files changed +85
-0
lines changed
Expand file tree Collapse file tree 3 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 6767 - name : Run tests with race detector
6868 run : make test-race
6969
70+ test-fuzz :
71+ strategy :
72+ matrix :
73+ target :
74+ - fuzz-config-json
75+ - fuzz-config-yaml
76+ runs-on : ubuntu-latest
77+ steps :
78+ - name : Checkout Repo
79+ uses : actions/checkout@v4
80+ - name : Install Go
81+ uses : actions/setup-go@v5
82+ with :
83+ go-version : ${{ env.DEFAULT_GO_VERSION }}
84+ check-latest : true
85+ cache-dependency-path : " **/go.sum"
86+ - name : Fuzzing
87+ run : make ${{ matrix.target }}
88+
7089 test-coverage :
7190 runs-on : ubuntu-latest
7291 steps :
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ CONTRIB_REPO_URL = https://github.com/open-telemetry/opentelemetry-go-contrib/tr
1414
1515GO = go
1616TIMEOUT = 60
17+ FUZZTIME = 180
1718
1819.DEFAULT_GOAL := precommit
1920
@@ -276,6 +277,18 @@ test-coverage/%:
276277 && $$ CMD ./... \
277278 && $(GO ) tool cover -html=coverage.out -o coverage.html;
278279
280+ # Fuzzing
281+
282+ .PHONY : fuzz-config-json
283+ fuzz-config-json :
284+ cd config/v0.3.0 \
285+ && $(GO ) test -run=^$ -fuzztime=$(FUZZTIME ) -fuzz=FuzzJSON
286+
287+ .PHONY : fuzz-config-yaml
288+ fuzz-config-yaml :
289+ cd config/v0.3.0 \
290+ && $(GO ) test -run=^$ -fuzztime=$(FUZZTIME ) -fuzz=FuzzYAML
291+
279292# Releasing
280293
281294.PHONY : gorelease
Original file line number Diff line number Diff line change 1+ package config
2+
3+ import (
4+ "context"
5+ "encoding/json"
6+ "os"
7+ "path/filepath"
8+ "testing"
9+
10+ "github.com/stretchr/testify/assert"
11+ "github.com/stretchr/testify/require"
12+ )
13+
14+ func FuzzJSON (f * testing.F ) {
15+ b , err := os .ReadFile (filepath .Join (".." , "testdata" , "v0.3.json" ))
16+ require .NoError (f , err )
17+ f .Add (b )
18+
19+ f .Fuzz (func (t * testing.T , data []byte ) {
20+ var cfg OpenTelemetryConfiguration
21+ err := json .Unmarshal (b , & cfg )
22+ if err != nil {
23+ return
24+ }
25+
26+ sdk , err := NewSDK (WithOpenTelemetryConfiguration (cfg ))
27+ if err != nil {
28+ return
29+ }
30+
31+ assert .NoError (t , sdk .Shutdown (context .Background ()))
32+ })
33+ }
34+
35+ func FuzzYAML (f * testing.F ) {
36+ b , err := os .ReadFile (filepath .Join (".." , "testdata" , "v0.3.yaml" ))
37+ require .NoError (f , err )
38+ f .Add (b )
39+
40+ f .Fuzz (func (t * testing.T , data []byte ) {
41+ cfg , err := ParseYAML (data )
42+ if err != nil {
43+ return
44+ }
45+
46+ sdk , err := NewSDK (WithOpenTelemetryConfiguration (* cfg ))
47+ if err != nil {
48+ return
49+ }
50+
51+ assert .NoError (t , sdk .Shutdown (context .Background ()))
52+ })
53+ }
You can’t perform that action at this time.
0 commit comments