Skip to content

Commit

Permalink
fix gracefulShutdownConfig unittest bug
Browse files Browse the repository at this point in the history
  • Loading branch information
justxuewei committed Jun 13, 2021
1 parent c83c789 commit 6b2299f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions config/graceful_shutdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,24 @@ import (
"testing"
)

import (
"go.uber.org/atomic"
)

import (
"dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/common/extension"
"dubbo.apache.org/dubbo-go/v3/filter"
"dubbo.apache.org/dubbo-go/v3/protocol"
)

func TestGracefulShutdownInit(t *testing.T) {
extension.SetFilter(constant.CONSUMER_SHUTDOWN_FILTER, func() filter.Filter {
return &mockGracefulShutdownFilter{}
})
extension.SetFilter(constant.PROVIDER_SHUTDOWN_FILTER, func() filter.Filter {
return &mockGracefulShutdownFilter{}
})
GracefulShutdownInit()
}

Expand All @@ -49,13 +60,16 @@ func TestBeforeShutdown(t *testing.T) {
}

// without configuration
consumerConfig = nil
providerConfig = nil
BeforeShutdown()

consumerConfig = &ConsumerConfig{
References: consumerReferences,
ShutdownConfig: &ShutdownConfig{
Timeout: "1",
StepTimeout: "1s",
RequestsFinished: &atomic.Bool{},
},
}

Expand All @@ -72,6 +86,7 @@ func TestBeforeShutdown(t *testing.T) {
ShutdownConfig: &ShutdownConfig{
Timeout: "1",
StepTimeout: "1s",
RequestsFinished: &atomic.Bool{},
},
Protocols: providerProtocols,
}
Expand All @@ -82,6 +97,7 @@ func TestBeforeShutdown(t *testing.T) {
ShutdownConfig: &ShutdownConfig{
Timeout: "1",
StepTimeout: "-1s",
RequestsFinished: &atomic.Bool{},
},
Protocols: providerProtocols,
}
Expand All @@ -91,6 +107,7 @@ func TestBeforeShutdown(t *testing.T) {
ShutdownConfig: &ShutdownConfig{
Timeout: "1",
StepTimeout: "-1s",
RequestsFinished: &atomic.Bool{},
},
}

Expand Down

0 comments on commit 6b2299f

Please sign in to comment.