diff --git a/.github/workflows/s3-digest-matrix.yml b/.github/workflows/s3-digest-matrix.yml new file mode 100644 index 0000000000..f11fff4836 --- /dev/null +++ b/.github/workflows/s3-digest-matrix.yml @@ -0,0 +1,220 @@ +name: "S3 digest and FIPS matrix" + +# Runs the S3 suites in every digest mode with both volume servers and JWT +# signing on, so the sha256 digest and GODEBUG=fips140=only stay working: +# md5 GODEBUG=fips140=off, the default digest +# sha256 GODEBUG=fips140=on with the filer's -digest=sha256 +# fips140only GODEBUG=fips140=only, built with GOFIPS140=v1.0.0 +# test/s3/digest_matrix/start_cluster.sh starts each cell's cluster. + +on: + push: + branches: [ master ] + paths: + - 'weed/s3api/**' + - 'weed/filer/**' + - 'weed/server/**' + - 'weed/operation/**' + - 'weed/storage/**' + - 'weed/security/**' + - 'weed/util/**' + - 'weed/command/**' + - 'weed/pb/**' + - 'seaweed-volume/**' + - 'seaweed-common/**' + - 'test/s3/digest_matrix/**' + - 'test/s3/compatibility/**' + - 'test/s3/etag/**' + - 'test/s3/checksum/**' + - 'docker/compose/s3.json' + - 'docker/compose/s3tests.conf' + - 'go.mod' + - 'go.sum' + - '.github/workflows/s3-digest-matrix.yml' + pull_request: + branches: [ master ] + paths: + - 'weed/s3api/**' + - 'weed/filer/**' + - 'weed/server/**' + - 'weed/operation/**' + - 'weed/storage/**' + - 'weed/security/**' + - 'weed/util/**' + - 'weed/command/**' + - 'weed/pb/**' + - 'seaweed-volume/**' + - 'seaweed-common/**' + - 'test/s3/digest_matrix/**' + - 'test/s3/compatibility/**' + - 'test/s3/etag/**' + - 'test/s3/checksum/**' + - 'docker/compose/s3.json' + - 'docker/compose/s3tests.conf' + - 'go.mod' + - 'go.sum' + - '.github/workflows/s3-digest-matrix.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.event_name == 'push' && github.ref) || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')) }} + +permissions: + contents: read + +jobs: + build: + name: Build weed (GOFIPS140) and weed-volume + runs-on: ubuntu-24.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v7 + + - uses: actions/setup-go@v7 + with: + go-version-file: 'go.mod' + cache: ${{ runner.environment == 'github-hosted' }} + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Fingerprint build toolchain + id: toolchain + run: echo "fingerprint=$(getconf GNU_LIBC_VERSION | tr ' ' '-')-rustc-$(rustc -V | awk '{print $2}')" >> "$GITHUB_OUTPUT" + + - name: Cache cargo registry and target + if: runner.environment == 'github-hosted' + uses: actions/cache@v6 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + seaweed-volume/target + key: rust-${{ steps.toolchain.outputs.fingerprint }}-${{ hashFiles('seaweed-volume/Cargo.lock', 'seaweed-common/Cargo.lock') }} + restore-keys: | + rust-${{ steps.toolchain.outputs.fingerprint }}- + + # GOFIPS140=v1.0.0 links the frozen Go Cryptographic Module, which the + # fips140only cells need; the other cells set GODEBUG to off or on. + - name: Build weed + run: | + cd weed + CGO_ENABLED=0 GOFIPS140=v1.0.0 go build -tags s3tests -buildvcs=false -o weed . + go version -m weed | grep GOFIPS140 + + - name: Build weed-volume + run: cd seaweed-volume && cargo build --release + + - name: Package binaries + run: tar cf digest-matrix-binaries.tar weed/weed seaweed-volume/target/release/weed-volume + + - uses: actions/upload-artifact@v7 + with: + name: digest-matrix-binaries + if-no-files-found: error + retention-days: 1 + path: digest-matrix-binaries.tar + + suites: + name: S3 suites (${{ matrix.digest }}, ${{ matrix.volume }} volume server) + needs: build + runs-on: ubuntu-24.04 + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + digest: [ md5, sha256, fips140only ] + volume: [ go, rust ] + # s3_digest names the ETag digest for the Go suites. ceph_deselect + # drops ceph tests whose answer the mode changes on purpose: + # test_object_write_check_etag expects MD5("bar") as the ETag, and + # under fips140=only SSE-C is refused with 501 before its headers are + # compared, so the SSE-C conflict tests get 501 where they expect 400. + include: + - digest: md5 + s3_digest: md5 + - digest: sha256 + s3_digest: sha256 + ceph_deselect: --deselect s3tests/functional/test_s3.py::test_object_write_check_etag + - digest: fips140only + s3_digest: sha256 + ceph_deselect: >- + --deselect s3tests/functional/test_s3.py::test_object_write_check_etag + --deselect s3tests/functional/test_s3.py::test_put_obj_enc_conflict_c_s3 + --deselect s3tests/functional/test_s3.py::test_put_obj_enc_conflict_c_kms + steps: + - uses: actions/checkout@v7 + + - uses: actions/setup-go@v7 + with: + go-version-file: 'go.mod' + cache: ${{ runner.environment == 'github-hosted' }} + + - uses: actions/setup-python@v7 + with: + python-version: '3.10' + + # The same s3-tests checkout and fixes as the "Ceph S3 tests" workflow. + - name: Clone s3-tests + run: | + git clone https://github.com/ceph/s3-tests.git + cd s3-tests + sudo apt-get update -qq + sudo apt-get install -y -qq libxml2-dev libxslt1-dev zlib1g-dev + python3 -m pip install -r requirements.txt + python3 -m pip install tox + python3 -m pip install -e . + cd .. + S3_TESTS_PATH=s3-tests python3 test/s3/compatibility/fix_s3_tests_bucket_conflicts.py + sed -i "s/assert prefixes == \['foo%2B1\/', 'foo\/', 'quux%20ab\/'\]/assert prefixes == \['foo\/', 'foo%2B1\/', 'quux%20ab\/'\]/" s3-tests/s3tests/functional/test_s3.py + sed -i "/# request PartNumber out of range/,+4{s/assert status == 400/assert status == 416/; s/assert error_code == 'InvalidPart'/assert error_code == 'InvalidPartNumber'/}" s3-tests/s3tests/functional/test_s3.py + + - uses: actions/download-artifact@v7 + with: + name: digest-matrix-binaries + + - name: Restore binaries + run: | + tar xf digest-matrix-binaries.tar + chmod +x weed/weed seaweed-volume/target/release/weed-volume + + - name: Start the cluster + env: + DIGEST_MODE: ${{ matrix.digest }} + VOLUME_SERVER: ${{ matrix.volume }} + WEED: ${{ github.workspace }}/weed/weed + WEED_VOLUME: ${{ github.workspace }}/seaweed-volume/target/release/weed-volume + WORK_DIR: /tmp/digest-matrix + S3_CONFIG: ${{ github.workspace }}/docker/compose/s3.json + run: bash test/s3/digest_matrix/start_cluster.sh + + - name: Run the basic ceph s3-tests + working-directory: s3-tests + env: + S3TEST_CONF: ${{ github.workspace }}/docker/compose/s3tests.conf + run: | + mapfile -t tests < <(grep -v '^[[:space:]]*#' "$GITHUB_WORKSPACE/test/s3/compatibility/s3tests_basic.txt") + # shellcheck disable=SC2086 # the deselect list is separate arguments + tox -- "${tests[@]}" ${{ matrix.ceph_deselect }} + + - name: Run the etag and checksum Go suites + env: + S3_ENDPOINT: http://127.0.0.1:8000 + S3_DIGEST: ${{ matrix.s3_digest }} + S3_FIPS140_ONLY: ${{ matrix.digest == 'fips140only' && '1' || '0' }} + S3_ACCESS_KEY: some_access_key1 + S3_SECRET_KEY: some_secret_key1 + run: go test -count=1 -timeout 10m ./test/s3/etag/ ./test/s3/checksum/ + + - name: Stop the cluster + if: always() + run: xargs kill < /tmp/digest-matrix/pids 2>/dev/null || true + + - name: Upload server logs on failure + if: failure() + uses: actions/upload-artifact@v7 + with: + name: digest-matrix-logs-${{ matrix.digest }}-${{ matrix.volume }} + path: /tmp/digest-matrix/*.log + retention-days: 3 + diff --git a/.github/workflows/s3tests.yml b/.github/workflows/s3tests.yml index 7c255cf6d6..65ac56e2eb 100644 --- a/.github/workflows/s3tests.yml +++ b/.github/workflows/s3tests.yml @@ -197,190 +197,9 @@ jobs: } trap cleanup EXIT - tox -- \ - s3tests/functional/test_s3.py::test_bucket_list_empty \ - s3tests/functional/test_s3.py::test_bucket_list_distinct \ - s3tests/functional/test_s3.py::test_bucket_list_many \ - s3tests/functional/test_s3.py::test_bucket_listv2_many \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_basic \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_basic \ - s3tests/functional/test_s3.py::test_bucket_listv2_encoding_basic \ - s3tests/functional/test_s3.py::test_bucket_list_encoding_basic \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_prefix \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_prefix \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_prefix_ends_with_delimiter \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_prefix_ends_with_delimiter \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_alt \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_alt \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_prefix_underscore \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_prefix_underscore \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_percentage \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_percentage \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_whitespace \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_whitespace \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_dot \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_dot \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_unreadable \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_unreadable \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_empty \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_empty \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_none \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_none \ - s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_not_exist \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_not_exist \ - s3tests/functional/test_s3.py::test_bucket_list_delimiter_not_skip_special \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_basic \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_basic \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_alt \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_alt \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_prefix_not_exist \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_prefix_not_exist \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_delimiter_not_exist \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_delimiter_not_exist \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_prefix_delimiter_not_exist \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_prefix_delimiter_not_exist \ - s3tests/functional/test_s3.py::test_bucket_listv2_fetchowner_notempty \ - s3tests/functional/test_s3.py::test_bucket_listv2_fetchowner_defaultempty \ - s3tests/functional/test_s3.py::test_bucket_listv2_fetchowner_empty \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_basic \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_basic \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_alt \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_alt \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_empty \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_empty \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_none \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_none \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_not_exist \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_not_exist \ - s3tests/functional/test_s3.py::test_bucket_list_prefix_unreadable \ - s3tests/functional/test_s3.py::test_bucket_listv2_prefix_unreadable \ - s3tests/functional/test_s3.py::test_bucket_list_maxkeys_one \ - s3tests/functional/test_s3.py::test_bucket_listv2_maxkeys_one \ - s3tests/functional/test_s3.py::test_bucket_list_maxkeys_zero \ - s3tests/functional/test_s3.py::test_bucket_listv2_maxkeys_zero \ - s3tests/functional/test_s3.py::test_bucket_list_maxkeys_none \ - s3tests/functional/test_s3.py::test_bucket_listv2_maxkeys_none \ - s3tests/functional/test_s3.py::test_bucket_list_unordered \ - s3tests/functional/test_s3.py::test_bucket_listv2_unordered \ - s3tests/functional/test_s3.py::test_bucket_list_maxkeys_invalid \ - s3tests/functional/test_s3.py::test_bucket_list_marker_none \ - s3tests/functional/test_s3.py::test_bucket_list_marker_empty \ - s3tests/functional/test_s3.py::test_bucket_listv2_continuationtoken_empty \ - s3tests/functional/test_s3.py::test_bucket_listv2_continuationtoken \ - s3tests/functional/test_s3.py::test_bucket_listv2_both_continuationtoken_startafter \ - s3tests/functional/test_s3.py::test_bucket_list_marker_unreadable \ - s3tests/functional/test_s3.py::test_bucket_listv2_startafter_unreadable \ - s3tests/functional/test_s3.py::test_bucket_list_marker_not_in_list \ - s3tests/functional/test_s3.py::test_bucket_listv2_startafter_not_in_list \ - s3tests/functional/test_s3.py::test_bucket_list_marker_after_list \ - s3tests/functional/test_s3.py::test_bucket_listv2_startafter_after_list \ - s3tests/functional/test_s3.py::test_bucket_list_return_data \ - s3tests/functional/test_s3.py::test_bucket_list_objects_anonymous \ - s3tests/functional/test_s3.py::test_bucket_listv2_objects_anonymous \ - s3tests/functional/test_s3.py::test_bucket_list_objects_anonymous_fail \ - s3tests/functional/test_s3.py::test_bucket_listv2_objects_anonymous_fail \ - s3tests/functional/test_s3.py::test_bucket_list_long_name \ - s3tests/functional/test_s3.py::test_bucket_list_special_prefix \ - s3tests/functional/test_s3.py::test_bucket_delete_notexist \ - s3tests/functional/test_s3.py::test_bucket_create_delete \ - s3tests/functional/test_s3.py::test_object_read_not_exist \ - s3tests/functional/test_s3.py::test_multi_object_delete \ - s3tests/functional/test_s3.py::test_multi_objectv2_delete \ - s3tests/functional/test_s3.py::test_object_head_zero_bytes \ - s3tests/functional/test_s3.py::test_object_write_check_etag \ - s3tests/functional/test_s3.py::test_object_write_cache_control \ - s3tests/functional/test_s3.py::test_object_write_expires \ - s3tests/functional/test_s3.py::test_put_obj_enc_conflict_c_s3 \ - s3tests/functional/test_s3.py::test_put_obj_enc_conflict_c_kms \ - s3tests/functional/test_s3.py::test_put_obj_enc_conflict_s3_kms \ - s3tests/functional/test_s3.py::test_put_obj_enc_conflict_bad_enc_kms \ - s3tests/functional/test_s3.py::test_object_content_encoding_aws_chunked \ - s3tests/functional/test_s3.py::test_object_write_read_update_read_delete \ - s3tests/functional/test_s3.py::test_object_metadata_replaced_on_put \ - s3tests/functional/test_s3.py::test_object_write_file \ - s3tests/functional/test_s3.py::test_post_object_invalid_date_format \ - s3tests/functional/test_s3.py::test_post_object_no_key_specified \ - s3tests/functional/test_s3.py::test_post_object_missing_signature \ - s3tests/functional/test_s3.py::test_post_object_condition_is_case_sensitive \ - s3tests/functional/test_s3.py::test_post_object_expires_is_case_sensitive \ - s3tests/functional/test_s3.py::test_post_object_missing_expires_condition \ - s3tests/functional/test_s3.py::test_post_object_missing_conditions_list \ - s3tests/functional/test_s3.py::test_post_object_upload_size_limit_exceeded \ - s3tests/functional/test_s3.py::test_post_object_missing_content_length_argument \ - s3tests/functional/test_s3.py::test_post_object_invalid_content_length_argument \ - s3tests/functional/test_s3.py::test_post_object_upload_size_below_minimum \ - s3tests/functional/test_s3.py::test_post_object_empty_conditions \ - s3tests/functional/test_s3.py::test_get_object_ifmatch_good \ - s3tests/functional/test_s3.py::test_get_object_ifnonematch_good \ - s3tests/functional/test_s3.py::test_get_object_ifmatch_failed \ - s3tests/functional/test_s3.py::test_get_object_ifnonematch_failed \ - s3tests/functional/test_s3.py::test_get_object_ifmodifiedsince_good \ - s3tests/functional/test_s3.py::test_get_object_ifmodifiedsince_failed \ - s3tests/functional/test_s3.py::test_get_object_ifunmodifiedsince_failed \ - s3tests/functional/test_s3.py::test_get_checksum_object_attributes \ - s3tests/functional/test_s3.py::test_bucket_head \ - s3tests/functional/test_s3.py::test_bucket_head_notexist \ - s3tests/functional/test_s3.py::test_object_raw_authenticated \ - s3tests/functional/test_s3.py::test_object_raw_authenticated_bucket_acl \ - s3tests/functional/test_s3.py::test_object_raw_authenticated_object_acl \ - s3tests/functional/test_s3.py::test_object_raw_authenticated_object_gone \ - s3tests/functional/test_s3.py::test_object_raw_get_x_amz_expires_out_range_zero \ - s3tests/functional/test_s3.py::test_object_anon_put \ - s3tests/functional/test_s3.py::test_object_put_authenticated \ - s3tests/functional/test_s3.py::test_bucket_recreate_overwrite_acl \ - s3tests/functional/test_s3.py::test_bucket_recreate_new_acl \ - s3tests/functional/test_s3.py::test_buckets_create_then_list \ - s3tests/functional/test_s3.py::test_buckets_list_ctime \ - s3tests/functional/test_s3.py::test_list_buckets_invalid_auth \ - s3tests/functional/test_s3.py::test_list_buckets_bad_auth \ - s3tests/functional/test_s3.py::test_bucket_create_naming_good_contains_period \ - s3tests/functional/test_s3.py::test_bucket_create_naming_good_contains_hyphen \ - s3tests/functional/test_s3.py::test_bucket_list_special_prefix \ - s3tests/functional/test_s3.py::test_object_copy_zero_size \ - s3tests/functional/test_s3.py::test_object_copy_same_bucket \ - s3tests/functional/test_s3.py::test_object_copy_to_itself \ - s3tests/functional/test_s3.py::test_object_copy_diff_bucket \ - s3tests/functional/test_s3.py::test_object_copy_canned_acl \ - s3tests/functional/test_s3.py::test_object_copy_bucket_not_found \ - s3tests/functional/test_s3.py::test_object_copy_key_not_found \ - s3tests/functional/test_s3.py::test_multipart_copy_small \ - s3tests/functional/test_s3.py::test_multipart_copy_without_range \ - s3tests/functional/test_s3.py::test_multipart_copy_special_names \ - s3tests/functional/test_s3.py::test_multipart_copy_multiple_sizes \ - s3tests/functional/test_s3.py::test_multipart_get_part \ - s3tests/functional/test_s3.py::test_multipart_upload \ - s3tests/functional/test_s3.py::test_multipart_upload_empty \ - s3tests/functional/test_s3.py::test_multipart_upload_multiple_sizes \ - s3tests/functional/test_s3.py::test_multipart_upload_contents \ - s3tests/functional/test_s3.py::test_multipart_upload_overwrite_existing_object \ - s3tests/functional/test_s3.py::test_multipart_upload_size_too_small \ - s3tests/functional/test_s3.py::test_multipart_resend_first_finishes_last \ - s3tests/functional/test_s3.py::test_multipart_upload_resend_part \ - s3tests/functional/test_s3.py::test_multipart_upload_missing_part \ - s3tests/functional/test_s3.py::test_multipart_upload_incorrect_etag \ - s3tests/functional/test_s3.py::test_abort_multipart_upload \ - s3tests/functional/test_s3.py::test_list_multipart_upload \ - s3tests/functional/test_s3.py::test_atomic_read_1mb \ - s3tests/functional/test_s3.py::test_atomic_read_4mb \ - s3tests/functional/test_s3.py::test_atomic_read_8mb \ - s3tests/functional/test_s3.py::test_atomic_write_1mb \ - s3tests/functional/test_s3.py::test_atomic_write_4mb \ - s3tests/functional/test_s3.py::test_atomic_write_8mb \ - s3tests/functional/test_s3.py::test_atomic_dual_write_1mb \ - s3tests/functional/test_s3.py::test_atomic_dual_write_4mb \ - s3tests/functional/test_s3.py::test_atomic_dual_write_8mb \ - s3tests/functional/test_s3.py::test_atomic_multipart_upload_write \ - s3tests/functional/test_s3.py::test_ranged_request_response_code \ - s3tests/functional/test_s3.py::test_ranged_big_request_response_code \ - s3tests/functional/test_s3.py::test_ranged_request_skip_leading_bytes_response_code \ - s3tests/functional/test_s3.py::test_ranged_request_return_trailing_bytes_response_code \ - s3tests/functional/test_s3.py::test_copy_object_ifmatch_good \ - s3tests/functional/test_s3.py::test_copy_object_ifnonematch_failed \ - s3tests/functional/test_s3.py::test_copy_object_ifmatch_failed \ - s3tests/functional/test_s3.py::test_copy_object_ifnonematch_good \ - s3tests/functional/test_s3.py::test_lifecycle_set \ - s3tests/functional/test_s3.py::test_lifecycle_get \ - s3tests/functional/test_s3.py::test_lifecycle_set_filter + # test/s3/compatibility/s3tests_basic.txt is shared with s3-digest-matrix.yml. + mapfile -t basic_tests < <(grep -v '^[[:space:]]*#' "$GITHUB_WORKSPACE/test/s3/compatibility/s3tests_basic.txt") + tox -- "${basic_tests[@]}" # The expiration tests race the lifecycle worker's meta-log replay; # under the suite's write flood a shard can trail an object's PUT diff --git a/test/s3/checksum/s3_checksum_multipart_test.go b/test/s3/checksum/s3_checksum_multipart_test.go index a09af198a0..671671d879 100644 --- a/test/s3/checksum/s3_checksum_multipart_test.go +++ b/test/s3/checksum/s3_checksum_multipart_test.go @@ -7,6 +7,7 @@ import ( "net/http/httptest" "net/http/httputil" "net/url" + "os" "strings" "testing" @@ -18,6 +19,15 @@ import ( "github.com/stretchr/testify/require" ) +// skipIfRefusedUnderFIPS140Only skips a case for a checksum algorithm the +// server refuses when S3_FIPS140_ONLY=1 says it runs under GODEBUG=fips140=only: +// SHA-1 is not an approved algorithm there, so SHA-1 checksums get NotImplemented. +func skipIfRefusedUnderFIPS140Only(t *testing.T, algorithm types.ChecksumAlgorithm) { + if os.Getenv("S3_FIPS140_ONLY") == "1" && algorithm == types.ChecksumAlgorithmSha1 { + t.Skip("SHA-1 checksums are refused under fips140=only") + } +} + // newTrailerChecksumClient returns a client that can send flexible checksums. // aws-sdk-go-v2 sends them as unsigned streaming trailers, which it refuses over // plain HTTP, so front the HTTP endpoint with a TLS proxy. @@ -91,6 +101,7 @@ func TestMultipartCopyPreservesChecksum(t *testing.T) { for _, tc := range cases { t.Run(string(tc.algorithm), func(t *testing.T) { + skipIfRefusedUnderFIPS140Only(t, tc.algorithm) sourceKey := "source-" + string(tc.algorithm) source, err := client.PutObject(context.Background(), &s3.PutObjectInput{ Bucket: aws.String(bucket), @@ -196,6 +207,7 @@ func TestMultipartUploadReturnsObjectChecksum(t *testing.T) { for _, tc := range cases { t.Run(string(tc.algorithm), func(t *testing.T) { + skipIfRefusedUnderFIPS140Only(t, tc.algorithm) key := "multipart-" + string(tc.algorithm) create, err := client.CreateMultipartUpload(context.Background(), &s3.CreateMultipartUploadInput{ Bucket: aws.String(bucket), diff --git a/test/s3/compatibility/s3tests_basic.txt b/test/s3/compatibility/s3tests_basic.txt new file mode 100644 index 0000000000..3d08ea43ca --- /dev/null +++ b/test/s3/compatibility/s3tests_basic.txt @@ -0,0 +1,185 @@ +# The ceph s3-tests the "Basic S3 tests" job of s3tests.yml runs, also run by +# every cell of s3-digest-matrix.yml. One test per line; lines starting with # +# are skipped. +s3tests/functional/test_s3.py::test_bucket_list_empty +s3tests/functional/test_s3.py::test_bucket_list_distinct +s3tests/functional/test_s3.py::test_bucket_list_many +s3tests/functional/test_s3.py::test_bucket_listv2_many +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_basic +s3tests/functional/test_s3.py::test_bucket_list_delimiter_basic +s3tests/functional/test_s3.py::test_bucket_listv2_encoding_basic +s3tests/functional/test_s3.py::test_bucket_list_encoding_basic +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_prefix +s3tests/functional/test_s3.py::test_bucket_list_delimiter_prefix +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_prefix_ends_with_delimiter +s3tests/functional/test_s3.py::test_bucket_list_delimiter_prefix_ends_with_delimiter +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_alt +s3tests/functional/test_s3.py::test_bucket_list_delimiter_alt +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_prefix_underscore +s3tests/functional/test_s3.py::test_bucket_list_delimiter_prefix_underscore +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_percentage +s3tests/functional/test_s3.py::test_bucket_list_delimiter_percentage +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_whitespace +s3tests/functional/test_s3.py::test_bucket_list_delimiter_whitespace +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_dot +s3tests/functional/test_s3.py::test_bucket_list_delimiter_dot +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_unreadable +s3tests/functional/test_s3.py::test_bucket_list_delimiter_unreadable +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_empty +s3tests/functional/test_s3.py::test_bucket_list_delimiter_empty +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_none +s3tests/functional/test_s3.py::test_bucket_list_delimiter_none +s3tests/functional/test_s3.py::test_bucket_listv2_delimiter_not_exist +s3tests/functional/test_s3.py::test_bucket_list_delimiter_not_exist +s3tests/functional/test_s3.py::test_bucket_list_delimiter_not_skip_special +s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_basic +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_basic +s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_alt +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_alt +s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_prefix_not_exist +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_prefix_not_exist +s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_delimiter_not_exist +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_delimiter_not_exist +s3tests/functional/test_s3.py::test_bucket_list_prefix_delimiter_prefix_delimiter_not_exist +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_delimiter_prefix_delimiter_not_exist +s3tests/functional/test_s3.py::test_bucket_listv2_fetchowner_notempty +s3tests/functional/test_s3.py::test_bucket_listv2_fetchowner_defaultempty +s3tests/functional/test_s3.py::test_bucket_listv2_fetchowner_empty +s3tests/functional/test_s3.py::test_bucket_list_prefix_basic +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_basic +s3tests/functional/test_s3.py::test_bucket_list_prefix_alt +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_alt +s3tests/functional/test_s3.py::test_bucket_list_prefix_empty +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_empty +s3tests/functional/test_s3.py::test_bucket_list_prefix_none +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_none +s3tests/functional/test_s3.py::test_bucket_list_prefix_not_exist +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_not_exist +s3tests/functional/test_s3.py::test_bucket_list_prefix_unreadable +s3tests/functional/test_s3.py::test_bucket_listv2_prefix_unreadable +s3tests/functional/test_s3.py::test_bucket_list_maxkeys_one +s3tests/functional/test_s3.py::test_bucket_listv2_maxkeys_one +s3tests/functional/test_s3.py::test_bucket_list_maxkeys_zero +s3tests/functional/test_s3.py::test_bucket_listv2_maxkeys_zero +s3tests/functional/test_s3.py::test_bucket_list_maxkeys_none +s3tests/functional/test_s3.py::test_bucket_listv2_maxkeys_none +s3tests/functional/test_s3.py::test_bucket_list_unordered +s3tests/functional/test_s3.py::test_bucket_listv2_unordered +s3tests/functional/test_s3.py::test_bucket_list_maxkeys_invalid +s3tests/functional/test_s3.py::test_bucket_list_marker_none +s3tests/functional/test_s3.py::test_bucket_list_marker_empty +s3tests/functional/test_s3.py::test_bucket_listv2_continuationtoken_empty +s3tests/functional/test_s3.py::test_bucket_listv2_continuationtoken +s3tests/functional/test_s3.py::test_bucket_listv2_both_continuationtoken_startafter +s3tests/functional/test_s3.py::test_bucket_list_marker_unreadable +s3tests/functional/test_s3.py::test_bucket_listv2_startafter_unreadable +s3tests/functional/test_s3.py::test_bucket_list_marker_not_in_list +s3tests/functional/test_s3.py::test_bucket_listv2_startafter_not_in_list +s3tests/functional/test_s3.py::test_bucket_list_marker_after_list +s3tests/functional/test_s3.py::test_bucket_listv2_startafter_after_list +s3tests/functional/test_s3.py::test_bucket_list_return_data +s3tests/functional/test_s3.py::test_bucket_list_objects_anonymous +s3tests/functional/test_s3.py::test_bucket_listv2_objects_anonymous +s3tests/functional/test_s3.py::test_bucket_list_objects_anonymous_fail +s3tests/functional/test_s3.py::test_bucket_listv2_objects_anonymous_fail +s3tests/functional/test_s3.py::test_bucket_list_long_name +s3tests/functional/test_s3.py::test_bucket_list_special_prefix +s3tests/functional/test_s3.py::test_bucket_delete_notexist +s3tests/functional/test_s3.py::test_bucket_create_delete +s3tests/functional/test_s3.py::test_object_read_not_exist +s3tests/functional/test_s3.py::test_multi_object_delete +s3tests/functional/test_s3.py::test_multi_objectv2_delete +s3tests/functional/test_s3.py::test_object_head_zero_bytes +s3tests/functional/test_s3.py::test_object_write_check_etag +s3tests/functional/test_s3.py::test_object_write_cache_control +s3tests/functional/test_s3.py::test_object_write_expires +s3tests/functional/test_s3.py::test_put_obj_enc_conflict_c_s3 +s3tests/functional/test_s3.py::test_put_obj_enc_conflict_c_kms +s3tests/functional/test_s3.py::test_put_obj_enc_conflict_s3_kms +s3tests/functional/test_s3.py::test_put_obj_enc_conflict_bad_enc_kms +s3tests/functional/test_s3.py::test_object_content_encoding_aws_chunked +s3tests/functional/test_s3.py::test_object_write_read_update_read_delete +s3tests/functional/test_s3.py::test_object_metadata_replaced_on_put +s3tests/functional/test_s3.py::test_object_write_file +s3tests/functional/test_s3.py::test_post_object_invalid_date_format +s3tests/functional/test_s3.py::test_post_object_no_key_specified +s3tests/functional/test_s3.py::test_post_object_missing_signature +s3tests/functional/test_s3.py::test_post_object_condition_is_case_sensitive +s3tests/functional/test_s3.py::test_post_object_expires_is_case_sensitive +s3tests/functional/test_s3.py::test_post_object_missing_expires_condition +s3tests/functional/test_s3.py::test_post_object_missing_conditions_list +s3tests/functional/test_s3.py::test_post_object_upload_size_limit_exceeded +s3tests/functional/test_s3.py::test_post_object_missing_content_length_argument +s3tests/functional/test_s3.py::test_post_object_invalid_content_length_argument +s3tests/functional/test_s3.py::test_post_object_upload_size_below_minimum +s3tests/functional/test_s3.py::test_post_object_empty_conditions +s3tests/functional/test_s3.py::test_get_object_ifmatch_good +s3tests/functional/test_s3.py::test_get_object_ifnonematch_good +s3tests/functional/test_s3.py::test_get_object_ifmatch_failed +s3tests/functional/test_s3.py::test_get_object_ifnonematch_failed +s3tests/functional/test_s3.py::test_get_object_ifmodifiedsince_good +s3tests/functional/test_s3.py::test_get_object_ifmodifiedsince_failed +s3tests/functional/test_s3.py::test_get_object_ifunmodifiedsince_failed +s3tests/functional/test_s3.py::test_get_checksum_object_attributes +s3tests/functional/test_s3.py::test_bucket_head +s3tests/functional/test_s3.py::test_bucket_head_notexist +s3tests/functional/test_s3.py::test_object_raw_authenticated +s3tests/functional/test_s3.py::test_object_raw_authenticated_bucket_acl +s3tests/functional/test_s3.py::test_object_raw_authenticated_object_acl +s3tests/functional/test_s3.py::test_object_raw_authenticated_object_gone +s3tests/functional/test_s3.py::test_object_raw_get_x_amz_expires_out_range_zero +s3tests/functional/test_s3.py::test_object_anon_put +s3tests/functional/test_s3.py::test_object_put_authenticated +s3tests/functional/test_s3.py::test_bucket_recreate_overwrite_acl +s3tests/functional/test_s3.py::test_bucket_recreate_new_acl +s3tests/functional/test_s3.py::test_buckets_create_then_list +s3tests/functional/test_s3.py::test_buckets_list_ctime +s3tests/functional/test_s3.py::test_list_buckets_invalid_auth +s3tests/functional/test_s3.py::test_list_buckets_bad_auth +s3tests/functional/test_s3.py::test_bucket_create_naming_good_contains_period +s3tests/functional/test_s3.py::test_bucket_create_naming_good_contains_hyphen +s3tests/functional/test_s3.py::test_object_copy_zero_size +s3tests/functional/test_s3.py::test_object_copy_same_bucket +s3tests/functional/test_s3.py::test_object_copy_to_itself +s3tests/functional/test_s3.py::test_object_copy_diff_bucket +s3tests/functional/test_s3.py::test_object_copy_canned_acl +s3tests/functional/test_s3.py::test_object_copy_bucket_not_found +s3tests/functional/test_s3.py::test_object_copy_key_not_found +s3tests/functional/test_s3.py::test_multipart_copy_small +s3tests/functional/test_s3.py::test_multipart_copy_without_range +s3tests/functional/test_s3.py::test_multipart_copy_special_names +s3tests/functional/test_s3.py::test_multipart_copy_multiple_sizes +s3tests/functional/test_s3.py::test_multipart_get_part +s3tests/functional/test_s3.py::test_multipart_upload +s3tests/functional/test_s3.py::test_multipart_upload_empty +s3tests/functional/test_s3.py::test_multipart_upload_multiple_sizes +s3tests/functional/test_s3.py::test_multipart_upload_contents +s3tests/functional/test_s3.py::test_multipart_upload_overwrite_existing_object +s3tests/functional/test_s3.py::test_multipart_upload_size_too_small +s3tests/functional/test_s3.py::test_multipart_resend_first_finishes_last +s3tests/functional/test_s3.py::test_multipart_upload_resend_part +s3tests/functional/test_s3.py::test_multipart_upload_missing_part +s3tests/functional/test_s3.py::test_multipart_upload_incorrect_etag +s3tests/functional/test_s3.py::test_abort_multipart_upload +s3tests/functional/test_s3.py::test_list_multipart_upload +s3tests/functional/test_s3.py::test_atomic_read_1mb +s3tests/functional/test_s3.py::test_atomic_read_4mb +s3tests/functional/test_s3.py::test_atomic_read_8mb +s3tests/functional/test_s3.py::test_atomic_write_1mb +s3tests/functional/test_s3.py::test_atomic_write_4mb +s3tests/functional/test_s3.py::test_atomic_write_8mb +s3tests/functional/test_s3.py::test_atomic_dual_write_1mb +s3tests/functional/test_s3.py::test_atomic_dual_write_4mb +s3tests/functional/test_s3.py::test_atomic_dual_write_8mb +s3tests/functional/test_s3.py::test_atomic_multipart_upload_write +s3tests/functional/test_s3.py::test_ranged_request_response_code +s3tests/functional/test_s3.py::test_ranged_big_request_response_code +s3tests/functional/test_s3.py::test_ranged_request_skip_leading_bytes_response_code +s3tests/functional/test_s3.py::test_ranged_request_return_trailing_bytes_response_code +s3tests/functional/test_s3.py::test_copy_object_ifmatch_good +s3tests/functional/test_s3.py::test_copy_object_ifnonematch_failed +s3tests/functional/test_s3.py::test_copy_object_ifmatch_failed +s3tests/functional/test_s3.py::test_copy_object_ifnonematch_good +s3tests/functional/test_s3.py::test_lifecycle_set +s3tests/functional/test_s3.py::test_lifecycle_get +s3tests/functional/test_s3.py::test_lifecycle_set_filter diff --git a/test/s3/digest_matrix/start_cluster.sh b/test/s3/digest_matrix/start_cluster.sh new file mode 100755 index 0000000000..61ac2f36be --- /dev/null +++ b/test/s3/digest_matrix/start_cluster.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +# Starts a single-node SeaweedFS cluster for one cell of the digest matrix and +# waits until the master can assign a file id. The process ids go to +# $WORK_DIR/pids, so `xargs kill < "$WORK_DIR/pids"` stops the cell. +# +# DIGEST_MODE md5 (GODEBUG=fips140=off), sha256 (fips140=on with the +# filer's -digest=sha256) or fips140only (GODEBUG=fips140=only) +# VOLUME_SERVER go (weed server's own volume server) or rust (weed-volume) +# WEED, WEED_VOLUME, WORK_DIR, S3_CONFIG binaries, scratch dir, identities +# +# security.toml enables JWT signing for the volume servers, so every chunk +# write and read in the cell goes through a volume server's JWT check. +set -euo pipefail + +: "${DIGEST_MODE:?md5, sha256 or fips140only}" +: "${VOLUME_SERVER:?go or rust}" +: "${S3_CONFIG:?path to the S3 identities file}" +WEED=${WEED:-weed} +WEED_VOLUME=${WEED_VOLUME:-weed-volume} +WORK_DIR=${WORK_DIR:-/tmp/seaweedfs-digest-matrix} + +case "$DIGEST_MODE" in + md5) export GODEBUG=fips140=off; digest_flag=() ;; + sha256) export GODEBUG=fips140=on; digest_flag=(-filer.digest=sha256) ;; + fips140only) export GODEBUG=fips140=only; digest_flag=() ;; + *) echo "unknown DIGEST_MODE $DIGEST_MODE" >&2; exit 2 ;; +esac +case "$VOLUME_SERVER" in + go) volume_flags=(-volume.port=8080 -volume.max=100 -volume.preStopSeconds=1) ;; + rust) volume_flags=(-volume=false) ;; + *) echo "unknown VOLUME_SERVER $VOLUME_SERVER" >&2; exit 2 ;; +esac + +rm -rf "$WORK_DIR" +mkdir -p "$WORK_DIR/conf" "$WORK_DIR/data" "$WORK_DIR/volume" +cat > "$WORK_DIR/conf/security.toml" < "$WORK_DIR/weed.log" 2>&1 & +echo "$!" > "$WORK_DIR/pids" + +if [ "$VOLUME_SERVER" = rust ]; then + env "${unset_inputs[@]}" "$WEED_VOLUME" --port 8080 --port.grpc 18080 --ip 127.0.0.1 --ip.bind 0.0.0.0 \ + --dir "$WORK_DIR/volume" --max 100 --master 127.0.0.1:9333 \ + --securityFile "$WORK_DIR/conf/security.toml" --preStopSeconds 1 \ + > "$WORK_DIR/volume.log" 2>&1 & + echo "$!" >> "$WORK_DIR/pids" +fi + +for _ in $(seq 1 60); do + if curl -sf "http://127.0.0.1:9333/dir/assign" | grep -q '"fid"' \ + && curl -sf -o /dev/null "http://127.0.0.1:8888/" \ + && curl -s -o /dev/null "http://127.0.0.1:8000/"; then + echo "cluster ready: DIGEST_MODE=$DIGEST_MODE VOLUME_SERVER=$VOLUME_SERVER" + exit 0 + fi + sleep 2 +done +echo "cluster did not become ready" >&2 +tail -50 "$WORK_DIR/weed.log" >&2 || true +[ -f "$WORK_DIR/volume.log" ] && tail -50 "$WORK_DIR/volume.log" >&2 +exit 1 diff --git a/test/s3/etag/s3_etag_test.go b/test/s3/etag/s3_etag_test.go index 5643afc186..28a3af146b 100644 --- a/test/s3/etag/s3_etag_test.go +++ b/test/s3/etag/s3_etag_test.go @@ -19,7 +19,6 @@ package etag_test import ( "bytes" "context" - "crypto/md5" "crypto/rand" "encoding/hex" "fmt" @@ -38,6 +37,8 @@ import ( "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/seaweedfs/seaweedfs/weed/util" ) // S3TestConfig holds configuration for S3 tests @@ -131,10 +132,18 @@ func generateRandomData(size int) []byte { return data } -// calculateMD5 calculates the MD5 hash of data and returns hex string -func calculateMD5(data []byte) string { - hash := md5.Sum(data) - return hex.EncodeToString(hash[:]) +// digestOf returns the digest the server stores and puts in ETags for data: +// MD5, or SHA-256 cut to MD5's size when S3_DIGEST=sha256 names the digest of +// the cluster under test (a filer run with -digest=sha256 or fips140=only). +func digestOf(data []byte) []byte { + h := util.NewMd5For(os.Getenv("S3_DIGEST")) + h.Write(data) + return h.Sum(nil) +} + +// digestHex is digestOf as the hex string a single-part ETag carries. +func digestHex(data []byte) string { + return hex.EncodeToString(digestOf(data)) } // cleanETag removes quotes from ETag @@ -215,7 +224,7 @@ func TestPutObjectETagFormat_SmallFile(t *testing.T) { defer cleanupTestBucket(ctx, client, bucketName) testData := generateRandomData(smallFileSize) - expectedMD5 := calculateMD5(testData) + expectedMD5 := digestHex(testData) objectKey := "small-file.bin" // Upload small file @@ -250,7 +259,7 @@ func TestPutObjectETagFormat_LargeFile(t *testing.T) { defer cleanupTestBucket(ctx, client, bucketName) testData := generateRandomData(largeFileSize) - expectedMD5 := calculateMD5(testData) + expectedMD5 := digestHex(testData) objectKey := "large-file.bin" t.Logf("Uploading large file (%d bytes, > %d byte auto-chunk threshold)...", @@ -302,7 +311,7 @@ func TestPutObjectETagFormat_ExtraLargeFile(t *testing.T) { defer cleanupTestBucket(ctx, client, bucketName) testData := generateRandomData(xlFileSize) - expectedMD5 := calculateMD5(testData) + expectedMD5 := digestHex(testData) objectKey := "xl-file.bin" expectedChunks := (xlFileSize / autoChunkSize) + 1 @@ -429,11 +438,8 @@ func TestMultipartUploadETagVerification(t *testing.T) { objectKey := "verify-etag-multipart.bin" // Pre-calculate expected ETag - md1 := md5.Sum(data1) - md2 := md5.Sum(data2) - concatenatedMD5s := append(md1[:], md2[:]...) - finalMD5 := md5.Sum(concatenatedMD5s) - expectedETagValue := fmt.Sprintf("%x-2", finalMD5) + concatenatedMD5s := append(digestOf(data1), digestOf(data2)...) + expectedETagValue := fmt.Sprintf("%x-2", digestOf(concatenatedMD5s)) t.Logf("Expected multipart ETag: %s", expectedETagValue) @@ -454,7 +460,7 @@ func TestMultipartUploadETagVerification(t *testing.T) { Body: bytes.NewReader(data1), }) require.NoError(t, err) - assert.Equal(t, "\""+calculateMD5(data1)+"\"", aws.ToString(putPart1.ETag)) + assert.Equal(t, "\""+digestHex(data1)+"\"", aws.ToString(putPart1.ETag)) // 3. UploadPart 2 putPart2, err := client.UploadPart(ctx, &s3.UploadPartInput{ @@ -465,7 +471,7 @@ func TestMultipartUploadETagVerification(t *testing.T) { Body: bytes.NewReader(data2), }) require.NoError(t, err) - assert.Equal(t, "\""+calculateMD5(data2)+"\"", aws.ToString(putPart2.ETag)) + assert.Equal(t, "\""+digestHex(data2)+"\"", aws.ToString(putPart2.ETag)) // 4. CompleteMultipartUpload completeResp, err := client.CompleteMultipartUpload(ctx, &s3.CompleteMultipartUploadInput{ @@ -619,7 +625,7 @@ func TestMultipleLargeFileUploads(t *testing.T) { numFiles := 5 for i := 0; i < numFiles; i++ { testData := generateRandomData(largeFileSize) - expectedMD5 := calculateMD5(testData) + expectedMD5 := digestHex(testData) objectKey := fmt.Sprintf("large-file-%d.bin", i) putResp, err := client.PutObject(ctx, &s3.PutObjectInput{