This is an automated email from the ASF dual-hosted git repository.

yuchanns pushed a commit to branch bindings-go-more-svcs
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit 89033a58fd327033390476ff5c53cd561e6f7413
Author: Hanchin Hsieh <[email protected]>
AuthorDate: Tue Nov 19 15:57:46 2024 +0800

    ci(bindings/go): support more storage services
    
    Signed-off-by: Hanchin Hsieh <[email protected]>
---
 .github/scripts/test_go_binding/matrix.yaml       |  4 ++++
 .github/workflows/ci_bindings_go.yml              |  2 +-
 bindings/go/README.md                             |  8 +++----
 bindings/go/tests/behavior_tests/go.mod           |  4 ++++
 bindings/go/tests/behavior_tests/opendal_test.go  | 21 +++++++---------
 bindings/go/tests/behavior_tests/scheme/azblob.go | 29 +++++++++++++++++++++++
 bindings/go/tests/behavior_tests/scheme/fs.go     | 28 ++++++++++++++++++++++
 bindings/go/tests/behavior_tests/scheme/gcs.go    | 29 +++++++++++++++++++++++
 bindings/go/tests/behavior_tests/scheme/hdfs.go   | 28 ++++++++++++++++++++++
 bindings/go/tests/behavior_tests/scheme/oss.go    | 29 +++++++++++++++++++++++
 bindings/go/tests/behavior_tests/scheme/scheme.go | 24 +++++++++++++++++++
 11 files changed, 188 insertions(+), 18 deletions(-)

diff --git a/.github/scripts/test_go_binding/matrix.yaml 
b/.github/scripts/test_go_binding/matrix.yaml
index b64fa19b6..e6aeca671 100644
--- a/.github/scripts/test_go_binding/matrix.yaml
+++ b/.github/scripts/test_go_binding/matrix.yaml
@@ -28,4 +28,8 @@ build:
     os: "macos-latest"
 service:
   - "fs"
+  - "hdfs"
+  - "gcs"
+  - "oss"
+  - "azblob"
 
diff --git a/.github/workflows/ci_bindings_go.yml 
b/.github/workflows/ci_bindings_go.yml
index 2264e18fa..2acb491bc 100644
--- a/.github/workflows/ci_bindings_go.yml
+++ b/.github/workflows/ci_bindings_go.yml
@@ -147,4 +147,4 @@ jobs:
           if [ ${{ matrix.build.os }} == 'macos-latest' ]; then
             export 
DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH:/opt/homebrew/opt/libffi/lib
           fi
-          CGO_ENABLE=0 go test -v -run TestBehavior
+          CGO_ENABLE=0 go test -tags "${{ matrix.service }}" -v -run 
TestBehavior
diff --git a/bindings/go/README.md b/bindings/go/README.md
index 3b6cd166e..1e27d16ac 100644
--- a/bindings/go/README.md
+++ b/bindings/go/README.md
@@ -96,11 +96,11 @@ cd tests/behavior_tests
 # Test a specific backend
 export OPENDAL_TEST=memory
 # Run all tests
-CGO_ENABLE=0 go test -v -run TestBehavior
+CGO_ENABLE=0 go test -v -run TestBehavior -tags "memory"
 # Run specific test
-CGO_ENABLE=0 go test -v -run TestBehavior/Write
+CGO_ENABLE=0 go test -v -run TestBehavior/Write -tags "memory"
 # Run synchronously
-CGO_ENABLE=0 GOMAXPROCS=1 go test -v -run TestBehavior
+CGO_ENABLE=0 GOMAXPROCS=1 go test -v -run TestBehavior -tags "memory"
 ```
 
 ### Benchmark
@@ -110,7 +110,7 @@ cd tests/behavior_tests
 # Benchmark a specific backend
 export OPENDAL_TEST=memory
 
-go test -bench .
+go test -bench -tags "memory" .
 ```
 
 <details>
