google.golang.org/grpc@v1.62.1/xds/internal/balancer/outlierdetection/config_test.go (about) 1 /* 2 * 3 * Copyright 2022 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * 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 outlierdetection 19 20 import ( 21 "reflect" 22 "testing" 23 ) 24 25 func TestSuccessRateEjection(t *testing.T) { 26 fields := map[string]bool{ 27 "StdevFactor": true, 28 "EnforcementPercentage": true, 29 "MinimumHosts": true, 30 "RequestVolume": true, 31 } 32 typ := reflect.TypeOf(SuccessRateEjection{}) 33 for i := 0; i < typ.NumField(); i++ { 34 if n := typ.Field(i).Name; !fields[n] { 35 t.Errorf("New field in SuccessRateEjection %q, update this test and Equal", n) 36 } 37 } 38 } 39 40 func TestEqualFieldsFailurePercentageEjection(t *testing.T) { 41 fields := map[string]bool{ 42 "Threshold": true, 43 "EnforcementPercentage": true, 44 "MinimumHosts": true, 45 "RequestVolume": true, 46 } 47 typ := reflect.TypeOf(FailurePercentageEjection{}) 48 for i := 0; i < typ.NumField(); i++ { 49 if n := typ.Field(i).Name; !fields[n] { 50 t.Errorf("New field in FailurePercentageEjection %q, update this test and Equal", n) 51 } 52 } 53 } 54 55 func TestEqualFieldsLBConfig(t *testing.T) { 56 fields := map[string]bool{ 57 "LoadBalancingConfig": true, 58 "Interval": true, 59 "BaseEjectionTime": true, 60 "MaxEjectionTime": true, 61 "MaxEjectionPercent": true, 62 "SuccessRateEjection": true, 63 "FailurePercentageEjection": true, 64 "ChildPolicy": true, 65 } 66 typ := reflect.TypeOf(LBConfig{}) 67 for i := 0; i < typ.NumField(); i++ { 68 if n := typ.Field(i).Name; !fields[n] { 69 t.Errorf("New field in LBConfig %q, update this test and EqualIgnoringChildPolicy", n) 70 } 71 } 72 }