mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	cmd/kube-proxy: refactor options test
Signed-off-by: Daman Arora <aroradaman@gmail.com>
This commit is contained in:
		@@ -179,6 +179,7 @@ nodePortAddresses:
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, tc := range testCases {
 | 
						for _, tc := range testCases {
 | 
				
			||||||
 | 
							t.Run(tc.name, func(t *testing.T) {
 | 
				
			||||||
			expBindAddr := tc.bindAddress
 | 
								expBindAddr := tc.bindAddress
 | 
				
			||||||
			if tc.bindAddress[0] == '"' {
 | 
								if tc.bindAddress[0] == '"' {
 | 
				
			||||||
				// Surrounding double quotes will get stripped by the yaml parser.
 | 
									// Surrounding double quotes will get stripped by the yaml parser.
 | 
				
			||||||
@@ -229,8 +230,8 @@ nodePortAddresses:
 | 
				
			|||||||
				NodePortAddresses:  []string{"10.20.30.40/16", "fd00:1::0/64"},
 | 
									NodePortAddresses:  []string{"10.20.30.40/16", "fd00:1::0/64"},
 | 
				
			||||||
				DetectLocalMode:    kubeproxyconfig.LocalModeClusterCIDR,
 | 
									DetectLocalMode:    kubeproxyconfig.LocalModeClusterCIDR,
 | 
				
			||||||
				DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
 | 
									DetectLocal: kubeproxyconfig.DetectLocalConfiguration{
 | 
				
			||||||
				BridgeInterface:     string("cbr0"),
 | 
										BridgeInterface:     "cbr0",
 | 
				
			||||||
				InterfaceNamePrefix: string("veth"),
 | 
										InterfaceNamePrefix: "veth",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				Logging: logsapi.LoggingConfiguration{
 | 
									Logging: logsapi.LoggingConfiguration{
 | 
				
			||||||
					Format:         "text",
 | 
										Format:         "text",
 | 
				
			||||||
@@ -252,8 +253,9 @@ nodePortAddresses:
 | 
				
			|||||||
			require.NoError(t, err, "unexpected error for %s: %v", tc.name, err)
 | 
								require.NoError(t, err, "unexpected error for %s: %v", tc.name, err)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if diff := cmp.Diff(config, expected); diff != "" {
 | 
								if diff := cmp.Diff(config, expected); diff != "" {
 | 
				
			||||||
			t.Fatalf("unexpected config for %s, diff = %s", tc.name, diff)
 | 
									t.Fatalf("unexpected config, diff = %s", diff)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -557,21 +559,13 @@ func TestAddressFromDeprecatedFlags(t *testing.T) {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for i := range testCases {
 | 
						for _, tc := range testCases {
 | 
				
			||||||
		gotHealthz := addressFromDeprecatedFlags(testCases[i].healthzBindAddress, testCases[i].healthzPort)
 | 
							t.Run(tc.name, func(t *testing.T) {
 | 
				
			||||||
		gotMetrics := addressFromDeprecatedFlags(testCases[i].metricsBindAddress, testCases[i].metricsPort)
 | 
								gotHealthz := addressFromDeprecatedFlags(tc.healthzBindAddress, tc.healthzPort)
 | 
				
			||||||
 | 
								gotMetrics := addressFromDeprecatedFlags(tc.metricsBindAddress, tc.metricsPort)
 | 
				
			||||||
		errFn := func(name, except, got string) {
 | 
					 | 
				
			||||||
			t.Errorf("case %s: expected %v, got %v", name, except, got)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if gotHealthz != testCases[i].expHealthz {
 | 
					 | 
				
			||||||
			errFn(testCases[i].name, testCases[i].expHealthz, gotHealthz)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if gotMetrics != testCases[i].expMetrics {
 | 
					 | 
				
			||||||
			errFn(testCases[i].name, testCases[i].expMetrics, gotMetrics)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								require.Equal(t, tc.expHealthz, gotHealthz)
 | 
				
			||||||
 | 
								require.Equal(t, tc.expMetrics, gotMetrics)
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user