diff --git a/bindings/go/tests/behavior_tests/go.mod 
b/bindings/go/tests/behavior_tests/go.mod
index fcaba00ec..d09f0bea8 100644
--- a/bindings/go/tests/behavior_tests/go.mod
+++ b/bindings/go/tests/behavior_tests/go.mod
@@ -21,6 +21,10 @@ go 1.22.5
 
 require (
        github.com/apache/opendal-go-services/fs v0.1.3
+       github.com/apache/opendal-go-services/hdfs v0.1.3
+       github.com/apache/opendal-go-services/gcs v0.1.3
+       github.com/apache/opendal-go-services/oss v0.1.3
+       github.com/apache/opendal-go-services/azblob 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
diff --git a/bindings/go/tests/behavior_tests/opendal_test.go 
b/bindings/go/tests/behavior_tests/opendal_test.go
index c421885b4..37dee198b 100644
--- a/bindings/go/tests/behavior_tests/opendal_test.go
+++ b/bindings/go/tests/behavior_tests/opendal_test.go
@@ -30,17 +30,12 @@ import (
        "sync"
        "testing"
 
-       "github.com/apache/opendal-go-services/fs"
        opendal "github.com/apache/opendal/bindings/go"
        "github.com/google/uuid"
        "github.com/stretchr/testify/require"
+       "opendal_test/scheme"
 )
 
-// Add more schemes for behavior tests here.
-var schemes = []opendal.Scheme{
-       fs.Scheme,
-}
-
 var op *opendal.Operator
 
 func TestMain(m *testing.M) {
@@ -101,8 +96,8 @@ func TestBehavior(t *testing.T) {
 
 func newOperator() (op *opendal.Operator, closeFunc func(), err error) {
        test := os.Getenv("OPENDAL_TEST")
-       var scheme opendal.Scheme
-       for _, s := range schemes {
+       var sch opendal.Scheme
+       for _, s := range scheme.Table {
                if s.Name() != test {
                        continue
                }
@@ -110,15 +105,15 @@ func newOperator() (op *opendal.Operator, closeFunc 
func(), err error) {
                if err != nil {
                        return
                }
-               scheme = s
+               sch = s
                break
        }
-       if scheme == nil {
+       if sch == nil {
                err = fmt.Errorf("unsupported scheme: %s", test)
                return
        }
 
-       prefix := fmt.Sprintf("OPENDAL_%s_", strings.ToUpper(scheme.Name()))
+       prefix := fmt.Sprintf("OPENDAL_%s_", strings.ToUpper(sch.Name()))
 
        opts := opendal.OperatorOptions{}
        for _, env := range os.Environ() {
@@ -134,7 +129,7 @@ func newOperator() (op *opendal.Operator, closeFunc func(), 
err error) {
                opts[strings.ToLower(strings.TrimPrefix(key, prefix))] = value
        }
 
-       op, err = opendal.NewOperator(scheme, opts)
+       op, err = opendal.NewOperator(sch, opts)
        if err != nil {
                err = fmt.Errorf("create operator must succeed: %s", err)
        }
@@ -142,7 +137,7 @@ func newOperator() (op *opendal.Operator, closeFunc func(), 
err error) {
        closeFunc = func() {
                op.Close()
 
-               os.Remove(scheme.Path())
+               os.Remove(sch.Path())
        }
 
        return
diff --git a/bindings/go/tests/behavior_tests/scheme/azblob.go 
b/bindings/go/tests/behavior_tests/scheme/azblob.go
new file mode 100644
index 000000000..c2bedc566
--- /dev/null
+++ b/bindings/go/tests/behavior_tests/scheme/azblob.go
@@ -0,0 +1,29 @@
+//go:build azblob
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package scheme
+
+import "github.com/apache/opendal-go-services/azblob"
+
+func init() {
+       Table = append(Table, azblob.Scheme)
+}
+
diff --git a/bindings/go/tests/behavior_tests/scheme/fs.go 
b/bindings/go/tests/behavior_tests/scheme/fs.go
new file mode 100644
index 000000000..0ace3709a
--- /dev/null
+++ b/bindings/go/tests/behavior_tests/scheme/fs.go
@@ -0,0 +1,28 @@
+//go:build fs
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package scheme
+
+import "github.com/apache/opendal-go-services/fs"
+
+func init() {
+       Table = append(Table, fs.Scheme)
+}
diff --git a/bindings/go/tests/behavior_tests/scheme/gcs.go 
b/bindings/go/tests/behavior_tests/scheme/gcs.go
new file mode 100644
index 000000000..01527790f
--- /dev/null
+++ b/bindings/go/tests/behavior_tests/scheme/gcs.go
@@ -0,0 +1,29 @@
+//go:build gcs
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package scheme
+
+import "github.com/apache/opendal-go-services/gcs"
+
+func init() {
+       Table = append(Table, gcs.Scheme)
+}
+
diff --git a/bindings/go/tests/behavior_tests/scheme/hdfs.go 
b/bindings/go/tests/behavior_tests/scheme/hdfs.go
new file mode 100644
index 000000000..f3a6aaee6
--- /dev/null
+++ b/bindings/go/tests/behavior_tests/scheme/hdfs.go
@@ -0,0 +1,28 @@
+//go:build hdfs
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package scheme
+
+import "github.com/apache/opendal-go-services/hdfs"
+
+func init() {
+       Table = append(Table, hdfs.Scheme)
+}
diff --git a/bindings/go/tests/behavior_tests/scheme/oss.go 
b/bindings/go/tests/behavior_tests/scheme/oss.go
new file mode 100644
index 000000000..ad6edd187
--- /dev/null
+++ b/bindings/go/tests/behavior_tests/scheme/oss.go
@@ -0,0 +1,29 @@
+//go:build oss
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package scheme
+
+import "github.com/apache/opendal-go-services/oss"
+
+func init() {
+       Table = append(Table, oss.Scheme)
+}
+
diff --git a/bindings/go/tests/behavior_tests/scheme/scheme.go 
b/bindings/go/tests/behavior_tests/scheme/scheme.go
new file mode 100644
index 000000000..22df52e01
--- /dev/null
+++ b/bindings/go/tests/behavior_tests/scheme/scheme.go
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package scheme
+
+import opendal "github.com/apache/opendal/bindings/go"
+
+var Table []opendal.Scheme

Reply via email to