-
Notifications
You must be signed in to change notification settings - Fork 1k
Feat/3255 new config api tests #3283
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
Merged
AlexStocks
merged 19 commits into
apache:develop
from
Snow-kal:feat/3255-new-config-api-tests
Apr 19, 2026
+780
−0
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
158fbe8
test(new-config-api): add instance integration smoke test
Snow-kal 37b2d19
test(new-config-api): trim instance itest dependencies
Snow-kal 7161397
test(new-config-api): add priority integration tests
Snow-kal cb316e0
test(new-config-api): add compat integration tests
Snow-kal d322120
test(new-config-api): rename itest files to integration
Snow-kal eb23a06
test(new-config-api): satisfy testifylint empty assertions
Snow-kal 1c92160
test(new-config-api): bound unary retries by attempt timeout
Snow-kal f0062a2
test(new-config-api): move tests to module packages without integrati…
Snow-kal 175c597
test(client): shorten priority test constant names
Snow-kal a824f5c
test(config): split compat coverage into focused tests
Snow-kal 8851525
test(server): add retry diagnostics in instance unary call test
Snow-kal 1e5d2d6
test(server): split instance flow test and shorten names
Snow-kal 2b95426
test(config): refactor compat fixture with factory helpers
Snow-kal b621914
test(client): simplify prio test names and strengthen service option …
Snow-kal 69412ed
style: imports-formatter
Snow-kal 779c594
style: imports-formatter
Snow-kal 863733e
style: imports-formatter
Snow-kal 29c629d
style: imports-formatter
Snow-kal ff152bb
fix: adjust comment format
Snow-kal 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,195 @@ | ||
| /* | ||
| * 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 client_test | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
| ) | ||
|
|
||
| import ( | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| import ( | ||
| dubbo "dubbo.apache.org/dubbo-go/v3" | ||
| "dubbo.apache.org/dubbo-go/v3/client" | ||
| _ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/available" | ||
|
Check warning on line 33 in client/prio_test.go
|
||
| "dubbo.apache.org/dubbo-go/v3/common/constant" | ||
| _ "dubbo.apache.org/dubbo-go/v3/protocol/triple" | ||
|
Check warning on line 35 in client/prio_test.go
|
||
| "dubbo.apache.org/dubbo-go/v3/server" | ||
| ) | ||
|
|
||
| const ( | ||
| prioTestInstanceGroup = "new-config-instance-group" | ||
| prioTestInstanceVersion = "new-config-instance-version" | ||
| prioTestServerGroup = "new-config-server-group" | ||
| prioTestServerVersion = "new-config-server-version" | ||
| prioTestClientGroup = "new-config-client-group" | ||
| prioTestClientVersion = "new-config-client-version" | ||
| prioTestServiceName = "com.example.NewConfigAPIPriorityService" | ||
| prioTestServiceMethod = "Ping" | ||
| ) | ||
|
|
||
| type prioRefSnapshot struct { | ||
| Group string | ||
| Version string | ||
| Protocol string | ||
| } | ||
|
|
||
| // TestPrio_ServerOverride verifies that server-level options override instance defaults, and the override does no leak into later server creations. | ||
| func TestPrio_ServerOverride(t *testing.T) { | ||
| ins, err := dubbo.NewInstance( | ||
| dubbo.WithName("new-config-api-prio-server"), | ||
| dubbo.WithGroup(prioTestInstanceGroup), | ||
| dubbo.WithVersion(prioTestInstanceVersion), | ||
| ) | ||
| require.NoError(t, err) | ||
|
|
||
| srvDefault, err := ins.NewServer() | ||
| require.NoError(t, err) | ||
| defaultServiceOpts := registerPrioService(t, srvDefault) | ||
| assert.Equal(t, prioTestInstanceGroup, defaultServiceOpts.Service.Group) | ||
| assert.Equal(t, prioTestInstanceVersion, defaultServiceOpts.Service.Version) | ||
|
|
||
| srvOverride, err := ins.NewServer( | ||
| server.WithServerGroup(prioTestServerGroup), | ||
| server.WithServerVersion(prioTestServerVersion), | ||
| ) | ||
| require.NoError(t, err) | ||
| overrideServiceOpts := registerPrioService(t, srvOverride) | ||
| assert.Equal(t, prioTestServerGroup, overrideServiceOpts.Service.Group) | ||
| assert.Equal(t, prioTestServerVersion, overrideServiceOpts.Service.Version) | ||
|
|
||
| srvVerify, err := ins.NewServer() | ||
| require.NoError(t, err) | ||
| verifyServiceOpts := registerPrioService(t, srvVerify) | ||
| assert.Equal(t, prioTestInstanceGroup, verifyServiceOpts.Service.Group) | ||
| assert.Equal(t, prioTestInstanceVersion, verifyServiceOpts.Service.Version) | ||
| } | ||
|
|
||
| // TestPrio_ClientOverride verifies that | ||
| // client-level options override instance defaults, and the override does not | ||
| // leak into later client creations. | ||
| func TestPrio_ClientOverride(t *testing.T) { | ||
| ins, err := dubbo.NewInstance( | ||
| dubbo.WithName("new-config-api-prio-client"), | ||
| dubbo.WithGroup(prioTestInstanceGroup), | ||
| dubbo.WithVersion(prioTestInstanceVersion), | ||
| ) | ||
| require.NoError(t, err) | ||
|
|
||
| cliDefault, err := ins.NewClient() | ||
| require.NoError(t, err) | ||
|
|
||
| defaultSnapshot := capturePrioRef(t, cliDefault) | ||
| assert.Equal(t, prioTestInstanceGroup, defaultSnapshot.Group) | ||
| assert.Equal(t, prioTestInstanceVersion, defaultSnapshot.Version) | ||
| assert.Equal(t, constant.TriProtocol, defaultSnapshot.Protocol) | ||
|
|
||
| cliOverride, err := ins.NewClient( | ||
| client.WithClientGroup(prioTestClientGroup), | ||
| client.WithClientVersion(prioTestClientVersion), | ||
| client.WithClientProtocolTriple(), | ||
| ) | ||
| require.NoError(t, err) | ||
|
|
||
| overrideSnapshot := capturePrioRef(t, cliOverride) | ||
| assert.Equal(t, prioTestClientGroup, overrideSnapshot.Group) | ||
| assert.Equal(t, prioTestClientVersion, overrideSnapshot.Version) | ||
| assert.Equal(t, constant.TriProtocol, overrideSnapshot.Protocol) | ||
|
|
||
| cliVerify, err := ins.NewClient() | ||
| require.NoError(t, err) | ||
|
|
||
| verifySnapshot := capturePrioRef(t, cliVerify) | ||
| assert.Equal(t, prioTestInstanceGroup, verifySnapshot.Group) | ||
| assert.Equal(t, prioTestInstanceVersion, verifySnapshot.Version) | ||
| assert.Equal(t, constant.TriProtocol, verifySnapshot.Protocol) | ||
| } | ||
|
|
||
| // capturePrioRef captures the effective reference | ||
| // values after client option initialization. | ||
| func capturePrioRef(t *testing.T, cli *client.Client) prioRefSnapshot { | ||
| t.Helper() | ||
|
|
||
| snapshot := prioRefSnapshot{} | ||
| var refOpts *client.ReferenceOptions | ||
|
|
||
| _, err := cli.DialWithInfo( | ||
| prioTestServiceName, | ||
| &client.ClientInfo{ | ||
| InterfaceName: prioTestServiceName, | ||
| MethodNames: []string{prioTestServiceMethod}, | ||
| }, | ||
| client.WithClusterAvailable(), | ||
| client.WithProtocolTriple(), | ||
| client.WithURL("tri://127.0.0.1:1"), | ||
| func(opts *client.ReferenceOptions) { | ||
| refOpts = opts | ||
| }, | ||
| ) | ||
| require.NoError(t, err) | ||
| require.NotNil(t, refOpts) | ||
|
|
||
| snapshot.Group = refOpts.Reference.Group | ||
| snapshot.Version = refOpts.Reference.Version | ||
| snapshot.Protocol = refOpts.Reference.Protocol | ||
|
|
||
| return snapshot | ||
| } | ||
|
|
||
| type prioService struct{} | ||
|
|
||
| func (s *prioService) Reference() string { | ||
| return prioTestServiceName | ||
| } | ||
|
|
||
| func (s *prioService) Ping(context.Context, string) (string, error) { | ||
| return "ok", nil | ||
| } | ||
|
|
||
| // registerPrioService registers a minimal non-IDL service and | ||
| // returns its resolved service options for assertions. | ||
| func registerPrioService(t *testing.T, srv *server.Server) *server.ServiceOptions { | ||
| t.Helper() | ||
|
|
||
| svc := &prioService{} | ||
| err := srv.RegisterService( | ||
| svc, | ||
| server.WithInterface(prioTestServiceName), | ||
| server.WithNotRegister(), | ||
| ) | ||
| require.NoError(t, err) | ||
|
|
||
| svcOpts := srv.GetServiceOptionsByInterfaceName(prioTestServiceName) | ||
| require.NotNil(t, svcOpts) | ||
| require.NotNil(t, svcOpts.Application) | ||
| require.NotNil(t, svcOpts.Provider) | ||
| require.NotNil(t, svcOpts.Service) | ||
| assert.Equal(t, prioTestServiceName, svcOpts.Id) | ||
| assert.Equal(t, prioTestServiceName, svcOpts.Service.Interface) | ||
| assert.True(t, svcOpts.Service.NotRegister) | ||
|
|
||
| svcOptsByID := srv.GetServiceOptions(prioTestServiceName) | ||
| require.NotNil(t, svcOptsByID) | ||
| assert.Same(t, svcOpts, svcOptsByID) | ||
|
|
||
| return svcOpts | ||
| } | ||
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.