-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Wei Fu <[email protected]>
- Loading branch information
Showing
3 changed files
with
56 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package request | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"k8s.io/client-go/tools/metrics" | ||
) | ||
|
||
type transportCacheTracker struct{} | ||
|
||
// Increment implements k8s.io/client-go/tools/metrics.TransportCreateCallsMetric interface. | ||
func (t *transportCacheTracker) Increment(result string) { | ||
if result != "uncacheable" { | ||
panic(fmt.Errorf("unexpected use cache transport: %s", result)) | ||
} | ||
fmt.Printf("transport cache: %s\n", result) | ||
} | ||
|
||
func init() { | ||
metrics.Register(metrics.RegisterOpts{ | ||
TransportCreateCalls: &transportCacheTracker{}, | ||
}) | ||
} | ||
|
||
func TestNewClientShouldNotPanic(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r != nil { | ||
t.Fatalf("should not reuse transport: %v", r) | ||
} | ||
}() | ||
_, err := NewClients("testdata/dummy_nonexistent_kubeconfig.yaml", 10) | ||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: v1 | ||
clusters: | ||
- cluster: | ||
server: https://unit-test.kperf.io | ||
name: unit-test.kperf.io | ||
contexts: | ||
- context: | ||
cluster: unit-test.kperf.io | ||
user: [email protected] | ||
name: [email protected] | ||
current-context: [email protected] | ||
kind: Config | ||
preferences: {} | ||
users: | ||
- name: [email protected] | ||
user: | ||
exec: | ||
apiVersion: client.authentication.k8s.io/v1beta1 | ||
command: unknown | ||
interactiveMode: IfAvailable | ||
provideClusterInfo: false |