diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 98fb6b791..dd03f62f0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,23 @@ jobs: go-version: ${{ matrix.go }} - run: go vet - name: Run unit tests - run: go test -v -tags unit -race + run: | + go test -v -tags unit -race '${{ matrix.tags }}gocql_debug' -timeout=5m -race ${{ env.args }} + + 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,7 +123,8 @@ jobs: echo "JVM_EXTRA_OPTS=$JVM_EXTRA_OPTS" >> $GITHUB_ENV - name: Integration tests run: | - export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}" + export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}" + go test -v -tags "${{ matrix.tags }} gocql_debug" -timeout=5m -race ${{ env.args }} - name: 'Save ccm logs' if: 'failure()' @@ -198,4 +215,5 @@ 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 }} 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) + } + }) +}