-
Notifications
You must be signed in to change notification settings - Fork 721
feat(bindings/dotnet): Bindings dotnet implement #7238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Fatorin
wants to merge
11
commits into
apache:main
Choose a base branch
from
Fatorin:bindings-dotnet-implement
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ea0044b
feat(bindings/dotnet): Implement operator safety and expection handle
Fatorin 4ba6425
feat(bindings/dotnet): implement Operator bindings
Fatorin 405919a
feat(bindings/dotnet): complete .NET bindings with README and behavio…
Fatorin cf71398
fix(bindings/dotnet): losing license header
Fatorin f0aa6bb
fix(bindings/dotnet): rust code format
Fatorin b31004a
fix(bindings/dotnet): fix behavior tests by updating scripts and Carg…
Fatorin 80726cf
fix(bindings/dotnet): enhance BehaviorTestBase with lock management f…
Fatorin a37ef4e
feat(bindings/dotnet): refactor behavior tests to use BehaviorOperato…
Fatorin b8e766f
refactor(bindings/dotnet): consolidate tests and simplify CI test com…
Fatorin 26ab291
fix(bindings/dotnet): add dedicated operator info tests to avoid serv…
Fatorin 025a764
fix(bindings/dotnet): fix append/list-limit behavior tests
Fatorin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # 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: Test Binding Dotnet | ||
| description: 'Test Dotnet binding with given setup and service' | ||
| inputs: | ||
| setup: | ||
| description: "The setup action for test" | ||
| service: | ||
| description: "The service to test" | ||
| feature: | ||
| description: "The feature to test" | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Setup | ||
| shell: bash | ||
| run: | | ||
| mkdir -p ./dynamic_test_binding_dotnet && | ||
| cat <<EOF >./dynamic_test_binding_dotnet/action.yml | ||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Setup Test | ||
| uses: ./.github/services/${{ inputs.service }}/${{ inputs.setup }} | ||
| - name: Run Test Binding Dotnet | ||
| shell: bash | ||
| working-directory: bindings/dotnet | ||
| run: | | ||
| cargo build | ||
| dotnet test --filter "FullyQualifiedName~Behavior" -f net10.0 --logger "console;verbosity=normal" | ||
| env: | ||
| OPENDAL_TEST: ${{ inputs.service }} | ||
| EOF | ||
| - name: Run | ||
| uses: ./dynamic_test_binding_dotnet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # 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: Behavior Test Binding Dotnet | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| os: | ||
| required: true | ||
| type: string | ||
| cases: | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| test: | ||
| name: ${{ matrix.cases.service }} / ${{ matrix.cases.setup }} | ||
| runs-on: ${{ inputs.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| cases: ${{ fromJson(inputs.cases) }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Setup dotnet toolchain | ||
| uses: actions/setup-dotnet@v5 | ||
| with: | ||
| dotnet-version: '10.0.x' | ||
| - name: Setup Rust toolchain | ||
| uses: ./.github/actions/setup | ||
| with: | ||
| need-nextest: true | ||
| need-protoc: true | ||
| need-rocksdb: true | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Setup 1Password Connect | ||
| uses: 1password/load-secrets-action/configure@v3 | ||
| with: | ||
| connect-host: ${{ secrets.OP_CONNECT_HOST }} | ||
| connect-token: ${{ secrets.OP_CONNECT_TOKEN }} | ||
|
|
||
| - name: Test Core | ||
| uses: ./.github/actions/test_behavior_binding_dotnet | ||
| with: | ||
| setup: ${{ matrix.cases.setup }} | ||
| service: ${{ matrix.cases.service }} | ||
| feature: ${{ matrix.cases.feature }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
bindings/dotnet/DotOpenDAL.Tests/Behavior/BehaviorOperatorFixture.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| using System.Collections; | ||
|
|
||
| namespace DotOpenDAL.Tests; | ||
|
|
||
| public sealed class BehaviorOperatorFixture : IDisposable | ||
| { | ||
| private readonly Operator? op; | ||
|
|
||
| public string? Scheme { get; } | ||
|
|
||
| public BehaviorOperatorFixture() | ||
| { | ||
| Scheme = Environment.GetEnvironmentVariable("OPENDAL_TEST"); | ||
| if (string.IsNullOrWhiteSpace(Scheme)) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var scheme = Scheme.ToLowerInvariant().Replace('_', '-'); | ||
| var options = BuildConfigFromEnvironment(Scheme); | ||
|
|
||
| // Align with other bindings: isolate behavior tests with random roots by default. | ||
| if (!IsRandomRootDisabled()) | ||
| { | ||
| var baseRoot = options.TryGetValue("root", out var root) && !string.IsNullOrWhiteSpace(root) | ||
| ? root! | ||
| : "/"; | ||
| options["root"] = BuildRandomRoot(baseRoot); | ||
| } | ||
|
|
||
| op = new Operator(scheme, options); | ||
| } | ||
|
|
||
| public bool IsEnabled => op is not null; | ||
|
|
||
| public Operator Op => op ?? throw new InvalidOperationException("Behavior operator is not initialized."); | ||
|
|
||
| public Capability Capability => Op.Info.FullCapability; | ||
|
|
||
| public void Dispose() | ||
| { | ||
| op?.Dispose(); | ||
| } | ||
|
|
||
| private static Dictionary<string, string> BuildConfigFromEnvironment(string service) | ||
| { | ||
| var variables = Environment.GetEnvironmentVariables(); | ||
| var prefix = $"opendal_{service.ToLowerInvariant()}_"; | ||
| var config = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); | ||
|
|
||
| foreach (DictionaryEntry entry in variables) | ||
| { | ||
| var key = entry.Key?.ToString(); | ||
| var value = entry.Value?.ToString(); | ||
| if (string.IsNullOrWhiteSpace(key) || value is null) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| var normalized = key.ToLowerInvariant(); | ||
| if (!normalized.StartsWith(prefix, StringComparison.Ordinal)) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| config[normalized[prefix.Length..]] = value; | ||
| } | ||
|
|
||
| return config; | ||
| } | ||
|
|
||
| private static bool IsRandomRootDisabled() | ||
| { | ||
| return string.Equals( | ||
| Environment.GetEnvironmentVariable("OPENDAL_DISABLE_RANDOM_ROOT"), | ||
| "true", | ||
| StringComparison.OrdinalIgnoreCase); | ||
| } | ||
|
|
||
| private static string BuildRandomRoot(string baseRoot) | ||
| { | ||
| var trimmed = baseRoot.Trim(); | ||
| if (trimmed.Length == 0) | ||
| { | ||
| trimmed = "/"; | ||
| } | ||
|
|
||
| if (!trimmed.EndsWith('/')) | ||
| { | ||
| trimmed += "/"; | ||
| } | ||
|
|
||
| return $"{trimmed}{Guid.NewGuid():N}/"; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FullyQualifiedName~Behavior is for Test Binding Dotnet. [test_behavior_binding_dotnet/action.yaml]
FullyQualifiedName!~Behavior is for Bindings Dotnet CI. [ci_bindings_dotnet.yml]
one for behavior/integration coverage, and one for normal CI coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored the test cases make the structure clearer and simplify the CI test commands.