Repository: vanus-labs/vanus
Pull request #510 (2023-03-10 05:41:21)

fix: ut error
<!--

Thank you for contributing to Vanus!

PR Title Format: 

feat/fix/refactor/docs/...: what's changed

Note: see https://github.com/vanus-labs/vanus/blob/main/CONTRIBUTING.md to know details about title format

-->

### What problem does this PR solve?

<!--

Please create an issue first to describe the problem

There MUST be one line starting with "Issue Number:  ".

-->

Issue Number: close #xxx

### Problem Summary

### What is changed and how does it work?

### Check List

<!-- At least one of them must be included. -->

#### Tests

- [ ] Unit test
- [ ] Integration test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No code


codecov[bot]: ## [Codecov](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs) Report
> Merging [#510](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs) (da4c715) into [main](https://codecov.io/gh/vanus-labs/vanus/commit/ee76217182ba60efbcbb62fd374b8e75127d5133?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs) (ee76217) will **decrease** coverage by `0.48%`.
> The diff coverage is `55.89%`.

<details><summary>Additional details and impacted files</summary>


[![Impacted file tree graph](https://codecov.io/gh/vanus-labs/vanus/pull/510/graphs/tree.svg?width=650&height=150&src=pr&token=RSXSIMEY4V&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs)](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs)

```diff
@@            Coverage Diff             @@
##             main     #510      +/-   ##
==========================================
- Coverage   57.07%   56.60%   -0.48%     
==========================================
  Files         190      191       +1     
  Lines       15191    15339     +148     
==========================================
+ Hits         8670     8682      +12     
- Misses       5884     6012     +128     
- Partials      637      645       +8     
```


| [Impacted Files](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs) | Coverage Δ | |
|---|---|---|
| [internal/controller/eventbus/block/block.go](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs#diff-aW50ZXJuYWwvY29udHJvbGxlci9ldmVudGJ1cy9ibG9jay9ibG9jay5nbw==) | `52.63% <ø> (ø)` | |
| [internal/controller/eventbus/block/selector.go](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs#diff-aW50ZXJuYWwvY29udHJvbGxlci9ldmVudGJ1cy9ibG9jay9zZWxlY3Rvci5nbw==) | `100.00% <ø> (ø)` | |
| [internal/controller/eventbus/server/instance.go](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs#diff-aW50ZXJuYWwvY29udHJvbGxlci9ldmVudGJ1cy9zZXJ2ZXIvaW5zdGFuY2UuZ28=) | `72.04% <ø> (ø)` | |
| [internal/controller/trigger/storage/storage.go](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs#diff-aW50ZXJuYWwvY29udHJvbGxlci90cmlnZ2VyL3N0b3JhZ2Uvc3RvcmFnZS5nbw==) | `0.00% <ø> (ø)` | |
| [...nternal/controller/trigger/storage/subscription.go](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs#diff-aW50ZXJuYWwvY29udHJvbGxlci90cmlnZ2VyL3N0b3JhZ2Uvc3Vic2NyaXB0aW9uLmdv) | `54.71% <ø> (ø)` | |
| [...ernal/controller/trigger/storage/trigger\_worker.go](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs#diff-aW50ZXJuYWwvY29udHJvbGxlci90cmlnZ2VyL3N0b3JhZ2UvdHJpZ2dlcl93b3JrZXIuZ28=) | `63.41% <ø> (ø)` | |
| [internal/controller/trigger/worker/policy.go](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs#diff-aW50ZXJuYWwvY29udHJvbGxlci90cmlnZ2VyL3dvcmtlci9wb2xpY3kuZ28=) | `100.00% <ø> (ø)` | |
| [internal/gateway/config.go](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs#diff-aW50ZXJuYWwvZ2F0ZXdheS9jb25maWcuZ28=) | `61.11% <ø> (ø)` | |
| [internal/gateway/proxy/deadletter.go](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs#diff-aW50ZXJuYWwvZ2F0ZXdheS9wcm94eS9kZWFkbGV0dGVyLmdv) | `0.00% <0.00%> (ø)` | |
| [internal/primitive/cel/cel.go](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs#diff-aW50ZXJuYWwvcHJpbWl0aXZlL2NlbC9jZWwuZ28=) | `68.57% <0.00%> (ø)` | |
| ... and [106 more](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs) | |

... and [21 files with indirect coverage changes](https://codecov.io/gh/vanus-labs/vanus/pull/510/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs)

------

[Continue to review full report in Codecov by Sentry](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs). Last update [bfb94a2...da4c715](https://codecov.io/gh/vanus-labs/vanus/pull/510?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vanus-labs).

</details>

Patch:
diff --git a/go.mod b/go.mod
index a1693d4..624cd78 100644
--- a/go.mod
+++ b/go.mod
@@ -31,11 +31,11 @@ require (
 	github.com/sony/sonyflake v1.1.0
 	github.com/spf13/cobra v1.4.0
 	github.com/tidwall/gjson v1.14.1
-	github.com/vanus-labs/sdk/golang v0.2.0
+	github.com/vanus-labs/sdk/golang v0.2.1-0.20230308125440-1f823fdeae5b
 	github.com/vanus-labs/vanus/client v0.5.7
 	github.com/vanus-labs/vanus/observability v0.5.7
 	github.com/vanus-labs/vanus/pkg v0.5.7
-	github.com/vanus-labs/vanus/proto v0.5.8-0.20230202030707-115734791dcf
+	github.com/vanus-labs/vanus/proto v0.7.1-0.20230307065123-722eac99dbf9
 	github.com/vanus-labs/vanus/raft v0.5.7
 	go.etcd.io/etcd/client/v3 v3.5.7
 	go.mongodb.org/mongo-driver v1.11.0
@@ -49,7 +49,6 @@ require (
 	google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c
 	google.golang.org/grpc v1.51.0
 	google.golang.org/protobuf v1.28.1
-	gopkg.in/yaml.v2 v2.4.0
 	gopkg.in/yaml.v3 v3.0.1
 	k8s.io/apimachinery v0.25.0
 	k8s.io/client-go v0.25.0
@@ -85,7 +84,6 @@ require (
 	github.com/jmespath/go-jmespath v0.4.0 // indirect
 	github.com/jtolds/gls v4.20.0+incompatible // indirect
 	github.com/klauspost/compress v1.13.6 // indirect
-	github.com/linkall-labs/vanus/proto v0.5.8-0.20230202030707-115734791dcf // indirect
 	github.com/mattn/go-colorable v0.1.11 // indirect
 	github.com/mattn/go-isatty v0.0.16 // indirect
 	github.com/mattn/go-runewidth v0.0.13 // indirect
@@ -131,7 +129,6 @@ require (
 
 replace (
 	github.com/mwitkow/grpc-proxy => github.com/vanus-labs/grpc-proxy v0.0.0-20220624142509-a3b0cb2bb86c
-	github.com/vanus-labs/sdk/golang v0.2.0 => github.com/linkall-labs/sdk/golang v0.2.0
 	github.com/vanus-labs/vanus/client => ./client
 	github.com/vanus-labs/vanus/observability => ./observability
 	github.com/vanus-labs/vanus/pkg => ./pkg
diff --git a/go.sum b/go.sum
index 8f431ca..3bd32b4 100644
--- a/go.sum
+++ b/go.sum
@@ -275,10 +275,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
-github.com/linkall-labs/sdk/golang v0.2.0 h1:VZ4n1mvwwnxCmVopktgBYuwp/FjtusxeR+f7Snfgi4k=
-github.com/linkall-labs/sdk/golang v0.2.0/go.mod h1:ytY4b1U5jdXlJjbSN2BGqqMZ0oUNcI0jaml1Wu2H4N0=
-github.com/linkall-labs/vanus/proto v0.5.8-0.20230202030707-115734791dcf h1:e0IrxF1q7ZtC5IdYtv/iWpQnAtNSHYb+23F9uHjRz/8=
-github.com/linkall-labs/vanus/proto v0.5.8-0.20230202030707-115734791dcf/go.mod h1:uorUJ3Q597Wj/1H1viO1Q0K+BGsTX/avImDmU7BfTeg=
 github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
 github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
 github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
@@ -397,6 +393,8 @@ github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhV
 github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
 github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
 github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
+github.com/vanus-labs/sdk/golang v0.2.1-0.20230308125440-1f823fdeae5b h1:Xr615fIhorEmaxmlJ36HxigUYtzDEiwL0tz1bUiDhOg=
+github.com/vanus-labs/sdk/golang v0.2.1-0.20230308125440-1f823fdeae5b/go.mod h1:WudcIH7IGCK6Bx6P3R6VMtzu25uoufopfXF0KgdKd8Q=
 github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
 github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
 github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go
index 971e6d6..841551b 100644
--- a/internal/gateway/gateway.go
+++ b/internal/gateway/gateway.go
@@ -26,7 +26,8 @@ import (
 	"github.com/cloudevents/sdk-go/v2/client"
 	"github.com/cloudevents/sdk-go/v2/protocol"
 	cehttp "github.com/cloudevents/sdk-go/v2/protocol/http"
-	eb "github.com/vanus-labs/vanus/client"
+	"go.opentelemetry.io/otel/trace"
+
 	"github.com/vanus-labs/vanus/internal/gateway/proxy"
 	"github.com/vanus-labs/vanus/internal/primitive/vanus"
 	"github.com/vanus-labs/vanus/observability/log"
@@ -34,7 +35,6 @@ import (
 	"github.com/vanus-labs/vanus/proto/pkg/cloudevents"
 	"github.com/vanus-labs/vanus/proto/pkg/codec"
 	proxypb "github.com/vanus-labs/vanus/proto/pkg/proxy"
-	"go.opentelemetry.io/otel/trace"
 )
 
 const (
@@ -44,14 +44,13 @@ const (
 var requestDataFromContext = cehttp.RequestDataFromContext
 
 type EventData struct {
-	EventID string `json:"event_id"`
-	BusName string `json:"eventbus_name"`
+	EventID string   `json:"event_id"`
+	BusID   vanus.ID `json:"eventbus_id"`
 }
 
 type ceGateway struct {
 	// ceClient  v2.Client
 	config     Config
-	client     eb.Client
 	proxySrv   *proxy.ControllerProxy
 	tracer     *tracing.Tracer
 	ceListener net.Listener
@@ -60,7 +59,6 @@ type ceGateway struct {
 func NewGateway(config Config) *ceGateway {
 	return &ceGateway{
 		config:   config,
-		client:   eb.Connect(config.ControllerAddr),
 		proxySrv: proxy.NewControllerProxy(config.GetProxyConfig()),
 		tracer:   tracing.NewTracer("cloudevents", trace.SpanKindServer),
 	}
diff --git a/internal/gateway/proxy/proxy.go b/internal/gateway/proxy/proxy.go
index 5add404..3e269f6 100644
--- a/internal/gateway/proxy/proxy.go
+++ b/internal/gateway/proxy/proxy.go
@@ -147,11 +147,7 @@ type ControllerProxy struct {
 }
 
 func (cp *ControllerProxy) Publish(ctx context.Context, req *proxypb.PublishRequest) (*emptypb.Empty, error) {
-	meta, _ := cp.ctrl.EventbusService().GetEventbus(ctx, req.EventbusId)
-	if meta == nil {
-		return nil, v2.NewHTTPResult(http.StatusBadRequest, "invalid eventbus id")
-	}
-
+	eventbusID := vanus.NewIDFromUint64(req.EventbusId)
 	responseCode := 200
 	_ctx, span := cp.tracer.Start(ctx, "Publish")
 	start := stdtime.Now()
@@ -159,20 +155,20 @@ func (cp *ControllerProxy) Publish(ctx context.Context, req *proxypb.PublishRequ
 		span.End()
 		used := float64(stdtime.Since(start)) / float64(stdtime.Millisecond)
 		metrics.GatewayEventReceivedCountVec.WithLabelValues(
-			meta.Name,
+			eventbusID.Key(),
 			metrics.LabelValueProtocolHTTP,
 			strconv.FormatInt(int64(len(req.Events.Events)), 10),
 			strconv.Itoa(responseCode),
 		).Add(float64(len(req.Events.Events)))
 
 		metrics.GatewayEventWriteLatencySummaryVec.WithLabelValues(
-			meta.Name,
+			eventbusID.Key(),
 			metrics.LabelValueProtocolHTTP,
 			strconv.FormatInt(int64(len(req.Events.Events)), 10),
 		).Observe(used)
 	}()
 
-	eventbusName := meta.Name
+	// todo  common event with delay event mixture
 	for idx := range req.Events.Events {
 		e := req.Events.Events[idx]
 		err := checkExtension(e.Attributes)
@@ -184,7 +180,7 @@ func (cp *ControllerProxy) Publish(ctx context.Context, req *proxypb.PublishRequ
 			e.Attributes = make(map[string]*cloudevents.CloudEvent_CloudEventAttributeValue, 0)
 		}
 		e.Attributes[primitive.XVanusEventbus] = &cloudevents.CloudEvent_CloudEventAttributeValue{
-			Attr: &cloudevents.CloudEvent_CloudEventAttributeValue_CeString{CeString: eventbusName},
+			Attr: &cloudevents.CloudEvent_CloudEventAttributeValue_CeString{CeString: eventbusID.Key()},
 		}
 		if eventTime, ok := e.Attributes[primitive.XVanusDeliveryTime]; ok {
 			// validate event time
@@ -532,6 +528,11 @@ func NewControllerProxy(cfg Config) *ControllerProxy {
 	}
 }
 
+// SetClient just for test.
+func (cp *ControllerProxy) SetClient(client eb.Client) {
+	cp.client = client
+}
+
 func (cp *ControllerProxy) Start() error {
 	recoveryOpt := recovery.WithRecoveryHandlerContext(
 		func(ctx context.Context, p interface{}) error {
diff --git a/vsctl/command/cluster.go b/vsctl/command/cluster.go
index 39a4787..5d63ff0 100644
--- a/vsctl/command/cluster.go
+++ b/vsctl/command/cluster.go
@@ -30,7 +30,7 @@ import (
 	"github.com/jedib0t/go-pretty/v6/table"
 	"github.com/jedib0t/go-pretty/v6/text"
 	"github.com/spf13/cobra"
-	"gopkg.in/yaml.v2"
+	"gopkg.in/yaml.v3"
 )
 
 var (
@@ -904,4 +904,3 @@ func getUpgradableVersionList(curVersion string) []string {
 	}
 	return clusterVersionList[curIdx+1:]
 }
-


Test patch:
diff --git a/internal/gateway/gateway_test.go b/internal/gateway/gateway_test.go
index ea190fe..debf908 100644
--- a/internal/gateway/gateway_test.go
+++ b/internal/gateway/gateway_test.go
@@ -26,6 +26,7 @@ import (
 	. "github.com/golang/mock/gomock"
 	. "github.com/prashantv/gostub"
 	. "github.com/smartystreets/goconvey/convey"
+
 	"github.com/vanus-labs/vanus/client"
 	"github.com/vanus-labs/vanus/client/pkg/api"
 	"github.com/vanus-labs/vanus/internal/primitive"
@@ -123,12 +124,12 @@ func TestGateway_getEventbusFromPath(t *testing.T) {
 		vid := vanus.NewTestID()
 		reqData := &cehttp.RequestData{
 			URL: &url.URL{
-				Opaque: fmt.Sprintf("/gateway/%d", vid.Uint64()),
+				Opaque: fmt.Sprintf("/gateway/%s", vid),
 			},
 		}
 		id, err := getEventbusFromPath(reqData)
-		So(id, ShouldEqual, vid)
 		So(err, ShouldBeNil)
+		So(id, ShouldEqual, vid)
 	})
 }
 
@@ -136,8 +137,7 @@ func TestGateway_EventID(t *testing.T) {
 	ctrl := NewController(t)
 	defer ctrl.Finish()
 	var (
-		eventIDs    = "AABBCC"
-		busName     = "test"
+		busID       = vanus.NewTestID()
 		controllers = []string{"127.0.0.1:2048"}
 		port        = 8087
 	)
@@ -155,7 +155,7 @@ func TestGateway_EventID(t *testing.T) {
 	}
 	ga := NewGateway(cfg)
 
-	ga.client = mockClient
+	ga.proxySrv.SetClient(mockClient)
 	ctx, cancel := context.WithCancel(context.Background())
 	defer cancel()
 	_ = ga.startCloudEventsReceiver(ctx)
@@ -175,17 +175,13 @@ func TestGateway_EventID(t *testing.T) {
 		_ = event.SetData(ce.ApplicationJSON, map[string]string{"hello": "world"})
 
 		ctx := ce.ContextWithTarget(context.Background(),
-			fmt.Sprintf("http://127.0.0.1:%d/gateway/%s", cfg.GetCloudEventReceiverPort(), busName))
+			fmt.Sprintf("http://127.0.0.1:%d/gateway/%s", cfg.GetCloudEventReceiverPort(), busID))
 		resEvent, res := c.Request(ctx, event)
 		So(ce.IsACK(res), ShouldBeTrue)
 		var httpResult *cehttp.Result
 		ce.ResultAs(res, &httpResult)
 		So(httpResult, ShouldNotBeNil)
 
-		var ed EventData
-		err = resEvent.DataAs(&ed)
-		So(err, ShouldBeNil)
-		So(ed.BusName, ShouldEqual, busName)
-		So(ed.EventID, ShouldEqual, eventIDs)
+		So(resEvent, ShouldBeNil)
 	})
 }
diff --git a/internal/gateway/proxy/proxy_test.go b/internal/gateway/proxy/proxy_test.go
index e94d859..fa3b2ad 100644
--- a/internal/gateway/proxy/proxy_test.go
+++ b/internal/gateway/proxy/proxy_test.go
@@ -55,23 +55,11 @@ func TestControllerProxy_GetEvent(t *testing.T) {
 			CloudEventReceiverPort: 18080,
 			Credentials:            insecure.NewCredentials(),
 		})
-
 		ctrl := gomock.NewController(t)
 		mockClient := client.NewMockClient(ctrl)
 		cp.client = mockClient
 		utEB1 := api.NewMockEventbus(ctrl)
-		utEB2 := api.NewMockEventbus(ctrl)
-		mockClient.EXPECT().Eventbus(gomock.Any(), gomock.Any()).AnyTimes().DoAndReturn(
-			func(ctx stdCtx.Context, eb string) api.Eventbus {
-				switch eb {
-				case "ut1":
-					return utEB1
-				case "ut2":
-					return utEB2
-				default:
-					return nil
-				}
-			})
+		mockClient.EXPECT().Eventbus(gomock.Any(), gomock.Any()).AnyTimes().Return(utEB1)
 
 		Convey("test invalid params", func() {
 			res, err := cp.GetEvent(stdCtx.Background(), &proxypb.GetEventRequest{
diff --git a/internal/trigger/trigger/trigger_test.go b/internal/trigger/trigger/trigger_test.go
index 461634f..13de915 100644
--- a/internal/trigger/trigger/trigger_test.go
+++ b/internal/trigger/trigger/trigger_test.go
@@ -259,9 +259,13 @@ func testSendEvent(tg *trigger) int64 {
 
 func makeSubscription(id vanus.ID) *primitive.Subscription {
 	return &primitive.Subscription{
-		ID:      id,
-		Sink:    "http://localhost:8080",
-		Filters: []*primitive.SubscriptionFilter{{Exact: map[string]string{"type": "test"}}},
+		ID:                   id,
+		Sink:                 "http://localhost:8080",
+		Filters:              []*primitive.SubscriptionFilter{{Exact: map[string]string{"type": "test"}}},
+		EventbusID:           vanus.NewTestID(),
+		TimerEventbusID:      vanus.NewTestID(),
+		DeadLetterEventbusID: vanus.NewTestID(),
+		RetryEventbusID:      vanus.NewTestID(),
 	}
 }