mirror of
https://github.com/rancher/steve.git
synced 2025-09-06 18:01:04 +00:00
Add support for modifying the created Factory clients (#602)
Add support for modifying the created Factory clients This adds a new functional-opt based mechanism for configuring the factory clients, and provides a new function for allowing consumers to provide the QPS and Burst values for configuring clients.
This commit is contained in:
32
pkg/client/factory_test.go
Normal file
32
pkg/client/factory_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
func TestWithQPSAndBurst(t *testing.T) {
|
||||
fo := defaultFactoryOptions()
|
||||
|
||||
assert.Equal(t, defaultQPS, fo.qps)
|
||||
assert.Equal(t, defaultBurst, fo.burst)
|
||||
|
||||
WithQPSAndBurst(50, 20)(fo)
|
||||
|
||||
assert.Equal(t, float32(50.0), fo.qps)
|
||||
assert.Equal(t, 20, fo.burst)
|
||||
}
|
||||
|
||||
func TestNewFactoryWithOptions(t *testing.T) {
|
||||
cfg := &rest.Config{
|
||||
QPS: 5.0,
|
||||
Burst: 10,
|
||||
}
|
||||
f, err := NewFactory(cfg, false, WithQPSAndBurst(50, 20))
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, float32(50.0), f.clientCfg.QPS)
|
||||
assert.Equal(t, 20, f.clientCfg.Burst)
|
||||
}
|
Reference in New Issue
Block a user