Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
536245a
feat(router): support affinity and script config centers
xiaobaicai66695 Sep 5, 2026
8be8569
test(router): add missing license headers
xiaobaicai66695 Sep 12, 2026
2be080f
fix(router): unify ZooKeeper rule paths
xiaobaicai66695 Oct 17, 2026
9b4062f
fix(router): restore Nacos rule encoding import
xiaobaicai66695 Oct 17, 2026
05fc942
feat(console): manage affinity and script router rules
xiaobaicai66695 Sep 5, 2026
ff2e02b
fix(router): preserve optional rule boolean presence
xiaobaicai66695 Oct 17, 2026
b9a63e6
test(router): cover console API and grouped ZooKeeper paths
xiaobaicai66695 Oct 19, 2026
c05a1d3
fix(nacos): disable scripts before deletion
xiaobaicai66695 Oct 19, 2026
3ea537c
fix(router): preserve legacy rule booleans
xiaobaicai66695 Oct 19, 2026
64f05c8
fix: always publish script rule enabled
xiaobaicai66695 Oct 21, 2026
bc4febc
fix: normalize affinity rule enabled
xiaobaicai66695 Oct 21, 2026
f5f018d
feat(frontend): manage affinity and script router rules
xiaobaicai66695 Sep 5, 2026
890906c
test(frontend): cover affinity and script YAML rule creation
xiaobaicai66695 Sep 5, 2026
f48936f
test(e2e): verify affinity and script router propagation
xiaobaicai66695 Sep 5, 2026
16b66f4
test(e2e): split router rule lifecycle coverage
xiaobaicai66695 Sep 5, 2026
dc4d938
test(router): add nacos router rule propagation coverage
xiaobaicai66695 Sep 12, 2026
3bb4043
test(e2e): verify router rules through Console APIs
xiaobaicai66695 Oct 19, 2026
166f474
test(e2e): split config center test adapters
xiaobaicai66695 Oct 19, 2026
3b5e040
fix(traffic): use canonical service key for affinity rules
xiaobaicai66695 Oct 24, 2026
35094c8
fix(router): preserve omitted affinity enabled semantics
xiaobaicai66695 Oct 28, 2026
ef20d36
fix(ci): format router locale and cover editor save failures
xiaobaicai66695 Oct 28, 2026
7320fb5
merge: carry latest config-center fixes into router UI PR
xiaobaicai66695 Oct 28, 2026
c9e0e8c
merge: resolve #1555 against upstream develop
xiaobaicai66695 Nov 2, 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
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ header:
- 'Jenkinsfile'
- '**/vendor/**'
- '**/go.sum'
- 'go.router-e2e.sum'
- '**/addons/manifests/**'
- '**/dubbo-ui/dist/**'
- '**/ui/**'
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += --no-print-directory

.PHONY: help test fmt clean lint
.PHONY: help test test-router-rule-chain-e2e fmt clean lint

help:
@echo "Available commands:"
@echo " test - Run unit tests"
@echo " test-router-rule-chain-e2e - Run router-rule-chain E2E tests with Dubbo-Go v3.3.2"
@echo " clean - Clean test generate files"
@echo " fmt - Format code"
@echo " lint - Run golangci-lint"
Expand All @@ -34,6 +35,13 @@ help:
test: clean
go test ./... -gcflags=-l -coverprofile=coverage.txt -covermode=atomic

# Run the RouterChain E2E suite with its independent Go 1.25 / Dubbo-Go v3.3.2 module graph.
# Set DUBBO_ADMIN_E2E_ZK_ADDR and DUBBO_ADMIN_E2E_NACOS_ADDR to exercise the real config centers.
# Both host:port (for example 127.0.0.1:2181) and complete URLs are accepted.
# Example: DUBBO_ADMIN_E2E_ZK_ADDR=127.0.0.1:2181 DUBBO_ADMIN_E2E_NACOS_ADDR=http://127.0.0.1:8848 make test-router-rule-chain-e2e
test-router-rule-chain-e2e:
go test -modfile ./go.router-e2e.mod -mod=mod -tags=e2e -count=1 ./e2e/router-rule-chain

fmt:
go fmt ./...

Expand Down
162 changes: 162 additions & 0 deletions e2e/router-rule-chain/nacos_router_rule_chain_e2e_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
//go:build e2e

