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

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 6909f3a3d feat(core): add OpenStack Swift e2e test (#3493)
6909f3a3d is described below

commit 6909f3a3df89c6746c4cb8113c34eb47fceda72d
Author: Morris Tai <[email protected]>
AuthorDate: Mon Nov 6 19:26:54 2023 -0500

    feat(core): add OpenStack Swift e2e test (#3493)
    
    * chore: add openstack swift into .env.example
    
    * feat: add openstack swift e2e test
    
    * feat: drop rename as swift doesn't support it
    
    * fix: correct OPENDAL_SWIFT_ROOT value
    
    * chore: use another way to export env variables
    
    * tmp: add debug log
    
    * chore: modify timout and retries values
    
    * fix: adding tr -d '\n' to fix weird bug
    
    * chore: add trim_end to token as triage weird bug
    
    * chore: don't use token from GITHUB_ENV
    
    * feat: export env variable at once
    
    * chore: use different format to export env variable
    
    * chore: use echo -e to enable backslash escapes.
    
    * chore: use cat EOF to set token
    
    * chore: workaround by pre-apply token and trim end
    
    * chore: triage by merge two steps together
    
    * chore: prune and separate steps
    
    * chore: reset comment out for debug purpose
---
 .env.example                            |  6 +++++
 .github/services/swift/swift/action.yml | 45 +++++++++++++++++++++++++++++++++
 .github/workflows/ci.yml                |  1 +
 bindings/java/Cargo.toml                |  2 ++
 bindings/nodejs/Cargo.toml              |  2 ++
 bindings/python/Cargo.toml              |  2 ++
 core/src/services/swift/backend.rs      |  1 -
 fixtures/swift/docker-compose-swift.yml | 29 +++++++++++++++++++++
 8 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/.env.example b/.env.example
index f84d0bec6..e57e121c7 100644
--- a/.env.example
+++ b/.env.example
@@ -155,3 +155,9 @@ OPENDAL_AZFILE_ROOT=/tmp/opendal/
 OPENDAL_AZFILE_ACCOUNT_NAME=<account_name>
 OPENDAL_AZFILE_ACCOUNT_KEY=<account_key>
 OPENDAL_AZFILE_SHARE_NAME=<shared_name>
+# openstack swift
+OPENDAL_SWIFT_ENDPOINT=<endpoint>
+OPENDAL_SWIFT_ACCOUNT=<account>
+OPENDAL_SWIFT_CONTAINER=<container>
+OPENDAL_SWIFT_ROOT=/path/to/dir
+OPENDAL_SWIFT_TOKEN=<token>
diff --git a/.github/services/swift/swift/action.yml 
b/.github/services/swift/swift/action.yml
new file mode 100644
index 000000000..397eba16a
--- /dev/null
+++ b/.github/services/swift/swift/action.yml
@@ -0,0 +1,45 @@
+# 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.
+
+name: swift
+description: "Behavior test for OpenStack Swift"
+
+runs:
+  using: "composite"
+  steps:
+    - name: Setup Swift service
+      shell: bash
+      working-directory: fixtures/swift
+      run: |
+        docker compose -f docker-compose-swift.yml up -d --wait
+
+    - name: Create test token and setup test container
+      shell: bash
+      run: |
+        token=$(curl -i -H 'X-Storage-User: test:tester' -H 'X-Storage-Pass: 
testing' http://127.0.0.1:8080/auth/v1.0 | grep X-Auth-Token | head -n1 | awk 
'{print $2}')
+        curl --location --request PUT 
'http://127.0.0.1:8080/v1/AUTH_test/testing' --header "X-Auth-Token: $token"
+        echo "OPENDAL_SWIFT_TOKEN=$(echo "$token" | tr -d '[:space:]')" >> 
$GITHUB_ENV
+
+    - name: Set environment variables
+      shell: bash
+      run: |
+        cat << EOF >> $GITHUB_ENV
+        OPENDAL_SWIFT_ENDPOINT=http://127.0.0.1:8080
+        OPENDAL_SWIFT_ACCOUNT=AUTH_test
+        OPENDAL_SWIFT_CONTAINER=testing
+        OPENDAL_SWIFT_ROOT=/
+        EOF
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 79fc2bd0a..de199f5d3 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -238,6 +238,7 @@ jobs:
             # TODO: sftp is known to not work on windows, waiting for 
https://github.com/apache/incubator-opendal/issues/2963
             # services-sftp
             services-sled
+            services-swift
             services-supabase
             services-tikv
             services-vercel-artifacts
diff --git a/bindings/java/Cargo.toml b/bindings/java/Cargo.toml
index 87c7ca2c7..b21fc2fd7 100644
--- a/bindings/java/Cargo.toml
+++ b/bindings/java/Cargo.toml
@@ -83,6 +83,7 @@ services-all = [
   "services-sqlite",
   "services-azfile",
   "services-libsql",
+  "services-swift",
 ]
 
 # Default services provided by opendal.
@@ -131,6 +132,7 @@ services-tikv = ["opendal/services-tikv"]
 services-vercel-artifacts = ["opendal/services-vercel-artifacts"]
 services-wasabi = ["opendal/services-wasabi"]
 services-libsql = ["opendal/services-libsql"]
+services-swift = ["opendal/services-swift"]
 
 
 [dependencies]
diff --git a/bindings/nodejs/Cargo.toml b/bindings/nodejs/Cargo.toml
index 4460e7826..a8294b33a 100644
--- a/bindings/nodejs/Cargo.toml
+++ b/bindings/nodejs/Cargo.toml
@@ -73,6 +73,7 @@ services-all = [
   "services-rocksdb",
   "services-sled",
   "services-supabase",
+  "services-swift",
   "services-tikv",
   "services-vercel-artifacts",
   "services-wasabi",
@@ -123,6 +124,7 @@ services-sftp = ["opendal/services-sftp"]
 services-sled = ["opendal/services-sled"]
 services-sqlite = ["opendal/services-sqlite"]
 services-supabase = ["opendal/services-supabase"]
+services-swift = ["opendal/services-swift"]
 services-tikv = ["opendal/services-tikv"]
 services-vercel-artifacts = ["opendal/services-vercel-artifacts"]
 services-wasabi = ["opendal/services-wasabi"]
diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml
index 7ace6adb4..dca2c5b18 100644
--- a/bindings/python/Cargo.toml
+++ b/bindings/python/Cargo.toml
@@ -73,6 +73,7 @@ services-all = [
   "services-rocksdb",
   "services-sled",
   "services-supabase",
+  "services-swift",
   "services-tikv",
   "services-vercel-artifacts",
   "services-wasabi",
@@ -123,6 +124,7 @@ services-sftp = ["opendal/services-sftp"]
 services-sled = ["opendal/services-sled"]
 services-sqlite = ["opendal/services-sqlite"]
 services-supabase = ["opendal/services-supabase"]
+services-swift = ["opendal/services-swift"]
 services-tikv = ["opendal/services-tikv"]
 services-vercel-artifacts = ["opendal/services-vercel-artifacts"]
 services-wasabi = ["opendal/services-wasabi"]
diff --git a/core/src/services/swift/backend.rs 
b/core/src/services/swift/backend.rs
index 1bfc4124c..080b525c1 100644
--- a/core/src/services/swift/backend.rs
+++ b/core/src/services/swift/backend.rs
@@ -235,7 +235,6 @@ impl Accessor for SwiftBackend {
                 write: true,
                 create_dir: true,
                 delete: true,
-                rename: true,
 
                 list: true,
                 list_with_delimiter_slash: true,
diff --git a/fixtures/swift/docker-compose-swift.yml 
b/fixtures/swift/docker-compose-swift.yml
new file mode 100644
index 000000000..02b83572b
--- /dev/null
+++ b/fixtures/swift/docker-compose-swift.yml
@@ -0,0 +1,29 @@
+# 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.
+
+version: '3.8'
+
+services:
+  swift:
+    image: openstackswift/saio:py3
+    ports:
+      - 8080:8080
+    healthcheck:
+      test: ["CMD", "curl", "-i", "-H", "X-Storage-User: test:tester", "-H", 
"X-Storage-Pass: testing", "http://localhost:8080/";]
+      interval: 3s
+      timeout: 20s
+      retries: 10
\ No newline at end of file

Reply via email to