dubbo.apache.org/dubbo-go/v3@v3.1.1/config/graceful_shutdown_test.go (about) 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package config 19 20 // 21 //import ( 22 // "dubbo.apache.org/dubbo-go/v3/config" 23 // "dubbo.apache.org/dubbo-go/v3/config/consumer" 24 // protocol2 "dubbo.apache.org/dubbo-go/v3/config/protocol" 25 // "dubbo.apache.org/dubbo-go/v3/config/provider" 26 // "dubbo.apache.org/dubbo-go/v3/config/reference" 27 // "testing" 28 //) 29 // 30 //import ( 31 // "dubbo.apache.org/dubbo-go/v3/common/constant" 32 // "dubbo.apache.org/dubbo-go/v3/common/extension" 33 // "dubbo.apache.org/dubbo-go/v3/filter" 34 // "dubbo.apache.org/dubbo-go/v3/protocol" 35 //) 36 // 37 //func TestGracefulShutdownInit(t *testing.T) { 38 // extension.SetFilter(constant.GracefulShutdownConsumerFilterKey, func() filter.Filter { 39 // return &config.mockGracefulShutdownFilter{} 40 // }) 41 // extension.SetFilter(constant.GracefulShutdownProviderFilterKey, func() filter.Filter { 42 // return &config.mockGracefulShutdownFilter{} 43 // }) 44 // GracefulShutdownInit() 45 //} 46 // 47 //func TestBeforeShutdown(t *testing.T) { 48 // extension.SetProtocol("registry", func() protocol.Protocol { 49 // return &config.mockRegistryProtocol{} 50 // }) 51 // extension.SetProtocol(constant.DUBBO, func() protocol.Protocol { 52 // return &config.mockRegistryProtocol{} 53 // }) 54 // 55 // extension.SetProtocol("mock", func() protocol.Protocol { 56 // return &config.mockRegistryProtocol{} 57 // }) 58 // 59 // consumerReferences := map[string]*reference.ReferenceConfig{} 60 // consumerReferences[constant.DUBBO] = &reference.ReferenceConfig{ 61 // Protocol: constant.DUBBO, 62 // } 63 // 64 // // without configuration 65 // config.consumerConfig = nil 66 // config.referenceConfig = nil 67 // BeforeShutdown() 68 // 69 // config.consumerConfig = &consumer.ShutdownConfig{ 70 // References: consumerReferences, 71 // ShutdownConfig: &ShutdownConfig{ 72 // Timeout: "1", 73 // StepTimeout: "1s", 74 // }, 75 // } 76 // 77 // providerProtocols := map[string]*protocol2.ProtocolConfig{} 78 // providerProtocols[constant.DUBBO] = &protocol2.ProtocolConfig{ 79 // Name: constant.DUBBO, 80 // } 81 // 82 // providerProtocols["mock"] = &protocol2.ProtocolConfig{ 83 // Name: "mock", 84 // } 85 // 86 // config.referenceConfig = &provider.ProviderConfig{ 87 // ShutdownConfig: &ShutdownConfig{ 88 // Timeout: "1", 89 // StepTimeout: "1s", 90 // }, 91 // Protocols: providerProtocols, 92 // } 93 // // test destroy protocol 94 // BeforeShutdown() 95 // 96 // config.referenceConfig = &provider.ProviderConfig{ 97 // ShutdownConfig: &ShutdownConfig{ 98 // Timeout: "1", 99 // StepTimeout: "-1s", 100 // }, 101 // Protocols: providerProtocols, 102 // } 103 // 104 // config.consumerConfig = &consumer.ShutdownConfig{ 105 // References: consumerReferences, 106 // ShutdownConfig: &ShutdownConfig{ 107 // Timeout: "1", 108 // StepTimeout: "-1s", 109 // }, 110 // } 111 // 112 // // test ignore steps 113 // BeforeShutdown() 114 //}