/*
* 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 routerrulechain_test

import (
"fmt"
"io"
stdlog "log"
"os"
"strings"
"testing"
"time"

"k8s.io/client-go/tools/cache"

"dubbo.apache.org/dubbo-go/v3/common"
dubbogoconstant "dubbo.apache.org/dubbo-go/v3/common/constant"
_ "dubbo.apache.org/dubbo-go/v3/config_center/nacos"
dubbogologger "dubbo.apache.org/dubbo-go/v3/logger"
"dubbo.apache.org/dubbo-go/v3/remoting"
gostlogger "github.com/dubbogo/gost/log/logger"
nacoslogger "github.com/nacos-group/nacos-sdk-go/v2/common/logger"

"github.com/apache/dubbo-admin/pkg/common/constants"
logcfg "github.com/apache/dubbo-admin/pkg/config/log"
"github.com/apache/dubbo-admin/pkg/core/logger"
coremodel "github.com/apache/dubbo-admin/pkg/core/resource/model"
_ "github.com/apache/dubbo-admin/pkg/discovery/nacos2"
_ "github.com/apache/dubbo-admin/pkg/governor/nacos2"
)

const (
e2eNacosAddressEnv = "DUBBO_ADMIN_E2E_NACOS_ADDR"
e2eLogEnv = "DUBBO_ADMIN_E2E_LOG"
)

func TestMain(m *testing.M) {
configureE2ELogging()
code := m.Run()
shutdownAdminRuntimeFixture()
os.Exit(code)
}

// TestNacosRouterRuleChainLifecycle uses the same real Admin runtime as the
// ZooKeeper test. Nacos discovery converts configurations directly into typed
// route resources, so there is no NacosConfig wrapper equivalent to ZKConfig.
func TestNacosRouterRuleChainLifecycle(t *testing.T) {
address := configCenterAddress(configCenterNacos, os.Getenv(e2eNacosAddressEnv))
if address == "" {
t.Skipf("set %s to run the Nacos integration test", e2eNacosAddressEnv)
}
e2e := newNacosRouterRuleChainE2E(t, requireAdminRuntimeFixture(t), address)
t.Run("Affinity", e2e.testAffinityLifecycle)
t.Run("Script", e2e.testScriptLifecycle)
}

func newNacosRouterRuleChainE2E(t *testing.T, fixture *adminRuntimeFixture, address string) *routerRuleChainE2E {
t.Helper()
return newRouterRuleChainE2E(t, fixture, configCenterNacos, e2eNacosMesh, address, nacosConfigCenterE2EAdapter{})
}

// nacosConfigCenterE2EAdapter documents Nacos-specific propagation behavior.
// Its ListWatcher materializes typed rules directly, without a raw config
// resource equivalent to ZooKeeper's ZKConfig.
type nacosConfigCenterE2EAdapter struct{}

func (nacosConfigCenterE2EAdapter) configureURL(url *common.URL) {
url.AddParam(dubbogoconstant.ClientNameKey, fmt.Sprintf("router-rule-chain-%d", time.Now().UnixNano()))
url.AddParam(dubbogoconstant.ConfigGroupKey, constants.NacosConfigGroup)
if level := nacosSDKLogLevel(); level != "" {
url.AddParam(dubbogoconstant.NacosLogLevelKey, level)
}
}

func (nacosConfigCenterE2EAdapter) configMatches(e2e *routerRuleChainE2E, name, content string, exists bool) bool {
value, err := e2e.dynamic.GetRule(name)
return err == nil && ((exists && strings.Contains(value, content)) || (!exists && value == ""))
}

func (nacosConfigCenterE2EAdapter) verifyUpsert(*testing.T, *routerRuleChainE2E, coremodel.Resource, *resourceEventRecorder, cache.DeltaType, string) {
// The typed route resource is asserted by the shared store check.
}

func (nacosConfigCenterE2EAdapter) verifyDelete(t *testing.T, _ *routerRuleChainE2E, rule coremodel.Resource, events *resourceEventRecorder) {
t.Helper()
// Nacos governor removes its local item synchronously, so this event is
// produced by Nacos discovery rather than by the governor itself.
events.waitFor(t, rule.ResourceKey(), cache.Deleted, "")
}

func (nacosConfigCenterE2EAdapter) listenerEventType(remoting.EventType) remoting.EventType {
// Nacos represents both updates and removals as Update callbacks; removal
// is separately verified through the Admin discovery delete event above.
return remoting.EventTypeUpdate
}

func configureE2ELogging() {
level := strings.ToLower(strings.TrimSpace(os.Getenv(e2eLogEnv)))
if level == "" {
level = "off"
}
if level == "off" {
configureE2ELoggingOff()
return
}
if level != string(logcfg.LevelDebug) && level != string(logcfg.LevelInfo) && level != string(logcfg.LevelWarn) && level != string(logcfg.LevelError) {
fmt.Fprintf(os.Stderr, "invalid %s=%q; using off\n", e2eLogEnv, level)
configureE2ELoggingOff()
return
}
logger.Init(&logcfg.Config{Level: logcfg.Level(level), OutputPath: os.DevNull})
_ = dubbogologger.SetLoggerLevel(level)
_ = gostlogger.SetLoggerLevel(level)
}

func configureE2ELoggingOff() {
logger.Init(&logcfg.Config{Level: logcfg.LevelError, OutputPath: os.DevNull})
stdlog.SetOutput(io.Discard)
discard := e2eDiscardLogger{}
dubbogologger.SetLogger(discard)
gostlogger.SetLogger(discard)
nacoslogger.SetLogger(discard)
}

func nacosSDKLogLevel() string {
level := strings.ToLower(strings.TrimSpace(os.Getenv(e2eLogEnv)))
if level == "" || level == "off" {
return string(logcfg.LevelError)
}
return level
}

type e2eDiscardLogger struct{}

func (e2eDiscardLogger) Debug(...any) {}
func (e2eDiscardLogger) Debugf(string, ...any) {}
func (e2eDiscardLogger) Info(...any) {}
func (e2eDiscardLogger) Infof(string, ...any) {}
func (e2eDiscardLogger) Warn(...any) {}
func (e2eDiscardLogger) Warnf(string, ...any) {}
func (e2eDiscardLogger) Error(...any) {}
func (e2eDiscardLogger) Errorf(string, ...any) {}
func (e2eDiscardLogger) Fatal(...any) {}
func (e2eDiscardLogger) Fatalf(string, ...any) {}
func (e2eDiscardLogger) Close() error { return nil }
Loading
Loading