diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 98fb6b791..7a499aa8d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,30 @@ jobs: go-version: ${{ matrix.go }} - run: go vet - name: Run unit tests - run: go test -v -tags unit -race + run: | + # Get the list of all packages + #packages=$(go list ./...) + + # for pkg in $packages; do + # Run tests in the package, excluding fuzz tests + go test -v -tags unit -race '${{ matrix.tags }}gocql_debug' -timeout=5m -race ${{ env.args }} + #$pkg | grep -v 'Fuzz' + #done + + Fuzzing: + name: Fuzz tests + runs-on: ubuntu-latest + strategy: + matrix: + go: [ '1.19', '1.20' ] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go }} + - run: go vet + - name: Run unit tests + run: go test -race -v -fuzz Fuzz -fuzztime 30s -parallel=1 -tags fuzz integration-cassandra: timeout-minutes: 15 needs: @@ -107,8 +130,17 @@ jobs: echo "JVM_EXTRA_OPTS=$JVM_EXTRA_OPTS" >> $GITHUB_ENV - name: Integration tests run: | - export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}" - go test -v -tags "${{ matrix.tags }} gocql_debug" -timeout=5m -race ${{ env.args }} + export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}" + + # Get the list of all packages + #packages=$(go list ./...) + + #for pkg in $packages; do + # Run tests in the package, excluding fuzz tests + # go test -v -tags '${{ matrix.tags }}gocql_debug' -timeout=5m -race ${{ env.args }} $pkg | grep -v 'Fuzz' + #done + + go test -v -tags "${{ matrix.tags }} gocql_debug" -timeout=5m -race ${{ env.args }} - name: 'Save ccm logs' if: 'failure()' uses: actions/upload-artifact@v3 @@ -198,4 +230,18 @@ jobs: - name: Integration tests run: | export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}" - go test -v -run=TestAuthentication -tags "${{ matrix.tags }} gocql_debug" -timeout=15s -runauth ${{ env.args }} + + # Get the list of all packages + #packages=$(go list ./...) + + #for pkg in $packages; do + # Run tests in the package, excluding fuzz tests + # go test -v -run=TestAuthentication -tags '${{ matrix.tags }}gocql_debug' -timeout=15s -runauth ${{ env.args }} $pkg | grep -v 'Fuzz' + #done + + + #for pkg in $(go list ./...); do + # go test -v -tags "${{ matrix.tags }} gocql_debug" -timeout=15s -runauth ${{ env.args }} $(find . -name "*_test.go" ! -name "*Fuzz*") -run=TestAuthentication $pkg + #done + + go test -v -run=TestAuthentication -tags "${{ matrix.tags }} gocql_debug" -timeout=15s -runauth ${{ env.args }} diff --git a/fuzz_cassandra_test.go b/fuzz_cassandra_test.go new file mode 100644 index 000000000..91c1728d7 --- /dev/null +++ b/fuzz_cassandra_test.go @@ -0,0 +1,30 @@ +//go:build fuzz +// +build fuzz + +package gocql + +import ( + "testing" +) + +// FuzzMarshalFloat64Ptr aimed to repeatedly test float64 marshaling with generated inputs based on seed corpus. +func FuzzMarshalFloat64Ptr(f *testing.F) { + f.Add(float64(7500), float64(7500.00)) + + f.Fuzz(func(t *testing.T, num, numWithPoints float64) { + session := createSession(t) + defer session.Close() + + if err := createTable(session, "CREATE TABLE IF NOT EXISTS gocql_test.float_test (id double, test double, primary key (id))"); err != nil { + t.Fatal("create table:", err) + } + + if err := session.Query(`TRUNCATE TABLE gocql_test.float_test`).Exec(); err != nil { + t.Fatal("truncate table:", err) + } + + if err := session.Query(`INSERT INTO float_test (id,test) VALUES (?,?)`, numWithPoints, &num).Exec(); err != nil { + t.Fatal("insert float64:", err) + } + }) +}