From 45357c397de2cf1c278cd1d9a54382ba1ca05e9d Mon Sep 17 00:00:00 2001 From: Hanchin Hsieh Date: Tue, 24 Sep 2024 21:19:30 +0800 Subject: [PATCH] ci(bindings/go): test against service-fs Signed-off-by: Hanchin Hsieh --- .github/scripts/test_go_binding/matrix.yaml | 2 +- .github/workflows/ci_bindings_go.yml | 1 + bindings/go/tests/behavior_tests/go.mod | 5 +++-- bindings/go/tests/behavior_tests/go.sum | 10 ++++++---- bindings/go/tests/behavior_tests/opendal_test.go | 2 ++ bindings/go/tests/behavior_tests/write_test.go | 6 ++++-- bindings/go/types.go | 9 +++++++++ bindings/go/write.go | 2 +- 8 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/scripts/test_go_binding/matrix.yaml b/.github/scripts/test_go_binding/matrix.yaml index 27ba73a8501..e477aea073e 100644 --- a/.github/scripts/test_go_binding/matrix.yaml +++ b/.github/scripts/test_go_binding/matrix.yaml @@ -22,5 +22,5 @@ build: goos: "linux" goarch: "amd64" service: - - "memory" + - "fs" diff --git a/.github/workflows/ci_bindings_go.yml b/.github/workflows/ci_bindings_go.yml index bde9e0cb2d8..90f20509d50 100644 --- a/.github/workflows/ci_bindings_go.yml +++ b/.github/workflows/ci_bindings_go.yml @@ -127,5 +127,6 @@ jobs: - name: Run tests env: OPENDAL_TEST: ${{ matrix.service }} + OPENDAL_FS_ROOT: "/tmp/opendal" working-directory: bindings/go/tests/behavior_tests run: CGO_ENABLE=0 go test -v -run TestBehavior diff --git a/bindings/go/tests/behavior_tests/go.mod b/bindings/go/tests/behavior_tests/go.mod index b6c1ff39f0d..dae1477ff16 100644 --- a/bindings/go/tests/behavior_tests/go.mod +++ b/bindings/go/tests/behavior_tests/go.mod @@ -20,7 +20,8 @@ module opendal_test go 1.22.5 require ( - github.com/apache/opendal-go-services/memory v0.0.0-20240719030108-74ff217cfef9 + github.com/apache/opendal-go-services/fs v0.1.3 + github.com/apache/opendal-go-services/memory v0.1.3 github.com/apache/opendal/bindings/go v0.0.0-20240719044908-d9d4279b3a24 github.com/google/uuid v1.6.0 github.com/stretchr/testify v1.9.0 @@ -30,7 +31,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/ebitengine/purego v0.7.1 // indirect github.com/jupiterrider/ffi v0.1.0-beta.9 // indirect - github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/compress v1.17.10 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/sys v0.22.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/bindings/go/tests/behavior_tests/go.sum b/bindings/go/tests/behavior_tests/go.sum index 3594204ba23..d9f6957f138 100644 --- a/bindings/go/tests/behavior_tests/go.sum +++ b/bindings/go/tests/behavior_tests/go.sum @@ -1,5 +1,7 @@ -github.com/apache/opendal-go-services/memory v0.0.0-20240719030108-74ff217cfef9 h1:tV4Xmoa5Zq2RyrygaXreayLz10C6JqTpyvMYAtdshXQ= -github.com/apache/opendal-go-services/memory v0.0.0-20240719030108-74ff217cfef9/go.mod h1:vldOQuikErKA1wfGnqvjAYB9MON/PWTuFIulMCKIQqM= +github.com/apache/opendal-go-services/fs v0.1.3 h1:k5pA73gKbQ3MHH2envsKhr1cec2spLm2tl/bCyU53j8= +github.com/apache/opendal-go-services/fs v0.1.3/go.mod h1:7EnuyeXRuQh+L47rZ7y2OrhYJLlUYvgvFPItM98XJ5s= +github.com/apache/opendal-go-services/memory v0.1.3 h1:lUe4n4Y9AmwS6a1KV/ZTLyWLtWpRSSuNZHchcW2s+LQ= +github.com/apache/opendal-go-services/memory v0.1.3/go.mod h1:vldOQuikErKA1wfGnqvjAYB9MON/PWTuFIulMCKIQqM= github.com/apache/opendal/bindings/go v0.0.0-20240719044908-d9d4279b3a24 h1:2fAl+WS/lZMTtP6onlrmDbb3pltf+5xNTc0Aeu9nYWE= github.com/apache/opendal/bindings/go v0.0.0-20240719044908-d9d4279b3a24/go.mod h1:jyMN6M6h0jMDZitnjvB3KPobM+oZiESrFb3XUplLxhI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -10,8 +12,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jupiterrider/ffi v0.1.0-beta.9 h1:HCeAPTsTFgwvcfavyJwy1L2ANz0c85W+ZE7LfzjZi3A= github.com/jupiterrider/ffi v0.1.0-beta.9/go.mod h1:sOp6VJGFaYyr4APi8gwy6g20QNHv5F8Iq1CVbtC900s= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0= +github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= diff --git a/bindings/go/tests/behavior_tests/opendal_test.go b/bindings/go/tests/behavior_tests/opendal_test.go index 551087c5f3e..9368e78979a 100644 --- a/bindings/go/tests/behavior_tests/opendal_test.go +++ b/bindings/go/tests/behavior_tests/opendal_test.go @@ -30,6 +30,7 @@ import ( "sync" "testing" + "github.com/apache/opendal-go-services/fs" "github.com/apache/opendal-go-services/memory" opendal "github.com/apache/opendal/bindings/go" "github.com/google/uuid" @@ -39,6 +40,7 @@ import ( // Add more schemes for behavior tests here. var schemes = []opendal.Scheme{ memory.Scheme, + fs.Scheme, } var op *opendal.Operator diff --git a/bindings/go/tests/behavior_tests/write_test.go b/bindings/go/tests/behavior_tests/write_test.go index e8a72e79e6c..05d626972d5 100644 --- a/bindings/go/tests/behavior_tests/write_test.go +++ b/bindings/go/tests/behavior_tests/write_test.go @@ -113,8 +113,10 @@ func testWriterWrite(assert *require.Assertions, op *opendal.Operator, fixture * w, err := op.Writer(path) assert.Nil(err) - assert.Nil(w.Write(contentA)) - assert.Nil(w.Write(contentB)) + _, err = w.Write(contentA) + assert.Nil(err) + _, err = w.Write(contentB) + assert.Nil(err) assert.Nil(w.Close()) meta, err := op.Stat(path) diff --git a/bindings/go/types.go b/bindings/go/types.go index 4ee2de18841..f4b8be049c6 100644 --- a/bindings/go/types.go +++ b/bindings/go/types.go @@ -89,6 +89,15 @@ var ( }[0], } + typeResultOperatorWriter = ffi.Type{ + Type: ffi.Struct, + Elements: &[]*ffi.Type{ + &ffi.TypePointer, + &ffi.TypePointer, + nil, + }[0], + } + typeResultWriterWrite = ffi.Type{ Type: ffi.Struct, Elements: &[]*ffi.Type{ diff --git a/bindings/go/write.go b/bindings/go/write.go index 4b191dd8f31..dc77ef9ac87 100644 --- a/bindings/go/write.go +++ b/bindings/go/write.go @@ -246,7 +246,7 @@ type operatorWriter func(op *opendalOperator, path string) (*opendalWriter, erro var withOperatorWriter = withFFI(ffiOpts{ sym: symOperatorWriter, - rType: &ffi.TypePointer, + rType: &typeResultOperatorWriter, aTypes: []*ffi.Type{&ffi.TypePointer, &ffi.TypePointer}, }, func(ctx context.Context, ffiCall func(rValue unsafe.Pointer, aValues ...unsafe.Pointer)) operatorWriter { return func(op *opendalOperator, path string) (*opendalWriter, error) {