Skip to content

Commit eedef0e

Browse files
committed
Revert initial benchmark tests
This reverts commit f8ae501.
1 parent 2f9662b commit eedef0e

File tree

2 files changed

+0
-128
lines changed

2 files changed

+0
-128
lines changed

Diff for: internal/authentication/tokengetter_test.go

-62
Original file line numberDiff line numberDiff line change
@@ -85,65 +85,3 @@ func TestTokenGetterGet(t *testing.T) {
8585
}
8686
}
8787
}
88-
89-
func BenchmarkTokenGetterGet(b *testing.B) {
90-
fakeClient := fake.NewSimpleClientset()
91-
fakeClient.PrependReactor("create", "serviceaccounts/token",
92-
func(action ctest.Action) (bool, runtime.Object, error) {
93-
act, ok := action.(ctest.CreateActionImpl)
94-
if !ok {
95-
return false, nil, nil
96-
}
97-
tokenRequest := act.GetObject().(*authenticationv1.TokenRequest)
98-
var err error
99-
if act.Name == "test-service-account-1" {
100-
tokenRequest.Status = authenticationv1.TokenRequestStatus{
101-
Token: "test-token-1",
102-
ExpirationTimestamp: metav1.NewTime(metav1.Now().Add(DefaultExpirationDuration)),
103-
}
104-
}
105-
if act.Name == "test-service-account-2" {
106-
tokenRequest.Status = authenticationv1.TokenRequestStatus{
107-
Token: "test-token-2",
108-
ExpirationTimestamp: metav1.NewTime(metav1.Now().Add(1 * time.Second)),
109-
}
110-
}
111-
if act.Name == "test-service-account-3" {
112-
tokenRequest.Status = authenticationv1.TokenRequestStatus{
113-
Token: "test-token-3",
114-
ExpirationTimestamp: metav1.NewTime(metav1.Now().Add(-10 * time.Second)),
115-
}
116-
}
117-
if act.Name == "test-service-account-4" {
118-
tokenRequest = nil
119-
err = fmt.Errorf("error when fetching token")
120-
}
121-
return true, tokenRequest, err
122-
},
123-
)
124-
125-
tg := NewTokenGetter(fakeClient.CoreV1(),
126-
WithExpirationDuration(DefaultExpirationDuration),
127-
)
128-
129-
test := struct {
130-
serviceAccountName string
131-
namespace string
132-
}{
133-
serviceAccountName: "test-service-account-1",
134-
namespace: "test-namespace-1",
135-
}
136-
137-
for n := 0; n < b.N; n++ {
138-
token, err := tg.Get(context.Background(),
139-
types.NamespacedName{
140-
Namespace: test.namespace,
141-
Name: test.serviceAccountName,
142-
},
143-
)
144-
if err != nil {
145-
b.Logf("token creation; %v", err)
146-
}
147-
_ = token
148-
}
149-
}

Diff for: internal/contentmanager/contentmanager_test.go

-66
Original file line numberDiff line numberDiff line change
@@ -108,48 +108,6 @@ func TestWatch(t *testing.T) {
108108
}
109109
}
110110

111-
func BenchmarkWatch(b *testing.B) {
112-
rcm := func(_ context.Context, _ client.Object, cfg *rest.Config) (*rest.Config, error) {
113-
return cfg, nil
114-
}
115-
config := &rest.Config{}
116-
117-
ce := &v1alpha1.ClusterExtension{
118-
ObjectMeta: metav1.ObjectMeta{
119-
Name: "test-cluster-extension",
120-
},
121-
}
122-
objs := []client.Object{
123-
&corev1.Pod{
124-
TypeMeta: metav1.TypeMeta{
125-
APIVersion: "v1",
126-
Kind: "Pod",
127-
},
128-
ObjectMeta: metav1.ObjectMeta{
129-
Name: "webserver",
130-
},
131-
},
132-
}
133-
134-
for n := 0; n < b.N; n++ {
135-
mgr, _ := manager.New(config, manager.Options{})
136-
ctrl, err := controller.New("test-controller", mgr, controller.Options{
137-
Reconciler: reconcile.Func(func(context.Context, reconcile.Request) (reconcile.Result, error) {
138-
return reconcile.Result{}, nil
139-
}),
140-
})
141-
if err != nil {
142-
b.Logf("creating controller; %v", err)
143-
}
144-
145-
instance := New(rcm, config, mgr.GetRESTMapper())
146-
err = instance.Watch(context.Background(), ctrl, ce, objs)
147-
if err != nil {
148-
b.Logf("setup watcher; %v", err)
149-
}
150-
}
151-
}
152-
153111
func TestBuildScheme(t *testing.T) {
154112
type validation struct {
155113
gvks []schema.GroupVersionKind
@@ -247,27 +205,3 @@ func TestBuildScheme(t *testing.T) {
247205
})
248206
}
249207
}
250-
251-
func BenchmarkBuildScheme(b *testing.B) {
252-
objects := []client.Object{
253-
&appsv1.Deployment{
254-
TypeMeta: metav1.TypeMeta{
255-
APIVersion: "apps/v1",
256-
Kind: "Deployment",
257-
},
258-
ObjectMeta: metav1.ObjectMeta{
259-
Name: "webserver",
260-
},
261-
},
262-
}
263-
264-
gvk := appsv1.SchemeGroupVersion.WithKind("Deployment")
265-
266-
for n := 0; n < b.N; n++ {
267-
scheme, err := buildScheme(objects)
268-
if err != nil {
269-
b.Logf("failed creating scheme; %v", err)
270-
}
271-
_ = scheme.Recognizes(gvk)
272-
}
273-
}

0 commit comments

Comments
 (0)