From 0aee13f484581fc2ac45a6a65641eb180b7daaad Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Thu, 28 Dec 2023 18:31:04 +0800 Subject: [PATCH] ci: Migrate ftp to test planner (#3843) * ci: Migrate ftp to test planner Signed-off-by: Xuanwo * Don't reuse conn Signed-off-by: Xuanwo --------- Signed-off-by: Xuanwo --- .github/services/ftp/vsftpd/action.yml | 36 ++++++++++ .github/workflows/service_test_ftp.yml | 91 -------------------------- core/src/services/ftp/backend.rs | 6 +- fixtures/ftp/docker-compose-vsftpd.yml | 35 ++++++++++ 4 files changed, 75 insertions(+), 93 deletions(-) create mode 100644 .github/services/ftp/vsftpd/action.yml delete mode 100644 .github/workflows/service_test_ftp.yml create mode 100644 fixtures/ftp/docker-compose-vsftpd.yml diff --git a/.github/services/ftp/vsftpd/action.yml b/.github/services/ftp/vsftpd/action.yml new file mode 100644 index 00000000000..832009edaf1 --- /dev/null +++ b/.github/services/ftp/vsftpd/action.yml @@ -0,0 +1,36 @@ +# 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: vsftpd +description: 'Behavior test for vsftpd' + +runs: + using: "composite" + steps: + - name: Setup vsftpd cluster + shell: bash + working-directory: fixtures/ftp + run: docker compose -f docker-compose-vsftpd.yml up -d --wait + - name: Setup + shell: bash + run: | + cat << EOF >> $GITHUB_ENV + OPENDAL_FTP_ENDPOINT=ftp://127.0.0.1:2121 + OPENDAL_FTP_ROOT=/ + OPENDAL_FTP_USER=admin + OPENDAL_FTP_PASSWORD=admin + EOF diff --git a/.github/workflows/service_test_ftp.yml b/.github/workflows/service_test_ftp.yml deleted file mode 100644 index 3775dcdea28..00000000000 --- a/.github/workflows/service_test_ftp.yml +++ /dev/null @@ -1,91 +0,0 @@ -# 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: Service Test Ftp - -on: - push: - branches: - - main - pull_request: - branches: - - main - paths: - - "core/src/**" - - "core/tests/**" - - "!core/src/docs/**" - - "!core/src/services/**" - - "core/src/services/ftp/**" - - ".github/workflows/service_test_ftp.yml" - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} - cancel-in-progress: true - -jobs: - vsftpd: - runs-on: ubuntu-latest - - services: - ftp: - image: fauria/vsftpd - ports: - - 2121:21 - - 20000-22000:20000-22000 - env: - FTP_USER: admin - FTP_PASS: admin - PASV_ADDRESS: 127.0.0.1 - PASV_MIN_PORT: 20000 - PASV_MAX_PORT: 22000 - volumes: - - vsftpd-data:/home/vsftpd - - steps: - - uses: actions/checkout@v4 - - name: Set swap - shell: bash - run: | - SWAP_PATH="swapfile" - - sudo fallocate -l 10G $SWAP_PATH - sudo chmod 600 $SWAP_PATH - sudo mkswap $SWAP_PATH - sudo swapon $SWAP_PATH - - name: Swap space report after modification - shell: bash - run: | - echo "Memory and swap:" - free -h - echo - swapon --show - echo - - - name: Setup Rust toolchain - uses: ./.github/actions/setup - with: - need-nextest: true - - name: Test - shell: bash - working-directory: core - run: cargo nextest run behavior --features tests,services-ftp - env: - OPENDAL_TEST: ftp - OPENDAL_FTP_ENDPOINT: ftp://127.0.0.1:2121 - OPENDAL_FTP_ROOT: / - OPENDAL_FTP_USER: admin - OPENDAL_FTP_PASSWORD: admin diff --git a/core/src/services/ftp/backend.rs b/core/src/services/ftp/backend.rs index 7a44b99c587..b5ddda58126 100644 --- a/core/src/services/ftp/backend.rs +++ b/core/src/services/ftp/backend.rs @@ -260,9 +260,11 @@ impl bb8::ManageConnection for Manager { conn.noop().await } - /// Always allow reuse conn. + /// Don't allow reuse conn. + /// + /// We need to investigate why reuse conn will cause error. fn has_broken(&self, _: &mut Self::Connection) -> bool { - false + true } } diff --git a/fixtures/ftp/docker-compose-vsftpd.yml b/fixtures/ftp/docker-compose-vsftpd.yml new file mode 100644 index 00000000000..65f74a74d7f --- /dev/null +++ b/fixtures/ftp/docker-compose-vsftpd.yml @@ -0,0 +1,35 @@ +# 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: + vsftpd: + image: fauria/vsftpd + ports: + - "2121:21" + - "20000-22000:20000-22000" + environment: + FTP_USER: admin + FTP_PASS: admin + PASV_ADDRESS: 127.0.0.1 + PASV_MIN_PORT: 20000 + PASV_MAX_PORT: 22000 + volumes: + - vsftpd-data:/home/vsftpd + +volumes: + vsftpd-data: