Skip to content

Commit

Permalink
ci(bindings/go): test against service-fs
Browse files Browse the repository at this point in the history
Signed-off-by: Hanchin Hsieh <[email protected]>
  • Loading branch information
yuchanns committed Sep 25, 2024
1 parent 1d5b8ce commit 45357c3
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/test_go_binding/matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ build:
goos: "linux"
goarch: "amd64"
service:
- "memory"
- "fs"

1 change: 1 addition & 0 deletions .github/workflows/ci_bindings_go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions bindings/go/tests/behavior_tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions bindings/go/tests/behavior_tests/go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand All @@ -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=
Expand Down
2 changes: 2 additions & 0 deletions bindings/go/tests/behavior_tests/opendal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -39,6 +40,7 @@ import (
// Add more schemes for behavior tests here.
var schemes = []opendal.Scheme{
memory.Scheme,
fs.Scheme,
}

var op *opendal.Operator
Expand Down
6 changes: 4 additions & 2 deletions bindings/go/tests/behavior_tests/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions bindings/go/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion bindings/go/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 45357c3

Please sign in to comment.