Skip to content
Merged
Show file tree
Hide file tree
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 Mar 29, 2026
37b2d19
test(new-config-api): trim instance itest dependencies
Snow-kal Mar 29, 2026
7161397
test(new-config-api): add priority integration tests
Snow-kal Mar 29, 2026
cb316e0
test(new-config-api): add compat integration tests
Snow-kal Mar 29, 2026
d322120
test(new-config-api): rename itest files to integration
Snow-kal Mar 29, 2026
eb23a06
test(new-config-api): satisfy testifylint empty assertions
Snow-kal Mar 29, 2026
1c92160
test(new-config-api): bound unary retries by attempt timeout
Snow-kal Mar 29, 2026
f0062a2
test(new-config-api): move tests to module packages without integrati…
Snow-kal Apr 5, 2026
175c597
test(client): shorten priority test constant names
Snow-kal Apr 12, 2026
a824f5c
test(config): split compat coverage into focused tests
Snow-kal Apr 12, 2026
8851525
test(server): add retry diagnostics in instance unary call test
Snow-kal Apr 12, 2026
1e5d2d6
test(server): split instance flow test and shorten names
Snow-kal Apr 12, 2026
2b95426
test(config): refactor compat fixture with factory helpers
Snow-kal Apr 12, 2026
b621914
test(client): simplify prio test names and strengthen service option …
Snow-kal Apr 12, 2026
69412ed
style: imports-formatter
Snow-kal Apr 12, 2026
779c594
style: imports-formatter
Snow-kal Apr 12, 2026
863733e
style: imports-formatter
Snow-kal Apr 12, 2026
29c629d
style: imports-formatter
Snow-kal Apr 12, 2026
ff152bb
fix: adjust comment format
Snow-kal Apr 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions client/prio_test.go
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 (
Comment thread
AlexStocks marked this conversation as resolved.
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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a comment explaining why this blank import is needed.

See more on https://sonarcloud.io/project/issues?id=apache_dubbo-go&issues=AZ04x4pGRnJvyhKavfX0&open=AZ04x4pGRnJvyhKavfX0&pullRequest=3283
"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

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add a comment explaining why this blank import is needed.

See more on https://sonarcloud.io/project/issues?id=apache_dubbo-go&issues=AZ04x4pHRnJvyhKavfX1&open=AZ04x4pHRnJvyhKavfX1&pullRequest=3283
"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
}
Loading
Loading